1 /* 2 3 @Copyright Barrett Adair 2015-2017 4 Distributed under the Boost Software License, Version 1.0. 5 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 6 7 */ 8 9 #ifndef BOOST_CLBL_TRTS_HAS_VOID_RETURN_HPP 10 #define BOOST_CLBL_TRTS_HAS_VOID_RETURN_HPP 11 12 #include <boost/callable_traits/detail/core.hpp> 13 14 namespace boost { namespace callable_traits { 15 16 //[ has_void_return_hpp 17 /*`[section:ref_has_void_return has_void_return] 18 [heading Header] 19 ``#include <boost/callable_traits/has_void_return.hpp>`` 20 [heading Definition] 21 */ 22 23 // inherits from either std::true_type or std::false_type 24 template<typename T> 25 struct has_void_return; 26 27 //<- 28 template<typename T> 29 struct has_void_return 30 : std::is_same<typename detail::traits< 31 detail::shallow_decay<T>>::return_type, void> {}; 32 33 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES 34 35 template<typename T> 36 struct has_void_return_v { 37 static_assert(std::is_same<T, detail::dummy>::value, 38 "Variable templates not supported on this compiler."); 39 }; 40 41 #else 42 //-> 43 44 // only available when variable templates are supported 45 template<typename T> 46 //<- 47 BOOST_CLBL_TRAITS_INLINE_VAR 48 //-> 49 constexpr bool has_void_return_v = //see below 50 //<- 51 std::is_same<typename detail::traits< 52 detail::shallow_decay<T>>::return_type, void>::value; 53 54 #endif 55 56 }} // namespace boost::callable_traits 57 //-> 58 59 60 /*` 61 [heading Constraints] 62 * none 63 64 [heading Behavior] 65 * `std::false_type` is inherited by `has_void_return<T>` and is aliased by `typename has_void_return<T>::type`, except when one of the following criteria is met, in which case `std::true_type` would be similarly inherited and aliased: 66 * `T` is a function, function pointer, or function reference where the function's return type is `void`. 67 * `T` is a pointer to a member function whose return type is `void`. 68 * `T` is a function object with a non-overloaded `operator()`, where the `operator()` function returns `void`. 69 * On compilers that support variable templates, `has_void_return_v<T>` is equivalent to `has_void_return<T>::value`. 70 71 [heading Input/Output Examples] 72 [table 73 [[`T`] [`has_void_return_v<T>`]] 74 [[`void()`] [`true`]] 75 [[`void(int) const`] [`true`]] 76 [[`void(* const &)()`] [`true`]] 77 [[`void(&)()`] [`true`]] 78 [[`void(foo::*)() const`] [`true`]] 79 [[`int(*)()`] [`false`]] 80 [[`int(*&)()`] [`false`]] 81 [[`int`] [`false`]] 82 [[`int foo::*`] [`false`]] 83 [[`void* foo::*`] [`false`]] 84 ] 85 86 [heading Example Program] 87 [import ../example/has_void_return.cpp] 88 [has_void_return] 89 [endsect] 90 */ 91 //] 92 93 #endif 94