1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix math/comparison.hpp

This commit is contained in:
bolero-MURAKAMI 2012-07-07 14:58:46 +09:00
parent 1c65d59971
commit 3b6ba46f17
23 changed files with 389 additions and 175 deletions

View file

@ -1,19 +1,22 @@
#ifndef SPROUT_UTILITY_AS_CONST_HPP
#define SPROUT_UTILITY_AS_CONST_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// as_const
//
template<typename T>
inline T const& as_const(T& t) {
return t;
}
template<typename T>
inline SPROUT_CONSTEXPR T const& as_const(T const& t) {
return t;
inline SPROUT_CONSTEXPR typename std::conditional<
std::is_lvalue_reference<T>::value,
typename std::remove_reference<T>::type const&,
typename std::remove_reference<T>::type const&&
>::type
as_const(T&& t) {
return sprout::forward<T>(t);
}
} // namespace sprout

View file

@ -8,11 +8,13 @@ namespace sprout {
// as_lvalue
//
template<typename T>
inline T& as_lvalue(T& t) {
inline SPROUT_CONSTEXPR T&
as_lvalue(T& t) {
return t;
}
template<typename T>
inline SPROUT_CONSTEXPR T const& as_lvalue(T const& t) {
inline SPROUT_CONSTEXPR T const&
as_lvalue(T const& t) {
return t;
}
} // namespace sprout

View file

@ -9,11 +9,13 @@ namespace sprout {
// forward
//
template<typename T>
inline SPROUT_CONSTEXPR T&& forward(typename std::remove_reference<T>::type& t) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR T&&
forward(typename std::remove_reference<T>::type& t) SPROUT_NOEXCEPT {
return static_cast<T&&>(t);
}
template<typename T>
inline SPROUT_CONSTEXPR T&& forward(typename std::remove_reference<T>::type&& t) SPROUT_NOEXCEPT = delete;
inline SPROUT_CONSTEXPR T&&
forward(typename std::remove_reference<T>::type&& t) SPROUT_NOEXCEPT = delete;
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_FORWARD_HPP

View file

@ -9,7 +9,8 @@ namespace sprout {
// move
//
template<typename T>
inline SPROUT_CONSTEXPR typename std::remove_reference<T>::type&& move(T&& x) SPROUT_NOEXCEPT {
inline SPROUT_CONSTEXPR typename std::remove_reference<T>::type&&
move(T&& x) SPROUT_NOEXCEPT {
return static_cast<typename std::remove_reference<T>::type&&>(x);
}
@ -21,7 +22,8 @@ namespace sprout {
!std::is_nothrow_move_constructible<T>::value && std::is_copy_constructible<T>::value,
T const&,
T&&
>::type move_if_noexcept(T& x) SPROUT_NOEXCEPT {
>::type
move_if_noexcept(T& x) SPROUT_NOEXCEPT {
return sprout::move(x);
}
} // namespace sprout