Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame^] | 1 | /*============================================================================= |
| 2 | Copyright (c) 2007 Tobias Schwinger |
| 3 | |
| 4 | Use modification and distribution are subject to the Boost Software |
| 5 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | http://www.boost.org/LICENSE_1_0.txt). |
| 7 | ==============================================================================*/ |
| 8 | |
| 9 | #include <boost/functional/factory.hpp> |
| 10 | #include <boost/detail/lightweight_test.hpp> |
| 11 | |
| 12 | #include <memory> |
| 13 | |
| 14 | class sum |
| 15 | { |
| 16 | int val_sum; |
| 17 | public: |
| 18 | sum(int a, int b) : val_sum(a + b) { } |
| 19 | |
| 20 | operator int() const { return this->val_sum; } |
| 21 | }; |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | int one = 1, two = 2; |
| 26 | { |
| 27 | sum* instance( ndnboost::factory< sum* >()(one,two) ); |
| 28 | BOOST_TEST(*instance == 3); |
| 29 | } |
| 30 | { |
| 31 | std::auto_ptr<sum> instance( ndnboost::factory< std::auto_ptr<sum> >()(one,two) ); |
| 32 | BOOST_TEST(*instance == 3); |
| 33 | } |
| 34 | return ndnboost::report_errors(); |
| 35 | } |
| 36 | |