diff --git a/libcxx/test/std/iterators/iterator.container/ssize.sfinae.compile.pass.cpp b/libcxx/test/std/iterators/iterator.container/ssize.sfinae.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.container/ssize.sfinae.compile.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-has-no-concepts + +// + +// template +// constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept; +// +// Peter Dimov gives "clang -m32" as an example of a platform where the +// use of ptrdiff_t, not size_t, has an observable SFINAE effect. + +#include +#include + +static_assert(!(sizeof(std::ptrdiff_t) == 4 && sizeof(std::size_t) == 8), "Run only on these platforms"); + +template +concept HasSsize = requires (T&& t) { + std::ssize(t); +}; + +//static_assert( HasSsize); +//static_assert(!HasSsize);