From 246eb897c921e1aee45361d7c10c6fd274cc7f74 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 13 Jun 2017 14:34:58 +0000 Subject: [PATCH] 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 --- include/__functional_base | 17 +++++++---------- .../associative/map/map.ops/count0.pass.cpp | 7 ++++++- .../map/map.ops/equal_range0.pass.cpp | 7 ++++++- .../associative/map/map.ops/find0.pass.cpp | 7 ++++++- .../map/map.ops/lower_bound0.pass.cpp | 7 ++++++- .../map/map.ops/upper_bound0.pass.cpp | 7 ++++++- .../multimap/multimap.ops/count0.pass.cpp | 7 ++++++- .../multimap/multimap.ops/equal_range0.pass.cpp | 7 ++++++- .../multimap/multimap.ops/find0.pass.cpp | 7 ++++++- .../multimap/multimap.ops/lower_bound0.pass.cpp | 7 ++++++- .../multimap/multimap.ops/upper_bound0.pass.cpp | 7 ++++++- test/support/is_transparent.h | 16 +++++++++++++--- 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 void cref(const _Tp&&) = delete; #endif #if _LIBCPP_STD_VER > 11 -template -struct __is_transparent -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::is_transparent* = 0); -public: - static const bool value = sizeof(__test<_Tp1>(0)) == 1; -}; +template +struct __is_transparent : false_type {}; + +template +struct __is_transparent<_Tp, _Up, + typename __void_t::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 M; - M().count(C2Int{5}); + } + { + typedef std::map 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 M; - M().equal_range(C2Int{5}); + } + { + typedef std::map 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 M; - M().find(C2Int{5}); + } + { + typedef std::map 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 M; - M().lower_bound(C2Int{5}); + } + { + typedef std::map 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 M; - M().upper_bound(C2Int{5}); + } + { + typedef std::map 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 M; - M().count(C2Int{5}); + } + { + typedef std::multimap 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 M; - M().equal_range(C2Int{5}); + } + { + typedef std::multimap 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 M; - M().find(C2Int{5}); + } + { + typedef std::multimap 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 M; - M().lower_bound(C2Int{5}); + } + { + typedef std::multimap 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 M; - M().upper_bound(C2Int{5}); + } + { + typedef std::multimap 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) < std::forward(u))) -> decltype (std::forward(t) < std::forward(u)) { return std::forward(t) < std::forward(u); } - typedef void is_transparent; // correct + using is_transparent = void; // correct +}; + +struct transparent_less_not_referenceable +{ + template + constexpr auto operator()(T&& t, U&& u) const + noexcept(noexcept(std::forward(t) < std::forward(u))) + -> decltype (std::forward(t) < std::forward(u)) + { return std::forward(t) < std::forward(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) < std::forward(u)) { return std::forward(t) < std::forward(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) < std::forward(u)) { return std::forward(t) < std::forward(u); } private: - typedef void is_transparent; // error - should be accessible + using is_transparent = void; // error - should be accessible }; struct transparent_less_not_a_type