Ticket #4814: multi_index_initializer_list.patch
File multi_index_initializer_list.patch, 2.1 KB (added by , 12 years ago) |
---|
-
.hpp
old new 62 62 #define BOOST_MULTI_INDEX_CHECK_INVARIANT 63 63 #endif 64 64 65 #if !defined(BOOST_NO_INITIALIZER_LISTS) 66 #include <initializer_list> 67 #endif 68 65 69 namespace boost{ 66 70 67 71 namespace multi_index{ … … 125 129 typedef typename super::index_type_list super_index_type_list; 126 130 #endif 127 131 132 template<typename InputIterator> 133 void iterator_initialize(InputIterator first,InputIterator last) 134 { 135 BOOST_MULTI_INDEX_CHECK_INVARIANT; 136 BOOST_TRY{ 137 iterator hint=super::end(); 138 for(;first!=last;++first){ 139 hint=super::make_iterator(insert_(*first,hint.get_node()).first); 140 } 141 } 142 BOOST_CATCH(...){ 143 clear_(); 144 BOOST_RETHROW; 145 } 146 BOOST_CATCH_END 147 } 148 149 128 150 public: 129 151 /* All types are inherited from super, a few are explicitly 130 152 * brought forward here to save us some typename's. … … 228 250 super(args_list,bfm_allocator::member), 229 251 node_count(0) 230 252 { 231 BOOST_MULTI_INDEX_CHECK_INVARIANT; 232 BOOST_TRY{ 233 iterator hint=super::end(); 234 for(;first!=last;++first){ 235 hint=super::make_iterator(insert_(*first,hint.get_node()).first); 236 } 237 } 238 BOOST_CATCH(...){ 239 clear_(); 240 BOOST_RETHROW; 241 } 242 BOOST_CATCH_END 253 iterator_initialize(first, last); 254 } 255 256 #if !defined(BOOST_NO_INITIALIZER_LISTS) 257 template<typename U> 258 multi_index_container(std::initializer_list<U> init): 259 #if BOOST_WORKAROUND(__IBMCPP__,<=600) 260 bfm_allocator(typename mpl::identity<multi_index_container>::type::allocator_type()), 261 super(typename mpl::identity<multi_index_container>::type::ctor_args_list(), 262 bfm_allocator::member), 263 #else 264 bfm_allocator(allocator_type()), 265 super(ctor_args_list(),bfm_allocator::member), 266 #endif 267 node_count(0) 268 { 269 iterator_initialize(init.begin(), init.end()); 243 270 } 271 #endif 244 272 245 273 multi_index_container( 246 274 const multi_index_container<Value,IndexSpecifierList,Allocator>& x):