From 1f718e452093550c8ef1526af5a2870ef8aa6e3c Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Tue, 10 Sep 2013 12:47:28 +0000 Subject: [PATCH] Wave: Merging from trunk [SVN r85641] --- doc/tuple.qbk | 4 +- .../struct/detail/define_struct_inline.hpp | 133 ++++++++++++++++-- .../boost/fusion/container/deque/deque.hpp | 2 +- preprocess/preprocess.bat | 7 - preprocess/preprocess.cpp | 10 -- preprocess/wave.cfg | 14 -- 6 files changed, 125 insertions(+), 45 deletions(-) delete mode 100644 preprocess/preprocess.bat delete mode 100644 preprocess/preprocess.cpp delete mode 100644 preprocess/wave.cfg diff --git a/doc/tuple.qbk b/doc/tuple.qbk index 3be81bbe..5dd6be51 100644 --- a/doc/tuple.qbk +++ b/doc/tuple.qbk @@ -91,7 +91,7 @@ Where `Vi` is `X&` if the cv-unqualified type `Ti` is `reference_wrapper`, ot template tuple tie(T1& t1, T2& t2, ..., TN& tn); -[*Returns]: tuple(t1, t2, ..., tN). When argument `ti` is `ignore`, assigning any value to the corresponding tuple element has has no effect. +[*Returns]: tuple(t1, t2, ..., tN). When argument `ti` is `ignore`, assigning any value to the corresponding tuple element has no effect. [endsect] @@ -254,7 +254,7 @@ The __tr1__tuple__ interface is specified to provide uniform access to `std::pai [*Type]: `T2` -[*Value]: Returns thetype of the second element of the pair +[*Value]: Returns the type of the second element of the pair template P& get(std::pair& pr); diff --git a/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp b/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp index 7bc5fe08..bc05e9a8 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct_inline.hpp @@ -8,6 +8,7 @@ #ifndef BOOST_FUSION_ADAPTED_STRUCT_DETAIL_DEFINE_STRUCT_INLINE_HPP #define BOOST_FUSION_ADAPTED_STRUCT_DETAIL_DEFINE_STRUCT_INLINE_HPP +#include #include #include #include @@ -25,8 +26,32 @@ #include #include #include +#include #include +// MSVC and GCC <= 4.4 have a bug that affects partial specializations of +// nested templates under some circumstances. This affects the implementation +// of BOOST_FUSION_DEFINE_STRUCT_INLINE, which uses such specializations for +// the iterator class's 'deref' and 'value_of' metafunctions. On these compilers +// an alternate implementation for these metafunctions is used that does not +// require such specializations. The alternate implementation takes longer +// to compile so its use is restricted to the offending compilers. +// For MSVC, the bug was reported at https://connect.microsoft.com/VisualStudio/feedback/details/757891/c-compiler-error-involving-partial-specializations-of-nested-templates +// For GCC, 4.4 and earlier are no longer maintained so there is no need +// to report a bug. +#if defined(BOOST_MSVC) || (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 4))) + #define BOOST_FUSION_NEED_NESTED_TEMPLATE_PARTIAL_SPEC_WKND +#endif + +#ifdef BOOST_FUSION_NEED_NESTED_TEMPLATE_PARTIAL_SPEC_WKND +#include +#include +#include +#include +#include +#endif + + #define BOOST_FUSION_MAKE_DEFAULT_INIT_LIST_ENTRY(R, DATA, N, ATTRIBUTE) \ BOOST_PP_COMMA_IF(N) BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE)() @@ -148,6 +173,95 @@ #define BOOST_FUSION_MAKE_DATA_MEMBER(R, DATA, N, ATTRIBUTE) \ BOOST_PP_TUPLE_ELEM(2, 0, ATTRIBUTE) BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE); +#ifdef BOOST_FUSION_NEED_NESTED_TEMPLATE_PARTIAL_SPEC_WKND + +#define BOOST_FUSION_DEFINE_ITERATOR_VALUE_OF(NAME, ATTRIBUTE_SEQ_SIZE) \ + template \ + struct value_of : boost::fusion::result_of::at_c< \ + ref_vec_t, \ + boost_fusion_detail_Iterator::index::value \ + > \ + { \ + }; + +#define BOOST_FUSION_DEFINE_ITERATOR_DEREF(NAME, ATTRIBUTES_SEQ) \ + template \ + struct deref \ + { \ + typedef typename boost::remove_const< \ + boost_fusion_detail_Iterator \ + >::type iterator_raw_type; \ + \ + static const int index = iterator_raw_type::index::value; \ + \ + typedef typename boost::fusion::result_of::at_c< \ + ref_vec_t, \ + index \ + >::type result_raw_type; \ + \ + typedef typename boost::mpl::if_< \ + boost::is_const, \ + typename boost::add_const::type, \ + result_raw_type \ + >::type type; \ + \ + static type call(iterator_raw_type const& iter) \ + { \ + return boost::fusion::at_c(iter.ref_vec); \ + } \ + }; + +#define BOOST_FUSION_MAKE_ITERATOR_WKND_FIELD_NAME(R, DATA, N, ATTRIBUTE) \ + BOOST_PP_COMMA_IF(N) seq.BOOST_PP_TUPLE_ELEM(2, 1, ATTRIBUTE) + +#define BOOST_FUSION_DEFINE_ITERATOR_WKND_INIT_LIST_ENTRIES(ATTRIBUTES_SEQ) \ + , ref_vec(BOOST_PP_SEQ_FOR_EACH_I( \ + BOOST_FUSION_MAKE_ITERATOR_WKND_FIELD_NAME, \ + ~, \ + BOOST_PP_SEQ_TAIL(ATTRIBUTES_SEQ))) + +#define BOOST_FUSION_MAKE_ITERATOR_WKND_REF(Z, N, DATA) \ + BOOST_PP_COMMA_IF(N) \ + typename boost::mpl::if_< \ + boost::is_const, \ + typename boost::add_const< \ + typename boost_fusion_detail_Seq::t##N##_type \ + >::type, \ + typename boost_fusion_detail_Seq::t##N##_type \ + >::type& + +#define BOOST_FUSION_DEFINE_ITERATOR_WKND_MEMBERS(ATTRIBUTES_SEQ_SIZE) \ + typedef boost::fusion::vector< \ + BOOST_PP_REPEAT( \ + ATTRIBUTES_SEQ_SIZE, \ + BOOST_FUSION_MAKE_ITERATOR_WKND_REF, \ + ~) \ + > ref_vec_t; \ + \ + ref_vec_t ref_vec; + +#else + +#define BOOST_FUSION_DEFINE_ITERATOR_VALUE_OF(NAME, ATTRIBUTES_SEQ_SIZE) \ + template struct value_of; \ + BOOST_PP_REPEAT( \ + ATTRIBUTES_SEQ_SIZE, \ + BOOST_FUSION_MAKE_ITERATOR_VALUE_OF_SPECS, \ + NAME) + +#define BOOST_FUSION_DEFINE_ITERATOR_DEREF(NAME, ATTRIBUTES_SEQ) \ + template struct deref; \ + BOOST_PP_SEQ_FOR_EACH_I( \ + BOOST_FUSION_MAKE_ITERATOR_DEREF_SPECS, \ + NAME, \ + ATTRIBUTES_SEQ) + +#define BOOST_FUSION_DEFINE_ITERATOR_WKND_INIT_LIST_ENTRIES(ATTRIBUTES_SEQ) + +#define BOOST_FUSION_DEFINE_ITERATOR_WKND_MEMBERS(ATTRIBUTES_SEQ_SIZE) + +#endif // BOOST_FUSION_NEED_NESTED_TEMPLATE_PARTIAL_SPEC_WKND + // Note: We can't nest the iterator inside the struct because we run into // a MSVC10 bug involving partial specializations of nested templates. @@ -219,21 +333,18 @@ typedef boost_fusion_detail_Seq sequence_type; \ \ BOOST_FUSION_ITERATOR_NAME(NAME)(boost_fusion_detail_Seq& seq) \ - : seq_(seq) {} \ + : seq_(seq) \ + BOOST_FUSION_DEFINE_ITERATOR_WKND_INIT_LIST_ENTRIES( \ + (0)ATTRIBUTES_SEQ) \ + {} \ \ boost_fusion_detail_Seq& seq_; \ \ - template struct value_of; \ - BOOST_PP_REPEAT( \ - ATTRIBUTES_SEQ_SIZE, \ - BOOST_FUSION_MAKE_ITERATOR_VALUE_OF_SPECS, \ - NAME) \ + BOOST_FUSION_DEFINE_ITERATOR_WKND_MEMBERS(ATTRIBUTES_SEQ_SIZE) \ \ - template struct deref; \ - BOOST_PP_SEQ_FOR_EACH_I( \ - BOOST_FUSION_MAKE_ITERATOR_DEREF_SPECS, \ - NAME, \ - ATTRIBUTES_SEQ) \ + BOOST_FUSION_DEFINE_ITERATOR_VALUE_OF(NAME, ATTRIBUTES_SEQ_SIZE) \ + \ + BOOST_FUSION_DEFINE_ITERATOR_DEREF(NAME, ATTRIBUTES_SEQ) \ \ template \ struct next \ diff --git a/include/boost/fusion/container/deque/deque.hpp b/include/boost/fusion/container/deque/deque.hpp index 56ae290e..057064a0 100644 --- a/include/boost/fusion/container/deque/deque.hpp +++ b/include/boost/fusion/container/deque/deque.hpp @@ -11,7 +11,7 @@ #include /////////////////////////////////////////////////////////////////////////////// -// With variadics, we will use the PP version version +// With variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// #if defined(BOOST_NO_VARIADIC_TEMPLATES) # include diff --git a/preprocess/preprocess.bat b/preprocess/preprocess.bat deleted file mode 100644 index f5c94977..00000000 --- a/preprocess/preprocess.bat +++ /dev/null @@ -1,7 +0,0 @@ - - -wave @wave.cfg -DFUSION_MAX_VECTOR_SIZE=10 -DFUSION_MAX_LIST_SIZE=10 -DFUSION_MAX_ZIP_SEQUENCES=10 preprocess.cpp -wave @wave.cfg -DFUSION_MAX_VECTOR_SIZE=20 -DFUSION_MAX_LIST_SIZE=20 -DFUSION_MAX_ZIP_SEQUENCES=20 preprocess.cpp -wave @wave.cfg -DFUSION_MAX_VECTOR_SIZE=30 -DFUSION_MAX_LIST_SIZE=30 -DFUSION_MAX_ZIP_SEQUENCES=30 preprocess.cpp -wave @wave.cfg -DFUSION_MAX_VECTOR_SIZE=40 -DFUSION_MAX_LIST_SIZE=40 -DFUSION_MAX_ZIP_SEQUENCES=40 preprocess.cpp -wave @wave.cfg -DFUSION_MAX_VECTOR_SIZE=50 -DFUSION_MAX_LIST_SIZE=50 -DFUSION_MAX_ZIP_SEQUENCES=50 preprocess.cpp diff --git a/preprocess/preprocess.cpp b/preprocess/preprocess.cpp deleted file mode 100644 index 1cc59ef3..00000000 --- a/preprocess/preprocess.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/*============================================================================= - Copyright (c) 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) -==============================================================================*/ -#include -#include -#include - diff --git a/preprocess/wave.cfg b/preprocess/wave.cfg deleted file mode 100644 index 6d13cf63..00000000 --- a/preprocess/wave.cfg +++ /dev/null @@ -1,14 +0,0 @@ --DBOOST_FUSION_DONT_USE_PREPROCESSED_FILES --DBOOST_FUSION_CREATE_PREPROCESSED_FILES --SC:/dev/boost --SC:/dev/tools/mingw/include --SC:/dev/tools/mingw/lib/gcc/mingw32/4.5.2/include --SC:/dev/tools/mingw/lib/gcc/mingw32/4.5.2/include/c++ --SC:/dev/tools/mingw/lib/gcc/mingw32/4.5.2/include/c++/mingw32 ---variadics --NBOOST_FUSION_ADAPT_TPL_STRUCT_NO_PARTIAL --NBOOST_PROTO_USE_GET_POINTER --NBOOST_PROTO_GET_POINTER ---timer - -