blob: f07495637aa736f864889d3985ad5c6928605da5 [file] [log] [blame]
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <vector>
// void assign(size_type n, const_reference v);
#include <vector>
#include <algorithm>
#include <cassert>
#include <iostream>
#include "test_macros.h"
#include "min_allocator.h"
#include "asan_testing.h"
#include "test_iterators.h"
#if TEST_STD_VER >= 11
#include "emplace_constructible.h"
#include "container_test_types.h"
#endif
void test_emplaceable_concept() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
{
using T = EmplaceConstructibleMoveableAndAssignable<int>;
using It = forward_iterator<int*>;
{
std::vector<T> v;
v.assign(It(arr1), It(std::end(arr1)));
assert(v[0].value == 42);
}
{
std::vector<T> v;
v.assign(It(arr2), It(std::end(arr2)));
assert(v[0].value == 1);
assert(v[1].value == 101);
assert(v[2].value == 42);
}
}
{
using T = EmplaceConstructibleMoveableAndAssignable<int>;
using It = input_iterator<int*>;
{
std::vector<T> v;
v.assign(It(arr1), It(std::end(arr1)));
assert(v[0].copied == 0);
assert(v[0].value == 42);
}
{
std::vector<T> v;
v.assign(It(arr2), It(std::end(arr2)));
//assert(v[0].copied == 0);
assert(v[0].value == 1);
//assert(v[1].copied == 0);
assert(v[1].value == 101);
assert(v[2].copied == 0);
assert(v[2].value == 42);
}
}
#endif
}
int main()
{
test_emplaceable_concept();
}