6 #if __has_feature(cxx_nullptr) && __has_feature(cxx_decltype)
7 # define OS_HAS_NULLPTR 1
10 #if __has_feature(cxx_rvalue_references) || __has_extension(cxx_rvalue_references)
11 # define OS_HAS_RVALUE_REFERENCES 1
14 void* operator new(size_t, void*);
18 typedef decltype(nullptr) nullptr_t
;
25 template <class _T
> struct remove_reference
{typedef _T type
;};
26 template <class _T
> struct remove_reference
<_T
&> {typedef _T type
;};
27 template <class _T
> struct remove_reference
<_T
&&> {typedef _T type
;};
28 template <class _T
> using remove_reference_t
= typename remove_reference
<_T
>::type
;
34 template <class _T
> struct remove_const
{typedef _T type
;};
35 template <class _T
> struct remove_const
<const _T
> {typedef _T type
;};
36 template <class _T
> using remove_const_t
= typename remove_const
<_T
>::type
;
38 template <class T
> struct is_lvalue_reference
{ static constexpr bool value
= false; };
39 template <class T
> struct is_lvalue_reference
<T
&> { static constexpr bool value
= true; };
46 inline typename remove_reference
<_T
>::type
&&
49 typedef typename
os::remove_reference
<_T
>::type _U
;
50 return static_cast<_U
&&>(_t
);
55 move(T
* first
, T
* last
, T
* d_first
)
57 for (; first
!= last
; ++d_first
, (void)++first
) {
58 *d_first
= os::move(*first
);
64 constexpr T
&& forward(os::remove_reference_t
<T
>&t
) noexcept {
65 return static_cast<T
&&>(t
);
69 constexpr T
&& forward(os::remove_reference_t
<T
>&& t
) noexcept {
70 static_assert(!os::is_lvalue_reference
<T
>::value
,
71 "can not forward an rvalue as an lvalue");
72 return static_cast<T
&&>(t
);
75 // Moves [first, last) into the range ending at d_last,
76 // proceeding backwards (from last to first)
77 // UB if d_last is within (first, last]
80 move_backward(T
* first
, T
* last
, T
* d_last
)
82 while (first
!= last
) {
83 *(--d_last
) = os::move(*(--last
));
90 uninitialized_move(T
* first
, T
* last
, T
* d_first
)
92 for (; first
!= last
; ++d_first
, (void) ++first
) {
93 ::new (static_cast<void*>(d_first
)) T(os::move(*first
));
100 destroy(T
* first
, T
* last
)
102 for (; first
!= last
; ++first
) {
109 uninitialized_value_construct(T
* first
, T
* last
)
111 for (; first
!= last
; ++first
) {
112 ::new (static_cast<void*>(first
)) T();
117 #endif /* _OS_CPP_UTIL_H */