forked from boostorg/preprocessor
Fixes for empty tuple processing
This commit is contained in:
52
include/boost/preprocessor/array/detail/get_data.hpp
Normal file
52
include/boost/preprocessor/array/detail/get_data.hpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# /* **************************************************************************
|
||||||
|
# * *
|
||||||
|
# * (C) Copyright Edward Diener 2014. *
|
||||||
|
# * 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) *
|
||||||
|
# * *
|
||||||
|
# ************************************************************************** */
|
||||||
|
#
|
||||||
|
# /* See http://www.boost.org for most recent version. */
|
||||||
|
#
|
||||||
|
# ifndef BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP
|
||||||
|
# define BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP
|
||||||
|
#
|
||||||
|
# include <boost/preprocessor/config/config.hpp>
|
||||||
|
# include <boost/preprocessor/tuple/rem.hpp>
|
||||||
|
#
|
||||||
|
# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER != 1400
|
||||||
|
# include <boost/preprocessor/cat.hpp>
|
||||||
|
# include <boost/preprocessor/control/if.hpp>
|
||||||
|
# include <boost/preprocessor/control/iif.hpp>
|
||||||
|
# include <boost/preprocessor/facilities/is_1.hpp>
|
||||||
|
#
|
||||||
|
# /* BOOST_PP_ARRAY_DETAIL_GET_DATA */
|
||||||
|
#
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA_REM(...) BOOST_PP_CAT(__VA_ARGS__,)
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA_TUPLE_REM(size) BOOST_PP_ARRAY_DETAIL_GET_DATA_REM
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE(size, data) BOOST_PP_ARRAY_DETAIL_GET_DATA_TUPLE_REM(size) data
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY(size, data) BOOST_PP_TUPLE_REM(size) data
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO(size, data) \
|
||||||
|
BOOST_PP_IF \
|
||||||
|
( \
|
||||||
|
size, \
|
||||||
|
BOOST_PP_ARRAY_DETAIL_GET_DATA_ANY, \
|
||||||
|
BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE \
|
||||||
|
) \
|
||||||
|
(size,data) \
|
||||||
|
/**/
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA(size, data) \
|
||||||
|
BOOST_PP_IIF \
|
||||||
|
( \
|
||||||
|
BOOST_PP_IS_1(size), \
|
||||||
|
BOOST_PP_ARRAY_DETAIL_GET_DATA_SINGLE, \
|
||||||
|
BOOST_PP_ARRAY_DETAIL_GET_DATA_CHECK_ZERO \
|
||||||
|
) \
|
||||||
|
(size,data) \
|
||||||
|
/**/
|
||||||
|
# else
|
||||||
|
# define BOOST_PP_ARRAY_DETAIL_GET_DATA(size, data) BOOST_PP_TUPLE_REM(size) data
|
||||||
|
# endif /* BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC && _MSC_VER != 1400 */
|
||||||
|
#
|
||||||
|
# endif /* BOOST_PREPROCESSOR_ARRAY_DETAIL_GET_DATA_HPP */
|
@ -1,6 +1,7 @@
|
|||||||
# /* **************************************************************************
|
# /* **************************************************************************
|
||||||
# * *
|
# * *
|
||||||
# * (C) Copyright Paul Mensonides 2002.
|
# * (C) Copyright Paul Mensonides 2002.
|
||||||
|
# * (C) Copyright Edward Diener 2014.
|
||||||
# * Distributed under the Boost Software License, Version 1.0. (See
|
# * Distributed under the Boost Software License, Version 1.0. (See
|
||||||
# * accompanying file LICENSE_1_0.txt or copy at
|
# * accompanying file LICENSE_1_0.txt or copy at
|
||||||
# * http://www.boost.org/LICENSE_1_0.txt)
|
# * http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -18,6 +19,7 @@
|
|||||||
# include <boost/preprocessor/config/config.hpp>
|
# include <boost/preprocessor/config/config.hpp>
|
||||||
# include <boost/preprocessor/punctuation/comma_if.hpp>
|
# include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||||
# include <boost/preprocessor/tuple/rem.hpp>
|
# include <boost/preprocessor/tuple/rem.hpp>
|
||||||
|
# include <boost/preprocessor/array/detail/get_data.hpp>
|
||||||
#
|
#
|
||||||
# /* BOOST_PP_ARRAY_PUSH_BACK */
|
# /* BOOST_PP_ARRAY_PUSH_BACK */
|
||||||
#
|
#
|
||||||
@ -28,6 +30,6 @@
|
|||||||
# define BOOST_PP_ARRAY_PUSH_BACK_D(array, elem) BOOST_PP_ARRAY_PUSH_BACK_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem)
|
# define BOOST_PP_ARRAY_PUSH_BACK_D(array, elem) BOOST_PP_ARRAY_PUSH_BACK_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem)
|
||||||
# endif
|
# endif
|
||||||
#
|
#
|
||||||
# define BOOST_PP_ARRAY_PUSH_BACK_I(size, data, elem) (BOOST_PP_INC(size), (BOOST_PP_TUPLE_REM(size) data BOOST_PP_COMMA_IF(size) elem))
|
# define BOOST_PP_ARRAY_PUSH_BACK_I(size, data, elem) (BOOST_PP_INC(size), (BOOST_PP_ARRAY_DETAIL_GET_DATA(size,data) BOOST_PP_COMMA_IF(size) elem))
|
||||||
#
|
#
|
||||||
# endif
|
# endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# /* **************************************************************************
|
# /* **************************************************************************
|
||||||
# * *
|
# * *
|
||||||
# * (C) Copyright Paul Mensonides 2002.
|
# * (C) Copyright Paul Mensonides 2002.
|
||||||
|
# * (C) Copyright Edward Diener 2014.
|
||||||
# * Distributed under the Boost Software License, Version 1.0. (See
|
# * Distributed under the Boost Software License, Version 1.0. (See
|
||||||
# * accompanying file LICENSE_1_0.txt or copy at
|
# * accompanying file LICENSE_1_0.txt or copy at
|
||||||
# * http://www.boost.org/LICENSE_1_0.txt)
|
# * http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -18,6 +19,7 @@
|
|||||||
# include <boost/preprocessor/config/config.hpp>
|
# include <boost/preprocessor/config/config.hpp>
|
||||||
# include <boost/preprocessor/punctuation/comma_if.hpp>
|
# include <boost/preprocessor/punctuation/comma_if.hpp>
|
||||||
# include <boost/preprocessor/tuple/rem.hpp>
|
# include <boost/preprocessor/tuple/rem.hpp>
|
||||||
|
# include <boost/preprocessor/array/detail/get_data.hpp>
|
||||||
#
|
#
|
||||||
# /* BOOST_PP_ARRAY_PUSH_FRONT */
|
# /* BOOST_PP_ARRAY_PUSH_FRONT */
|
||||||
#
|
#
|
||||||
@ -28,6 +30,6 @@
|
|||||||
# define BOOST_PP_ARRAY_PUSH_FRONT_D(array, elem) BOOST_PP_ARRAY_PUSH_FRONT_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem)
|
# define BOOST_PP_ARRAY_PUSH_FRONT_D(array, elem) BOOST_PP_ARRAY_PUSH_FRONT_I(BOOST_PP_ARRAY_SIZE(array), BOOST_PP_ARRAY_DATA(array), elem)
|
||||||
# endif
|
# endif
|
||||||
#
|
#
|
||||||
# define BOOST_PP_ARRAY_PUSH_FRONT_I(size, data, elem) (BOOST_PP_INC(size), (elem BOOST_PP_COMMA_IF(size) BOOST_PP_TUPLE_REM(size) data))
|
# define BOOST_PP_ARRAY_PUSH_FRONT_I(size, data, elem) (BOOST_PP_INC(size), (elem BOOST_PP_COMMA_IF(size) BOOST_PP_ARRAY_DETAIL_GET_DATA(size,data)))
|
||||||
#
|
#
|
||||||
# endif
|
# endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# /* **************************************************************************
|
# /* **************************************************************************
|
||||||
# * *
|
# * *
|
||||||
# * (C) Copyright Edward Diener 2011.
|
# * (C) Copyright Paul Mensonides 2011.
|
||||||
|
# * (C) Copyright Edward Diener 2011,2014.
|
||||||
# * Distributed under the Boost Software License, Version 1.0. (See
|
# * Distributed under the Boost Software License, Version 1.0. (See
|
||||||
# * accompanying file LICENSE_1_0.txt or copy at
|
# * accompanying file LICENSE_1_0.txt or copy at
|
||||||
# * http://www.boost.org/LICENSE_1_0.txt)
|
# * http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -19,6 +20,7 @@
|
|||||||
# include <boost/preprocessor/list/adt.hpp>
|
# include <boost/preprocessor/list/adt.hpp>
|
||||||
# include <boost/preprocessor/tuple/elem.hpp>
|
# include <boost/preprocessor/tuple/elem.hpp>
|
||||||
# include <boost/preprocessor/tuple/rem.hpp>
|
# include <boost/preprocessor/tuple/rem.hpp>
|
||||||
|
# include <boost/preprocessor/array/detail/get_data.hpp>
|
||||||
#
|
#
|
||||||
# /* BOOST_PP_LIST_TO_ARRAY */
|
# /* BOOST_PP_LIST_TO_ARRAY */
|
||||||
#
|
#
|
||||||
@ -114,7 +116,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# define BOOST_PP_LIST_TO_ARRAY_P(d, state) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(3, 0, state))
|
# define BOOST_PP_LIST_TO_ARRAY_P(d, state) BOOST_PP_LIST_IS_CONS(BOOST_PP_TUPLE_ELEM(3, 0, state))
|
||||||
# define BOOST_PP_LIST_TO_ARRAY_O(d, state) BOOST_PP_LIST_TO_ARRAY_O_I state
|
# define BOOST_PP_LIST_TO_ARRAY_O(d, state) BOOST_PP_LIST_TO_ARRAY_O_I state
|
||||||
# define BOOST_PP_LIST_TO_ARRAY_O_I(list, size, tuple) (BOOST_PP_LIST_REST(list), BOOST_PP_INC(size), (BOOST_PP_TUPLE_REM(size) tuple, BOOST_PP_LIST_FIRST(list)))
|
# define BOOST_PP_LIST_TO_ARRAY_O_I(list, size, tuple) (BOOST_PP_LIST_REST(list), BOOST_PP_INC(size), (BOOST_PP_ARRAY_DETAIL_GET_DATA(size,tuple), BOOST_PP_LIST_FIRST(list)))
|
||||||
#
|
#
|
||||||
# /* BOOST_PP_LIST_TO_ARRAY_D */
|
# /* BOOST_PP_LIST_TO_ARRAY_D */
|
||||||
#
|
#
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# */
|
# */
|
||||||
#
|
#
|
||||||
# /* Revised by Paul Mensonides (2002-2011) */
|
# /* Revised by Paul Mensonides (2002-2011) */
|
||||||
# /* Revised by Edward Diener (2011) */
|
# /* Revised by Edward Diener (2011,2014) */
|
||||||
#
|
#
|
||||||
# /* See http://www.boost.org for most recent version. */
|
# /* See http://www.boost.org for most recent version. */
|
||||||
#
|
#
|
||||||
@ -21,15 +21,38 @@
|
|||||||
# include <boost/preprocessor/tuple/rem.hpp>
|
# include <boost/preprocessor/tuple/rem.hpp>
|
||||||
# include <boost/preprocessor/variadic/elem.hpp>
|
# include <boost/preprocessor/variadic/elem.hpp>
|
||||||
#
|
#
|
||||||
|
# if BOOST_PP_VARIADICS && BOOST_PP_VARIADICS_MSVC
|
||||||
|
# include <boost/preprocessor/comparison/equal.hpp>
|
||||||
|
# include <boost/preprocessor/control/iif.hpp>
|
||||||
|
# include <boost/preprocessor/tuple/size.hpp>
|
||||||
|
# endif
|
||||||
|
#
|
||||||
# if BOOST_PP_VARIADICS
|
# if BOOST_PP_VARIADICS
|
||||||
# if BOOST_PP_VARIADICS_MSVC
|
# if BOOST_PP_VARIADICS_MSVC
|
||||||
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__), (__VA_ARGS__))
|
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__), (__VA_ARGS__))
|
||||||
# define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args)
|
# define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args)
|
||||||
# define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,)
|
# define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,)
|
||||||
|
/*
|
||||||
|
Use BOOST_PP_TUPLE_ELEM_O_2_CAT if it is a single element tuple ( which might be empty )
|
||||||
|
else use BOOST_PP_REM. This fixes a VC++ problem with an empty tuple and BOOST_PP_TUPLE_ELEM
|
||||||
|
functionality.
|
||||||
|
*/
|
||||||
|
# define BOOST_PP_TUPLE_ELEM_O_2_CAT(...) BOOST_PP_CAT(__VA_ARGS__,)
|
||||||
|
# define BOOST_PP_TUPLE_ELEM_O_2_SINGLE(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_TUPLE_ELEM_O_2_CAT tuple)
|
||||||
|
# define BOOST_PP_TUPLE_ELEM_O_2_ANY(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple)
|
||||||
|
# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) \
|
||||||
|
BOOST_PP_IIF \
|
||||||
|
( \
|
||||||
|
BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple),1), \
|
||||||
|
BOOST_PP_TUPLE_ELEM_O_2_SINGLE, \
|
||||||
|
BOOST_PP_TUPLE_ELEM_O_2_ANY \
|
||||||
|
) \
|
||||||
|
(n, tuple) \
|
||||||
|
/**/
|
||||||
# else
|
# else
|
||||||
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__)
|
# define BOOST_PP_TUPLE_ELEM(...) BOOST_PP_OVERLOAD(BOOST_PP_TUPLE_ELEM_O_, __VA_ARGS__)(__VA_ARGS__)
|
||||||
|
# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple)
|
||||||
# endif
|
# endif
|
||||||
# define BOOST_PP_TUPLE_ELEM_O_2(n, tuple) BOOST_PP_VARIADIC_ELEM(n, BOOST_PP_REM tuple)
|
|
||||||
# define BOOST_PP_TUPLE_ELEM_O_3(size, n, tuple) BOOST_PP_TUPLE_ELEM_O_2(n, tuple)
|
# define BOOST_PP_TUPLE_ELEM_O_3(size, n, tuple) BOOST_PP_TUPLE_ELEM_O_2(n, tuple)
|
||||||
# else
|
# else
|
||||||
# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
|
# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
|
||||||
|
Reference in New Issue
Block a user