1/*
2Copyright 2020 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 A1 {
13 typedef T value_type;
14 A1() { }
15};
16
17#if !defined(BOOST_NO_CXX11_ALLOCATOR)
18template<class T>
19struct A2 {
20 typedef T value_type;
21 A2() { }
22 template<class U, class V>
23 void construct(U* p, const V& v) {
24 ::new((void*)p) U(v + 1);
25 }
26};
27#endif
28
29int main()
30{
31 {
32 A1<int> a;
33 int i = 0;
34 boost::allocator_construct(a, p: &i, args: 5);
35 BOOST_TEST_EQ(i, 5);
36 }
37#if !defined(BOOST_NO_CXX11_ALLOCATOR)
38 {
39 A2<int> a;
40 int i = 0;
41 boost::allocator_construct(a, p: &i, args: 5);
42 BOOST_TEST_EQ(i, 6);
43 }
44#endif
45 return boost::report_errors();
46}
47

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