1/*
2Copyright 2022 Glen Joseph Fernandes
3(glenjofe@gmail.com)
4
5Distributed under the Boost Software License, Version 1.0.
6(http://www.boost.org/LICENSE_1_0.txt)
7*/
8#include <boost/core/allocator_access.hpp>
9#include <boost/core/lightweight_test.hpp>
10
11template<class T>
12struct A {
13 typedef T value_type;
14 A() { }
15};
16
17int main()
18{
19 {
20 A<int> a;
21 int i[3] = { 5, 5, 5 };
22 boost::allocator_construct_n(a, p: &i[0], n: 3);
23 BOOST_TEST_EQ(i[0], 0);
24 BOOST_TEST_EQ(i[1], 0);
25 BOOST_TEST_EQ(i[2], 0);
26 }
27 {
28 A<int> a;
29 int i[4] = { 5, 5, 5, 5 };
30 int j[2] = { 1, 2 };
31 boost::allocator_construct_n(a, p: &i[0], n: 4, l: &j[0], m: 2);
32 BOOST_TEST_EQ(i[0], 1);
33 BOOST_TEST_EQ(i[1], 2);
34 BOOST_TEST_EQ(i[2], 1);
35 BOOST_TEST_EQ(i[3], 2);
36 }
37 {
38 A<int> a;
39 int i[3] = { 5, 5, 5 };
40 int j[3] = { 1, 2, 3 };
41 boost::allocator_construct_n(a, p: &i[0], n: 3, b: &j[0]);
42 BOOST_TEST_EQ(i[0], 1);
43 BOOST_TEST_EQ(i[1], 2);
44 BOOST_TEST_EQ(i[2], 3);
45 }
46 return boost::report_errors();
47}
48

source code of boost/libs/core/test/allocator_construct_n_test.cpp