1 // Boost.Assign library
\r
3 // Copyright Thorsten Ottosen 2006. Use, modification and
\r
4 // distribution is subject to the Boost Software License, Version
\r
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
\r
6 // http://www.boost.org/LICENSE_1_0.txt)
\r
8 // For more information, see http://www.boost.org/libs/assign/
\r
11 #ifndef BOOST_ASSIGN_PTR_CONTAINER_PTR_MAP_INSERTER_HPP
\r
12 #define BOOST_ASSIGN_PTR_CONTAINER_PTR_MAP_INSERTER_HPP
\r
14 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
\r
18 #include <boost/assign/list_inserter.hpp>
\r
19 #include <boost/type_traits/remove_reference.hpp>
\r
20 #include <boost/type_traits/remove_pointer.hpp>
\r
27 template< class PtrMap, class Obj >
\r
28 class ptr_map_inserter
\r
30 typedef BOOST_DEDUCED_TYPENAME
\r
31 remove_pointer< BOOST_DEDUCED_TYPENAME
\r
32 remove_reference<Obj>::type >::type
\r
34 typedef BOOST_DEDUCED_TYPENAME PtrMap::key_type
\r
39 ptr_map_inserter( PtrMap& m ) : m_( m )
\r
42 template< class Key >
\r
43 ptr_map_inserter& operator()( const Key& t )
\r
46 m_.insert( k, new obj_type );
\r
50 #ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value
\r
51 #define BOOST_ASSIGN_MAX_PARAMS 6
\r
53 #define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1)
\r
54 #define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T)
\r
55 #define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t)
\r
56 #define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t)
\r
58 #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS)
\r
59 #define BOOST_PP_LOCAL_MACRO(n) \
\r
60 template< class T, BOOST_ASSIGN_PARAMS1(n) > \
\r
61 ptr_map_inserter& operator()( const T& t, BOOST_ASSIGN_PARAMS2(n) ) \
\r
64 m_.insert( k, new obj_type( BOOST_ASSIGN_PARAMS3(n) ) ); \
\r
69 #include BOOST_PP_LOCAL_ITERATE()
\r
73 ptr_map_inserter& operator=( const ptr_map_inserter& );
\r
77 template< class PtrMap >
\r
78 inline ptr_map_inserter< PtrMap, typename PtrMap::mapped_reference >
\r
79 ptr_map_insert( PtrMap& m )
\r
81 return ptr_map_inserter< PtrMap, typename PtrMap::mapped_reference >( m );
\r
84 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
\r
86 template< class T, class PtrMap >
\r
87 inline ptr_map_inserter< PtrMap, T >
\r
88 ptr_map_insert( PtrMap& m )
\r
90 return ptr_map_inserter< PtrMap, T >( m );
\r
95 } // namespace 'assign'
\r
96 } // namespace 'boost'
\r
98 #undef BOOST_ASSIGN_PARAMS1
\r
99 #undef BOOST_ASSIGN_PARAMS2
\r
100 #undef BOOST_ASSIGN_PARAMS3
\r
101 #undef BOOST_ASSIGN_MAX_PARAMETERS
\r