[Boost-bugs] [Boost C++ Libraries] #12117: flat_set constructor with ordered_unique_range

Subject: [Boost-bugs] [Boost C++ Libraries] #12117: flat_set constructor with ordered_unique_range
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-04-08 08:01:53


#12117: flat_set constructor with ordered_unique_range
------------------------------+----------------------------
 Reporter: dariomt@… | Owner: igaztanaga
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: container
  Version: Boost 1.61.0 | Severity: Not Applicable
 Keywords: |
------------------------------+----------------------------
 I would expect that the constructors taking a ordered_unique_range_t would
 assert that the passed range indeed is sorted and unique according to the
 sorting criteria of the flat_set.

 e.g. I'd expect the following code to assert, but instead it prints 0

 {{{
 #include <boost/container/flat_set.hpp>
 #include <iostream>

 using namespace std;
 using namespace boost::container;

 int main()
 {
     auto l = {3, 2, 1};
     flat_set<int> s (ordered_unique_range, l);
     cout << s.count(1) << endl;
 }
 }}}

 I think the constructor should use std::is_sorted (or the Boost
 equivalent) to assert that the passed range indeed meets the specified
 ordered_unique_range.

 std::is_sorted has complexity Linear in N, so with this change these
 constructors would keep their current complexity (which is also Linear in
 N) even when NDEBUG is not #defined.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12117>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC