diff options
Diffstat (limited to 'boost/vmd/tuple')
-rw-r--r-- | boost/vmd/tuple/is_vmd_tuple.hpp | 56 | ||||
-rw-r--r-- | boost/vmd/tuple/pop_back.hpp | 73 | ||||
-rw-r--r-- | boost/vmd/tuple/pop_front.hpp | 73 | ||||
-rw-r--r-- | boost/vmd/tuple/push_back.hpp | 53 | ||||
-rw-r--r-- | boost/vmd/tuple/push_front.hpp | 53 | ||||
-rw-r--r-- | boost/vmd/tuple/remove.hpp | 84 | ||||
-rw-r--r-- | boost/vmd/tuple/size.hpp | 52 | ||||
-rw-r--r-- | boost/vmd/tuple/to_array.hpp | 52 | ||||
-rw-r--r-- | boost/vmd/tuple/to_list.hpp | 52 | ||||
-rw-r--r-- | boost/vmd/tuple/to_seq.hpp | 49 |
10 files changed, 597 insertions, 0 deletions
diff --git a/boost/vmd/tuple/is_vmd_tuple.hpp b/boost/vmd/tuple/is_vmd_tuple.hpp new file mode 100644 index 0000000000..58595b601a --- /dev/null +++ b/boost/vmd/tuple/is_vmd_tuple.hpp @@ -0,0 +1,56 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_IS_VMD_TUPLE_HPP) +#define BOOST_VMD_IS_VMD_TUPLE_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/vmd/identity.hpp> +#include <boost/vmd/is_empty.hpp> +#include <boost/vmd/is_tuple.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_IS_VMD_TUPLE(sequence) + + \brief Determines if a sequence is a VMD tuple. + + The macro checks that the sequence is a VMD tuple. + A VMD tuple, which may be a Boost PP tuple or emptiness, is a superset of a Boost PP tuple. + It returns 1 if it is a VMD tuple, else if returns 0. + + sequence = a possible Boost PP tuple + + returns = 1 if it a VMD tuple, else returns 0. + +*/ + +#define BOOST_VMD_IS_VMD_TUPLE(sequence) \ + BOOST_VMD_IDENTITY_RESULT \ + ( \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(sequence), \ + BOOST_VMD_IDENTITY(1), \ + BOOST_VMD_IS_TUPLE \ + ) \ + (sequence) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_IS_VMD_TUPLE_HPP */ diff --git a/boost/vmd/tuple/pop_back.hpp b/boost/vmd/tuple/pop_back.hpp new file mode 100644 index 0000000000..e9a7558969 --- /dev/null +++ b/boost/vmd/tuple/pop_back.hpp @@ -0,0 +1,73 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_POP_BACK_HPP) +#define BOOST_VMD_TUPLE_POP_BACK_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/comparison/equal.hpp> +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/pop_back.hpp> +#include <boost/preprocessor/tuple/size.hpp> +#include <boost/vmd/empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_POP_BACK(tuple) + + \brief pops an element from the end of a tuple. + + tuple = tuple to pop an element from. + + If the tuple is an empty tuple the result is undefined. + If the tuple is a single element the result is an empty tuple. + Otherwise the result is a tuple after removing the last element. +*/ + +#define BOOST_VMD_TUPLE_POP_BACK(tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_POP_BACK \ + ) \ + (tuple) \ +/**/ + +/** \def BOOST_VMD_TUPLE_POP_BACK_Z(z,tuple) + + \brief pops an element from the end of a tuple. It reenters BOOST_PP_REPEAT with maximum efficiency. + + z = the next available BOOST_PP_REPEAT dimension. + tuple = tuple to pop an element from. + + If the tuple is an empty tuple the result is undefined. + If the tuple is a single element the result is an empty tuple. + Otherwise the result is a tuple after removing the last element. +*/ + +#define BOOST_VMD_TUPLE_POP_BACK_Z(z,tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_POP_BACK_Z \ + ) \ + (z,tuple) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_POP_BACK_HPP */ diff --git a/boost/vmd/tuple/pop_front.hpp b/boost/vmd/tuple/pop_front.hpp new file mode 100644 index 0000000000..fc84492184 --- /dev/null +++ b/boost/vmd/tuple/pop_front.hpp @@ -0,0 +1,73 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_POP_FRONT_HPP) +#define BOOST_VMD_TUPLE_POP_FRONT_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/comparison/equal.hpp> +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/pop_front.hpp> +#include <boost/preprocessor/tuple/size.hpp> +#include <boost/vmd/empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_POP_FRONT(tuple) + + \brief pops an element from the front of a tuple. + + tuple = tuple to pop an element from. + + If the tuple is an empty tuple the result is undefined. + If the tuple is a single element the result is an empty tuple. + Otherwise the result is a tuple after removing the first element. +*/ + +#define BOOST_VMD_TUPLE_POP_FRONT(tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_POP_FRONT \ + ) \ + (tuple) \ +/**/ + +/** \def BOOST_VMD_TUPLE_POP_FRONT_Z(z,tuple) + + \brief pops an element from the front of a tuple. It reenters BOOST_PP_REPEAT with maximum efficiency. + + z = the next available BOOST_PP_REPEAT dimension. + tuple = tuple to pop an element from. + + If the tuple is an empty tuple the result is undefined. + If the tuple is a single element the result is an empty tuple. + Otherwise the result is a tuple after removing the first element. +*/ + +#define BOOST_VMD_TUPLE_POP_FRONT_Z(z,tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_POP_FRONT_Z \ + ) \ + (z,tuple) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_POP_FRONT_HPP */ diff --git a/boost/vmd/tuple/push_back.hpp b/boost/vmd/tuple/push_back.hpp new file mode 100644 index 0000000000..778e257c88 --- /dev/null +++ b/boost/vmd/tuple/push_back.hpp @@ -0,0 +1,53 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_PUSH_BACK_HPP) +#define BOOST_VMD_TUPLE_PUSH_BACK_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/push_back.hpp> +#include <boost/vmd/identity.hpp> +#include <boost/vmd/is_empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_PUSH_BACK(tuple,elem) + + \brief appends an element to the end of a tuple. + + tuple = tuple to to append an element to. + elem = element to append. + + If the tuple is an empty tuple the result is a tuple with the single element. + Otherwise the result is a tuple after adding the element to the end. +*/ + +#define BOOST_VMD_TUPLE_PUSH_BACK(tuple,elem) \ + BOOST_VMD_IDENTITY_RESULT \ + ( \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(tuple), \ + BOOST_VMD_IDENTITY((elem)), \ + BOOST_PP_TUPLE_PUSH_BACK \ + ) \ + (tuple,elem) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_PUSH_BACK_HPP */ diff --git a/boost/vmd/tuple/push_front.hpp b/boost/vmd/tuple/push_front.hpp new file mode 100644 index 0000000000..4ec57ad698 --- /dev/null +++ b/boost/vmd/tuple/push_front.hpp @@ -0,0 +1,53 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_PUSH_FRONT_HPP) +#define BOOST_VMD_TUPLE_PUSH_FRONT_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/push_front.hpp> +#include <boost/vmd/identity.hpp> +#include <boost/vmd/is_empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_PUSH_FRONT(tuple,elem) + + \brief inserts an element at the beginning of a tuple. + + tuple = tuple to insert an element at. + elem = element to insert. + + If the tuple is an empty tuple the result is a tuple with the single element. + Otherwise the result is a tuple after inserting the element at the beginning. +*/ + +#define BOOST_VMD_TUPLE_PUSH_FRONT(tuple,elem) \ + BOOST_VMD_IDENTITY_RESULT \ + ( \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(tuple), \ + BOOST_VMD_IDENTITY((elem)), \ + BOOST_PP_TUPLE_PUSH_FRONT \ + ) \ + (tuple,elem) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_PUSH_FRONT_HPP */ diff --git a/boost/vmd/tuple/remove.hpp b/boost/vmd/tuple/remove.hpp new file mode 100644 index 0000000000..7f1324798d --- /dev/null +++ b/boost/vmd/tuple/remove.hpp @@ -0,0 +1,84 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_REMOVE_HPP) +#define BOOST_VMD_TUPLE_REMOVE_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/comparison/equal.hpp> +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/logical/bitand.hpp> +#include <boost/preprocessor/tuple/remove.hpp> +#include <boost/preprocessor/tuple/size.hpp> +#include <boost/vmd/empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_REMOVE(tuple,index) + + \brief removes an element from a tuple. + + tuple = tuple from which an element is to be removed. + index = The zero-based position in tuple of the element to be removed. + + If index is greater or equal to the tuple size the result is undefined. + If the tuple is a single element and the index is 0 the result is an empty tuple. + Otherwise the result is a tuple after removing the index element. +*/ + +#define BOOST_VMD_TUPLE_REMOVE(tuple,index) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_BITAND \ + ( \ + BOOST_PP_EQUAL(index,0), \ + BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1) \ + ), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_REMOVE \ + ) \ + (tuple,index) \ +/**/ + +/** \def BOOST_VMD_TUPLE_REMOVE_D(d,tuple,index) + + \brief removes an element from a tuple. It reenters BOOST_PP_WHILE with maximum efficiency. + + d = The next available BOOST_PP_WHILE iteration. + tuple = tuple from which an element is to be removed. + index = The zero-based position in tuple of the element to be removed. + + If index is greater or equal to the tuple size the result is undefined. + If the tuple is a single element and the index is 0 the result is an empty tuple. + Otherwise the result is a tuple after removing the index element. +*/ + +#define BOOST_VMD_TUPLE_REMOVE_D(d,tuple,index) \ + BOOST_PP_IIF \ + ( \ + BOOST_PP_BITAND \ + ( \ + BOOST_PP_EQUAL_D(d,index,0), \ + BOOST_PP_EQUAL_D(d,BOOST_PP_TUPLE_SIZE(tuple),1) \ + ), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_REMOVE_D \ + ) \ + (d,tuple,index) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_REMOVE_HPP */ diff --git a/boost/vmd/tuple/size.hpp b/boost/vmd/tuple/size.hpp new file mode 100644 index 0000000000..1e8d27169f --- /dev/null +++ b/boost/vmd/tuple/size.hpp @@ -0,0 +1,52 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_SIZE_HPP) +#define BOOST_VMD_TUPLE_SIZE_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/size.hpp> +#include <boost/vmd/identity.hpp> +#include <boost/vmd/is_empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_SIZE(tuple) + + \brief expands to the size of the tuple passed to it. + + tuple = tuple whose size is to be extracted. + + If the tuple is an empty tuple its size is 0. + Otherwise the result is the number of elements in the tuple. +*/ + +#define BOOST_VMD_TUPLE_SIZE(tuple) \ + BOOST_VMD_IDENTITY_RESULT \ + ( \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(tuple), \ + BOOST_VMD_IDENTITY(0), \ + BOOST_PP_TUPLE_SIZE \ + ) \ + (tuple) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_SIZE_HPP */ diff --git a/boost/vmd/tuple/to_array.hpp b/boost/vmd/tuple/to_array.hpp new file mode 100644 index 0000000000..4e9c8a2945 --- /dev/null +++ b/boost/vmd/tuple/to_array.hpp @@ -0,0 +1,52 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_TO_ARRAY_HPP) +#define BOOST_VMD_TUPLE_TO_ARRAY_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/to_array.hpp> +#include <boost/vmd/identity.hpp> +#include <boost/vmd/is_empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_TO_ARRAY(tuple) + + \brief converts a tuple to an array. + + tuple = tuple to be converted. + + If the tuple is an empty tuple it is converted to an array with 0 elements. + Otherwise the tuple is converted to an array with the same number of elements as the tuple. +*/ + +#define BOOST_VMD_TUPLE_TO_ARRAY(tuple) \ + BOOST_VMD_IDENTITY_RESULT \ + ( \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(tuple), \ + BOOST_VMD_IDENTITY((0,())), \ + BOOST_PP_TUPLE_TO_ARRAY \ + ) \ + (tuple) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_TO_ARRAY_HPP */ diff --git a/boost/vmd/tuple/to_list.hpp b/boost/vmd/tuple/to_list.hpp new file mode 100644 index 0000000000..a66f26055b --- /dev/null +++ b/boost/vmd/tuple/to_list.hpp @@ -0,0 +1,52 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_TO_LIST_HPP) +#define BOOST_VMD_TUPLE_TO_LIST_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/to_list.hpp> +#include <boost/vmd/identity.hpp> +#include <boost/vmd/is_empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_TO_LIST(tuple) + + \brief converts a tuple to a list. + + tuple = tuple to be converted. + + If the tuple is an empty tuple it is converted to an empty list (BOOST_PP_NIL). + Otherwise the tuple is converted to a list with the same number of elements as the tuple. +*/ + +#define BOOST_VMD_TUPLE_TO_LIST(tuple) \ + BOOST_VMD_IDENTITY_RESULT \ + ( \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(tuple), \ + BOOST_VMD_IDENTITY(BOOST_PP_NIL), \ + BOOST_PP_TUPLE_TO_LIST \ + ) \ + (tuple) \ + ) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_TO_LIST_HPP */ diff --git a/boost/vmd/tuple/to_seq.hpp b/boost/vmd/tuple/to_seq.hpp new file mode 100644 index 0000000000..de4a3d42e4 --- /dev/null +++ b/boost/vmd/tuple/to_seq.hpp @@ -0,0 +1,49 @@ + +// (C) Copyright Edward Diener 2015 +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). + +#if !defined(BOOST_VMD_TUPLE_TO_SEQ_HPP) +#define BOOST_VMD_TUPLE_TO_SEQ_HPP + +#include <boost/vmd/detail/setup.hpp> + +#if BOOST_PP_VARIADICS + +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/tuple/to_seq.hpp> +#include <boost/vmd/empty.hpp> +#include <boost/vmd/is_empty.hpp> + +/* + + The succeeding comments in this file are in doxygen format. + +*/ + +/** \file +*/ + +/** \def BOOST_VMD_TUPLE_TO_SEQ(tuple) + + \brief converts a tuple to a seq. + + tuple = tuple to be converted. + + If the tuple is an empty tuple it is converted to an empty seq. + Otherwise the tuple is converted to a seq with the same number of elements as the tuple. +*/ + +#define BOOST_VMD_TUPLE_TO_SEQ(tuple) \ + BOOST_PP_IIF \ + ( \ + BOOST_VMD_IS_EMPTY(tuple), \ + BOOST_VMD_EMPTY, \ + BOOST_PP_TUPLE_TO_SEQ \ + ) \ + (tuple) \ +/**/ + +#endif /* BOOST_PP_VARIADICS */ +#endif /* BOOST_VMD_TUPLE_TO_SEQ_HPP */ |