forked from OSchip/llvm-project
[libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".
In C++17, these iterators are allowed but not required to inherit from the deprecated std::iterator base class. Fixes D32727. llvm-svn: 302318
This commit is contained in:
parent
64293fca39
commit
40608ce4c9
|
@ -40,12 +40,22 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
typedef std::istream_iterator<double> I1; // double is trivially destructible
|
typedef std::istream_iterator<double> I1; // double is trivially destructible
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert((std::is_convertible<I1,
|
static_assert((std::is_convertible<I1,
|
||||||
std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
|
std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
|
||||||
const double*, const double&> >::value), "");
|
const double*, const double&> >::value), "");
|
||||||
|
#else
|
||||||
|
static_assert((std::is_same<I1::iterator_category, std::input_iterator_tag>::value), "");
|
||||||
|
static_assert((std::is_same<I1::value_type, double>::value), "");
|
||||||
|
static_assert((std::is_same<I1::difference_type, std::ptrdiff_t>::value), "");
|
||||||
|
static_assert((std::is_same<I1::pointer, const double*>::value), "");
|
||||||
|
static_assert((std::is_same<I1::reference, const double&>::value), "");
|
||||||
|
#endif
|
||||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||||
static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
|
static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
|
||||||
|
@ -53,9 +63,17 @@ int main()
|
||||||
static_assert( std::is_trivially_destructible<I1>::value, "");
|
static_assert( std::is_trivially_destructible<I1>::value, "");
|
||||||
|
|
||||||
typedef std::istream_iterator<unsigned, wchar_t> I2; // unsigned is trivially destructible
|
typedef std::istream_iterator<unsigned, wchar_t> I2; // unsigned is trivially destructible
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert((std::is_convertible<I2,
|
static_assert((std::is_convertible<I2,
|
||||||
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
|
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
|
||||||
const unsigned*, const unsigned&> >::value), "");
|
const unsigned*, const unsigned&> >::value), "");
|
||||||
|
#else
|
||||||
|
static_assert((std::is_same<I2::iterator_category, std::input_iterator_tag>::value), "");
|
||||||
|
static_assert((std::is_same<I2::value_type, unsigned>::value), "");
|
||||||
|
static_assert((std::is_same<I2::difference_type, std::ptrdiff_t>::value), "");
|
||||||
|
static_assert((std::is_same<I2::pointer, const unsigned*>::value), "");
|
||||||
|
static_assert((std::is_same<I2::reference, const unsigned&>::value), "");
|
||||||
|
#endif
|
||||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||||
static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
|
static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
|
||||||
|
|
|
@ -23,17 +23,35 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
typedef std::ostream_iterator<double> I1;
|
typedef std::ostream_iterator<double> I1;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert((std::is_convertible<I1,
|
static_assert((std::is_convertible<I1,
|
||||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||||
|
#else
|
||||||
|
static_assert((std::is_same<I1::iterator_category, std::output_iterator_tag>::value), "");
|
||||||
|
static_assert((std::is_same<I1::value_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I1::difference_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I1::pointer, void>::value), "");
|
||||||
|
static_assert((std::is_same<I1::reference, void>::value), "");
|
||||||
|
#endif
|
||||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||||
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
|
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
|
||||||
typedef std::ostream_iterator<unsigned, wchar_t> I2;
|
typedef std::ostream_iterator<unsigned, wchar_t> I2;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert((std::is_convertible<I2,
|
static_assert((std::is_convertible<I2,
|
||||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||||
|
#else
|
||||||
|
static_assert((std::is_same<I2::iterator_category, std::output_iterator_tag>::value), "");
|
||||||
|
static_assert((std::is_same<I2::value_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I2::difference_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I2::pointer, void>::value), "");
|
||||||
|
static_assert((std::is_same<I2::reference, void>::value), "");
|
||||||
|
#endif
|
||||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||||
static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
|
static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
|
||||||
|
|
|
@ -24,19 +24,37 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
typedef std::ostreambuf_iterator<char> I1;
|
typedef std::ostreambuf_iterator<char> I1;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert((std::is_convertible<I1,
|
static_assert((std::is_convertible<I1,
|
||||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||||
|
#else
|
||||||
|
static_assert((std::is_same<I1::iterator_category, std::output_iterator_tag>::value), "");
|
||||||
|
static_assert((std::is_same<I1::value_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I1::difference_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I1::pointer, void>::value), "");
|
||||||
|
static_assert((std::is_same<I1::reference, void>::value), "");
|
||||||
|
#endif
|
||||||
static_assert((std::is_same<I1::char_type, char>::value), "");
|
static_assert((std::is_same<I1::char_type, char>::value), "");
|
||||||
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
|
||||||
static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
|
static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
|
||||||
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
|
static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
|
||||||
|
|
||||||
typedef std::ostreambuf_iterator<wchar_t> I2;
|
typedef std::ostreambuf_iterator<wchar_t> I2;
|
||||||
|
#if TEST_STD_VER <= 14
|
||||||
static_assert((std::is_convertible<I2,
|
static_assert((std::is_convertible<I2,
|
||||||
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
|
||||||
|
#else
|
||||||
|
static_assert((std::is_same<I2::iterator_category, std::output_iterator_tag>::value), "");
|
||||||
|
static_assert((std::is_same<I2::value_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I2::difference_type, void>::value), "");
|
||||||
|
static_assert((std::is_same<I2::pointer, void>::value), "");
|
||||||
|
static_assert((std::is_same<I2::reference, void>::value), "");
|
||||||
|
#endif
|
||||||
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
|
||||||
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
|
||||||
static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
|
static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
|
||||||
|
|
Loading…
Reference in New Issue