Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2006-05-16 06:28:08


WHAT:
=====

The patch changes the internal pair concept, so STL pairs and Fusion pairs also work as MPL pairs.

STL pair:
  first (value)
  second (value)
  first_type (type)
  second_type (type)

Fusion pair:
  second (value)
  first_type (type)
  second_type (type)

MPL pair (CVS):
  first (type)
  second (type)

MPL pair (after applying this patch):
  first_type (type)
  second_type (type)

FILES:
======

- mpl.patch

  changes in boost/mpl (note: preprocessed files for mpl::map are not
  included to not flood the list)

- test.patch

  changes in libs/mpl/test (some tests access the type members directly)

diffed against: CVS HEAD

TESTED WITH:
============

- MSVC 8.0
- MSVC 7.1
- GCC 3.4.2

Index: boost/mpl/pair.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/pair.hpp,v
retrieving revision 1.5
diff -u -r1.5 pair.hpp
--- boost/mpl/pair.hpp 14 Dec 2004 14:05:31 -0000 1.5
+++ boost/mpl/pair.hpp 15 May 2006 23:31:20 -0000
@@ -28,8 +28,8 @@
 struct pair
 {
     typedef pair type;
- typedef T1 first;
- typedef T2 second;
+ typedef T1 first_type;
+ typedef T2 second_type;
 
     BOOST_MPL_AUX_LAMBDA_SUPPORT(2,pair,(T1,T2))
 };
@@ -40,9 +40,9 @@
 struct first
 {
 #if !defined(BOOST_MPL_CFG_MSVC_70_ETI_BUG)
- typedef typename P::first type;
+ typedef typename P::first_type type;
 #else
- typedef typename aux::msvc_eti_base<P>::first type;
+ typedef typename aux::msvc_eti_base<P>::first_type type;
 #endif
     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,first,(P))
 };
@@ -53,9 +53,9 @@
 struct second
 {
 #if !defined(BOOST_MPL_CFG_MSVC_70_ETI_BUG)
- typedef typename P::second type;
+ typedef typename P::second_type type;
 #else
- typedef typename aux::msvc_eti_base<P>::second type;
+ typedef typename aux::msvc_eti_base<P>::second_type type;
 #endif
     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,second,(P))
 };
Index: boost/mpl/unique.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/unique.hpp,v
retrieving revision 1.7
diff -u -r1.7 unique.hpp
--- boost/mpl/unique.hpp 2 Sep 2004 15:40:42 -0000 1.7
+++ boost/mpl/unique.hpp 15 May 2006 23:45:40 -0000
@@ -36,8 +36,8 @@
 {
     template< typename Pair, typename T > struct apply
     {
- typedef typename Pair::first seq_;
- typedef typename Pair::second prior_;
+ typedef typename Pair::first_type seq_;
+ typedef typename Pair::second_type prior_;
         typedef typename eval_if<
               and_< is_not_na<prior_>, apply2<Predicate,prior_,T> >
             , identity<seq_>
Index: boost/mpl/aux_/apply_1st.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/aux_/apply_1st.hpp,v
retrieving revision 1.4
diff -u -r1.4 apply_1st.hpp
--- boost/mpl/aux_/apply_1st.hpp 2 Sep 2004 15:40:43 -0000 1.4
+++ boost/mpl/aux_/apply_1st.hpp 15 May 2006 23:37:58 -0000
@@ -22,8 +22,8 @@
 {
     template< typename Pair, typename T > struct apply
         : apply2<
- typename Pair::first
- , typename Pair::second
+ typename Pair::first_type
+ , typename Pair::second_type
             , T
>
     {
Index: boost/mpl/aux_/partition_op.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/aux_/partition_op.hpp,v
retrieving revision 1.4
diff -u -r1.4 partition_op.hpp
--- boost/mpl/aux_/partition_op.hpp 28 Nov 2004 01:46:37 -0000 1.4
+++ boost/mpl/aux_/partition_op.hpp 15 May 2006 23:38:44 -0000
@@ -31,8 +31,8 @@
     template< typename State, typename T >
     struct apply
     {
- typedef typename State::first first_;
- typedef typename State::second second_;
+ typedef typename State::first_type first_;
+ typedef typename State::second_type second_;
         typedef typename apply1< Pred,T >::type pred_;
 
         typedef typename eval_if<
Index: boost/mpl/aux_/sort_impl.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/aux_/sort_impl.hpp,v
retrieving revision 1.5
diff -u -r1.5 sort_impl.hpp
--- boost/mpl/aux_/sort_impl.hpp 28 Nov 2004 01:47:44 -0000 1.5
+++ boost/mpl/aux_/sort_impl.hpp 15 May 2006 23:39:47 -0000
@@ -63,8 +63,8 @@
         , back_inserter< vector<> >
>::type partitioned;
 
- typedef typename quick_sort< typename partitioned::first, Pred >::type part1;
- typedef typename quick_sort< typename partitioned::second, Pred >::type part2;
+ typedef typename quick_sort< typename partitioned::first_type, Pred >::type part1;
+ typedef typename quick_sort< typename partitioned::second_type, Pred >::type part2;
 
     typedef joint_view<
               joint_view< part1, single_view< typename deref<pivot>::type > >
Index: boost/mpl/map/aux_/contains_impl.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/map/aux_/contains_impl.hpp,v
retrieving revision 1.2
diff -u -r1.2 contains_impl.hpp
--- boost/mpl/map/aux_/contains_impl.hpp 2 Sep 2004 15:41:00 -0000 1.2
+++ boost/mpl/map/aux_/contains_impl.hpp 15 May 2006 23:40:57 -0000
@@ -30,9 +30,9 @@
         : is_same<
               typename at_impl<aux::map_tag>::apply<
                   Map
- , typename Pair::first
+ , typename Pair::first_type
>::type
- , typename Pair::second
+ , typename Pair::second_type
>
     {
     };
Index: boost/mpl/map/aux_/erase_impl.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/map/aux_/erase_impl.hpp,v
retrieving revision 1.3
diff -u -r1.3 erase_impl.hpp
--- boost/mpl/map/aux_/erase_impl.hpp 5 Sep 2004 09:42:58 -0000 1.3
+++ boost/mpl/map/aux_/erase_impl.hpp 15 May 2006 23:41:34 -0000
@@ -31,7 +31,7 @@
>
     struct apply
         : erase_key_impl<aux::map_tag>
- ::apply<Map,typename Pos::type::first>
+ ::apply<Map,typename Pos::type::first_type>
     {
     };
 };
Index: boost/mpl/map/aux_/insert_impl.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/map/aux_/insert_impl.hpp,v
retrieving revision 1.4
diff -u -r1.4 insert_impl.hpp
--- boost/mpl/map/aux_/insert_impl.hpp 14 Dec 2004 14:05:31 -0000 1.4
+++ boost/mpl/map/aux_/insert_impl.hpp 15 May 2006 23:42:00 -0000
@@ -33,15 +33,15 @@
         , Map
 #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
         , m_item<
- typename Pair::first
- , typename Pair::second
+ typename Pair::first_type
+ , typename Pair::second_type
             , Map
>
 #else
         , m_item<
               next< typename Map::size >::type::value
- , typename Pair::first
- , typename Pair::second
+ , typename Pair::first_type
+ , typename Pair::second_type
             , Map
>
 #endif
Index: boost/mpl/map/aux_/numbered.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/mpl/map/aux_/numbered.hpp,v
retrieving revision 1.4
diff -u -r1.4 numbered.hpp
--- boost/mpl/map/aux_/numbered.hpp 14 Dec 2004 14:05:32 -0000 1.4
+++ boost/mpl/map/aux_/numbered.hpp 15 May 2006 23:42:50 -0000
@@ -39,8 +39,8 @@
>
 struct BOOST_PP_CAT(map,i_)
     : m_item<
- typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::first
- , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::second
+ typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::first_type
+ , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::second_type
         , AUX778076_MAP_TAIL(map,BOOST_PP_DEC(i_),P)
>
 {
@@ -93,8 +93,8 @@
 struct BOOST_PP_CAT(map,i_)
     : m_item<
           i_
- , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::first
- , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::second
+ , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::first_type
+ , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::second_type
         , AUX778076_MAP_TAIL(map,BOOST_PP_DEC(i_),P)
>
 {


? libs/mpl/test/Jamfile_timestamp
? libs/mpl/test/results.7.1
? libs/mpl/test/results.8.0
Index: libs/mpl/test/partition.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/mpl/test/partition.cpp,v
retrieving revision 1.2
diff -u -r1.2 partition.cpp
--- libs/mpl/test/partition.cpp 28 Nov 2004 03:35:12 -0000 1.2
+++ libs/mpl/test/partition.cpp 15 May 2006 23:56:24 -0000
@@ -37,6 +37,6 @@
         , mpl::back_inserter< vector<> >
>::type r;
 
- MPL_ASSERT(( equal< r::first, vector_c<int,1,3,5,7,9> > ));
- MPL_ASSERT(( equal< r::second, vector_c<int,0,2,4,6,8> > ));
+ MPL_ASSERT(( equal< r::first_type, vector_c<int,1,3,5,7,9> > ));
+ MPL_ASSERT(( equal< r::second_type, vector_c<int,0,2,4,6,8> > ));
 }
Index: libs/mpl/test/stable_partition.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/mpl/test/stable_partition.cpp,v
retrieving revision 1.3
diff -u -r1.3 stable_partition.cpp
--- libs/mpl/test/stable_partition.cpp 2 Sep 2004 15:41:35 -0000 1.3
+++ libs/mpl/test/stable_partition.cpp 15 May 2006 23:56:54 -0000
@@ -31,8 +31,8 @@
         , less< _, int_<3> >
>::type result;
 
- MPL_ASSERT(( equal< result::first,manual_first > ));
- MPL_ASSERT(( equal< result::second,manual_second > ));
+ MPL_ASSERT(( equal< result::first_type,manual_first > ));
+ MPL_ASSERT(( equal< result::second_type,manual_second > ));
 }
 
 MPL_TEST_CASE()
@@ -42,6 +42,6 @@
         , greater_equal< _, int_<3> >
>::type result;
 
- MPL_ASSERT(( equal< result::first,manual_second > ));
- MPL_ASSERT(( equal< result::second,manual_first > ));
+ MPL_ASSERT(( equal< result::first_type,manual_second > ));
+ MPL_ASSERT(( equal< result::second_type,manual_first > ));
 }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk