savepoint, changelog later..
This commit is contained in:
parent
7d3c4a0be0
commit
1bc1fd1913
45 changed files with 12866 additions and 10981 deletions
58
include/crlib/cr-movable.h
Normal file
58
include/crlib/cr-movable.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
//
|
||||
// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd").
|
||||
// Copyright (c) YaPB Development Team.
|
||||
//
|
||||
// This software is licensed under the BSD-style license.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://yapb.ru/license
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <crlib/cr-basic.h>
|
||||
|
||||
CR_NAMESPACE_BEGIN
|
||||
|
||||
namespace detail {
|
||||
template <typename T> struct ClearRef {
|
||||
using Type = T;
|
||||
};
|
||||
template <typename T> struct ClearRef <T &> {
|
||||
using Type = T;
|
||||
};
|
||||
template <typename T> struct ClearRef <T &&> {
|
||||
using Type = T;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T> typename detail::ClearRef <T>::Type constexpr &&move (T &&type) noexcept {
|
||||
return static_cast <typename detail::ClearRef <T>::Type &&> (type);
|
||||
}
|
||||
|
||||
template <typename T> constexpr T &&forward (typename detail::ClearRef <T>::Type &type) noexcept {
|
||||
return static_cast <T &&> (type);
|
||||
}
|
||||
|
||||
template <typename T> constexpr T &&forward (typename detail::ClearRef <T>::Type &&type) noexcept {
|
||||
return static_cast <T &&> (type);
|
||||
}
|
||||
|
||||
template <typename T> inline void swap (T &left, T &right) noexcept {
|
||||
auto temp = cr::move (left);
|
||||
left = cr::move (right);
|
||||
right = cr::move (temp);
|
||||
}
|
||||
|
||||
template <typename T, size_t S> inline void swap (T (&left)[S], T (&right)[S]) noexcept {
|
||||
if (&left == &right) {
|
||||
return;
|
||||
}
|
||||
auto begin = left;
|
||||
auto end = begin + S;
|
||||
|
||||
for (auto temp = right; begin != end; ++begin, ++temp) {
|
||||
cr::swap (*begin, *temp);
|
||||
}
|
||||
}
|
||||
|
||||
CR_NAMESPACE_END
|
||||
Loading…
Add table
Add a link
Reference in a new issue