Chris@16: // Boost.Assign library Chris@16: // Chris@16: // Copyright Thorsten Ottosen 2006. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/assign/ Chris@16: // Chris@16: Chris@16: #ifndef BOOST_ASSIGN_PTR_CONTAINER_PTR_MAP_INSERTER_HPP Chris@16: #define BOOST_ASSIGN_PTR_CONTAINER_PTR_MAP_INSERTER_HPP Chris@16: Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: Chris@16: namespace assign Chris@16: { Chris@16: template< class PtrMap, class Obj > Chris@16: class ptr_map_inserter Chris@16: { Chris@16: typedef BOOST_DEDUCED_TYPENAME Chris@16: remove_pointer< BOOST_DEDUCED_TYPENAME Chris@16: remove_reference::type >::type Chris@16: obj_type; Chris@16: typedef BOOST_DEDUCED_TYPENAME PtrMap::key_type Chris@16: key_type; Chris@16: Chris@16: public: Chris@16: Chris@16: ptr_map_inserter( PtrMap& m ) : m_( m ) Chris@16: {} Chris@16: Chris@16: template< class Key > Chris@16: ptr_map_inserter& operator()( const Key& t ) Chris@16: { Chris@16: key_type k(t); Chris@16: m_.insert( k, new obj_type ); Chris@16: return *this; Chris@16: } Chris@16: Chris@16: #ifndef BOOST_ASSIGN_MAX_PARAMS // use user's value Chris@16: #define BOOST_ASSIGN_MAX_PARAMS 6 Chris@16: #endif Chris@16: #define BOOST_ASSIGN_MAX_PARAMETERS (BOOST_ASSIGN_MAX_PARAMS - 1) Chris@16: #define BOOST_ASSIGN_PARAMS1(n) BOOST_PP_ENUM_PARAMS(n, class T) Chris@16: #define BOOST_ASSIGN_PARAMS2(n) BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& t) Chris@16: #define BOOST_ASSIGN_PARAMS3(n) BOOST_PP_ENUM_PARAMS(n, t) Chris@16: Chris@16: #define BOOST_PP_LOCAL_LIMITS (1, BOOST_ASSIGN_MAX_PARAMETERS) Chris@16: #define BOOST_PP_LOCAL_MACRO(n) \ Chris@16: template< class T, BOOST_ASSIGN_PARAMS1(n) > \ Chris@16: ptr_map_inserter& operator()( const T& t, BOOST_ASSIGN_PARAMS2(n) ) \ Chris@16: { \ Chris@16: key_type k(t); \ Chris@16: m_.insert( k, new obj_type( BOOST_ASSIGN_PARAMS3(n) ) ); \ Chris@16: return *this; \ Chris@16: } \ Chris@16: /**/ Chris@16: Chris@16: #include BOOST_PP_LOCAL_ITERATE() Chris@16: Chris@16: private: Chris@16: Chris@16: ptr_map_inserter& operator=( const ptr_map_inserter& ); Chris@16: PtrMap& m_; Chris@16: }; Chris@16: Chris@16: template< class PtrMap > Chris@16: inline ptr_map_inserter< PtrMap, typename PtrMap::mapped_reference > Chris@16: ptr_map_insert( PtrMap& m ) Chris@16: { Chris@16: return ptr_map_inserter< PtrMap, typename PtrMap::mapped_reference >( m ); Chris@16: } Chris@16: Chris@16: #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING Chris@16: Chris@16: template< class T, class PtrMap > Chris@16: inline ptr_map_inserter< PtrMap, T > Chris@16: ptr_map_insert( PtrMap& m ) Chris@16: { Chris@16: return ptr_map_inserter< PtrMap, T >( m ); Chris@16: } Chris@16: Chris@16: #endif Chris@16: Chris@16: } // namespace 'assign' Chris@16: } // namespace 'boost' Chris@16: Chris@16: #undef BOOST_ASSIGN_PARAMS1 Chris@16: #undef BOOST_ASSIGN_PARAMS2 Chris@16: #undef BOOST_ASSIGN_PARAMS3 Chris@16: #undef BOOST_ASSIGN_MAX_PARAMETERS Chris@16: Chris@16: #endif