1[/ 2 (C) Copyright Edward Diener 2011-2015 3 Distributed under the Boost Software License, Version 1.0. 4 (See accompanying file LICENSE_1_0.txt or copy at 5 http://www.boost.org/LICENSE_1_0.txt). 6] 7 8[section:vmd_sequence_convert Converting sequences] 9 10The easiest way to work with a sequence is to convert it to a Boost PP 11data type. Likewise you can also convert a sequence to variadic data even though the 12Boost PP data types have much greater functionality than variadic data in Boost PP. 13 14To convert a sequence to a Boost PP data type or variadic data the macros to be used are: 15 16* BOOST_VMD_TO_ARRAY(sequence) to convert the sequence to an array 17* BOOST_VMD_TO_LIST(sequence) to convert the sequence to a list 18* BOOST_VMD_TO_SEQ(sequence) to convert the sequence to a seq 19* BOOST_VMD_TO_TUPLE(sequence) to convert the sequence to a tuple 20* BOOST_VMD_ENUM(sequence) to convert the sequence to variadic data 21 22After the conversion the elements of a sequence become the elements 23of the corresponding composite data type. 24 25Once the elements of the sequence have been converted to the elements 26of the composite data type the full power of that composite data type can be used 27to process each element. Furthermore the programmer can use VMD to discover 28the type of an individual element for further processing. 29 30For single element sequences the result is always a single element composite 31data type. For multi-element sequences the result is always a composite data 32type of more than one element. 33 34For a sequence that is empty the result is emptiness when converting to 35a seq, tuple, or variadic data; the result is an empty array or list when 36converting to each of those composite data types respectively. 37 38 #include <boost/vmd/enum.hpp> 39 #include <boost/vmd/to_array.hpp> 40 #include <boost/vmd/to_list.hpp> 41 #include <boost/vmd/to_seq.hpp> 42 #include <boost/vmd/to_tuple.hpp> 43 44 #define BOOST_VMD_REGISTER_ANID (ANID) 45 46 #define SEQUENCE_EMPTY 47 #define SEQUENCE_SINGLE 35 48 #define SEQUENCE_SINGLE_2 ANID 49 #define SEQUENCE_MULTI (0,1) (2)(3)(4) 50 #define SEQUENCE_MULTI_2 BOOST_VMD_TYPE_SEQ (2,(5,6)) 51 52 BOOST_VMD_TO_ARRAY(SEQUENCE_EMPTY) will return an empty array '(0,())' 53 BOOST_VMD_TO_LIST(SEQUENCE_SINGLE) will return a one-element list '(35,BOOST_PP_NIL)' 54 BOOST_VMD_TO_SEQ(SEQUENCE_SINGLE_2) will return a one-element seq '(ANID)' 55 BOOST_VMD_TO_TUPLE(SEQUENCE_MULTI) will return a multi-element tuple '((0,1),(2)(3)(4))' 56 BOOST_VMD_ENUM(SEQUENCE_MULTI_2) will return multi-element variadic data 'BOOST_VMD_TYPE_SEQ,(2,(5,6))' 57 58[heading Usage] 59 60You can use the general header file: 61 62 #include <boost/vmd/vmd.hpp> 63 64or you can use individual header files for each of these macros. 65The individual header files are: 66 67 #include <boost/vmd/to_array.hpp> // for the BOOST_VMD_TO_ARRAY macro 68 #include <boost/vmd/to_list.hpp> // for the BOOST_VMD_TO_LIST macro 69 #include <boost/vmd/to_seq.hpp> // for the BOOST_VMD_TO_SEQ macro 70 #include <boost/vmd/to_tuple.hpp> // for the BOOST_VMD_TO_TUPLE macro. 71 #include <boost/vmd/enum.hpp> // for the BOOST_VMD_ENUM macro. 72 73[endsect]