value_factory_args.cpp 936 B

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