Changeset 3285 for trunk/test/utility.cc


Ignore:
Timestamp:
Jul 11, 2014, 12:59:46 PM (8 years ago)
Author:
Peter
Message:

refs #803. Use boost concepts in sort_index. Make requirements more
accurate especially when iterator is random access and value_type
doesn't need to be, e.g., default constructible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/utility.cc

    r3255 r3285  
    3535
    3636#include <boost/concept_archetype.hpp>
     37#include <boost/iterator/iterator_archetypes.hpp>
    3738
    3839#include <cassert>
     
    533534  // do not run compiler tests
    534535  if (false) {
    535     std::vector<size_t> vec;
    536536    // value type must be possible to store in a vector so has to be
    537537    // default constructible and assignable
     
    541541    boost::input_iterator_archetype<value_type> iter;
    542542    utility::sort_index(iter, iter, vec);
     543
    543544    // try with a random access container as well
    544     std::vector<value_type> vec2;
    545     utility::sort_index(vec2.begin(), vec2.end(), vec);
     545    typedef boost::iterator_archetypes::readable_iterator_t access_type;
     546    typedef boost::random_access_traversal_tag traversal_type;
     547    typedef boost::copy_constructible_archetype<
     548      boost::less_than_comparable_archetype<> > value_type2;
     549    boost::iterator_archetype<value_type2, access_type, traversal_type> iter2;
     550    utility::sort_index(iter2, iter2, vec);
    546551  }
    547552  // same thing with four argument version
    548553  if (false) {
    549     std::vector<size_t> vec;
    550554    // value type must be possible to store in a vector so has to be
    551555    // default constructible and assignable
     
    555559    boost::input_iterator_archetype<value_type> iter;
    556560
    557     // Create a binary predicate that is assignable and default constructible
    558     boost::default_constructible_archetype<
    559       boost::sgi_assignable_archetype<
    560         boost::binary_predicate_archetype<
    561           value_type, value_type> > > comp;
     561    // Create a binary predicate that is copy constructible
     562    boost::copy_constructible_archetype<
     563        boost::binary_predicate_archetype<value_type, value_type>
     564      > comp;
    562565
    563566    utility::sort_index(iter, iter, vec, comp);
    564     // try with a random access container as well
    565     std::vector<value_type> vec2;
    566     utility::sort_index(vec2.begin(), vec2.end(), vec, comp);
     567
     568    // try with a random access iterator as well
     569    typedef boost::iterator_archetypes::readable_iterator_t access_type;
     570    typedef boost::random_access_traversal_tag traversal_type;
     571    typedef boost::copy_constructible_archetype<> value_type2;
     572    boost::iterator_archetype<value_type2, access_type, traversal_type> iter2;
     573    // Create a binary predicate that is copy constructible
     574    boost::copy_constructible_archetype<
     575        boost::binary_predicate_archetype<value_type2, value_type2>
     576      > comp2;
     577    utility::sort_index(iter2, iter2, vec, comp2);
    567578  }
    568579}
Note: See TracChangeset for help on using the changeset viewer.