traits: add func_traits for return types

This commit is contained in:
Danny Robson 2015-03-10 22:52:17 +11:00
parent e466b08a10
commit d4d5eaa6f8

View File

@ -20,6 +20,7 @@
#ifndef __UTIL_TYPES_TRAITS_HPP #ifndef __UTIL_TYPES_TRAITS_HPP
#define __UTIL_TYPES_TRAITS_HPP #define __UTIL_TYPES_TRAITS_HPP
#include <memory>
#include <type_traits> #include <type_traits>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -70,4 +71,23 @@ template <typename T, typename U> struct is_lossless_cast : std::enable_if<
std::true_type std::true_type
>::value { }; >::value { };
//-----------------------------------------------------------------------------
template <typename T>
struct func_traits : public func_traits<decltype(&T::operator())>
{ };
template <typename C, typename R, typename ...Args>
struct func_traits<R(C::*)(Args...) const> {
typedef R return_type;
};
template <typename R, typename ...Args>
struct func_traits<R(Args...)> {
typedef R return_type;
};
#endif #endif