]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Signals2 library |
2 | ||
3 | // Copyright Douglas Gregor 2001-2004. | |
4 | // Copyright Frank Mori Hess 2007. Use, modification and | |
5 | // distribution is subject to the Boost Software License, Version | |
6 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 | // http://www.boost.org/LICENSE_1_0.txt) | |
8 | ||
9 | // For more information, see http://www.boost.org | |
10 | ||
11 | #ifndef BOOST_SIGNALS2_RESULT_TYPE_WRAPPER_HPP | |
12 | #define BOOST_SIGNALS2_RESULT_TYPE_WRAPPER_HPP | |
13 | ||
14 | #include <boost/config.hpp> | |
15 | ||
16 | namespace boost { | |
17 | namespace signals2 { | |
18 | namespace detail { | |
19 | // A placeholder for void on compilers that don't support void returns | |
20 | struct void_type {}; | |
21 | ||
22 | // Replaces void with void_type | |
23 | template<typename R> | |
24 | struct nonvoid { | |
25 | typedef R type; | |
26 | }; | |
27 | template<> | |
28 | struct nonvoid<void> { | |
29 | typedef void_type type; | |
30 | }; | |
31 | ||
32 | // Replaces void with void_type only if compiler doesn't support void returns | |
33 | template<typename R> | |
34 | struct result_type_wrapper { | |
35 | typedef R type; | |
36 | }; | |
37 | #ifdef BOOST_NO_VOID_RETURNS | |
38 | template<> | |
39 | struct result_type_wrapper<void> { | |
40 | typedef void_type type; | |
41 | }; | |
42 | #endif | |
43 | ||
44 | // specialization deals with possible void return from combiners | |
45 | template<typename R> class combiner_invoker | |
46 | { | |
47 | public: | |
48 | typedef R result_type; | |
49 | template<typename Combiner, typename InputIterator> | |
50 | result_type operator()(Combiner &combiner, | |
51 | InputIterator first, InputIterator last) const | |
52 | { | |
53 | return combiner(first, last); | |
54 | } | |
55 | }; | |
56 | template<> class combiner_invoker<void> | |
57 | { | |
58 | public: | |
59 | typedef result_type_wrapper<void>::type result_type; | |
60 | template<typename Combiner, typename InputIterator> | |
61 | result_type operator()(Combiner &combiner, | |
62 | InputIterator first, InputIterator last) const | |
63 | { | |
64 | combiner(first, last); | |
65 | return result_type(); | |
66 | } | |
67 | }; | |
68 | } // end namespace detail | |
69 | } // end namespace signals2 | |
70 | } // end namespace boost | |
71 | ||
72 | #endif // BOOST_SIGNALS2_RESULT_TYPE_WRAPPER_HPP |