From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/property_map/Jamfile | 11 ++ src/boost/libs/property_map/LICENSE | 23 ++++ src/boost/libs/property_map/README.md | 35 ++++++ src/boost/libs/property_map/example/Jamfile.v2 | 16 +++ .../example/compose_property_map_example.cpp | 36 ++++++ src/boost/libs/property_map/example/example1.cpp | 48 +++++++ src/boost/libs/property_map/example/example2.cpp | 46 +++++++ src/boost/libs/property_map/example/example3.cpp | 21 ++++ src/boost/libs/property_map/index.html | 13 ++ src/boost/libs/property_map/meta/libraries.json | 15 +++ src/boost/libs/property_map/test/Jamfile.v2 | 26 ++++ .../test/compose_property_map_test.cpp | 101 +++++++++++++++ .../property_map/test/dynamic_properties_test.cpp | 138 +++++++++++++++++++++ .../test/function_property_map_test.cpp | 66 ++++++++++ .../libs/property_map/test/property_map_cc.cpp | 115 +++++++++++++++++ .../test/transform_value_property_map_test.cpp | 72 +++++++++++ 16 files changed, 782 insertions(+) create mode 100644 src/boost/libs/property_map/Jamfile create mode 100644 src/boost/libs/property_map/LICENSE create mode 100644 src/boost/libs/property_map/README.md create mode 100644 src/boost/libs/property_map/example/Jamfile.v2 create mode 100644 src/boost/libs/property_map/example/compose_property_map_example.cpp create mode 100644 src/boost/libs/property_map/example/example1.cpp create mode 100644 src/boost/libs/property_map/example/example2.cpp create mode 100644 src/boost/libs/property_map/example/example3.cpp create mode 100644 src/boost/libs/property_map/index.html create mode 100644 src/boost/libs/property_map/meta/libraries.json create mode 100644 src/boost/libs/property_map/test/Jamfile.v2 create mode 100644 src/boost/libs/property_map/test/compose_property_map_test.cpp create mode 100644 src/boost/libs/property_map/test/dynamic_properties_test.cpp create mode 100644 src/boost/libs/property_map/test/function_property_map_test.cpp create mode 100644 src/boost/libs/property_map/test/property_map_cc.cpp create mode 100644 src/boost/libs/property_map/test/transform_value_property_map_test.cpp (limited to 'src/boost/libs/property_map') diff --git a/src/boost/libs/property_map/Jamfile b/src/boost/libs/property_map/Jamfile new file mode 100644 index 000000000..fe20ff603 --- /dev/null +++ b/src/boost/libs/property_map/Jamfile @@ -0,0 +1,11 @@ +# Boost.PropertyMap Library Jamfile +# +# Copyright (c) 2018 James E. King III +# +# Use, modification, and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# please order by name to ease maintenance +build-project example ; +build-project test ; diff --git a/src/boost/libs/property_map/LICENSE b/src/boost/libs/property_map/LICENSE new file mode 100644 index 000000000..36b7cd93c --- /dev/null +++ b/src/boost/libs/property_map/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/boost/libs/property_map/README.md b/src/boost/libs/property_map/README.md new file mode 100644 index 000000000..0e8d2f918 --- /dev/null +++ b/src/boost/libs/property_map/README.md @@ -0,0 +1,35 @@ +PropertyMap, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), +defines a general purpose interface for mapping key objects to corresponding value objects, thereby hiding the details of how the mapping is implemented from algorithms. + +### License + +Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + +### Properties + +* C++03 +* Header-only + +### Build Status + +Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | +:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | +[`master`](https://github.com/boostorg/property_map/tree/master) | [![Build Status](https://travis-ci.org/boostorg/property_map.svg?branch=master)](https://travis-ci.org/boostorg/property_map) | [![Build status](https://ci.appveyor.com/api/projects/status/jo7n29t5w499dodk/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/property-map-06329/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15841/badge.svg)](https://scan.coverity.com/projects/boostorg-property_map) | [![codecov](https://codecov.io/gh/boostorg/property_map/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/property_map/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/property_map.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/property_map.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/property_map.html) +[`develop`](https://github.com/boostorg/property_map/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/property_map.svg?branch=develop)](https://travis-ci.org/boostorg/property_map) | [![Build status](https://ci.appveyor.com/api/projects/status/jo7n29t5w499dodk/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/property-map-06329/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15841/badge.svg)](https://scan.coverity.com/projects/boostorg-property_map) | [![codecov](https://codecov.io/gh/boostorg/property_map/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/property_map/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/property_map.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/property_map.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/property_map.html) + +### Directories + +| Name | Purpose | +| ----------- | ------------------------------ | +| `doc` | documentation | +| `example` | examples | +| `include` | headers | +| `test` | unit tests | + +### More information + +* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-property_map) +* [Report bugs](https://github.com/boostorg/property_map/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. +* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). +* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[property_map]` tag at the beginning of the subject line. + diff --git a/src/boost/libs/property_map/example/Jamfile.v2 b/src/boost/libs/property_map/example/Jamfile.v2 new file mode 100644 index 000000000..928f62a10 --- /dev/null +++ b/src/boost/libs/property_map/example/Jamfile.v2 @@ -0,0 +1,16 @@ +# Boost.PropertyMap Library example Jamfile +# +# Copyright (c) 2018 James E. King III +# +# Distributed under the Boost Software License, Version 1.0. (See accompany- +# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +test-suite "property_map-examples" + : [ run compose_property_map_example.cpp ] + [ run example1.cpp ] + [ run example2.cpp ] + [ run example3.cpp ] + ; + diff --git a/src/boost/libs/property_map/example/compose_property_map_example.cpp b/src/boost/libs/property_map/example/compose_property_map_example.cpp new file mode 100644 index 000000000..ed809632a --- /dev/null +++ b/src/boost/libs/property_map/example/compose_property_map_example.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2013 Eurodecision +// Authors: Guillaume Pinot +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +int main() +{ + const int idx[] = {2, 0, 4, 1, 3}; + double v[] = {1., 3., 0., 4., 2.}; + boost::compose_property_map cpm(v, idx); + + for (int i = 0; i < 5; ++i) + std::cout << get(cpm, i) << " "; + std::cout << std::endl; + + for (int i = 0; i < 5; ++i) + ++cpm[i]; + + for (int i = 0; i < 5; ++i) + std::cout << get(cpm, i) << " "; + std::cout << std::endl; + + for (int i = 0; i < 5; ++i) + put(cpm, i, 42.); + + for (int i = 0; i < 5; ++i) + std::cout << get(cpm, i) << " "; + std::cout << std::endl; + + return 0; +} diff --git a/src/boost/libs/property_map/example/example1.cpp b/src/boost/libs/property_map/example/example1.cpp new file mode 100644 index 000000000..fdaebb193 --- /dev/null +++ b/src/boost/libs/property_map/example/example1.cpp @@ -0,0 +1,48 @@ +// (C) Copyright Jeremy Siek 2002. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + + +template +void foo(AddressMap address) +{ + typedef typename boost::property_traits::value_type value_type; + typedef typename boost::property_traits::key_type key_type; + + value_type old_address, new_address; + key_type fred = "Fred"; + old_address = get(address, fred); + new_address = "384 Fitzpatrick Street"; + put(address, fred, new_address); + + key_type joe = "Joe"; + value_type& joes_address = address[joe]; + joes_address = "325 Cushing Avenue"; +} + +int +main() +{ + std::map name2address; + boost::associative_property_map< std::map > + address_map(name2address); + + name2address.insert(make_pair(std::string("Fred"), + std::string("710 West 13th Street"))); + name2address.insert(make_pair(std::string("Joe"), + std::string("710 West 13th Street"))); + + foo(address_map); + + for (std::map::iterator i = name2address.begin(); + i != name2address.end(); ++i) + std::cout << i->first << ": " << i->second << "\n"; + + return EXIT_SUCCESS; +} diff --git a/src/boost/libs/property_map/example/example2.cpp b/src/boost/libs/property_map/example/example2.cpp new file mode 100644 index 000000000..334027235 --- /dev/null +++ b/src/boost/libs/property_map/example/example2.cpp @@ -0,0 +1,46 @@ +// (C) Copyright Ronald Garcia, Jeremy Siek 2002. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + + +template +void display(ConstAddressMap address) +{ + typedef typename boost::property_traits::value_type + value_type; + typedef typename boost::property_traits::key_type key_type; + + key_type fred = "Fred"; + key_type joe = "Joe"; + + value_type freds_address = get(address, fred); + value_type joes_address = get(address, joe); + + std::cout << fred << ": " << freds_address << "\n" + << joe << ": " << joes_address << "\n"; +} + +int +main() +{ + std::map name2address; + boost::const_associative_property_map< std::map > + address_map(name2address); + + name2address.insert(make_pair(std::string("Fred"), + std::string("710 West 13th Street"))); + name2address.insert(make_pair(std::string("Joe"), + std::string("710 West 13th Street"))); + + display(address_map); + + return EXIT_SUCCESS; +} + + diff --git a/src/boost/libs/property_map/example/example3.cpp b/src/boost/libs/property_map/example/example3.cpp new file mode 100644 index 000000000..2fed1beec --- /dev/null +++ b/src/boost/libs/property_map/example/example3.cpp @@ -0,0 +1,21 @@ +// Copyright Vladimir Prus 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +int main() +{ + boost::vector_property_map m; + + // Assign string to '4'. + m[4] = "e"; + std::cout << "'" << m[4] << "'\n"; + + // Grab string from '10'. Since none is associated, + // "" will be returned. + std::cout << "'" << m[10] << "'\n"; +} diff --git a/src/boost/libs/property_map/index.html b/src/boost/libs/property_map/index.html new file mode 100644 index 000000000..d5846e3de --- /dev/null +++ b/src/boost/libs/property_map/index.html @@ -0,0 +1,13 @@ + + + + + +Automatic redirection failed, please go to +doc/property_map.html
+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt)

+ + diff --git a/src/boost/libs/property_map/meta/libraries.json b/src/boost/libs/property_map/meta/libraries.json new file mode 100644 index 000000000..6d96e88a3 --- /dev/null +++ b/src/boost/libs/property_map/meta/libraries.json @@ -0,0 +1,15 @@ +{ + "key": "property_map", + "name": "Property Map", + "authors": [ + "Jeremy Siek" + ], + "description": "Concepts defining interfaces which map key objects to value objects.", + "category": [ + "Containers", + "Generic" + ], + "maintainers": [ + "Douglas Gregor " + ] +} diff --git a/src/boost/libs/property_map/test/Jamfile.v2 b/src/boost/libs/property_map/test/Jamfile.v2 new file mode 100644 index 000000000..b6353d294 --- /dev/null +++ b/src/boost/libs/property_map/test/Jamfile.v2 @@ -0,0 +1,26 @@ +# PropertyMap library + +# Copyright (C) 2005 Trustees of Indiana University +# +# Author: Douglas Gregor +# +# Use, modification and distribution is subject to the Boost Software License, +# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# For more information, see http://www.boost.org/ + +import os ; + +project + : requirements + cygwin:_POSIX_C_SOURCE=201112L + ; + +test-suite property_map + : [ compile property_map_cc.cpp ] + [ run compose_property_map_test.cpp ] + [ run dynamic_properties_test.cpp ] + [ run function_property_map_test.cpp ] + [ run transform_value_property_map_test.cpp ] + ; diff --git a/src/boost/libs/property_map/test/compose_property_map_test.cpp b/src/boost/libs/property_map/test/compose_property_map_test.cpp new file mode 100644 index 000000000..7ee716682 --- /dev/null +++ b/src/boost/libs/property_map/test/compose_property_map_test.cpp @@ -0,0 +1,101 @@ +// Copyright (C) 2013 Eurodecision +// Authors: Guillaume Pinot +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +void concept_checks() +{ + using namespace boost; + { + typedef null_archetype<> Key; + //typedef assignable_archetype > Value; + typedef copy_constructible_archetype > Value; + typedef readable_property_map_archetype GPMap; + typedef readable_property_map_archetype FPMap; + typedef compose_property_map CPM; + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef copy_constructible_archetype > Value; + typedef readable_property_map_archetype GPMap; + typedef writable_property_map_archetype FPMap; + typedef compose_property_map CPM; + BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef copy_constructible_archetype > Value; + typedef readable_property_map_archetype GPMap; + typedef read_write_property_map_archetype FPMap; + typedef compose_property_map CPM; + BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef copy_constructible_archetype > Value; + typedef readable_property_map_archetype GPMap; + typedef lvalue_property_map_archetype FPMap; + typedef compose_property_map CPM; + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef copy_constructible_archetype > Value; + typedef readable_property_map_archetype GPMap; + typedef mutable_lvalue_property_map_archetype FPMap; + typedef compose_property_map CPM; + BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); + } +} + +void pointer_pmap_check() +{ + const int idx[] = {2, 0, 4, 1, 3}; + double v[] = {1., 3., 0., 4., 2.}; + boost::compose_property_map cpm(v, idx); + + for (int i = 0; i < 5; ++i) { + BOOST_CHECK(get(cpm, i) == static_cast(i)); + ++cpm[i]; + BOOST_CHECK(cpm[i] == static_cast(i + 1)); + put(cpm, i, 42.); + BOOST_CHECK(cpm[i] == 42.); + } +} + +struct modulo_add_one { + typedef int result_type; + modulo_add_one(int m): modulo(m) {} + int operator()(int i) const {return (i + 1) % modulo;} + int modulo; +}; + +void readable_pmap_checks() +{ + using namespace boost; + typedef function_property_map modulo_add_one_pmap; + + compose_property_map + cpm(modulo_add_one(5), modulo_add_one(5)); + + for (int i = 0; i < 10; ++i) + BOOST_CHECK(get(cpm, i) == (i + 2) % 5); +} + +int +test_main(int, char**) +{ + concept_checks(); + pointer_pmap_check(); + readable_pmap_checks(); + + return 0; +} diff --git a/src/boost/libs/property_map/test/dynamic_properties_test.cpp b/src/boost/libs/property_map/test/dynamic_properties_test.cpp new file mode 100644 index 000000000..813225d59 --- /dev/null +++ b/src/boost/libs/property_map/test/dynamic_properties_test.cpp @@ -0,0 +1,138 @@ + +// Copyright 2005 The Trustees of Indiana University. + +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// +// dynamic_properties_test.cpp - test cases for the dynamic property maps. +// + +// Author: Ronald Garcia +#include + +// For Borland, act like BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS is defined +#if defined (__BORLANDC__) && (__BORLANDC__ <= 0x570) && !defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) +# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +// generate a dynamic_property_map that maps strings to strings +// WARNING: This code leaks memory. For testing purposes only! +// WARNING: This code uses library internals. For testing purposes only! +boost::shared_ptr +string2string_gen(const std::string& name, + const boost::any&, + const boost::any&) { + typedef std::map map_t; + typedef + boost::associative_property_map< std::map > + property_t; + + + map_t* mymap = new map_t(); // hint: leaky memory here! + + property_t property_map(*mymap); + + boost::shared_ptr pm( + new + boost::detail::dynamic_property_map_adaptor(property_map)); + + return pm; +} + + +int test_main(int,char**) { + + // build property maps using associative_property_map + + std::map string2int; + std::map double2string; + boost::associative_property_map< std::map > + int_map(string2int); + boost::associative_property_map< std::map > + dbl_map(double2string); + + + // add key-value information + string2int["one"] = 1; + string2int["five"] = 5; + + double2string[5.3] = "five point three"; + double2string[3.14] = "pi"; + + + // build and populate dynamic interface + boost::dynamic_properties properties; + properties.property("int",int_map); + properties.property("double",dbl_map); + + using boost::get; + using boost::put; + using boost::type; + // Get tests + { + BOOST_CHECK(get("int",properties,std::string("one")) == "1"); +#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS + BOOST_CHECK(boost::get("int",properties,std::string("one")) == 1); +#endif + BOOST_CHECK(get("int",properties,std::string("one"), type()) == 1); + BOOST_CHECK(get("double",properties,5.3) == "five point three"); + } + + // Put tests + { + put("int",properties,std::string("five"),6); + BOOST_CHECK(get("int",properties,std::string("five")) == "6"); + put("int",properties,std::string("five"),std::string("5")); +#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS + BOOST_CHECK(get("int",properties,std::string("five")) == 5); +#endif + BOOST_CHECK(get("int",properties,std::string("five"),type()) == 5); + put("double",properties,3.14,std::string("3.14159")); + BOOST_CHECK(get("double",properties,3.14) == "3.14159"); + put("double",properties,3.14,std::string("pi")); +#ifndef BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS + BOOST_CHECK(get("double",properties,3.14) == "pi"); +#endif + BOOST_CHECK(get("double",properties,3.14,type()) == "pi"); + } + + // Nonexistent property + { + try { + get("nope",properties,3.14); + BOOST_ERROR("No exception thrown."); + } catch (boost::dynamic_get_failure&) { } + + try { + put("nada",properties,3.14,std::string("3.14159")); + BOOST_ERROR("No exception thrown."); + } catch (boost::property_not_found&) { } + } + + // Nonexistent property gets generated + { + boost::dynamic_properties props(&string2string_gen); + put("nada",props,std::string("3.14"),std::string("pi")); + BOOST_CHECK(get("nada",props,std::string("3.14")) == "pi"); + } + + // Use the ignore_other_properties generator + { + boost::dynamic_properties props(&boost::ignore_other_properties); + bool value = put("nada",props,std::string("3.14"),std::string("pi")); + BOOST_CHECK(value == false); + } + + return boost::exit_success; +} diff --git a/src/boost/libs/property_map/test/function_property_map_test.cpp b/src/boost/libs/property_map/test/function_property_map_test.cpp new file mode 100644 index 000000000..8f072ec3f --- /dev/null +++ b/src/boost/libs/property_map/test/function_property_map_test.cpp @@ -0,0 +1,66 @@ +// +//======================================================================= +// Author: Jeremiah Willcock +// +// Copyright 2012, Trustees of Indiana University +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +//======================================================================= +// + +#include +#include +#include +#include +#include + +template +struct add1 {typedef T result_type; T operator()(const T& x) const {return x + 1;}}; + +template +struct add1_val {typedef T result_type; T operator()(T x) const {return x + 1;}}; + +template +struct return_fixed_ref { + int* ptr; + return_fixed_ref(int* ptr): ptr(ptr) {} + typedef int& result_type; + int& operator()(const T&) const {return *ptr;} +}; + +int test_main(int, char**) { + using namespace boost; + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int, double>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int, double>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, int>, int>)); + BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept, int>, int>)); + BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept, int>, int>)); + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept, int>, int>)); + + BOOST_STATIC_ASSERT((boost::is_same, int> >::category, boost::readable_property_map_tag>::value)); + BOOST_STATIC_ASSERT((boost::is_same, int> >::category, boost::readable_property_map_tag>::value)); + BOOST_STATIC_ASSERT((boost::is_same, int> >::category, boost::lvalue_property_map_tag>::value)); + + BOOST_CHECK(get(function_property_map, int>(), 3) == 4); + BOOST_CHECK(get(function_property_map, int>(add1()), 4) == 5); + BOOST_CHECK(get(make_function_property_map(add1()), 5) == 6); + BOOST_CHECK(get(function_property_map, int>(), 3) == 4); + BOOST_CHECK(get(function_property_map, int>(add1_val()), 4) == 5); + BOOST_CHECK(get(make_function_property_map(add1_val()), 5) == 6); + int val; + const function_property_map, int> pm = return_fixed_ref((&val)); + put(pm, 1, 6); + BOOST_CHECK(get(pm, 2) == 6); + BOOST_CHECK((get(pm, 3) = 7) == 7); + BOOST_CHECK(get(pm, 4) == 7); + const function_property_map, int> pm2 = pm; // Check shallow copying + BOOST_CHECK(get(pm2, 5) == 7); + put(pm2, 3, 1); + BOOST_CHECK(get(pm, 1) == 1); + + return 0; +} diff --git a/src/boost/libs/property_map/test/property_map_cc.cpp b/src/boost/libs/property_map/test/property_map_cc.cpp new file mode 100644 index 000000000..82606ac7b --- /dev/null +++ b/src/boost/libs/property_map/test/property_map_cc.cpp @@ -0,0 +1,115 @@ +// (C) Copyright Jeremy Siek 2001. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +// This file checks the property map concepts against the property map +// archetypes to make sure they are consistent and that they compile. +// This also checks all the property map classes defined in +// property_map.hpp against the concept checking classes. + +int +main() +{ + using namespace boost; + { + typedef null_archetype<> Key; + typedef assignable_archetype > Value; + typedef readable_property_map_archetype PMap; + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef assignable_archetype > Value; + typedef writable_property_map_archetype PMap; + BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef assignable_archetype > Value; + typedef read_write_property_map_archetype PMap; + BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef assignable_archetype > Value; + typedef lvalue_property_map_archetype PMap; + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); + } + { + typedef null_archetype<> Key; + typedef assignable_archetype > Value; + typedef mutable_lvalue_property_map_archetype PMap; + BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); + } + { + typedef std::ptrdiff_t Key; + typedef int* PMap; + BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); + } + { + typedef std::ptrdiff_t Key; + typedef const int* PMap; + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); + } + { + typedef sgi_assignable_archetype<> Key; // ? + typedef sgi_assignable_archetype<> Value; + typedef random_access_iterator_archetype Iterator; + typedef readable_property_map_archetype IndexMap; + typedef iterator_property_map PMap; + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); + } + { + typedef sgi_assignable_archetype<> Key; + typedef sgi_assignable_archetype<> Value; + typedef mutable_random_access_iterator_archetype Iterator; + typedef readable_property_map_archetype IndexMap; + typedef iterator_property_map PMap; + BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); + } + { + typedef sgi_assignable_archetype< less_than_comparable_archetype<> > Key; + typedef default_constructible_archetype< sgi_assignable_archetype<> > + Value; + typedef std::map Container; + typedef associative_property_map PMap; + BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); + } + { + typedef sgi_assignable_archetype< less_than_comparable_archetype<> > Key; + typedef default_constructible_archetype< sgi_assignable_archetype<> > + Value; + typedef std::map Container; + typedef const_associative_property_map PMap; + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept)); + } + { + typedef identity_property_map PMap; + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept)); + } + { + typedef dummy_property_map PMap; + BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept)); + } + { + typedef sgi_assignable_archetype<> Key; // ? + typedef sgi_assignable_archetype<> Value; + typedef readable_property_map_archetype IndexMap; + typedef shared_array_property_map PMap; + BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept)); + } + return 0; +} diff --git a/src/boost/libs/property_map/test/transform_value_property_map_test.cpp b/src/boost/libs/property_map/test/transform_value_property_map_test.cpp new file mode 100644 index 000000000..d9032f447 --- /dev/null +++ b/src/boost/libs/property_map/test/transform_value_property_map_test.cpp @@ -0,0 +1,72 @@ +// +//======================================================================= +// Author: Jeremiah Willcock +// +// Copyright 2012, Trustees of Indiana University +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +//======================================================================= +// + +#include +#include +#include +#include +#include +#include + +// Ensure this is not default constructible +struct times2 {typedef int result_type; times2(int) {}; int operator()(int x) const {return 2 * x;}}; + +template +struct add1 {typedef T result_type; T operator()(const T& x) const {return x + 1;}}; + +template +struct add1_val {typedef T result_type; T operator()(T x) const {return x + 1;}}; + +template +struct return_fixed_ref { + int* ptr; + return_fixed_ref(int* ptr): ptr(ptr) {} + typedef int& result_type; + int& operator()(const T&) const {return *ptr;} +}; + +int test_main(int, char**) { + using namespace boost; + typedef function_property_map PM; + PM orig_pm(times2(0)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM, double>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM, double>, int>)); + BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept, PM>, int>)); + BOOST_CONCEPT_ASSERT((WritablePropertyMapConcept, PM>, int>)); + BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept, PM>, int>)); + BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept, PM>, int>)); + + BOOST_STATIC_ASSERT((boost::is_same, PM> >::category, boost::readable_property_map_tag>::value)); + BOOST_STATIC_ASSERT((boost::is_same, PM> >::category, boost::readable_property_map_tag>::value)); + BOOST_STATIC_ASSERT((boost::is_same, PM> >::category, boost::lvalue_property_map_tag>::value)); + + BOOST_CHECK(get(transform_value_property_map, PM>(add1(), orig_pm), 3) == 7); + BOOST_CHECK(get(transform_value_property_map, PM>(add1(), orig_pm), 4) == 9); + BOOST_CHECK(get(make_transform_value_property_map(add1(), orig_pm), 5) == 11); + BOOST_CHECK(get(transform_value_property_map, PM>(add1_val(), orig_pm), 3) == 7); + BOOST_CHECK(get(transform_value_property_map, PM>(add1_val(), orig_pm), 4) == 9); + BOOST_CHECK(get(make_transform_value_property_map(add1_val(), orig_pm), 5) == 11); + int val; + const transform_value_property_map, PM> pm(return_fixed_ref((&val)), orig_pm); + put(pm, 1, 6); + BOOST_CHECK(get(pm, 2) == 6); + BOOST_CHECK((get(pm, 3) = 7) == 7); + BOOST_CHECK(get(pm, 4) == 7); + const transform_value_property_map, PM> pm2 = pm; // Check shallow copying + BOOST_CHECK(get(pm2, 5) == 7); + put(pm2, 3, 1); + BOOST_CHECK(get(pm, 1) == 1); + + return 0; +} -- cgit v1.2.3