Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / functional / factory / test / factory_args.cpp
1 /*
2 Copyright 2019 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/config.hpp>
9 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
10     !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
11 #include <boost/functional/factory.hpp>
12 #include <boost/core/lightweight_test.hpp>
13 #include <boost/smart_ptr/scoped_ptr.hpp>
14
15 class sum {
16 public:
17     explicit sum(int a = 0, int b = 0, int c = 0, int d = 0,
18                  int e = 0, int f = 0, int g = 0, int h = 0,
19                  int i = 0, int j = 0, int k = 0, int l = 0)
20         : value_(a + b + c + d + e + f + g + h + i + j + k + l) { }
21
22     int get() const {
23         return value_;
24     }
25
26 private:
27     int value_;
28 };
29
30 int main()
31 {
32     boost::scoped_ptr<sum> s(boost::factory<sum*>()(1, 2, 3, 4, 5, 6, 7, 8, 9,
33         10, 11, 12));
34     BOOST_TEST(s->get() == 78);
35     return boost::report_errors();
36 }
37 #else
38 int main()
39 {
40     return 0;
41 }
42 #endif