### Boost.Fusion as_set Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/conversion/functions/as_set Demonstrates a simple usage example of the 'as_set' function, converting a fusion sequence created with 'make_vector' into a set. ```cpp as_set(make_vector('x', 123, "hello")) ``` -------------------------------- ### Boost Fusion make_set Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/make_set An example demonstrating the practical usage of the make_set function, creating a set with different data types. ```cpp make_set(123, "hello", 12.5) ``` -------------------------------- ### Boost.Fusion make_list C++ Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/make_list Demonstrates a practical example of calling the make_list function with different data types to create a Fusion list. ```cpp make_list(123, "hello", 12.5) ``` -------------------------------- ### Boost.Fusion at_key Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/functions/at_key An example demonstrating the usage of the at_key function in C++. It shows how to create a fusion sequence and retrieve an element using its key. ```cpp #include #include #include #include int main() { using namespace boost::fusion; set s(1, 'x', true); assert(at_key(s) == 'x'); return 0; } ``` -------------------------------- ### front_extended_deque Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/front_extended_deque An example demonstrating the usage of `front_extended_deque` to create a new deque with an element prepended. It shows how to initialize and access elements from the extended deque. ```cpp typedef deque initial_deque; initial_deque d(12, 5.5f); front_extended_deque d2(d, 999); std::cout << at_c<0>(d2) << std::endl; std::cout << at_c<1>(d2) << std::endl; std::cout << at_c<2>(d2) << std::endl; ``` -------------------------------- ### Boost.Fusion push_back Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/push_back Demonstrates a practical C++ example of using the push_back algorithm with Boost.Fusion's make_vector to append an element and verify the result using an assertion. ```cpp assert(push_back(make_vector(1,2,3),4) == make_vector(1,2,3,4)); ``` -------------------------------- ### as_set Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/conversion/metafunctions/as_set Provides an example of how to use as_set to convert a vector sequence to a set. ```cpp result_of::as_set >::type ``` -------------------------------- ### fused Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/functional/adapters/fused Provides a practical example of using the fused adapter with std::plus and a make_vector to sum elements, asserting the correct result. ```cpp fused< std::plus > f; assert(f(make_vector(1,2l)) == 3l); ``` -------------------------------- ### Boost.Fusion invoke header and example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/functional/invocation/functions/invoke This provides the necessary header file to use the 'invoke' function and an example demonstrating its usage with std::plus and make_vector. ```cpp #include std::plus add; assert(invoke(add,make_vector(1,1)) == 2); ``` -------------------------------- ### Make Map Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/make_map An example demonstrating the usage of make_map to create a map, with conditional compilation for C++03 and C++11 compatibility. ```cpp #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) result_of::make_map::type #else result_of::make_map::apply::type #endif ``` -------------------------------- ### Boost Fusion map_tie Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/map_tie An example demonstrating the usage of `map_tie` with custom key types and variables to create a map of references. ```cpp struct int_key; struct double_key; ... int i = 123; double d = 123.456; map_tie(i, d) ``` -------------------------------- ### Include Boost.Fusion Algorithm Headers Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/quick_start Includes the necessary headers for using Boost.Fusion's algorithmic functionalities. ```cpp #include #include ``` -------------------------------- ### Create and Access Boost.Fusion Vector Elements Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/quick_start Demonstrates the creation of a Fusion vector with heterogeneous elements and accessing them using at_c. ```cpp vector stuff(1, 'x', "howdy"); int i = at_c<0>(stuff); char ch = at_c<1>(stuff); std::string s = at_c<2>(stuff); ``` -------------------------------- ### Include Boost.Fusion Sequence Headers Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/quick_start Includes the necessary headers for using Boost.Fusion's sequence functionalities. ```cpp #include #include ``` -------------------------------- ### Boost.Fusion front function synopsis and example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/functions/front Demonstrates the C++ function signature for accessing the front element of a Boost.Fusion sequence and provides a usage example with assertions. ```cpp template typename result_of::front::type front(Sequence& seq); template typename result_of::front::type front(Sequence const& seq); vector v(1, 2, 3); assert(front(v) == 1); ``` -------------------------------- ### Boost.Fusion.back Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/back An example demonstrating the usage of `boost::fusion::back` with a `boost::fusion::vector`. It asserts that the result type of `back` is the same as the type of the last element. ```cpp typedef vector vec; BOOST_MPL_ASSERT((boost::is_same::type, char&>)); ``` -------------------------------- ### Boost Fusion make_map Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/make_map A simple example demonstrating the usage of the make_map function to create a map with specified key and value types. ```cpp make_map('X', "Men") ``` -------------------------------- ### Boost Fusion move Algorithm Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/auxiliary/functions/move An example demonstrating the usage of the Boost Fusion move algorithm to transfer elements from a vector to a list. It includes necessary headers and assertions. ```cpp #include #include #include #include #include #include int main() { using namespace boost::fusion; vector vec(1,2); list ls; move(std::move(vec), ls); assert(ls == make_list(1,2)); return 0; } ``` -------------------------------- ### Boost.Fusion invoke_procedure Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/functional/invocation/functions/invoke_proc Demonstrates a practical example of using invoke_procedure with a lambda expression and a Boost.Fusion vector. ```cpp vector v(1,2); using namespace boost::lambda; invoke_procedure(_1 += _2, v); assert(front(v) == 3); ``` -------------------------------- ### Boost.Fusion as_vector Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/conversion/metafunctions/as_vector Demonstrates a practical example of using Boost.Fusion's as_vector to convert a fusion list of characters and integers into a vector type. ```cpp result_of::as_vector >::type ``` -------------------------------- ### list_tie Example Usage (C++) Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/list_tie Demonstrates a practical example of using list_tie to create a list of references for 'int' and 'double' types. ```cpp result_of::list_tie::type ``` -------------------------------- ### Boost Fusion make_set Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/make_set An example demonstrating how to use make_set to create a set with elements of different types (int, char, double). ```cpp result_of::make_set::type ``` -------------------------------- ### Boost.Fusion for_each Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/iteration/functions/for_each An example demonstrating the usage of the Boost.Fusion for_each algorithm with a custom function object to increment elements in a vector. ```cpp struct increment { template void operator()(T& t) const { ++t; } }; vector vec(1,2); for_each(vec, increment()); assert(vec == make_vector(2,3)); ``` -------------------------------- ### Boost.Fusion advance_c Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/advance_c Demonstrates advancing an iterator using advance_c and verifying the result with MPL. ```cpp typedef vector vec; typedef result_of::begin::type first; typedef result_of::next::type second; typedef result_of::next::type third; BOOST_MPL_ASSERT((result_of::equal_to::type, third>)); ``` -------------------------------- ### Boost Fusion zip Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/zip An example demonstrating how to use the Boost Fusion zip algorithm to combine two vector sequences and assert the expected result. ```cpp vector v1(1, 'a'); vector v2(2, 'b'); assert(zip(v1, v2) == make_vector(make_vector(1, 2),make_vector('a', 'b')); ``` -------------------------------- ### Boost Fusion make_list Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/make_list Demonstrates a concrete example of using `make_list` with different types, including `int`, a C-style string literal, and `double`, to derive the resulting list type. ```cpp result_of::make_list::type ``` -------------------------------- ### Boost Fusion Count Algorithm Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/query/functions/count An example demonstrating the usage of the Boost Fusion count algorithm. It initializes a vector with specific types and then asserts that the count of a particular element matches the expected value. ```cpp const vector vec(1.0,2,3); assert(count(vec,2) == 1); ``` -------------------------------- ### Boost Fusion cons Initialization and Access Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/cons Demonstrates how to create and initialize a 'cons' list with different data types and access its elements using 'at_c'. The example shows creating a nested 'cons' structure and printing its elements. ```cpp cons > l(12, cons(5.5f)); std::cout << at_c<0>(l) << std::endl; std::cout << at_c<1>(l) << std::endl; ``` -------------------------------- ### Boost Fusion pop_back example usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/pop_back An example demonstrating the `pop_back` function's behavior by creating a vector and removing its last element, then asserting the result. ```cpp assert(pop_back(make_vector(1,2,3)) == make_vector(1,2)); ``` -------------------------------- ### list_tie Synopsis and Example (C++) Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/list_tie Defines the synopsis for the list_tie function, which constructs a tie using a list sequence. It also shows an example of its usage and the necessary header. ```cpp template list list_tie(T0& x0, T1& x1... TN& xN); #define FUSION_MAX_LIST_SIZE 20 #include #include int i = 123; double d = 123.456; list_tie(i, d) ``` -------------------------------- ### Iterate and Print Fusion Vector Elements Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/quick_start Applies the print_xml function object to each element of a Fusion vector using the for_each algorithm. ```cpp for_each(stuff, print_xml()); ``` -------------------------------- ### map_tie Example Usage (C++) Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/map_tie Provides a concrete example of using map_tie with specific key and value types to demonstrate its application in creating a map. ```cpp struct int_key; struct double_key; ... result_of::map_tie::type ``` -------------------------------- ### Boost.Fusion join Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/join Demonstrates how to use the join algorithm with Boost.Fusion vectors to concatenate them and verify the result. ```cpp vector v1(1, 'a'); vector v2(2, 'b'); assert(join(v1, v2) == make_vector(1,'a',2,'b')); ``` -------------------------------- ### Fusion make_vector Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/make_vector An example demonstrating the instantiation of the result_of::make_vector type, showing how to specify different types like int, a C-style string literal, and double as template arguments. ```cpp result_of::make_vector::type ``` -------------------------------- ### Boost.Fusion reverse algorithm example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/reverse This C++ code snippet provides a usage example for the Boost.Fusion reverse algorithm. It demonstrates reversing a vector and asserting that the result matches the expected reversed vector. ```cpp assert(reverse(make_vector(1,2,3)) == make_vector(3,2,1)); ``` -------------------------------- ### BOOST_FUSION_ADAPT_ADT Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/adapt_adt An example demonstrating the usage of BOOST_FUSION_ADAPT_ADT to adapt a 'demo::employee' struct as a Random Access Sequence, including how to access and modify its elements. ```cpp #include #include #include #include namespace demo { struct employee { private: std::string name; int age; public: void set_name(std::string const& n) { name=n; } void set_age(int a) { age=a; } std::string const& get_name()const { return name; } int get_age()const { return age; } }; } BOOST_FUSION_ADAPT_ADT( demo::employee, (obj.get_name(), obj.set_name(val)) (obj.get_age(), obj.set_age(val))) int main() { demo::employee e; boost::fusion::front(e) = "Edward Norton"; boost::fusion::back(e) = 41; //Prints 'Edward Norton is 41 years old' std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl; return 0; } ``` -------------------------------- ### vector_tie Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/vector_tie A simple example demonstrating the usage of vector_tie to get the result type for a vector of an int and a double. ```cpp result_of::vector_tie::type ``` -------------------------------- ### Boost Fusion any algorithm example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/query/functions/any An example demonstrating the usage of the Boost Fusion 'any' algorithm with a custom predicate 'odd'. It shows how 'any' returns true for a sequence containing an odd number and false otherwise. ```cpp struct odd { template bool operator()(T t) const { return t % 2; } }; assert(any(make_vector(1,2), odd())); assert(!any(make_vector(2,4), odd())); ``` -------------------------------- ### Create and Print zip_view in Boost.Fusion Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/view/zip_view Example demonstrating how to create two vector sequences, combine them into a zip_view, and print the resulting view. ```cpp typedef vector vec1; typedef vector vec2; vec1 v1(1,2); vec2 v2('a','b'); typedef vector sequences; std::cout << zip_view(sequences(v1, v2)) << std::endl; // ((1 a) (2 b)) ``` -------------------------------- ### Boost.Fusion as_list - Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/conversion/metafunctions/as_list Demonstrates how to use as_list to get the result type for converting a vector to a list. ```cpp result_of::as_list >::type ``` -------------------------------- ### Fusion make_list element conversion example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/notes This C++ example shows how the `make_list` function in Boost.Fusion converts its arguments to suitable sequence element types. By default, elements are stored as plain values. ```cpp make_list(1, 'x') ``` -------------------------------- ### Boost.Fusion as_map Conversion Examples Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/conversion/metafunctions/as_map Provides examples of using `as_map` to convert different types of fusion sequences into map types. This includes sequences of fusion pairs and associative structs. ```cpp // from sequence of __fusion_pair__ result_of::as_map , fusion::pair > >::type // from associative sequence namespace ns { struct x_member; struct y_member; } BOOST_FUSION_DEFINE_ASSOC_STRUCT( (ns), point, (int, x, ns::x_member) (int, y, ns::y_member) ) ... result_of::as_map::type // __map__<__fusion_pair__, __fusion_pair__ > ``` -------------------------------- ### Boost.Fusion prior usage example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/prior Demonstrates how to use the Boost.Fusion prior type trait to get the iterator to the previous element in a sequence. It includes assertions to verify the iterator types. ```cpp typedef vector vec; typedef result_of::next::type>::type second; BOOST_MPL_ASSERT((boost::is_same::type, double>)); typedef result_of::prior::type first; BOOST_MPL_ASSERT((boost::is_same::type, int>)); ``` -------------------------------- ### Boost.Fusion vector Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/vector Provides a practical example of creating and accessing elements within a Boost.Fusion vector. It shows the instantiation of a vector with specific types and values, and then uses `at_c` to retrieve individual elements. ```cpp vector v(12, 5.5f); std::cout << at_c<0>(v) << std::endl; std::cout << at_c<1>(v) << std::endl; ``` -------------------------------- ### Boost.Fusion Set Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/set Demonstrates the creation and usage of a Boost.Fusion set. It shows how to declare a set with specific types, initialize it with values, access elements by key, and check for the existence of a key. ```cpp typedef set S; S s(12, 5.5f); std::cout << at_key(s) << std::endl; std::cout << at_key(s) << std::endl; std::cout << result_of::has_key::value << std::endl; ``` -------------------------------- ### iter_fold Example - Boost Fusion Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/iteration/functions/iter_fold Demonstrates the usage of iter_fold with a custom struct 'make_string' to concatenate elements of a Boost Fusion vector into a string. It shows the setup of the functor and the assertion of the expected result. ```cpp struct make_string { typedef std::string result_type; template std::string operator()(const std::string& str, const T& t) const { return str + boost::lexical_cast(deref(t)); } }; ... const vector vec(1,2); assert(iter_fold(vec,std::string(""), make_string()) == "12"); ``` -------------------------------- ### Boost.Fusion Advance Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/advance Demonstrates how to use the advance algorithm to move an iterator and assert equality with another iterator. ```cpp typedef vector vec; typedef result_of::begin::type first; typedef result_of::next::type second; typedef result_of::next::type third; BOOST_MPL_ASSERT((result_of::equal_to >::type, third>)); ``` -------------------------------- ### Boost Fusion push_front Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/push_front Demonstrates the usage of the push_front function by creating a vector sequence and prepending an element to it, then asserting the equality of the resulting sequence with an expected sequence. ```cpp assert(push_front(make_vector(1,2,3),0) == make_vector(0,1,2,3)); ``` -------------------------------- ### Boost.Fusion reverse_view Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/view/reverse_view This example demonstrates how to use `reverse_view` with a Boost.Fusion `vector`. It creates a `vector_type`, initializes an instance `vec`, then creates a `reverse_view` named `reverse` of `vec`, and prints the `reverse` view to standard output. ```cpp typedef vector vector_type; vector_type vec(2, 5, 3.3); reverse_view reverse(vec); std::cout << reverse << std::endl; ``` -------------------------------- ### Boost.Fusion.any Header Inclusion Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/query/metafunctions/any Shows the necessary header files to include for using the Boost.Fusion.any metafunction and algorithm. ```cpp #include #include ``` -------------------------------- ### filter_if Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/filter_if An example demonstrating the usage of filter_if with a vector and the is_integral predicate to filter for integer elements. ```cpp #include #include #include #include #include #include #include #include using namespace boost::fusion; using namespace boost::mpl; int main() { const vector vec(1,2,3.0,4.0); assert(filter_if >(vec) == make_vector(1,2)); return 0; } ``` -------------------------------- ### Example Usage of Boost Fusion std::pair Adapter Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/std__pair This C++ example demonstrates how to use the Boost Fusion adapter with std::pair. It shows creating a std::pair, accessing its elements using `at_c`, and printing the pair. ```cpp std::pair p(123, "Hola!!!"); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; std::cout << p << std::endl; ``` -------------------------------- ### vector_tie Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/vector_tie Demonstrates a practical example of using `vector_tie` with different data types (int and double) in C++. ```cpp int i = 123; double d = 123.456; vector_tie(i, d) ``` -------------------------------- ### Instantiate and Print Boost.Fusion single_view Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/view/single_view Demonstrates how to create a single_view with an integer value and print its contents to standard output. This example requires iostream for output. ```cpp single_view view(3); std::cout << view << std::endl; ``` -------------------------------- ### Boost.Fusion remove_if Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/remove_if An example demonstrating the usage of the Boost.Fusion remove_if algorithm to filter a vector, removing elements that are floating-point numbers. ```cpp const vector vec(1,2.0); assert(remove_if >(vec) == make_vector(1)); ``` -------------------------------- ### back_extended_deque Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/back_extended_deque Demonstrates how to use back_extended_deque by creating an initial deque, extending it, and then accessing its elements using at_c. ```cpp typedef deque initial_deque; initial_deque d(12, 5.5f); back_extended_deque d2(d, 999); std::cout << at_c<0>(d2) << std::endl; std::cout << at_c<1>(d2) << std::endl; std::cout << at_c<2>(d2) << std::endl; ``` -------------------------------- ### Access Elements in a Fusion Map by Key Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/quick_start Demonstrates accessing elements in a Fusion map using type-based keys (name and age) via at_key. ```cpp using namespace fields; std::string person_name = at_key(a_person); int person_age = at_key(a_person); ``` -------------------------------- ### Boost.Fusion insert_range Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/insert_range An example demonstrating the usage of insert_range. It shows how to insert a vector into another vector and asserts the expected result. ```cpp const vector vec(1,2); assert(insert_range(vec, next(begin(vec)), make_vector(3,4)) == make_vector(1,3,4,2)); ``` -------------------------------- ### Boost.Fusion 'all' Algorithm Synopsis Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/query/functions/all Provides the C++ template signature for the 'all' algorithm, detailing its parameters and return type. It requires the Boost.Fusion library. ```cpp template< typename Sequence, typename F > typename result_of::all::type all( Sequence const& seq, F f); ``` -------------------------------- ### deque_tie Example - C++ Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/deque_tie An example demonstrating the usage of deque_tie to create a deque of references with specified types (int and double). ```cpp result_of::deque_tie::type ``` -------------------------------- ### Boost.Fusion filter Algorithm Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/filter An example demonstrating the usage of the Boost.Fusion filter algorithm. It filters a vector to retain only integer elements. ```cpp const vector vec(1,2,3,4); assert(filter(vec) == make_vector(1,2)); ``` -------------------------------- ### Create and Access Boost Fusion list Elements Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/list An example of creating a Boost Fusion list with specific data types and accessing its elements using `at_c`. This showcases the basic usage and element retrieval. ```c++ list l(12, 5.5f); std::cout << at_c<0>(l) << std::endl; std::cout << at_c<1>(l) << std::endl; ``` -------------------------------- ### Boost.Fusion Pair Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/support/pair Demonstrates how to create and use a Boost.Fusion pair. It shows construction with a value, outputting the pair to a stream, and comparing it with a pair created using the make_pair helper function. ```cpp pair p('X'); std::cout << p << std::endl; std::cout << make_pair('X') << std::endl; assert((p == make_pair('X'))); ``` -------------------------------- ### Example: Using Boost Fusion with std::tuple Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/std__tuple Demonstrates the usage of Boost Fusion adapters with std::tuple. It shows how to create a tuple, access its elements using at_c, and print the entire tuple. ```cpp std::tuple p(123, "Hola!!!", 456.f); std::cout << at_c<0>(p) << std::endl; std::cout << at_c<1>(p) << std::endl; std::cout << p << std::endl; ``` -------------------------------- ### make_cons Example - C++ Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/metafunctions/make_cons Demonstrates a practical example of using make_cons to create a nested cons structure with different data types. ```C++ result_of::make_cons::type>::type ``` -------------------------------- ### Boost Fusion any header include Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/query/functions/any The necessary header files to include for using the Boost Fusion 'any' algorithm in C++ projects. ```cpp #include #include ``` -------------------------------- ### nview Example Usage Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/view/nview Demonstrates how to create and use nview with a vector sequence and an mpl::vector_c for indices. It shows outputting the nview directly and using the as_nview helper function. ```cpp typedef vector vec; typedef mpl::vector_c indices; vec v1(1, 'c', 2.0); std::cout << nview(v1) << std::endl; // (2.0 c 1 2.0 1) std::cout << as_nview<2, 1, 1, 0>(v1) << std::endl; // (2.0 c c 1) ``` -------------------------------- ### Boost Fusion Copy Algorithm Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/auxiliary/functions/copy Demonstrates how to use the Boost Fusion copy algorithm to copy elements from a vector to a list and asserts the result. ```cpp vector vec(1,2); list ls; copy(vec, ls); assert(ls == make_list(1,2)); ``` -------------------------------- ### Boost.Fusion transform: Unary Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/transform Example demonstrating the unary version of Boost.Fusion transform. It applies a 'triple' function to a vector, multiplying each element by 3. ```c++ struct triple { typedef int result_type; int operator()(int t) const { return t * 3; }; }; transform(make_vector(1,2,3), triple()) ``` -------------------------------- ### Create and Use Boost Fusion map Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/map An example demonstrating the creation and usage of a Boost Fusion map. It shows how to define a map type with specific key-value pairs and access elements using `at_key`. ```cpp typedef map< pair , pair > map_type; map_type m( make_pair('X') , make_pair("Men")); std::cout << at_key(m) << std::endl; std::cout << at_key(m) << std::endl; ``` -------------------------------- ### Example Usage of Boost.Fusion with Boost Tuple Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/boost__tuple Demonstrates how to use a boost::tuple with Boost.Fusion functionalities. It shows creating a tuple, accessing its elements using iterators from Boost.Fusion, and printing them. ```cpp boost::tuple example_tuple(101, "hello"); std::cout << *begin(example_tuple) << '\n'; std::cout << *next(begin(example_tuple)) << '\n'; ``` -------------------------------- ### Example Usage of BOOST_FUSION_DEFINE_STRUCT Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/define_struct An example demonstrating how to use BOOST_FUSION_DEFINE_STRUCT to adapt a C++ struct named 'employee' within the 'demo' namespace as a Fusion sequence. ```cpp // demo::employee is a Fusion sequence BOOST_FUSION_DEFINE_STRUCT( (demo), employee, (std::string, name) (int, age)) ``` -------------------------------- ### value_at_key Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/value_at_key An example showing how to use value_at_key with a Boost.Fusion map to assert the type of a value associated with an integer key. It utilizes BOOST_MPL_ASSERT for compile-time verification. ```cpp typedef map, pair, pair > mymap; BOOST_MPL_ASSERT((boost::is_same::type, char>)); ``` -------------------------------- ### Boost.Fusion value_of_data Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/value_of_data Provides a C++ example using Boost.Fusion and Boost.MPL to assert that the value_of_data for a map iterator correctly returns the associated integer type. ```cpp #include #include #include #include typedef boost::fusion::map > vec; typedef boost::fusion::result_of::begin::type first; BOOST_MPL_ASSERT((boost::is_same::type, int>)); ``` -------------------------------- ### Fusion deref Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/deref A C++ example demonstrating the usage of Boost.Fusion's deref struct with MPL assertions to verify iterator dereferencing types for a vector sequence. ```cpp #include #include #include #include #include #include #include // Assuming necessary Boost.Fusion and Boost.MPL headers are included typedef boost::fusion::vector vec; typedef const vec const_vec; typedef boost::fusion::result_of::begin::type first; typedef boost::fusion::result_of::next::type second; typedef boost::fusion::result_of::begin::type const_first; typedef boost::fusion::result_of::next::type const_second; BOOST_MPL_ASSERT((boost::is_same::type, int&>)); BOOST_MPL_ASSERT((boost::is_same::type, int&>)); ``` -------------------------------- ### Boost.Fusion deref_data Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/deref_data An example demonstrating the usage of `deref_data` with a `boost::fusion::map`. It asserts that dereferencing the data of an iterator to a `pair` results in `int&`. ```C++ typedef map > map_type; typedef boost::fusion::result_of::begin::type i_type; typedef boost::fusion::result_of::deref_data::type r_type; BOOST_STATIC_ASSERT((boost::is_same::value)); ``` -------------------------------- ### Boost Fusion at_key Header Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/at_key Specifies the necessary header files for using the `at_key` functionality in Boost Fusion. ```cpp #include #include ``` -------------------------------- ### Boost.Fusion deque Documentation Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/deque This section details the Boost.Fusion deque container, including its description, header files, synopsis, template parameters, model of, notation, expression semantics, and examples. ```APIDOC ## Boost.Fusion deque ### Description `deque` is a simple Bidirectional Sequence that supports constant-time insertion and removal of elements at both ends. It is more efficient than `vector` for sequences constructed piecemeal and offers constant runtime cost for element access. ### Header ```cpp #include #include #include #include ``` ### Synopsis ```cpp template struct deque; ``` For C++11 and later, the variadic class interface has no upper bound. For C++03, it accepts 0 to `FUSION_MAX_DEQUE_SIZE` elements (defaulting to 10). ### Template Parameters - **Elements** (type): Element types. ### Model of - Bidirectional Sequence ### Notation - `D`: A `deque` type - `d`, `d2`: Instances of `deque` - `e0`...`en`: Heterogeneous values - `s`: A Forward Sequence - `N`: An MPL Integral Constant ### Expression Semantics - `D()`: Creates a deque with default constructed elements. - `D(e0, e1,... en)`: Creates a deque with elements `e0`...`en`. - `D(s)`: Copy constructs a deque from a Forward Sequence, `s`. - `d = s`: Assigns to a deque, `d`, from a Forward Sequence, `s`. - `at(d)`: The Nth element from the beginning of the sequence. Access is constant time, relying on ADL. ### Example ```cpp deque d(12, 5.5f); std::cout << at_c<0>(d) << std::endl; std::cout << at_c<1>(d) << std::endl; ``` ``` -------------------------------- ### Boost Fusion 'at' Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/at A C++ example demonstrating the usage of Boost Fusion's 'at' intrinsic to assert the type of an element within a vector sequence. ```cpp typedef vector vec; BOOST_MPL_ASSERT((boost::is_same >::type, float&>)); ``` -------------------------------- ### Boost Fusion pop_front Function Synopsis Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/pop_front Provides the C++ template syntax for the pop_front function, detailing its input and output types. It requires a Sequence model as input. ```cpp template< typename Sequence > typename result_of::pop_front::type pop_front(Sequence const& seq); ``` -------------------------------- ### Boost.Fusion as_deque Usage Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/conversion/metafunctions/as_deque Provides an example of how to use the as_deque struct to determine the result type for converting a specific vector sequence (containing char and int) into a deque. ```cpp result_of::as_deque >::type ``` -------------------------------- ### Boost.Fusion joint_view Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/view/joint_view Demonstrates how to create and use a joint_view. It shows the initialization of two different vector types and concatenating them using joint_view, then printing the resulting view. ```cpp vector v1(3, 'x'); vector v2("hello", 123); joint_view< vector , vector > view(v1, v2); std::cout << view << std::endl; ``` -------------------------------- ### Include Headers for Boost Fusion Insert (C++) Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/metafunctions/insert Specifies the necessary header files to use the Boost Fusion insert algorithm in C++ projects. These headers provide the definitions for the insert functionality. ```C++ #include #include ``` -------------------------------- ### Example Usage of BOOST_FUSION_DEFINE_ASSOC_STRUCT Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/define_assoc_struct This example demonstrates how to use BOOST_FUSION_DEFINE_ASSOC_STRUCT to define a 'demo::employee' struct as a Fusion sequence with 'name' and 'age' members, using custom key types. ```cpp namespace keys { struct name; struct age; } // demo::employee is a Fusion sequence BOOST_FUSION_DEFINE_ASSOC_STRUCT( (demo), employee, (std::string, name, keys::name) (int, age, keys::age)) ``` -------------------------------- ### Boost Fusion value_at Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/value_at An example showing how to use value_at to assert the type of an element in a Boost Fusion vector. It verifies that the type at index 1 is indeed 'float'. ```cpp typedef vector vec; BOOST_MPL_ASSERT((boost::is_same >::type, float>)); ``` -------------------------------- ### Boost Fusion swap Header Files Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/metafunctions/swap Provides the necessary include directives for using the swap intrinsic from the Boost Fusion library. ```cpp #include #include ``` -------------------------------- ### Boost Fusion make_cons Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/container/generation/functions/make_cons Provides a practical C++ example of using `make_cons` to create a nested 'cons' structure, demonstrating its usage for building linked lists. ```cpp make_cons('x', make_cons(123)) ``` -------------------------------- ### Boost.Fusion advance_c Header Inclusion Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/iterator/metafunctions/advance_c Shows the necessary header files for using the advance_c functionality. ```cpp #include #include ``` -------------------------------- ### Example Usage of BOOST_FUSION_ADAPT_TPL_ADT Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/adapt_tpl_adt An example demonstrating how to use BOOST_FUSION_ADAPT_TPL_ADT to adapt a templated struct 'employee' as a Fusion Random Access Sequence, allowing element access and modification using Fusion functions. ```cpp namespace demo { template struct employee { private: Name name; Age age; public: void set_name(Name const& n) { name=n; } void set_age(Age const& a) { age=a; } Name const& get_name()const { return name; } Age const& get_age()const { return age; } }; } BOOST_FUSION_ADAPT_TPL_ADT( (Name)(Age), (demo::employee) (Name)(Age), (Name const&, Name const&, obj.get_name(), obj.set_name(val)) (Age const&, Age const&, obj.get_age(), obj.set_age(val))) demo::employee e; boost::fusion::front(e)="Edward Norton"; boost::fusion::back(e)=41; //Prints 'Edward Norton is 41 years old' std::cout << e.get_name() << " is " << e.get_age() << " years old" << std::endl; ``` -------------------------------- ### Boost.Fusion 'all' Algorithm Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/query/functions/all Demonstrates the usage of the Boost.Fusion 'all' algorithm with a custom predicate 'odd'. It shows how to check if all elements in a vector are odd. Requires Boost.Fusion. ```cpp struct odd { template bool operator()(T t) const { return t % 2; } }; ... (assuming make_vector and other necessary components are available) assert(all(make_vector(1,3), odd())); assert(!all(make_vector(1,2), odd())); ``` -------------------------------- ### Begin Function Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/sequence/intrinsic/functions/begin Returns an iterator pointing to the first element in the sequence. ```APIDOC ## begin ### Description Returns an iterator pointing to the first element in the sequence. ### Method GET ### Endpoint /begin ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "vector v(1, 2, 3);\nassert(deref(begin(v)) == 1);" } ``` ### Response #### Success Response (200) - **type** (iterator) - An iterator pointing to the first element of the sequence. The specific type of iterator depends on the sequence type (Forward, Bidirectional, Random Access, or Associative). #### Response Example ```json { "example": "1" } ``` ### Header ``` #include #include ``` ``` -------------------------------- ### Example Usage of BOOST_FUSION_DEFINE_STRUCT_INLINE Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/adapted/define_struct_inline An example demonstrating how to use the BOOST_FUSION_DEFINE_STRUCT_INLINE macro to define an 'employee' struct within a 'enclosing' class, making it a Fusion sequence. This showcases its application for adapting structs. ```cpp // enclosing::employee is a Fusion sequence class enclosing { BOOST_FUSION_DEFINE_STRUCT_INLINE( employee, (std::string, name) (int, age)) }; ``` -------------------------------- ### Boost Fusion replace Algorithm Example Source: https://www.boost.org/doc/libs/latest/libs/fusion/doc/html/fusion/algorithm/transformation/functions/replace Demonstrates the usage of the Boost Fusion replace algorithm by replacing a value in a vector and asserting the result. ```cpp assert(replace(make_vector(1,2), 2, 3) == make_vector(1,3)); ```