summaryrefslogtreecommitdiffhomepage
path: root/compat/move.hpp
blob: ca17aa72d203fc70c46ef7022a787811df5839d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <type_traits>
#include <Corrade/Utility/Macros.h>

namespace floormat {

template<typename T> concept AlwaysTrue = true;

// from Corrade/Utility/Move.h

template<AlwaysTrue T>
constexpr CORRADE_ALWAYS_INLINE T&& forward(std::remove_reference_t<T>& t) noexcept
{
    return static_cast<T&&>(t);
}

template<AlwaysTrue T>
constexpr CORRADE_ALWAYS_INLINE T&& forward(std::remove_reference_t<T>&& t) noexcept
{
    static_assert(!std::is_lvalue_reference_v<T>);
    return static_cast<T&&>(t);
}

template<AlwaysTrue T>
constexpr CORRADE_ALWAYS_INLINE std::remove_reference_t<T>&& move(T&& t) noexcept
{
    return static_cast<std::remove_reference_t<T>&&>(t);
}

template<AlwaysTrue T>
constexpr inline void swap(T& a, std::common_type_t<T>& b)
noexcept(std::is_nothrow_move_constructible_v<T> && std::is_nothrow_move_assignable_v<T>)
{
    T tmp = static_cast<T&&>(a);
    a = static_cast<T&&>(b);
    b = static_cast<T&&>(tmp);
}

} // namespace floormat