From 7b6cf39540824ec03ac4d826f1bddcccbca86237 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Mon, 4 Feb 2013 03:49:34 +0000 Subject: [PATCH] modern c++11 map implemented + various tweaks [SVN r82708] --- .../boost/fusion/container/deque/deque.hpp | 11 +- .../container/deque/detail/cpp03/deque.hpp | 2 +- .../detail/cpp03/deque_keyed_values_call.hpp | 2 + .../generation/detail/pp_make_map.hpp | 132 ++++++++++++++ .../generation/detail/pp_map_tie.hpp | 136 +++++++++++++++ .../container/generation/make_deque.hpp | 2 - .../fusion/container/generation/make_map.hpp | 146 ++++------------ .../fusion/container/generation/map_tie.hpp | 136 +++------------ .../fusion/container/map/detail/at_impl.hpp | 55 ++++++ .../container/map/detail/at_key_impl.hpp | 58 ++++++ .../container/map/detail/begin_impl.hpp | 38 ++++ .../fusion/container/map/detail/end_impl.hpp | 38 ++++ .../fusion/container/map/detail/map_impl.hpp | 165 ++++++++++++++++++ .../map/detail/value_at_key_impl.hpp | 38 ++++ include/boost/fusion/container/map/map.hpp | 48 ++++- .../boost/fusion/container/map/map_fwd.hpp | 26 ++- .../fusion/container/map/map_iterator.hpp | 164 +++++++++++++++++ .../boost/fusion/iterator/basic_iterator.hpp | 2 +- 18 files changed, 965 insertions(+), 234 deletions(-) create mode 100644 include/boost/fusion/container/generation/detail/pp_make_map.hpp create mode 100644 include/boost/fusion/container/generation/detail/pp_map_tie.hpp create mode 100644 include/boost/fusion/container/map/detail/at_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/at_key_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/begin_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/end_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/map_impl.hpp create mode 100644 include/boost/fusion/container/map/detail/value_at_key_impl.hpp create mode 100644 include/boost/fusion/container/map/map_iterator.hpp diff --git a/include/boost/fusion/container/deque/deque.hpp b/include/boost/fusion/container/deque/deque.hpp index 53623a9a..96b2978c 100644 --- a/include/boost/fusion/container/deque/deque.hpp +++ b/include/boost/fusion/container/deque/deque.hpp @@ -8,20 +8,17 @@ #if !defined(BOOST_FUSION_DEQUE_26112006_1649) #define BOOST_FUSION_DEQUE_26112006_1649 -#include +# include /////////////////////////////////////////////////////////////////////////////// -// With variadics, we will use the PP version +// Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// -#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#if !defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) # include #else -# if !defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) -# define BOOST_FUSION_HAS_VARIADIC_DEQUE -# endif /////////////////////////////////////////////////////////////////////////////// -// C++11 variadic interface +// C++11 interface /////////////////////////////////////////////////////////////////////////////// #include #include diff --git a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp index 2e25a690..e1a547c6 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp @@ -164,7 +164,7 @@ namespace boost { namespace fusion { typename enable_if< mpl::and_< traits::is_sequence - , result_of::empty>>::type* /*dummy*/ = 0) + , result_of::empty > >::type* /*dummy*/ = 0) {} deque() {} diff --git a/include/boost/fusion/container/deque/detail/cpp03/deque_keyed_values_call.hpp b/include/boost/fusion/container/deque/detail/cpp03/deque_keyed_values_call.hpp index 0b8543b6..7be11319 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/deque_keyed_values_call.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/deque_keyed_values_call.hpp @@ -43,6 +43,7 @@ >::construct(BOOST_PP_ENUM_SHIFTED_PARAMS(N, t))); } +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template static type forward_(BOOST_PP_ENUM_BINARY_PARAMS(N, T_, && t)) { @@ -54,6 +55,7 @@ #endif >::forward_(BOOST_PP_ENUM_SHIFTED(N, FUSION_DEQUE_KEYED_VALUES_FORWARD, _))); } +#endif #undef N #endif diff --git a/include/boost/fusion/container/generation/detail/pp_make_map.hpp b/include/boost/fusion/container/generation/detail/pp_make_map.hpp new file mode 100644 index 00000000..9bea617f --- /dev/null +++ b/include/boost/fusion/container/generation/detail/pp_make_map.hpp @@ -0,0 +1,132 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#ifndef BOOST_PP_IS_ITERATING +#if !defined(FUSION_PP_MAKE_MAP_07222005_1247) +#define FUSION_PP_MAKE_MAP_07222005_1247 + +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) +#include +#else +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/make_map" FUSION_MAX_MAP_SIZE_STR".hpp") +#endif + +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) + + This is an auto-generated file. Do not edit! +==============================================================================*/ + +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +#pragma wave option(preserve: 1) +#endif + +namespace boost { namespace fusion +{ + struct void_; + + namespace result_of + { + template < + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + FUSION_MAX_VECTOR_SIZE, typename K, void_) + , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + FUSION_MAX_VECTOR_SIZE, typename D, void_) + , typename Extra = void_ + > + struct make_map; + + template <> + struct make_map<> + { + typedef map<> type; + }; + } + + inline map<> + make_map() + { + return map<>(); + } + +#define BOOST_FUSION_PAIR(z, n, data) \ + fusion::pair< \ + BOOST_PP_CAT(K, n) \ + , typename detail::as_fusion_element::type> + +#define BOOST_FUSION_MAKE_PAIR(z, n, data) \ + fusion::make_pair(BOOST_PP_CAT(_, n)) \ + +#define BOOST_PP_FILENAME_1 +#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE) +#include BOOST_PP_ITERATE() + +#undef BOOST_FUSION_PAIR +#undef BOOST_FUSION_MAKE_PAIR + +}} + +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +#pragma wave option(output: null) +#endif + +#endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES + +#endif +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// + +#define N BOOST_PP_ITERATION() + + namespace result_of + { + template < + BOOST_PP_ENUM_PARAMS(N, typename K) + , BOOST_PP_ENUM_PARAMS(N, typename D) + > +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + #define TEXT(z, n, text) , text + struct make_map + #undef TEXT +#else + struct make_map +#endif + { + typedef map type; + }; + } + + template < + BOOST_PP_ENUM_PARAMS(N, typename K) + , BOOST_PP_ENUM_PARAMS(N, typename D) + > + inline map + make_map(BOOST_PP_ENUM_BINARY_PARAMS(N, D, const& _)) + { + return map( + BOOST_PP_ENUM(N, BOOST_FUSION_MAKE_PAIR, _)); + } + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) + diff --git a/include/boost/fusion/container/generation/detail/pp_map_tie.hpp b/include/boost/fusion/container/generation/detail/pp_map_tie.hpp new file mode 100644 index 00000000..e6287ba1 --- /dev/null +++ b/include/boost/fusion/container/generation/detail/pp_map_tie.hpp @@ -0,0 +1,136 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2006 Dan Marsden + + 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) +==============================================================================*/ +#ifndef BOOST_PP_IS_ITERATING +#if !defined(FUSION_PP_MAP_TIE_20060814_1116) +#define FUSION_PP_MAP_TIE_20060814_1116 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) +#include +#else +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/map_tie" FUSION_MAX_MAP_SIZE_STR".hpp") +#endif + +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) + + This is an auto-generated file. Do not edit! +==============================================================================*/ + +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +#pragma wave option(preserve: 1) +#endif + +namespace boost { namespace fusion +{ + struct void_; + + namespace result_of + { + template < + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + FUSION_MAX_MAP_SIZE, typename K, void_) + , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + FUSION_MAX_MAP_SIZE, typename D, void_) + , typename Extra = void_ + > + struct map_tie; + + template <> + struct map_tie<> + { + typedef map<> type; + }; + } + + inline map<> + map_tie() + { + return map<>(); + } + +#define BOOST_FUSION_TIED_PAIR(z, n, data) \ + fusion::pair< \ + BOOST_PP_CAT(K, n) \ + , typename add_reference::type> + +#define BOOST_FUSION_PAIR_TIE(z, n, data) \ + fusion::pair_tie(BOOST_PP_CAT(_, n)) \ + +#define BOOST_PP_FILENAME_1 +#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_MAP_SIZE) +#include BOOST_PP_ITERATE() + +#undef BOOST_FUSION_PAIR +#undef BOOST_FUSION_MAKE_PAIR + +}} + +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +#pragma wave option(output: null) +#endif + +#endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES + +#endif +#else // defined(BOOST_PP_IS_ITERATING) +/////////////////////////////////////////////////////////////////////////////// +// +// Preprocessor vertical repetition code +// +/////////////////////////////////////////////////////////////////////////////// + +#define N BOOST_PP_ITERATION() + + namespace result_of + { + template < + BOOST_PP_ENUM_PARAMS(N, typename K) + , BOOST_PP_ENUM_PARAMS(N, typename D) + > +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + #define TEXT(z, n, text) , text + + struct map_tie + #undef TEXT +#else + struct map_tie +#endif + { + typedef map type; + }; + } + + template < + BOOST_PP_ENUM_PARAMS(N, typename K) + , BOOST_PP_ENUM_PARAMS(N, typename D) + > + inline map + map_tie(BOOST_PP_ENUM_BINARY_PARAMS(N, D, & _)) + { + return map( + BOOST_PP_ENUM(N, BOOST_FUSION_PAIR_TIE, _)); + } + +#undef N +#endif // defined(BOOST_PP_IS_ITERATING) + diff --git a/include/boost/fusion/container/generation/make_deque.hpp b/include/boost/fusion/container/generation/make_deque.hpp index f0178c5c..f13a379a 100644 --- a/include/boost/fusion/container/generation/make_deque.hpp +++ b/include/boost/fusion/container/generation/make_deque.hpp @@ -21,8 +21,6 @@ namespace boost { namespace fusion { - struct void_; - namespace result_of { template diff --git a/include/boost/fusion/container/generation/make_map.hpp b/include/boost/fusion/container/generation/make_map.hpp index 08938d4c..042574d2 100644 --- a/include/boost/fusion/container/generation/make_map.hpp +++ b/include/boost/fusion/container/generation/make_map.hpp @@ -1,132 +1,62 @@ /*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2001-2013 Joel de Guzman 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) ==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING #if !defined(FUSION_MAKE_MAP_07222005_1247) #define FUSION_MAKE_MAP_07222005_1247 -#include -#include -#include -#include -#include #include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) +# include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// #include #include -#if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) -#include -#else -#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/make_map" FUSION_MAX_MAP_SIZE_STR".hpp") -#endif - -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - - 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) - - This is an auto-generated file. Do not edit! -==============================================================================*/ - -#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 1) -#endif - namespace boost { namespace fusion { - struct void_; - namespace result_of { - template < - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - FUSION_MAX_VECTOR_SIZE, typename K, void_) - , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - FUSION_MAX_VECTOR_SIZE, typename D, void_) - , typename Extra = void_ - > - struct make_map; - - template <> - struct make_map<> + template + struct make_map { - typedef map<> type; + template + struct apply + { + typedef map< + fusion::pair< + Key + , typename detail::as_fusion_element::type + >...> + type; + }; }; } - inline map<> - make_map() + template + inline map< + fusion::pair< + Key + , typename detail::as_fusion_element::type + >...> + make_map(T const&... arg) { - return map<>(); + typedef map< + fusion::pair< + Key + , typename detail::as_fusion_element::type + >...> + result_type; + + return result_type(arg...); } - -#define BOOST_FUSION_PAIR(z, n, data) \ - fusion::pair< \ - BOOST_PP_CAT(K, n) \ - , typename detail::as_fusion_element::type> - -#define BOOST_FUSION_MAKE_PAIR(z, n, data) \ - fusion::make_pair(BOOST_PP_CAT(_, n)) \ - -#define BOOST_PP_FILENAME_1 -#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE) -#include BOOST_PP_ITERATE() - -#undef BOOST_FUSION_PAIR -#undef BOOST_FUSION_MAKE_PAIR - -}} - -#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(output: null) -#endif - -#endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES + }} #endif -#else // defined(BOOST_PP_IS_ITERATING) -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// - -#define N BOOST_PP_ITERATION() - - namespace result_of - { - template < - BOOST_PP_ENUM_PARAMS(N, typename K) - , BOOST_PP_ENUM_PARAMS(N, typename D) - > -#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) - #define TEXT(z, n, text) , text - struct make_map - #undef TEXT -#else - struct make_map -#endif - { - typedef map type; - }; - } - - template < - BOOST_PP_ENUM_PARAMS(N, typename K) - , BOOST_PP_ENUM_PARAMS(N, typename D) - > - inline map - make_map(BOOST_PP_ENUM_BINARY_PARAMS(N, D, const& _)) - { - return map( - BOOST_PP_ENUM(N, BOOST_FUSION_MAKE_PAIR, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - +#endif \ No newline at end of file diff --git a/include/boost/fusion/container/generation/map_tie.hpp b/include/boost/fusion/container/generation/map_tie.hpp index 4e8b3854..314df39d 100644 --- a/include/boost/fusion/container/generation/map_tie.hpp +++ b/include/boost/fusion/container/generation/map_tie.hpp @@ -1,136 +1,46 @@ /*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - Copyright (c) 2006 Dan Marsden + Copyright (c) 2001-2013 Joel de Guzman 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) ==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#if !defined(FUSION_MAP_TIE_20060814_1116) -#define FUSION_MAP_TIE_20060814_1116 +#if !defined(FUSION_MAP_TIE_07222005_1247) +#define FUSION_MAP_TIE_07222005_1247 -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) -#include +#if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) +# include #else -#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/map_tie" FUSION_MAX_MAP_SIZE_STR".hpp") -#endif -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - - 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) - - This is an auto-generated file. Do not edit! -==============================================================================*/ - -#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 1) -#endif +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// +#include namespace boost { namespace fusion { - struct void_; - namespace result_of { - template < - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - FUSION_MAX_MAP_SIZE, typename K, void_) - , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - FUSION_MAX_MAP_SIZE, typename D, void_) - , typename Extra = void_ - > - struct map_tie; - - template <> - struct map_tie<> + template + struct map_tie { - typedef map<> type; + template + struct apply + { + typedef map...> type; + }; }; } - inline map<> - map_tie() + template + inline map...> + map_tie(T&... arg) { - return map<>(); + typedef map...> result_type; + return result_type(arg...); } - -#define BOOST_FUSION_TIED_PAIR(z, n, data) \ - fusion::pair< \ - BOOST_PP_CAT(K, n) \ - , typename add_reference::type> - -#define BOOST_FUSION_PAIR_TIE(z, n, data) \ - fusion::pair_tie(BOOST_PP_CAT(_, n)) \ - -#define BOOST_PP_FILENAME_1 -#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_MAP_SIZE) -#include BOOST_PP_ITERATE() - -#undef BOOST_FUSION_PAIR -#undef BOOST_FUSION_MAKE_PAIR - -}} - -#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(output: null) -#endif - -#endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES + }} #endif -#else // defined(BOOST_PP_IS_ITERATING) -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// - -#define N BOOST_PP_ITERATION() - - namespace result_of - { - template < - BOOST_PP_ENUM_PARAMS(N, typename K) - , BOOST_PP_ENUM_PARAMS(N, typename D) - > -#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) - #define TEXT(z, n, text) , text - - struct map_tie - #undef TEXT -#else - struct map_tie -#endif - { - typedef map type; - }; - } - - template < - BOOST_PP_ENUM_PARAMS(N, typename K) - , BOOST_PP_ENUM_PARAMS(N, typename D) - > - inline map - map_tie(BOOST_PP_ENUM_BINARY_PARAMS(N, D, & _)) - { - return map( - BOOST_PP_ENUM(N, BOOST_FUSION_PAIR_TIE, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - +#endif \ No newline at end of file diff --git a/include/boost/fusion/container/map/detail/at_impl.hpp b/include/boost/fusion/container/map/detail/at_impl.hpp new file mode 100644 index 00000000..176b1103 --- /dev/null +++ b/include/boost/fusion/container/map/detail/at_impl.hpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2001-2013 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_DETAIL_AT_IMPL_02042013_0821) +#define BOOST_FUSION_MAP_DETAIL_AT_IMPL_02042013_0821 + +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + namespace extension + { + template + struct at_impl; + + template <> + struct at_impl + { + template + struct apply + { + typedef + decltype(std::declval().get(N())) + type; + + static type + call(Sequence& m) + { + return m.get(N()); + } + }; + + template + struct apply + { + typedef + decltype(std::declval().get(N())) + type; + + static type + call(Sequence const& m) + { + return m.get(N()); + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/container/map/detail/at_key_impl.hpp b/include/boost/fusion/container/map/detail/at_key_impl.hpp new file mode 100644 index 00000000..1f08a47b --- /dev/null +++ b/include/boost/fusion/container/map/detail/at_key_impl.hpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 2001-2013 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_DETAIL_AT_KEY_IMPL_02042013_0821) +#define BOOST_FUSION_MAP_DETAIL_AT_KEY_IMPL_02042013_0821 + +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + namespace extension + { + template + struct at_key_impl; + + template <> + struct at_key_impl + { + template + struct apply + { + typedef + decltype(std::declval().get(mpl::identity())) + type; + + static type + call(Sequence& m) + { + return m.get(mpl::identity()); + } + }; + + template + struct apply + { + typedef + decltype(std::declval().get(mpl::identity())) + type; + + static type + call(Sequence const& m) + { + return m.get(mpl::identity()); + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/container/map/detail/begin_impl.hpp b/include/boost/fusion/container/map/detail/begin_impl.hpp new file mode 100644 index 00000000..047683b8 --- /dev/null +++ b/include/boost/fusion/container/map/detail/begin_impl.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2005-2013 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_BEGIN_IMPL_02042013_0857) +#define BOOST_FUSION_MAP_BEGIN_IMPL_02042013_0857 + +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + namespace extension + { + template + struct begin_impl; + + template<> + struct begin_impl + { + template + struct apply + { + typedef map_iterator type; + + static type call(Sequence& seq) + { + return type(seq); + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/container/map/detail/end_impl.hpp b/include/boost/fusion/container/map/detail/end_impl.hpp new file mode 100644 index 00000000..03c1fdd9 --- /dev/null +++ b/include/boost/fusion/container/map/detail/end_impl.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2005-2013 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_END_IMPL_02042013_0857) +#define BOOST_FUSION_MAP_END_IMPL_02042013_0857 + +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + namespace extension + { + template + struct end_impl; + + template<> + struct end_impl + { + template + struct apply + { + typedef map_iterator type; + + static type call(Sequence& seq) + { + return type(seq); + } + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/container/map/detail/map_impl.hpp b/include/boost/fusion/container/map/detail/map_impl.hpp new file mode 100644 index 00000000..7f313f4c --- /dev/null +++ b/include/boost/fusion/container/map/detail/map_impl.hpp @@ -0,0 +1,165 @@ +/*============================================================================= + Copyright (c) 2005-2013 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_IMPL_02032013_2233) +#define BOOST_FUSION_MAP_IMPL_02032013_2233 + +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct fusion_sequence_tag; +}} + +namespace boost { namespace fusion { namespace detail +{ + struct map_impl_from_iterator {}; + + template + struct map_impl; + + template + struct map_impl + { + typedef fusion_sequence_tag tag; + static int const index = index_; + static int const size = 0; + + map_impl() {} + + template + map_impl(Iterator const& iter, map_impl_from_iterator) + {} + + void get(); + void get_val(); + void get_key(); + }; + + template + struct map_impl : map_impl + { + typedef fusion_sequence_tag tag; + typedef map_impl rest_type; + + using rest_type::get; + using rest_type::get_val; + using rest_type::get_key; + + static int const index = index_; + static int const size = rest_type::size + 1; + + typedef Pair pair_type; + typedef typename Pair::first_type key_type; + typedef typename Pair::second_type value_type; + + map_impl() + : rest_type(), element() + {} + + map_impl(map_impl const& rhs) + : rest_type(rhs.get_base()), element(rhs.element) + {} + + map_impl(map_impl&& rhs) + : rest_type(std::forward(*static_cast(this))) + , element(std::forward(rhs.element)) + {} + + template + map_impl(map_impl const& rhs) + : rest_type(rhs.get_base()), element(rhs.element) + {} + + map_impl(typename detail::call_param::type element + , typename detail::call_param::type... rest) + : rest_type(rest...), element(element) + {} + + map_impl(Pair&& element, T&&... rest) + : rest_type(std::forward(rest)...) + , element(std::forward(element)) + {} + + template + map_impl(Iterator const& iter, map_impl_from_iterator fi) + : rest_type(fusion::next(iter), fi) + , element(*iter) + {} + + rest_type& get_base() + { + return *this; + } + + rest_type const& get_base() const + { + return *this; + } + + value_type get_val(mpl::identity); + pair_type get_val(mpl::int_); + value_type get_val(mpl::identity) const; + pair_type get_val(mpl::int_) const; + + key_type get_key(mpl::int_); + key_type get_key(mpl::int_) const; + + typename cref_result::type + get(mpl::identity) const + { + return element.second; + } + + typename ref_result::type + get(mpl::identity) + { + return element.second; + } + + typename cref_result::type + get(mpl::int_) const + { + return element; + } + + typename ref_result::type + get(mpl::int_) + { + return element; + } + + template + map_impl& operator=(map_impl const& rhs) + { + rest_type::operator=(rhs); + element = rhs.element; + return *this; + } + + map_impl& operator=(map_impl const& rhs) + { + rest_type::operator=(rhs); + element = rhs.element; + return *this; + } + + map_impl& operator=(map_impl&& rhs) + { + rest_type::operator=(std::forward(rhs)); + element = std::forward(rhs.element); + return *this; + } + + Pair element; + }; +}}} + +#endif diff --git a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp new file mode 100644 index 00000000..708e9913 --- /dev/null +++ b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp @@ -0,0 +1,38 @@ +/*============================================================================= + Copyright (c) 2001-2013 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_DETAIL_VALUE_AT_KEY_IMPL_02042013_0821) +#define BOOST_FUSION_MAP_DETAIL_VALUE_AT_KEY_IMPL_02042013_0821 + +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + namespace extension + { + template + struct value_at_key_impl; + + template <> + struct value_at_key_impl + { + template + struct apply + { + typedef + decltype(std::declval().get_val(mpl::identity())) + type; + }; + }; + } +}} + +#endif diff --git a/include/boost/fusion/container/map/map.hpp b/include/boost/fusion/container/map/map.hpp index ad18955f..106b6658 100644 --- a/include/boost/fusion/container/map/map.hpp +++ b/include/boost/fusion/container/map/map.hpp @@ -7,6 +7,52 @@ #if !defined(FUSION_MAP_MAIN_07212005_1106) #define FUSION_MAP_MAIN_07212005_1106 -#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// Without variadics, we will use the PP version +/////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) +# include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct map_tag; + + template + struct map : detail::map_impl<0, T...>, sequence_base> + { + typedef map_tag fusion_tag; + typedef detail::map_impl<0, T...> base_type; + + struct category : random_access_traversal_tag, associative_tag {}; + typedef mpl::int_ size; + typedef mpl::false_ is_view; + + map() {}; + + map(typename detail::call_param::type... element) + : base_type(element...) + {} + }; +}} #endif +#endif diff --git a/include/boost/fusion/container/map/map_fwd.hpp b/include/boost/fusion/container/map/map_fwd.hpp index 1b7b1f43..15df6329 100644 --- a/include/boost/fusion/container/map/map_fwd.hpp +++ b/include/boost/fusion/container/map/map_fwd.hpp @@ -7,6 +7,30 @@ #if !defined(FUSION_MAP_FORWARD_MAIN_07212005_1105) #define FUSION_MAP_FORWARD_MAIN_07212005_1105 -#include +#include + +/////////////////////////////////////////////////////////////////////////////// +// With no decltype and variadics, we will use the C++03 version +/////////////////////////////////////////////////////////////////////////////// +#if (defined(BOOST_NO_CXX11_DECLTYPE) \ + || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ + || defined(BOOST_NO_CXX11_RVALUE_REFERENCES)) +# include +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_MAP) +# define BOOST_FUSION_HAS_VARIADIC_MAP +# endif + +#include + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + template + struct map; +}} #endif +#endif diff --git a/include/boost/fusion/container/map/map_iterator.hpp b/include/boost/fusion/container/map/map_iterator.hpp new file mode 100644 index 00000000..7761fdba --- /dev/null +++ b/include/boost/fusion/container/map/map_iterator.hpp @@ -0,0 +1,164 @@ +/*============================================================================= + Copyright (c) 2005-2013 Joel de Guzman + Copyright (c) 2005-2006 Dan Marsden + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_MAP_ITERATOR_02042013_0835) +#define BOOST_FUSION_MAP_ITERATOR_02042013_0835 + +#include +#include +#include + +namespace boost { namespace fusion +{ + struct random_access_traversal_tag; + + template + struct map_iterator + : iterator_facade< + map_iterator + , random_access_traversal_tag> + { + typedef Seq sequence; + typedef mpl::int_ index; + + map_iterator(Seq& seq) + : seq_(seq) + {} + + template + struct value_of + { + typedef typename Iterator::sequence sequence; + typedef typename Iterator::index index; + typedef + decltype(std::declval().get_val(index())) + type; + }; + + template + struct value_of_data + { + typedef typename Iterator::sequence sequence; + typedef typename Iterator::index index; + typedef + decltype(std::declval().get_val(index()).second) + type; + }; + + template + struct key_of + { + typedef typename Iterator::sequence sequence; + typedef typename Iterator::index index; + typedef + decltype(std::declval().get_key(index())) + type; + }; + + template + struct deref + { + typedef typename Iterator::sequence sequence; + typedef typename Iterator::index index; + typedef + decltype(std::declval().get(index())) + type; + + static type + call(Iterator const& it) + { + return it.seq_.get(typename Iterator::index()); + } + }; + + template + struct deref_data + { + typedef typename Iterator::sequence sequence; + typedef typename Iterator::index index; + typedef + decltype(std::declval().get(index()).second) + type; + + static type + call(Iterator const& it) + { + return it.seq_.get(typename Iterator::index()).second; + } + }; + + //~ template + //~ struct deref_data + //~ { + //~ typedef typename Iterator::sequence sequence; + //~ typedef typename Iterator::index index; + //~ typedef + //~ decltype(std::declval().get(index())) + //~ type; + + //~ static type + //~ call(Iterator const& it) + //~ { + //~ return it.seq_.get(typename Iterator::index()); + //~ } + //~ }; + + template + struct advance + { + typedef typename Iterator::index index; + typedef typename Iterator::sequence sequence; + typedef map_iterator type; + + static type + call(Iterator const& i) + { + return type(i.seq_); + } + }; + + template + struct next + : advance > + {}; + + template + struct prior + : advance > + {}; + + template + struct distance : mpl::minus + { + typedef typename + mpl::minus< + typename I2::index, typename I1::index + >::type + type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; + + template + struct equal_to + : mpl::equal_to + {}; + + Seq& seq_; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + map_iterator& operator= (map_iterator const&); + }; + +}} + +#endif diff --git a/include/boost/fusion/iterator/basic_iterator.hpp b/include/boost/fusion/iterator/basic_iterator.hpp index 4327a8ce..995bdb10 100644 --- a/include/boost/fusion/iterator/basic_iterator.hpp +++ b/include/boost/fusion/iterator/basic_iterator.hpp @@ -39,7 +39,7 @@ namespace boost { namespace fusion template struct basic_iterator - : iterator_facade, Category> + : iterator_facade, Category> { typedef mpl::int_ index; typedef Seq seq_type;