mirror of
https://github.com/boostorg/algorithm.git
synced 2025-07-29 12:07:18 +02:00
Updated constexpr tests for all affected modules. Added conditional constexpr to equal, which uses std::distance.
This commit is contained in:
@ -25,16 +25,27 @@ namespace ba = boost::algorithm;
|
||||
template <typename T>
|
||||
struct less_than {
|
||||
public:
|
||||
less_than ( T foo ) : val ( foo ) {}
|
||||
less_than ( const less_than &rhs ) : val ( rhs.val ) {}
|
||||
BOOST_CXX14_CONSTEXPR less_than ( T foo ) : val ( foo ) {}
|
||||
BOOST_CXX14_CONSTEXPR less_than ( const less_than &rhs ) : val ( rhs.val ) {}
|
||||
|
||||
bool operator () ( const T &v ) const { return v < val; }
|
||||
BOOST_CXX14_CONSTEXPR bool operator () ( const T &v ) const { return v < val; }
|
||||
private:
|
||||
less_than ();
|
||||
less_than operator = ( const less_than &rhs );
|
||||
T val;
|
||||
};
|
||||
|
||||
|
||||
BOOST_CXX14_CONSTEXPR bool test_constexpr() {
|
||||
int v[] = { 4, 5, 6, 7, 8, 9, 10 };
|
||||
bool res = true;
|
||||
res = ( res && ba::is_partitioned ( v, less_than<int>(3))); // no elements
|
||||
res = ( res && ba::is_partitioned ( v, less_than<int>(5))); // only the first element
|
||||
res = ( res && ba::is_partitioned ( v, less_than<int>(8))); // in the middle somewhere
|
||||
res = ( res && ba::is_partitioned ( v, less_than<int>(99))); // all elements
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void test_sequence1 () {
|
||||
std::vector<int> v;
|
||||
@ -61,4 +72,6 @@ void test_sequence1 () {
|
||||
BOOST_AUTO_TEST_CASE( test_main )
|
||||
{
|
||||
test_sequence1 ();
|
||||
BOOST_CXX14_CONSTEXPR bool constexpr_res = test_constexpr ();
|
||||
BOOST_CHECK ( constexpr_res );
|
||||
}
|
||||
|
Reference in New Issue
Block a user