mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
More P0202 constexpr work. This commit adds fill/fill_n/generate/generate_n/unique/unique_copy. I removed a specialization of fill_n that recognized when we were dealing with raw pointers and 1 byte trivially-assignable types and did a memset, because the compiler will do that optimization for us.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323050 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
|
||||
// requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
|
||||
// && CopyConstructible<Pred>
|
||||
// Iter
|
||||
// constexpr Iter // constexpr after C++17
|
||||
// unique(Iter first, Iter last, Pred pred);
|
||||
|
||||
#include <algorithm>
|
||||
@@ -22,6 +22,19 @@
|
||||
#include "test_macros.h"
|
||||
#include "test_iterators.h"
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
TEST_CONSTEXPR bool test_constexpr() {
|
||||
int ia[] = {0, 1, 1, 3, 4};
|
||||
const int expected[] = {0, 1, 3, 4};
|
||||
const size_t N = 4;
|
||||
|
||||
auto it = std::unique(std::begin(ia), std::end(ia), [](int a, int b) {return a == b; });
|
||||
return it == (std::begin(ia) + N)
|
||||
&& std::equal(std::begin(ia), it, std::begin(expected), std::end(expected))
|
||||
;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct count_equal
|
||||
{
|
||||
static unsigned count;
|
||||
@@ -224,4 +237,8 @@ int main()
|
||||
test1<random_access_iterator<Ptr*> >();
|
||||
test1<Ptr*>();
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
static_assert(test_constexpr());
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user