### Property Map Interface Example (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/property_map Demonstrates the usage of Boost Property Map interface functions (get, put, operator[]) with std::map and boost::associative_property_map. It shows how to access and modify address mappings for people. ```C++ #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; } ``` -------------------------------- ### C++ Iterator Property Map Adaptor Example Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/iterator_property_map This example demonstrates how to use the iterator_property_map to create property maps for edge capacities and flows in a Boost graph. It shows the setup of the graph, property arrays, and the creation of iterator property maps using the edge index map, finally calling a print_network function that utilizes these maps. ```cpp // print out the capacity and flow for all the edges in the graph template void print_network(Graph& G, CapacityPMap capacity, FlowPMap flow) { typedef typename boost::graph_traits::vertex_iterator Viter; typedef typename boost::graph_traits::out_edge_iterator OutEdgeIter; typedef typename boost::graph_traits::in_edge_iterator InEdgeIter; Viter ui, uiend; for (boost::tie(ui, uiend) = vertices(G); ui != uiend; ++ui) { OutEdgeIter out, out_end; std::cout << *ui << "\t"; for(boost::tie(out, out_end) = out_edges(*ui, G); out != out_end; ++out) std::cout << "--(" << get(capacity, *out) << ", " << get(flow, *out) << ")--> " << target(*out,G) << "\t"; std::cout << std::endl << "\t"; InEdgeIter in, in_end; for(boost::tie(in, in_end) = in_edges(*ui, G); in != in_end; ++in) std::cout << "<--(" << get(capacity, *in) << "," << get(flow, *in) << ")-- " << source(*in,G) << "\t"; std::cout << std::endl; } } int main(int, char*[]) { typedef boost::adjacency_list > Graph; const int num_vertices = 9; Graph G(num_vertices); int capacity[] = { 10, 20, 20, 20, 40, 40, 20, 20, 20, 10 }; int flow[] = { 8, 12, 12, 12, 12, 12, 16, 16, 16, 8 }; // add edges to the graph, and assign each edge an ID number // to index into the property arrays add_edge(G, 0, 1, 0); // ... typedef boost::graph_traits::edge_descriptor Edge; typedef boost::property_map::type EdgeID_PMap; EdgeID_PMap edge_id = get(boost::edge_index(), G); boost::iterator_property_map capacity_pa(capacity, edge_id), flow_pa(flow, edge_id); print_network(G, capacity_pa, flow_pa); return 0; } ``` -------------------------------- ### Compose Property Map Adaptor Example Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/compose_property_map Demonstrates the usage of compose_property_map, an adaptor that combines two property maps. FPMap can be any property map, while GPMap must be a Readable Property Map. The example shows how to create, read from, and write to the composed property map. ```cpp #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; } ``` -------------------------------- ### Example Usage of Associative Property Map Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/associative_property_map Demonstrates how to use `associative_property_map` with `std::map`. The `foo` function takes an address map (which can be an `associative_property_map`) and modifies it using `get` and `put`. The main function sets up the `std::map`, creates the adaptor, calls `foo`, and prints the results. ```cpp #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; } ``` -------------------------------- ### Manipulate Fred's Info with Property Maps Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map A generic C++ function demonstrating basic property map operations. It uses `boost::property_traits` to determine key and value types, and `get` and `put` functions to retrieve and update property values. This example requires property maps to have compatible key types and value types constructible from int and float respectively. ```cpp template void manipulate_freds_info(AgeMap ages, GPAMap gpas) { typedef typename boost::property_traits::key_type name_type; typedef typename boost::property_traits::value_type age_type; typedef typename boost::property_traits::value_type gpa_type; name_type fred = "Fred"; age_type old_age = get(ages, fred); gpa_type old_gpa = get(gpas, fred); std::cout << "Fred's old age: " << old_age << "\n" << "Fred's old gpa: " << old_gpa << "\n"; age_type new_age = 18; gpa_type new_gpa = 3.9; put(ages, fred, new_age); put(gpas, fred, new_gpa); } ``` -------------------------------- ### Initialize and Use Boost Associative Property Map Source: https://www.boost.org/doc/libs/latest/libs/property_map/example/example1 Creates a Boost associative_property_map wrapper around a standard std::map to enable generic property map operations. Initializes the underlying map with string key-value pairs representing names and addresses, then passes it to a generic template function for manipulation. Demonstrates the bridge between standard containers and the Boost property map abstraction. ```cpp 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; } ``` -------------------------------- ### Initialize and Use dynamic_properties with Property Maps Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map A main function that demonstrates how to construct dynamic_properties objects, populate them with associative_property_map adaptors backed by std::map containers, and then use them to manipulate properties. The example creates property maps for age (int) and GPA (double) data, registers them with the dynamic_properties object using string keys, and calls the manipulation function. ```cpp int main() { using boost::get; // build property maps using associative_property_map std::map name2age; std::map name2gpa; boost::associative_property_map< std::map > age_map(name2age); boost::associative_property_map< std::map > gpa_map(name2gpa); std::string fred("Fred"); // add key-value information name2age.insert(make_pair(fred,17)); name2gpa.insert(make_pair(fred,2.7)); // build and populate dynamic interface boost::dynamic_properties properties; properties.property("age",age_map); properties.property("gpa",gpa_map); manipulate_freds_info(properties); std::cout << "Fred's age: " << get(age_map,fred) << "\n" << "Fred's gpa: " << get(gpa_map,fred) << "\n"; } ``` -------------------------------- ### Example Usage of vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Demonstrates how to use vector_property_map to store and access string properties associated with integer keys. It shows assigning a value to a key, retrieving an existing value, and accessing a non-existent key which returns a default-constructed value. ```cpp #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"; } ``` -------------------------------- ### Assign and Retrieve Strings with boost::vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/example/example3 This C++ code snippet utilizes boost::vector_property_map to store string values associated with integer keys. It demonstrates assigning a string 'e' to key 4 and retrieving values for both an assigned key (4) and an unassigned key (10), which defaults to an empty string. Requires the Boost Property Map library. ```cpp // 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"; } ``` -------------------------------- ### Generic Property Map Template Function with Boost Source: https://www.boost.org/doc/libs/latest/libs/property_map/example/example1 Defines a template function that accepts a property map parameter and demonstrates both get/put operations and direct array-style access to modify values in an associative container. Uses boost::property_traits to extract key and value types at compile time. The function showcases three different methods of accessing and modifying property map entries. ```cpp 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"; } ``` -------------------------------- ### get Method - dynamic_property_map Interface Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Member function that returns the value associated with a given key from the property map. The key object must be convertible to the map's key type, and the key must be associated with an existing value. ```cpp boost::any get(const any& key) ``` -------------------------------- ### Manipulate Fred's Info Using dynamic_properties Interface Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map A function that demonstrates how to use the dynamic_properties interface to get and put property values. The function retrieves Fred's age as an int and GPA as a string, then updates them with new values. String-based keys are used to identify properties, but the function still maintains type safety by specifying types in get() calls. ```cpp void manipulate_freds_info(boost::dynamic_properties& properties) { using boost::get; std::string fred = "Fred"; int old_age = get("age", properties, fred); std::string old_gpa = get("gpa", properties, fred); std::cout << "Fred's old age: " << old_age << "\n" << "Fred's old gpa: " << old_gpa << "\n"; std::string new_age = "18"; double new_gpa = 3.9; put("age",properties,fred,new_age); put("gpa",properties,fred,new_gpa); } ``` -------------------------------- ### get Function - Boost PropertyMap Template Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Template function that retrieves a value from a named property map using a provided key. If the Value type is std::string, the property map's value must be std::string or OutputStreamable. Throws dynamic_get_failure if no matching property map is found. ```cpp template Value get(const std::string& name, const dynamic_properties& dp, const Key& key) ``` -------------------------------- ### Readable Property Map Concept Checking Class Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/ReadablePropertyMap This C++ code defines a concept checking class for the Readable Property Map. It verifies that a given property map type conforms to the requirements of a readable property map, including the existence of the get() function and the correct category. ```cpp template struct ReadablePropertyMapConcept { typedef typename property_traits::key_type key_type; typedef typename property_traits::category Category; typedef boost::readable_property_map_tag ReadableTag; void constraints() { function_requires< ConvertibleConcept >(); val = get(pmap, k); } PMap pmap; Key k; typename property_traits::value_type val; }; ``` -------------------------------- ### get Function for Typed Identity Property Map (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/identity_property_map Provides a non-member get function for the typed_identity_property_map. Similar to operator[], it takes the property map and a key x of type T, returning a copy of x. This function is part of the Boost Property Map interface for readable maps. ```cpp T get(const typed_identity_property_map& pmap, const T& x) ``` -------------------------------- ### Factory Function to Create Shared Array Property Map Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/shared_array_property_map Creates a shared_array_property_map using template parameter deduction. This convenience function accepts size, a value type example, and an OffsetMap, returning a properly constructed shared_array_property_map without explicit template arguments. ```cpp template shared_array_property_map make_shared_array_property_map(size_t n, const ValueType&, OffsetMap omap) ``` -------------------------------- ### Get value_type from function_property_map Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/function_property_map Retrieves the value type of the function_property_map, which is the function's result type with reference and cv-qualifiers removed. ```cpp property_traits::value_type ``` -------------------------------- ### Get Property Map Value Type Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/shared_array_property_map Retrieves the value type of the shared_array_property_map using property_traits. This type is identical to the ValueType template parameter and represents the data type stored in the property map. ```cpp property_traits::value_type ``` -------------------------------- ### Finding the lower bound iterator in dynamic_properties Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map This member function returns an iterator to the first property map whose `dynamic_properties` key matches the provided `name`. It's important to note that multiple property maps can share the same `dynamic_properties` key if their internal property map key types differ. The range starting from this iterator up to `end()` contains all property maps associated with the given `name`. ```cpp iterator lower_bound(const std::string& name) ``` -------------------------------- ### Specialize Property Traits for Pointer Types Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/property_map This specialization of property_traits enables builtin C++ pointer types (T*) to be used as property maps. Pointers model LvaluePropertyMap with std::ptrdiff_t as the key type and random_access_iterator_pa_tag as the category. The specialization includes overloads of put() and get() functions for pointer-based property map operations. ```cpp namespace boost { // specialization for using pointers as property maps template struct property_traits { typedef T value_type; typedef T& reference; typedef std::ptrdiff_t key_type; typedef random_access_iterator_pa_tag category; }; // overloads of the property map functions for pointers template<> void put(T* pmap, std::ptrdiff_t k, const T& val) { pmap[k] = val; } template<> const T& get(const T* pmap, std::ptrdiff_t k) { return pmap[k]; } } ``` -------------------------------- ### Construct ref_property_map Instance (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/ref_property_map Demonstrates the constructors for the `ref_property_map` class. The primary constructor takes a reference to the value that the property map will return. A copy constructor is also provided for creating new instances from existing ones. ```cpp ref_property_map(ValueType& v) ref_property_map(const ref_property_map& x) ``` -------------------------------- ### Constructor for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Shows the basic constructor for vector_property_map which takes an optional index map. This constructor initializes the property map, ready to store properties associated with keys. ```cpp vector_property_map(const IndexMap& index = IndexMap()) ``` -------------------------------- ### Constructor with Initial Size for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Presents a constructor for vector_property_map that allows specifying an initial size. This can optimize performance by pre-allocating storage for elements up to the given index, though the map remains dynamically resizable. ```cpp vector_property_map(unsigned initial_size, const IndexMap& index = IndexMap()) ``` -------------------------------- ### Factory Function for Compose Property Map Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/compose_property_map Provides a non-member function 'make_compose_property_map' to create an instance of the 'compose_property_map' adaptor. This function simplifies the creation of the adaptor by taking two property maps as arguments. ```cpp template compose_property_map make_compose_property_map(const FPMap& f, const GPMap& g); ``` -------------------------------- ### make_vector_property_map Helper Function in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map A convenience function to create a vector_property_map. It simplifies instantiation by taking an index map as an argument and returning a newly created vector_property_map. ```cpp template vector_property_map make_vector_property_map(IndexMap index) { return vector_property_map(index); } ``` -------------------------------- ### Constructing dynamic_properties with a property map factory function Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map This constructor allows creating a `dynamic_properties` object with a custom factory function. The function is responsible for creating new property maps when needed. If no function is provided, attempts to add properties to non-existent keys will throw an exception. ```cpp dynamic_properties() dynamic_properties( const boost::function< boost::shared_ptr ( const std::string&, const boost::any&, const boost::any&) >& fn) ``` -------------------------------- ### Transform Value Property Map Constructor Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/transform_value_property_map The constructor for `transform_value_property_map`. It takes the unary function and the underlying property map as arguments to initialize the adaptor. ```cpp transform_value_property_map(const UnaryFunction& f, const PM& pm); ``` -------------------------------- ### Directly Inserting a dynamic_property_map Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map This function allows for the direct insertion of a `dynamic_property_map` object into the collection. It takes a `name` (string) as the key and a `boost::shared_ptr` representing the property map to be added. ```cpp void insert(const std::string& name, boost::shared_ptr pm) ``` -------------------------------- ### key Method - dynamic_property_map Type Query Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Member function that returns type information about the property map's key type. Provides runtime type information for introspection of the key type. ```cpp const std::type_info& key() const ``` -------------------------------- ### Make Associative Property Map Function Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/associative_property_map A non-member function template that provides a convenient way to create an `associative_property_map` instance by forwarding a reference to the underlying container. This function simplifies the instantiation process. ```cpp template associative_property_map make_assoc_property_map(UniquePairAssociativeContainer& c); ``` -------------------------------- ### C++ make_iterator_property_map Helper Function Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/iterator_property_map A convenience function for creating an `iterator_property_map` with a specified iterator and offset map. This simplifies instantiation compared to using the constructor directly. ```cpp template iterator_property_map::value_type, typename std::iterator_traits::reference> make_iterator_property_map(RAIter iter, OffsetMap omap) ``` -------------------------------- ### WritablePropertyMapConcept in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/WritablePropertyMap This C++ code defines a concept checking class for Writable Property Maps. It verifies that the provided `PMap` type meets the requirements of a writable property map, including the ability to use the `put()` function. ```cpp #include #include template struct WritablePropertyMapConcept { typedef typename boost::property_traits::key_type key_type; typedef typename boost::property_traits::category Category; typedef boost::writable_property_map_tag WritableTag; void constraints() { boost::function_requires >(); put(pmap, k, val); } PMap pmap; Key k; typename boost::property_traits::value_type val; }; ``` -------------------------------- ### Create function_property_map with Key and Ref Types Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/function_property_map Non-member function to create a function_property_map, explicitly specifying the Key and Ref types. ```cpp template function_property_map make_function_property_map(const UnaryFunction& f); ``` -------------------------------- ### Constructor for function_property_map Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/function_property_map Constructs a function_property_map, optionally taking a UnaryFunction object. ```cpp function_property_map(const UnaryFunction& f = UnaryFunction()) ``` -------------------------------- ### C++ iterator_property_map Constructors Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/iterator_property_map Provides the constructors for `iterator_property_map`. The first constructor defaults the `OffsetMap`, while the second explicitly takes an `OffsetMap` object. ```cpp iterator_property_map(Iterator i) iterator_property_map(Iterator i, OffsetMap m) ``` -------------------------------- ### Create Static Property Map Factory Function C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/static_property_map Non-member template function that constructs and returns a static_property_map instance with deduced key and value types. Takes a const reference to a value and returns a fully initialized static_property_map that can be used with Boost property map algorithms. ```cpp template static_property_map make_static_property_map(const ValueType& value); ``` -------------------------------- ### Boost ReadWritePropertyMapConcept C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/ReadWritePropertyMap This C++ code defines the `ReadWritePropertyMapConcept` template for concept checking in Boost property maps. It ensures that a property map satisfies both the `ReadablePropertyMapConcept` and `WritablePropertyMapConcept`, and that its category is convertible to `boost::read_write_property_map_tag`. This is crucial for verifying the correct usage of read/write property maps within the Boost library. ```cpp template struct ReadWritePropertyMapConcept { typedef typename property_traits::category Category; typedef boost::read_write_property_map_tag ReadWriteTag; void constraints() { function_requires< ReadablePropertyMapConcept >(); function_requires< WritablePropertyMapConcept >(); function_requires< ConvertibleConcept >(); } }; ``` -------------------------------- ### Boost make_assoc_property_map helper function Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/const_assoc_property_map A non-member function template that provides a convenient way to create a const_associative_property_map from any suitable associative container. This function simplifies the instantiation process. ```cpp template const_associative_property_map make_assoc_property_map(const UniquePairAssociativeContainer& c); ``` -------------------------------- ### Make Transform Value Property Map Helper Function Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/transform_value_property_map Provides a non-member function overload to conveniently create a `transform_value_property_map` when the function's result type can be deduced. It takes the unary function and the property map. ```cpp template transform_value_property_map make_transform_value_property_map(const UnaryFunction& f, const PM& pm); ``` -------------------------------- ### Construct Shared Array Property Map with Default OffsetMap Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/shared_array_property_map Initializes a shared_array_property_map with a specified number of elements and default-constructed OffsetMap. The constructor allocates storage for n elements using boost::shared_array internally. ```cpp shared_array_property_map(size_t n) ``` -------------------------------- ### dynamic_properties Class Declaration Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map The class definition template for dynamic_properties from the Boost property_map library. This class provides a dynamically-typed interface to a set of property maps and must be populated with property maps using the property() member function. ```cpp class dynamic_properties ``` -------------------------------- ### value Method - dynamic_property_map Type Query Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Member function that returns type information about the property map's value type. Provides runtime type information for introspection of the value type. ```cpp const std::type_info& value() const ``` -------------------------------- ### Define ref_property_map Class (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/ref_property_map This C++ template class, `ref_property_map`, wraps a reference to a specific object. It returns this reference whenever a key object is provided as input. It's defined in 'boost/property_map/property_map.hpp' and models an Lvalue Property Map. ```cpp template class ref_property_map ``` -------------------------------- ### Adding a Property Map to dynamic_properties Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map The `property` member function adds a new property map to the collection managed by `dynamic_properties`. It uses a string `name` as the key for this property map. The `PropertyMap` type must conform to either the Readable Property Map or Read/Write Property Map concepts. ```cpp template dynamic_properties& property(const std::string& name, PropertyMap property_map) ``` -------------------------------- ### C++ make_iterator_property_map with Dummy Argument Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/iterator_property_map An overloaded `make_iterator_property_map` function that accepts an additional dummy argument. This version is useful for compilers that do not support partial template specialization, such as older versions of Visual C++. ```cpp template iterator_property_map::value_type, typename std::iterator_traits::reference> make_iterator_property_map(RAIter iter, OffsetMap omap, ValueType dummy_arg) ``` -------------------------------- ### Create function_property_map with Key Type Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/function_property_map Non-member function to create a function_property_map, inferring the Ref type from the UnaryFunction and Key. ```cpp template function_property_map make_function_property_map(const UnaryFunction& f); ``` -------------------------------- ### Obtaining an Iterator to the beginning of dynamic_properties Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Returns an iterator pointing to the first property map within the `dynamic_properties` object. This function is overloaded for both mutable and constant access, allowing iteration over the collection of property maps. ```cpp iterator begin() const_iterator begin() const ``` -------------------------------- ### dynamic_property_map Class Interface - Boost PropertyMap Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Class that defines the polymorphic interface used by dynamic_properties to interact with user property maps. It provides methods for getting/putting values, retrieving string representations, and querying key and value type information. ```cpp class dynamic_property_map { public: boost::any get(const any& key); std::string get_string(const any& key); void put(const any& key, const any& value); const std::type_info& key() const; const std::type_info& value() const; }; ``` -------------------------------- ### put Method - dynamic_property_map Interface Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Member function that associates a key with a value in the property map. Both key and value objects must be convertible to the map's key and value types respectively. Not all property maps support this operation; errors are signaled if unsupported. ```cpp void put(const any& key, const any& value) ``` -------------------------------- ### Vector Property Map Template Definition and Description Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Defines the template signature for vector_property_map, which efficiently stores properties for a variable number of elements. It's suitable when the number of elements isn't known at creation time and offers a performance advantage over associative property maps while being more flexible than iterator property maps. It does not guarantee reference or pointer stability for stored values. ```cpp template class vector_property_map; ``` -------------------------------- ### Transform Value Property Map Declaration Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/transform_value_property_map Declares the `transform_value_property_map` class template, which adapts an existing property map by applying a unary function to its values. It is defined in `boost/property_map/transform_value_property_map.hpp`. ```cpp template class transform_value_property_map { // ... }; ``` -------------------------------- ### get_string Method - dynamic_property_map Interface Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Member function that returns the string representation of a value associated with a given key. Requires the property map's value type to model OutputStreamable. The key must be convertible to the map's key type and must be associated with an existing value. ```cpp std::string get_string(const any& key) ``` -------------------------------- ### Construct Shared Array Property Map with Custom OffsetMap Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/shared_array_property_map Initializes a shared_array_property_map with a specified number of elements and a provided OffsetMap instance. This constructor allows custom offset mapping behavior for key-to-index conversion. ```cpp shared_array_property_map(size_t n, OffsetMap m) ``` -------------------------------- ### Define Static Property Map Template Class C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/static_property_map Declares a template class that wraps a value object and implements the Readable Property Map concept. The class takes two template parameters: ValueType (required) and KeyType (defaults to void). This property map returns a copy of the wrapped value for any key query. ```cpp template class static_property_map ``` -------------------------------- ### Reserve Capacity Method for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map The reserve method allows pre-allocating space in the underlying vector for elements up to a specified maximum index. This can ensure O(1) access time for elements within the reserved range, provided no elements with larger indices are accessed. ```cpp void reserve(unsigned size) ``` -------------------------------- ### Exception Hierarchy - Boost PropertyMap Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Complete exception hierarchy for dynamic property map operations. Includes base class dynamic_property_exception and three concrete exception types: property_not_found, dynamic_get_failure, and dynamic_const_put_error. All exceptions derive from std::exception for generalized error handling. ```cpp struct dynamic_property_exception : public std::exception { virtual ~dynamic_property_exception() throw() {} }; struct property_not_found : public std::exception { std::string property; property_not_found(const std::string& property); virtual ~property_not_found() throw(); const char* what() const throw(); }; struct dynamic_get_failure : public std::exception { std::string property; dynamic_get_failure(const std::string& property); virtual ~dynamic_get_failure() throw(); const char* what() const throw(); }; struct dynamic_const_put_error : public std::exception { virtual ~dynamic_const_put_error() throw(); const char* what() const throw(); }; ``` -------------------------------- ### Boost Property Map Category Tags (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/property_map Defines tag structs for different property map categories (readable, writable, read/write, lvalue) in C++. These tags are used to identify the capabilities of a property map. ```C++ namespace boost { struct readable_property_map_tag { }; struct writable_property_map_tag { }; struct read_write_property_map_tag : public readable_property_map_tag, public writable_property_map_tag { }; struct lvalue_property_map_tag : public read_write_property_map_tag { }; } ``` -------------------------------- ### Boost Constant Associative Property Map Adaptor Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/const_assoc_property_map Demonstrates the usage of const_associative_property_map to create a read-only property map from a std::map. The code defines a generic display function that utilizes property map traits to access values associated with keys and then applies this function to an instance of the const_associative_property_map. ```cpp #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; } ``` -------------------------------- ### Define function_property_map Template Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/function_property_map Defines the function_property_map template, which adapts a function object into a property map. The category of the property map depends on the function's return type. ```cpp template class function_property_map : public boost::property_map_traits<...> { public: // ... members and constructors ... }; ``` -------------------------------- ### put Function - Boost PropertyMap Template Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Template function that adds a key-value pair to a named property map within a dynamic_properties object. If no matching property map exists, it uses a property map generator to create one, throws property_not_found if no generator is available, or throws dynamic_const_put_error if the map doesn't support put operations. ```cpp template bool put(const std::string& name, dynamic_properties& dp, const Key& key, const Value& value) ``` -------------------------------- ### Transform Value Property Map Value Type Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/transform_value_property_map Defines the `value_type` for a `transform_value_property_map`. This type is derived from the `Ref` template parameter, with any reference or cv-qualifiers removed. ```cpp using value_type = /* details of Ref with qualifiers removed */; template<> struct property_traits> { using value_type = /* details of Ref with qualifiers removed */; // ... other property_traits members }; ``` -------------------------------- ### Underlying Storage Iterator Accessors for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Provides access to the begin and end iterators of the internal vector storing the property values. These methods are useful for operations like initializing all elements but are named to reflect that the map is conceptually unbounded. ```cpp std::vector::iterator storage_begin() std::vector::iterator storage_end() std::vector::const_iterator storage_begin() const std::vector::const_iterator storage_end() const ``` -------------------------------- ### ignore_other_properties Function - Boost PropertyMap Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Free function that returns a dynamic property map generator for ignoring unknown property keys. When passed to the dynamic_properties constructor, it allows the object to disregard attempts to put values to unknown keys without signaling an error. ```cpp boost::shared_ptr ignore_other_properties(const std::string&, const boost::any&, const boost::any&) ``` -------------------------------- ### Make Transform Value Property Map with Explicit Result Type Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/transform_value_property_map Provides an overload for `make_transform_value_property_map` that allows explicitly specifying the function's result type (`Ref`) when type deduction might be ambiguous or for clarity. ```cpp template transform_value_property_map make_transform_value_property_map(const UnaryFunction& f, const PM& pm); ``` -------------------------------- ### C++ iterator_property_map Type Definition Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/iterator_property_map This snippet defines the `iterator_property_map` type, which is an adaptor that transforms a random access iterator into an Lvalue Property Map. It relies on an `OffsetMap` to map keys to integer offsets compatible with the iterator. ```cpp iterator_property_map ``` -------------------------------- ### Associative Property Map Adaptor Declaration Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/associative_property_map Declares the `associative_property_map` adaptor, which wraps associative containers. It requires the container to model Pair Associative Container and Unique Associative Container. The adaptor only holds a reference, so the container's lifetime must exceed the adaptor's usage. ```cpp template class associative_property_map : public boost::detail::property_map_value_by_reference_tag { // ... definition details ... }; ``` -------------------------------- ### Obtaining a terminal iterator for dynamic_properties Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/dynamic_property_map Returns a terminal iterator, often referred to as the 'end' iterator. This iterator signifies the end of the sequence of property maps held by the `dynamic_properties` object and is used to terminate iteration loops. ```cpp iterator end() const_iterator end() const ``` -------------------------------- ### Copy Constructor for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Defines the copy constructor for vector_property_map. Importantly, it notes that the copy shares the same underlying data, meaning modifications to the copied map will affect the original. ```cpp vector_property_map(const vector_property_map&) ``` -------------------------------- ### Static Property Map Subscript Operator C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/static_property_map Member function template that implements the subscript operator for the static_property_map class. Accepts any key type T and returns a copy of the contained ValueType, ignoring the specific key provided. This operator is const-qualified and enables property map access syntax. ```cpp template ValueType& operator[](T) const ``` -------------------------------- ### LvaluePropertyMapConcept in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/LvaluePropertyMap Defines the constraints for a non-mutable LvaluePropertyMap. It requires the property map to be a model of ReadWritePropertyMapConcept and its category to be convertible to boost::lvalue_property_map_tag. Accessing a property returns a const reference. ```cpp template struct LvaluePropertyMapConcept { typedef typename property_traits::category Category; typedef boost::lvalue_property_map_tag LvalueTag; typedef const typename property_traits::value_type& const_reference; void constraints() { function_requires< ReadWritePropertyMapConcept >(); function_requires< ConvertibleConcept >(); const_reference ref = pmap[k]; } PMap pmap; Key k; }; ``` -------------------------------- ### Define Shared Array Property Map Class Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/shared_array_property_map Declares the shared_array_property_map template class with ValueType and OffsetMap parameters. The OffsetMap must be a Readable Property Map with values convertible to std::size_t, responsible for converting key objects to array offsets. ```cpp shared_array_property_map ``` -------------------------------- ### Mutable_LvaluePropertyMapConcept in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/LvaluePropertyMap Defines the constraints for a mutable LvaluePropertyMap. Similar to the non-mutable version, it requires ReadWritePropertyMapConcept and convertibility to boost::lvalue_property_map_tag, but allows modification through the returned reference. ```cpp template struct Mutable_LvaluePropertyMapConcept { typedef typename property_traits::category Category; typedef boost::lvalue_property_map_tag LvalueTag; typedef typename property_traits::value_type& reference; void constraints() { function_requires< ReadWritePropertyMapConcept >(); function_requires >(); reference ref = pmap[k]; } PMap pmap; Key k; }; ``` -------------------------------- ### Assignment Operator for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Describes the assignment operator for vector_property_map. Similar to the copy constructor, assignment results in shared data, where changes to the assigned-to map affect the source map. ```cpp vector_property_map& operator=(const vector_property_map&) ``` -------------------------------- ### Typed Identity Property Map Declaration (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/identity_property_map Declares the typed_identity_property_map template and its common alias, identity_property_map, for use with std::size_t. This map applies the identity function, returning a copy of the key. It is defined in boost/property_map/property_map.hpp and models a Readable Property Map. ```cpp boost::typed_identity_property_map typedef boost::typed_identity_propoperty_map boost::identity_property_map ``` -------------------------------- ### Property Access Operator for vector_property_map in C++ Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/vector_property_map Details the bracket operator used for accessing and modifying properties within a vector_property_map. It takes a key type and returns a reference to the associated property value. ```cpp reference operator[](const key_type& v) const ``` -------------------------------- ### Operator[] for Typed Identity Property Map (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/identity_property_map Implements the operator[] for the typed_identity_property_map, which takes a key of type T and returns a copy of that key. This adheres to the Readable Property Map concept by returning a value of type T. Note that previous overloads returning copies of keys of any type are deprecated. ```cpp T operator[](const T& x) const ``` -------------------------------- ### Define Property Traits Template Structure Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/property_map The boost::property_traits template struct deduces types associated with a property map: key_type, value_type, reference, and category. This is the foundation for the property map interface and allows compile-time type introspection similar to std::iterator_traits. ```cpp namespace boost { template struct property_traits { typedef typename PropertyMap::key_type key_type; typedef typename PropertyMap::value_type value_type; typedef typename PropertyMap::reference reference; typedef typename PropertyMap::category category; }; } ``` -------------------------------- ### Access Contained Reference in ref_property_map (C++) Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/ref_property_map This function overload for the `operator[]` in `ref_property_map` returns the contained reference. It takes a constant reference to a KeyType object as input and returns a modifiable reference to the ValueType. ```cpp ValueType& operator[](KeyType const&) const ``` -------------------------------- ### Associative Property Map Type Traits Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/associative_property_map Defines the `property_traits` for `associative_property_map`. The `value_type` is derived from the underlying `UniquePairAssociativeContainer`'s `data_type`, indicating the type of values stored in the property map. ```cpp template struct property_traits> { typedef typename UniquePairAssociativeContainer::key_type key_type; typedef typename UniquePairAssociativeContainer::data_type value_type; // ... other traits ... }; ``` -------------------------------- ### C++ iterator_property_map Member Type Source: https://www.boost.org/doc/libs/latest/libs/property_map/doc/iterator_property_map Defines the `value_type` for the `iterator_property_map`, which is inherited from the underlying iterator's value type. ```cpp property_traits::value_type ```