SigUtil  0.95
Utility modules for modern C++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
eval.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Daniel Park
3  * All rights reserved.
4  *
5  * Permission to modify and redistribute this software is granted to
6  * anyone provided the above copyright notice, this condition and the
7  * following disclaimer are retained.
8  *
9  * This software is provided "as is", without and express or implied
10  * warranty. In no event shall the author be liable for damages arising
11  * from the use of this software.
12  */
13 
14 /*
15 Copyright© 2014 Akihiro Nishimura
16 
17 This software is released under the MIT License.
18 http://opensource.org/licenses/mit-license.php
19 */
20 
21 #ifndef SIG_EVAL_H
22 #define SIG_EVAL_H
23 
24 #include <type_traits>
25 #include <utility>
26 
27 
28 namespace sig
29 {
30 namespace impl
31 {
32 template<
33  class F, class... Args,
34  class = typename std::enable_if<!std::is_member_function_pointer<F>::value>::type,
35  class = typename std::enable_if<!std::is_member_object_pointer<F>::value>::type
36  >
37 auto eval(F&& f, Args&&... args) -> decltype(f(std::forward<Args>(args)...))
38 {
39  return std::forward<F>(f)(std::forward<Args>(args)...);
40 }
41 
43 template<class R, class C, class... Args>
44 auto eval(R(C::*f)() const, const C& c, Args&&... args) -> R
45 {
46  return (c.*f)(std::forward<Args>(args)...);
47 }
48 
50 template<class R, class C, class... Args>
51 auto eval(R(C::*f)() const, C& c, Args&&... args) -> R
52 {
53  return (c.*f)(std::forward<Args>(args)...);
54 }
55 
57 template<class R, class C, class... Args>
58 auto eval(R(C::*f)(), C& c, Args&&... args) -> R
59 {
60  return (c.*f)(std::forward<Args>(args)...);
61 }
62 
64 template<class R, class C>
65 auto eval(R(C::*m), const C& c) -> const R&
66 {
67  return c.*m;
68 }
69 
71 template<class R, class C>
72 auto eval(R(C::*m), C& c) -> R&
73 {
74  return c.*m;
75 }
76 
77 template<class... Args>
78 using eval_result_type = decltype(eval(std::declval<Args>()...));
79 
80 }
81 }
82 #endif
decltype(eval(std::declval< Args >()...)) eval_result_type
Definition: eval.hpp:78
auto eval(F &&f, Args &&...args) -> decltype(f(std::forward< Args >(args)...))
Definition: eval.hpp:37
Definition: array.hpp:15