From 2fc65041beabcb4c970deeb8ece010c10b0b40f9 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 28 Aug 2016 21:26:01 +0000 Subject: Implement LWG 2711. Constrain path members. llvm-svn: 279945 --- .../class.path/path.member/path.concat.pass.cpp | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp') diff --git a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp index cd627b8c842..89269362d06 100644 --- a/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp +++ b/libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp @@ -265,6 +265,68 @@ void doConcatECharTest(ConcatOperatorTestcase const& TC) } } + +template ()))> +constexpr bool has_concat(int) { return true; } +template +constexpr bool has_concat(long) { return false; } + +template ()))> +constexpr bool has_concat_op(int) { return true; } +template +constexpr bool has_concat_op(long) { return false; } +template +constexpr bool has_concat_op() { return has_concat_op(0); } + +template +constexpr bool has_concat() { + static_assert(has_concat(0) == has_concat_op(0), "must be same"); + return has_concat(0) && has_concat_op(0); +} + +void test_sfinae() { + using namespace fs; + { + static_assert(has_concat_op(), ""); + static_assert(has_concat_op(), ""); + static_assert(has_concat_op(), ""); + static_assert(has_concat_op(), ""); + } + { + using It = const char* const; + static_assert(has_concat(), ""); + } + { + using It = input_iterator; + static_assert(has_concat(), ""); + } + { + struct Traits { + using iterator_category = std::input_iterator_tag; + using value_type = const char; + using pointer = const char*; + using reference = const char&; + using difference_type = std::ptrdiff_t; + }; + using It = input_iterator; + static_assert(has_concat(), ""); + } + { + using It = output_iterator; + static_assert(!has_concat(), ""); + } + { + static_assert(!has_concat(0), ""); + // operator+=(int) is well formed since it converts to operator+=(value_type) + // but concat(int) isn't valid because there is no concat(value_type). + // This should probably be addressed by a LWG issue. + static_assert(has_concat_op(), ""); + } + { + static_assert(!has_concat(), ""); + } +} + int main() { using namespace fs; @@ -323,4 +385,5 @@ int main() doConcatECharTest(TC); doConcatECharTest(TC); } + test_sfinae(); } -- cgit v1.2.3