mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
sprout/compressed_pair.hpp 追加
This commit is contained in:
parent
7479f20c46
commit
9dbdf452d9
2 changed files with 488 additions and 0 deletions
58
sprout/detail/call_traits.hpp
Normal file
58
sprout/detail/call_traits.hpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#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
|
||||
|
||||
#endif // #ifndef SPROUT_DETAIL_CALL_TRAITS_HPP
|
Loading…
Add table
Add a link
Reference in a new issue