1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <functional>
11 
12 // template<Returnable R, CopyConstructible... ArgTypes>
13 // class function<R(ArgTypes...)>
14 //   : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
15 //                                       // ArgTypes contains T1
16 //   : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
17 //                                       // ArgTypes contains T1 and T2
18 // {
19 // public:
20 //     typedef R result_type;
21 //     ...
22 // };
23 
24 #include <functional>
25 #include <type_traits>
26 
27 int main()
28 {
29     static_assert((!std::is_base_of<std::unary_function <int, int>,
30                                            std::function<int()> >::value), "");
31     static_assert((!std::is_base_of<std::binary_function<int, int, int>,
32                                            std::function<int()> >::value), "");
33     static_assert(( std::is_same<          std::function<int()>::result_type,
34                                                          int>::value), "");
35 
36     static_assert(( std::is_base_of<std::unary_function <int, double>,
37                                            std::function<double(int)> >::value), "");
38     static_assert((!std::is_base_of<std::binary_function<int, int, double>,
39                                            std::function<double(int)> >::value), "");
40     static_assert(( std::is_same<          std::function<double(int)>::result_type,
41                                                          double>::value), "");
42 
43     static_assert((!std::is_base_of<std::unary_function <int, double>,
44                                            std::function<double(int, char)> >::value), "");
45     static_assert(( std::is_base_of<std::binary_function<int, char, double>,
46                                            std::function<double(int, char)> >::value), "");
47     static_assert(( std::is_same<          std::function<double(int, char)>::result_type,
48                                                          double>::value), "");
49 }
50