File size: 1,540 Bytes
8ae5fc5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef METAL_VALUE_SAME_HPP
#define METAL_VALUE_SAME_HPP

#include "../config.hpp"

namespace metal {
/// \cond
namespace detail {
    template <class... vals>
    struct _same;
}
/// \endcond

/// \ingroup value
///
/// ### Description
/// Checks whether all \values are identical.
///
/// ### Usage
/// For any \values `val_0, ..., val_n-1`
/// \code
///     using result = metal::same<val_0, ..., val_n-1>;
/// \endcode
///
/// \returns: \number
/// \semantics:
///     If at least two \values in `val_0, ..., val_n-1` are not identical
///     to each other, then
///     \code
///         using result = metal::false_;
///     \endcode
///     otherwise
///     \code
///         using result = metal::true_;
///     \endcode
///
/// ### Example
/// \snippet value.cpp same
///
/// ### See Also
/// \see distinct
template <class... vals>
using same = typename detail::_same<vals...>::type;
}

#include "../number/number.hpp"
#include "../value/value.hpp"

namespace metal {
/// \cond
namespace detail {
    template <class...>
    struct _same_impl : false_ {
    };

    template <template <class> class... _, class val>
    struct _same_impl<_<val>...> : true_ {
    };

    template <class... vals>
    struct _same : _same_impl<maybe<vals>...> {
    };

    template <class x, class y>
    struct _same<x, y> : false_ {
    };

    template <class x>
    struct _same<x, x> : true_ {
    };

    template <class x>
    struct _same<x> : true_ {
    };

    template <>
    struct _same<> : true_ {
    };
}
/// \endcond
}

#endif