Fix for LWG Issue 2369: constexpr max(initializer_list) vs max_element

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@236952 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2015-05-10 13:53:31 +00:00
parent 488025c316
commit 928735abf1
7 changed files with 107 additions and 33 deletions

View File

@@ -57,10 +57,24 @@ test()
test<Iter>(1000);
}
#if __cplusplus >= 201402L
constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
#endif
void constexpr_test()
{
#if __cplusplus >= 201402L
constexpr auto p = std::max_element(il,il+8);
static_assert ( *p == 8, "" );
#endif
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
constexpr_test ();
}

View File

@@ -75,6 +75,19 @@ void test_eq()
delete [] a;
}
#if __cplusplus >= 201402L
constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }};
#endif
void constexpr_test()
{
#if __cplusplus >= 201402L
constexpr auto p = std::max_element(il, il+8, less());
static_assert ( *p == 8, "" );
#endif
}
int main()
{
test<forward_iterator<const int*> >();
@@ -82,4 +95,6 @@ int main()
test<random_access_iterator<const int*> >();
test<const int*>();
test_eq();
constexpr_test();
}

View File

@@ -57,10 +57,24 @@ test()
test<Iter>(1000);
}
#if __cplusplus >= 201402L
constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
#endif
void constexpr_test()
{
#if __cplusplus >= 201402L
constexpr auto p = std::min_element(il, il+8);
static_assert ( *p == 1, "" );
#endif
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
constexpr_test();
}

View File

@@ -75,6 +75,19 @@ void test_eq()
delete [] a;
}
#if __cplusplus >= 201402L
constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }};
#endif
void constexpr_test()
{
#if __cplusplus >= 201402L
constexpr auto p = std::min_element(il, il+8, less());
static_assert(*p == 1, "");
#endif
}
int main()
{
test<forward_iterator<const int*> >();
@@ -82,4 +95,6 @@ int main()
test<random_access_iterator<const int*> >();
test<const int*>();
test_eq();
constexpr_test();
}

View File

@@ -74,10 +74,25 @@ test()
}
}
#if __cplusplus >= 201402L
constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
#endif
void constexpr_test()
{
#if __cplusplus >= 201402L
constexpr auto p = std::minmax_element(il, il+8);
static_assert ( *(p.first) == 1, "" );
static_assert ( *(p.second) == 8, "" );
#endif
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
constexpr_test();
}

View File

@@ -79,10 +79,26 @@ test()
}
}
#if __cplusplus >= 201402L
constexpr int il[] = { 2, 4, 6, 8, 7, 5, 3, 1 };
struct less { constexpr bool operator ()( const int &x, const int &y) const { return x < y; }};
#endif
void constexpr_test()
{
#if __cplusplus >= 201402L
constexpr auto p = std::minmax_element(il, il+8, less());
static_assert ( *(p.first) == 1, "" );
static_assert ( *(p.second) == 8, "" );
#endif
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
constexpr_test();
}