concepts.hpp

1
2
3
4
5
#pragma once


#include <type_traits>
#include <utility>

libc++ doesn't have a concepts header yet, so these are just basic implementations whilst we wait for it to catch up to libstdc++

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
namespace felspar {


    template<typename T, typename U>
    concept same_as = std::is_same_v<T, U> and std::is_same_v<U, T>;


    template<class LHS, class RHS>
    concept assignable_from = requires(LHS lhs, RHS &&rhs) {
        { lhs = std::forward<RHS>(rhs) } -> same_as<LHS>;
    };


    template<typename N>
    concept numeric = std::is_integral_v<N> or std::is_floating_point_v<N>
            or std::is_pointer_v<N>;


}