Ticket #4814: multi_index_initializer_list.patch

File multi_index_initializer_list.patch, 2.1 KB (added by Akira Takahashi <faithandbrave@…>, 12 years ago)

initializer_list patch

  • .hpp

    old new  
    6262#define BOOST_MULTI_INDEX_CHECK_INVARIANT
    6363#endif
    6464
     65#if !defined(BOOST_NO_INITIALIZER_LISTS)
     66#include <initializer_list>
     67#endif
     68
    6569namespace boost{
    6670
    6771namespace multi_index{
     
    125129  typedef typename super::index_type_list         super_index_type_list;
    126130#endif
    127131
     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
    128150public:
    129151  /* All types are inherited from super, a few are explicitly
    130152   * brought forward here to save us some typename's.
     
    228250    super(args_list,bfm_allocator::member),
    229251    node_count(0)
    230252  {
    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());
    243270  }
     271#endif
    244272
    245273  multi_index_container(
    246274    const multi_index_container<Value,IndexSpecifierList,Allocator>& x):