Sprout/sprout/detail/call_traits.hpp

66 lines
1.8 KiB
C++
Raw Permalink Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
Copyright (c) 2011-2019 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
2012-01-05 10:53:06 +00:00
#ifndef SPROUT_DETAIL_CALL_TRAITS_HPP
#define SPROUT_DETAIL_CALL_TRAITS_HPP
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
namespace detail {
template<typename T, bool Small>
struct ct_impl_1 {
public:
typedef T const& param_type;
};
template<typename T>
struct ct_impl_1<T, true> {
public:
typedef T const param_type;
};
template<typename T, bool IsPointer, bool IsArithmetic>
struct ct_impl {
public:
typedef T const& param_type;
};
template<typename T, bool IsPointer>
struct ct_impl<T, IsPointer, true> {
public:
typedef typename sprout::detail::ct_impl_1<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
};
template<typename T, bool IsArithmetic>
struct ct_impl<T, true, IsArithmetic> {
public:
typedef T const param_type;
};
template<typename T>
struct call_traits {
public:
typedef T value_type;
typedef T& reference;
typedef T const& const_reference;
typedef typename sprout::detail::ct_impl<
T,
std::is_pointer<T>::value,
std::is_arithmetic<T>::value
>::param_type param_type;
};
template<typename T>
struct call_traits<T&> {
typedef T& value_type;
typedef T& reference;
typedef T const& const_reference;
typedef T& param_type;
};
} // namespace detail
} // namespace sprout
2013-03-22 05:24:19 +00:00
#endif // #ifndef SPROUT_DETAIL_CALL_TRAITS_HPP