Changeset 3254


Ignore:
Timestamp:
Jun 9, 2014, 9:53:25 AM (7 years ago)
Author:
Peter
Message:

fixes #799

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3220 r3254  
    44
    55version 0.13 (released NOT YET)
     6  - utility::get separates types in map and passed key (ticket #799)
    67
    78  A complete list of closed tickets can be found here [[br]]
  • trunk/test/utility.cc

    r3253 r3254  
    302302                << e.what() << "\n";
    303303  }
     304  // test ticket #799
     305  if (!suite.add(utility::get(m, "one")==1))
     306    suite.err() << "get(m, \"one\")!=1\n";
     307
    304308  // don't run compiler test code
    305309  if (false) {
     
    315319
    316320    std::map<key_type, value_type, Compare> m3;
    317     key_type my_key;
     321
     322    typedef boost::default_constructible_archetype<
     323      boost::sgi_assignable_archetype<> > key_type;
     324
     325    // create an object that is convertible to key_type
     326    boost::detail::dummy_constructor x;
     327    boost::convertible_to_archetype<key_type> my_key(x);
    318328    utility::get(m3, my_key);
    319329  }
  • trunk/yat/utility/stl_utility.h

    r3253 r3254  
    483483     the map.
    484484
     485     Type Requirment:
     486     - \a Key2 is convertible to Key
     487
    485488     \return const reference to m[k]
    486489
    487      \throw get_error if key \a k does not exist in map
     490     \throw get_error if key \a k does not exist in map \a m
    488491
    489492     \since New in yat 0.7
    490493   */
    491   template <typename Key, typename Tp, typename Compare, typename Alloc>
    492   const Tp& get(const std::map<Key, Tp, Compare, Alloc>& m, const Key& k);
     494  template <typename Key, typename Tp, typename Compare, typename Alloc,
     495            typename Key2>
     496  const Tp& get(const std::map<Key, Tp, Compare, Alloc>& m, const Key2& k);
    493497
    494498  /**
     
    927931  // template implementations
    928932
    929   template <typename Key, typename Tp, typename Compare, typename Alloc>
    930   const Tp& get(const std::map<Key, Tp, Compare, Alloc>& m, const Key& key)
    931   {
     933  template <typename Key, typename Tp, typename Compare, typename Alloc,
     934            typename Key2>
     935  const Tp& get(const std::map<Key, Tp, Compare, Alloc>& m, const Key2& key)
     936  {
     937    BOOST_CONCEPT_ASSERT((boost::Convertible<Key2, Key>));
    932938    typename std::map<Key, Tp, Compare,Alloc>::const_iterator iter(m.find(key));
    933939    if (iter==m.end()) {
     940      // Avoid throw exception with Key2 because we do not want to
     941      // require that Key2 is copy constructible. We know that Key is
     942      // copy constructible from std::map requirement.
    934943      throw
    935944        get_error<Key>("utility::get(const Map&, const Key&): key not found",
Note: See TracChangeset for help on using the changeset viewer.