blob: 58255248abc9caf055225b4a0216253bcacabb80 [file] [log] [blame]
Marshall Clow5b03e1a2015-06-30 18:16:12 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef TRANSPARENT_H
11#define TRANSPARENT_H
12
13// testing transparent
14#if _LIBCPP_STD_VER > 11
15
16struct transparent_less
17{
18 template <class T, class U>
19 constexpr auto operator()(T&& t, U&& u) const
20 noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
21 -> decltype (std::forward<T>(t) < std::forward<U>(u))
22 { return std::forward<T>(t) < std::forward<U>(u); }
23 typedef void is_transparent; // correct
24};
25
26struct transparent_less_no_type
27{
28 template <class T, class U>
29 constexpr auto operator()(T&& t, U&& u) const
30 noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
31 -> decltype (std::forward<T>(t) < std::forward<U>(u))
32 { return std::forward<T>(t) < std::forward<U>(u); }
33private:
34// typedef void is_transparent; // error - should exist
35};
36
37struct transparent_less_private
38{
39 template <class T, class U>
40 constexpr auto operator()(T&& t, U&& u) const
41 noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
42 -> decltype (std::forward<T>(t) < std::forward<U>(u))
43 { return std::forward<T>(t) < std::forward<U>(u); }
44private:
45 typedef void is_transparent; // error - should be accessible
46};
47
48struct transparent_less_not_a_type
49{
50 template <class T, class U>
51 constexpr auto operator()(T&& t, U&& u) const
52 noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u)))
53 -> decltype (std::forward<T>(t) < std::forward<U>(u))
54 { return std::forward<T>(t) < std::forward<U>(u); }
55
56 int is_transparent; // error - should be a type
57};
58
59struct C2Int { // comparable to int
60 C2Int() : i_(0) {}
61 C2Int(int i): i_(i) {}
62 int get () const { return i_; }
63private:
64 int i_;
65 };
66
67bool operator <(int rhs, const C2Int& lhs) { return rhs < lhs.get(); }
68bool operator <(const C2Int& rhs, const C2Int& lhs) { return rhs.get() < lhs.get(); }
69bool operator <(const C2Int& rhs, int lhs) { return rhs.get() < lhs; }
70
71#endif
72
73#endif // TRANSPARENT_H