mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add sprout::cbind
This commit is contained in:
parent
d6a01cd831
commit
aec77334ef
4 changed files with 54 additions and 4 deletions
|
@ -13,7 +13,22 @@ namespace sprout {
|
|||
template<typename T>
|
||||
class default_big_endian_traits<
|
||||
T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type
|
||||
typename std::enable_if<std::is_integral<T>::value && sizeof(T) == 1>::type
|
||||
> {
|
||||
public:
|
||||
typedef T type;
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t size() {
|
||||
return sizeof(type);
|
||||
}
|
||||
static SPROUT_CONSTEXPR unsigned char get_byte(type const& t, std::size_t i) {
|
||||
return static_cast<unsigned char>(t);
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
class default_big_endian_traits<
|
||||
T,
|
||||
typename std::enable_if<std::is_integral<T>::value && !(sizeof(T) == 1)>::type
|
||||
> {
|
||||
public:
|
||||
typedef T type;
|
||||
|
@ -34,7 +49,22 @@ namespace sprout {
|
|||
template<typename T>
|
||||
class default_little_endian_traits<
|
||||
T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type
|
||||
typename std::enable_if<std::is_integral<T>::value && sizeof(T) == 1>::type
|
||||
> {
|
||||
public:
|
||||
typedef T type;
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t size() {
|
||||
return sizeof(type);
|
||||
}
|
||||
static SPROUT_CONSTEXPR unsigned char get_byte(type const& t, std::size_t i) {
|
||||
return static_cast<unsigned char>(t);
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
class default_little_endian_traits<
|
||||
T,
|
||||
typename std::enable_if<std::is_integral<T>::value && !(sizeof(T) == 1)>::type
|
||||
> {
|
||||
public:
|
||||
typedef T type;
|
||||
|
|
|
@ -554,6 +554,26 @@ namespace sprout {
|
|||
typedef typename helper_type::type result_type;
|
||||
return result_type(maybe_type::do_wrap(sprout::forward<F>(f)), sprout::forward<BoundArgs>(args)...);
|
||||
}
|
||||
|
||||
//
|
||||
// cbind
|
||||
//
|
||||
template<typename F, typename... BoundArgs>
|
||||
inline SPROUT_CONSTEXPR typename sprout::detail::bind_helper<F, BoundArgs...>::type const
|
||||
cbind(F&& f, BoundArgs&&... args) {
|
||||
typedef sprout::detail::bind_helper<F, BoundArgs...> helper_type;
|
||||
typedef typename helper_type::maybe_type maybe_type;
|
||||
typedef typename helper_type::type result_type;
|
||||
return result_type(maybe_type::do_wrap(sprout::forward<F>(f)), sprout::forward<BoundArgs>(args)...);
|
||||
}
|
||||
template<typename R, typename F, typename... BoundArgs>
|
||||
inline SPROUT_CONSTEXPR typename sprout::detail::bindres_helper<R, F, BoundArgs...>::type const
|
||||
cbind(F&& f, BoundArgs&&... args) {
|
||||
typedef sprout::detail::bindres_helper<R, F, BoundArgs...> helper_type;
|
||||
typedef typename helper_type::maybe_type maybe_type;
|
||||
typedef typename helper_type::type result_type;
|
||||
return result_type(maybe_type::do_wrap(sprout::forward<F>(f)), sprout::forward<BoundArgs>(args)...);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_BIND_BIND_HPP
|
||||
|
|
Loading…
Reference in a new issue