diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2017-06-13 14:34:58 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2017-06-13 14:34:58 +0000 |
commit | 246eb897c921e1aee45361d7c10c6fd274cc7f74 (patch) | |
tree | b9a4e0c3118b52bf5abca68aadb5c046b4430a7d | |
parent | 6bb9569124fdfac71530417d701100a36dd02d51 (diff) |
Fix bug 33389 - __is_transparent check requires too much
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305292 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed, 80 insertions, 23 deletions
diff --git a/include/__functional_base b/include/__functional_base index 0d2c2fc65..79017fe75 100644 --- a/include/__functional_base +++ b/include/__functional_base @@ -548,16 +548,13 @@ template <class _Tp> void cref(const _Tp&&) = delete; #endif #if _LIBCPP_STD_VER > 11 -template <class _Tp1, class _Tp2 = void> -struct __is_transparent -{ -private: - struct __two {char __lx; char __lxx;}; - template <class _Up> static __two __test(...); - template <class _Up> static char __test(typename _Up::is_transparent* = 0); -public: - static const bool value = sizeof(__test<_Tp1>(0)) == 1; -}; +template <class _Tp, class, class = void> +struct __is_transparent : false_type {}; + +template <class _Tp, class _Up> +struct __is_transparent<_Tp, _Up, + typename __void_t<typename _Tp::is_transparent>::type> + : true_type {}; #endif // allocator_arg_t diff --git a/test/std/containers/associative/map/map.ops/count0.pass.cpp b/test/std/containers/associative/map/map.ops/count0.pass.cpp index 027834300..1fa8c4a70 100644 --- a/test/std/containers/associative/map/map.ops/count0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/count0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::map<int, double, transparent_less> M; - M().count(C2Int{5}); + } + { + typedef std::map<int, double, transparent_less_not_referenceable> M; + M().count(C2Int{5}); + } } diff --git a/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp b/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp index 3b9842686..c254fb6a7 100644 --- a/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::map<int, double, transparent_less> M; - M().equal_range(C2Int{5}); + } + { + typedef std::map<int, double, transparent_less_not_referenceable> M; + M().equal_range(C2Int{5}); + } } diff --git a/test/std/containers/associative/map/map.ops/find0.pass.cpp b/test/std/containers/associative/map/map.ops/find0.pass.cpp index d7de579d8..76fe9242a 100644 --- a/test/std/containers/associative/map/map.ops/find0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/find0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::map<int, double, transparent_less> M; - M().find(C2Int{5}); + } + { + typedef std::map<int, double, transparent_less_not_referenceable> M; + M().find(C2Int{5}); + } } diff --git a/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp b/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp index ea121df73..de7a545b6 100644 --- a/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::map<int, double, transparent_less> M; - M().lower_bound(C2Int{5}); + } + { + typedef std::map<int, double, transparent_less_not_referenceable> M; + M().lower_bound(C2Int{5}); + } } diff --git a/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp b/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp index 2e597b85c..94508d284 100644 --- a/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::map<int, double, transparent_less> M; - M().upper_bound(C2Int{5}); + } + { + typedef std::map<int, double, transparent_less_not_referenceable> M; + M().upper_bound(C2Int{5}); + } } diff --git a/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp index b993f4f89..289d40573 100644 --- a/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::multimap<int, double, transparent_less> M; - M().count(C2Int{5}); + } + { + typedef std::multimap<int, double, transparent_less_not_referenceable> M; + M().count(C2Int{5}); + } } diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp index a3a51e6cc..8cdd3c033 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::multimap<int, double, transparent_less> M; - M().equal_range(C2Int{5}); + } + { + typedef std::multimap<int, double, transparent_less_not_referenceable> M; + M().equal_range(C2Int{5}); + } } diff --git a/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp index 03a6e1883..a06ec4d70 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::multimap<int, double, transparent_less> M; - M().find(C2Int{5}); + } + { + typedef std::multimap<int, double, transparent_less_not_referenceable> M; + M().find(C2Int{5}); + } } diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp index 77927bb5a..1000aa772 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::multimap<int, double, transparent_less> M; - M().lower_bound(C2Int{5}); + } + { + typedef std::multimap<int, double, transparent_less_not_referenceable> M; + M().lower_bound(C2Int{5}); + } } diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp index 3f6852d08..1a572e9c5 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp @@ -28,7 +28,12 @@ int main() { + { typedef std::multimap<int, double, transparent_less> M; - M().upper_bound(C2Int{5}); + } + { + typedef std::multimap<int, double, transparent_less_not_referenceable> M; + M().upper_bound(C2Int{5}); + } } diff --git a/test/support/is_transparent.h b/test/support/is_transparent.h index 541689314..f7cdbbc14 100644 --- a/test/support/is_transparent.h +++ b/test/support/is_transparent.h @@ -22,7 +22,17 @@ struct transparent_less noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u))) -> decltype (std::forward<T>(t) < std::forward<U>(u)) { return std::forward<T>(t) < std::forward<U>(u); } - typedef void is_transparent; // correct + using is_transparent = void; // correct +}; + +struct transparent_less_not_referenceable +{ + template <class T, class U> + constexpr auto operator()(T&& t, U&& u) const + noexcept(noexcept(std::forward<T>(t) < std::forward<U>(u))) + -> decltype (std::forward<T>(t) < std::forward<U>(u)) + { return std::forward<T>(t) < std::forward<U>(u); } + using is_transparent = void () const &; // it's a type; a weird one, but a type }; struct transparent_less_no_type @@ -33,7 +43,7 @@ struct transparent_less_no_type -> decltype (std::forward<T>(t) < std::forward<U>(u)) { return std::forward<T>(t) < std::forward<U>(u); } private: -// typedef void is_transparent; // error - should exist +// using is_transparent = void; // error - should exist }; struct transparent_less_private @@ -44,7 +54,7 @@ struct transparent_less_private -> decltype (std::forward<T>(t) < std::forward<U>(u)) { return std::forward<T>(t) < std::forward<U>(u); } private: - typedef void is_transparent; // error - should be accessible + using is_transparent = void; // error - should be accessible }; struct transparent_less_not_a_type |