summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/test/detail/decay.cpp
blob: bc1ec5b608988a0b157ddd372668115d762dacc5 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)

#include <boost/hana/detail/decay.hpp>

#include <type_traits>
namespace hana = boost::hana;


template <typename T, typename Decayed>
void check() {
    static_assert(std::is_same<
        typename hana::detail::decay<T>::type,
        Decayed
    >::value, "");
}

int main() {
    // void is untouched
    check<void, void>();

    // normal types lose cv-qualifiers
    check<int, int>();
    check<int const, int>();
    check<int const volatile, int>();

    // [cv-qualified] references are stripped
    check<int&, int>();
    check<int const&, int>();
    check<int&&, int>();
    check<int const&&, int>();

    // pointers are untouched
    check<int*, int*>();
    check<int const*, int const*>();
    check<int volatile*, int volatile*>();
    check<int const volatile*, int const volatile*>();

    // arrays decay to pointers
    check<int[], int*>();
    check<int[10], int*>();
    check<int const[10], int const*>();
    check<int volatile[10], int volatile*>();
    check<int const volatile[10], int const volatile*>();

    // functions decay to function pointers
    check<void(), void(*)()>();
    check<void(...), void (*)(...)>();
    check<void(int), void(*)(int)>();
    check<void(int, ...), void(*)(int, ...)>();
    check<void(int, float), void(*)(int, float)>();
    check<void(int, float, ...), void(*)(int, float, ...)>();
}