move move/forward to utility.h

master
Daniel Kolesa 2015-04-18 00:11:16 +01:00
parent 97fd88be62
commit 296b7cdeb9
3 changed files with 19 additions and 23 deletions

View File

@ -9,7 +9,7 @@
#include <stddef.h>
#include "octa/types.h"
#include "octa/traits.h"
#include "octa/utility.h"
namespace octa {
struct InputRange {};

View File

@ -165,28 +165,6 @@ namespace octa {
template<typename > struct IsArray : false_t {};
template<typename T > struct IsArray<T[] >: true_t {};
template<typename T, size_t N> struct IsArray<T[N]>: true_t {};
/* move */
template<typename T>
static inline constexpr typename RemoveReference<T>::type &&
move(T &&v) noexcept {
return static_cast<typename RemoveReference<T>::type &&>(v);
}
/* forward */
template<typename T>
static inline constexpr T &&
forward(typename RemoveReference<T>::type &v) noexcept {
return static_cast<T &&>(v);
}
template<typename T>
static inline constexpr T &&
forward(typename RemoveReference<T>::type &&v) noexcept {
return static_cast<T &&>(v);
}
}
#endif

View File

@ -50,6 +50,24 @@ namespace octa {
swap(a[i], b[i]);
}
}
template<typename T>
static inline constexpr typename RemoveReference<T>::type &&
move(T &&v) noexcept {
return static_cast<typename RemoveReference<T>::type &&>(v);
}
template<typename T>
static inline constexpr T &&
forward(typename RemoveReference<T>::type &v) noexcept {
return static_cast<T &&>(v);
}
template<typename T>
static inline constexpr T &&
forward(typename RemoveReference<T>::type &&v) noexcept {
return static_cast<T &&>(v);
}
}
#endif