diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-08-28 21:26:01 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-08-28 21:26:01 +0000 |
commit | 2fc65041beabcb4c970deeb8ece010c10b0b40f9 (patch) | |
tree | 8cce662354b591f6e8dac297a744ae0721a2d7f7 /libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp | |
parent | 24b481370ac773231c38f15355a6277943a69911 (diff) | |
download | bcm5719-llvm-2fc65041beabcb4c970deeb8ece010c10b0b40f9.tar.gz bcm5719-llvm-2fc65041beabcb4c970deeb8ece010c10b0b40f9.zip |
Implement LWG 2711. Constrain path members.
llvm-svn: 279945
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp')
-rw-r--r-- | libcxx/test/std/experimental/filesystem/class.path/path.member/path.concat.pass.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
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 <class It, class = decltype(fs::path{}.concat(std::declval<It>()))> +constexpr bool has_concat(int) { return true; } +template <class It> +constexpr bool has_concat(long) { return false; } + +template <class It, class = decltype(fs::path{}.operator+=(std::declval<It>()))> +constexpr bool has_concat_op(int) { return true; } +template <class It> +constexpr bool has_concat_op(long) { return false; } +template <class It> +constexpr bool has_concat_op() { return has_concat_op<It>(0); } + +template <class It> +constexpr bool has_concat() { + static_assert(has_concat<It>(0) == has_concat_op<It>(0), "must be same"); + return has_concat<It>(0) && has_concat_op<It>(0); +} + +void test_sfinae() { + using namespace fs; + { + static_assert(has_concat_op<char>(), ""); + static_assert(has_concat_op<const char>(), ""); + static_assert(has_concat_op<char16_t>(), ""); + static_assert(has_concat_op<const char16_t>(), ""); + } + { + using It = const char* const; + static_assert(has_concat<It>(), ""); + } + { + using It = input_iterator<const char*>; + static_assert(has_concat<It>(), ""); + } + { + 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<const char*, Traits>; + static_assert(has_concat<It>(), ""); + } + { + using It = output_iterator<const char*>; + static_assert(!has_concat<It>(), ""); + } + { + static_assert(!has_concat<int>(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<int>(), ""); + } + { + static_assert(!has_concat<int*>(), ""); + } +} + int main() { using namespace fs; @@ -323,4 +385,5 @@ int main() doConcatECharTest<char16_t>(TC); doConcatECharTest<char32_t>(TC); } + test_sfinae(); } |