diff --git a/include/boost/mpl/aux_/insert_range_impl.hpp b/include/boost/mpl/aux_/insert_range_impl.hpp index baffb54..fa43315 100644 --- a/include/boost/mpl/aux_/insert_range_impl.hpp +++ b/include/boost/mpl/aux_/insert_range_impl.hpp @@ -14,9 +14,10 @@ // $Date$ // $Revision$ -#include +#include +#include +#include #include -#include #include #include #include @@ -43,29 +44,31 @@ struct insert_range_impl > struct apply #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING) - : reverse_copy< - joint_view< + : reverse_fold< + joint_view< iterator_range::type,Pos> - , joint_view< + , joint_view< Range , iterator_range::type> > > - , front_inserter< typename clear::type > + , typename clear::type + , insert<_1, begin<_1>, _2> > { #else { - typedef typename reverse_copy< - joint_view< - iterator_range::type,Pos> - , joint_view< - Range - , iterator_range::type> - > - > - , front_inserter< typename clear::type > - >::type type; + typedef typename reverse_fold< + joint_view< + iterator_range::type,Pos> + , joint_view< + Range + , iterator_range::type> + > + > + , typename clear::type + , insert<_1, begin<_1>, _2> + >::type type; #endif }; }; diff --git a/include/boost/mpl/map/aux_/insert_range_impl.hpp b/include/boost/mpl/map/aux_/insert_range_impl.hpp new file mode 100644 index 0000000..f1f0437 --- /dev/null +++ b/include/boost/mpl/map/aux_/insert_range_impl.hpp @@ -0,0 +1,41 @@ + +#ifndef BOOST_MPL_MAP_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED +#define BOOST_MPL_MAP_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED + +// Copyright Bruno Dutra 2015 +// +// 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/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + +template<> +struct insert_range_impl< aux::map_tag > +{ + template< + typename Sequence + , typename /*Pos*/ + , typename Range + > + struct apply + : fold > + { + }; +}; + +}} + +#endif // BOOST_MPL_MAP_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED diff --git a/include/boost/mpl/map/map0.hpp b/include/boost/mpl/map/map0.hpp index e1ea897..88ed4b7 100644 --- a/include/boost/mpl/map/map0.hpp +++ b/include/boost/mpl/map/map0.hpp @@ -19,6 +19,7 @@ #include //#include #include +#include #include #include #include diff --git a/include/boost/mpl/set/aux_/insert_range_impl.hpp b/include/boost/mpl/set/aux_/insert_range_impl.hpp new file mode 100644 index 0000000..f7150a8 --- /dev/null +++ b/include/boost/mpl/set/aux_/insert_range_impl.hpp @@ -0,0 +1,41 @@ + +#ifndef BOOST_MPL_SET_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED +#define BOOST_MPL_SET_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED + +// Copyright Bruno Dutra 2015 +// +// 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/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + +template<> +struct insert_range_impl< aux::set_tag > +{ + template< + typename Sequence + , typename /*Pos*/ + , typename Range + > + struct apply + : fold > + { + }; +}; + +}} + +#endif // BOOST_MPL_SET_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED diff --git a/include/boost/mpl/set/set0.hpp b/include/boost/mpl/set/set0.hpp index 8403731..1c424e4 100644 --- a/include/boost/mpl/set/set0.hpp +++ b/include/boost/mpl/set/set0.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/test/insert_range.cpp b/test/insert_range.cpp index 65e16fa..865017b 100644 --- a/test/insert_range.cpp +++ b/test/insert_range.cpp @@ -15,9 +15,17 @@ #include #include #include +#include +#include +#include #include #include #include +#include +#include +#include +#include +#include #include @@ -33,3 +41,33 @@ MPL_TEST_CASE() typedef insert_range< list0<>,end< list0<> >::type,list1 >::type result2; MPL_ASSERT_RELATION( size::value, ==, 1 ); } + +template +void test_associative() +{ + typedef typename insert_range< A,typename end< A >::type,B >::type C; + + MPL_ASSERT_RELATION( size::value, <=, (size::value + size::value) ); + MPL_ASSERT(( fold< joint_view< A,B >,true_,and_< _1,contains< C,_2 > > > )); +} + +MPL_TEST_CASE() +{ + typedef set3< short,int,long > signed_integers; + typedef set3< unsigned short,unsigned int,unsigned long > unsigned_integers; + test_associative(); + + typedef set_c< int,1,3,5,7,9 > odds; + typedef set_c< int,0,2,4,6,8 > evens; + test_associative(); + + typedef map2< + pair< void,void* > + , pair< int,int* > + > pointers; + typedef map2< + pair< void const,void const* > + , pair< int const,int const* > + > pointers_to_const; + test_associative(); +}