A few bits of N2994 didn't get fully implemented a long time ago. Thanks to STL@microsoft.com for the bug report
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@235134 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a4964aef3
commit
e9d030687d
@ -214,7 +214,7 @@ public:
|
||||
typedef traits traits_type;
|
||||
typedef basic_istream<charT,traits> istream_type;
|
||||
|
||||
istream_iterator();
|
||||
constexpr istream_iterator();
|
||||
istream_iterator(istream_type& s);
|
||||
istream_iterator(const istream_iterator& x);
|
||||
~istream_iterator();
|
||||
@ -765,7 +765,7 @@ private:
|
||||
istream_type* __in_stream_;
|
||||
_Tp __value_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY istream_iterator() : __in_stream_(0) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(&__s)
|
||||
{
|
||||
if (!(*__in_stream_ >> __value_))
|
||||
|
@ -21,8 +21,8 @@ template <intmax_t N, intmax_t D = 1>
|
||||
class ratio
|
||||
{
|
||||
public:
|
||||
static const intmax_t num;
|
||||
static const intmax_t den;
|
||||
static constexpr intmax_t num;
|
||||
static constexpr intmax_t den;
|
||||
typedef ratio<num, den> type;
|
||||
};
|
||||
|
||||
@ -236,13 +236,13 @@ class _LIBCPP_TYPE_VIS_ONLY ratio
|
||||
static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
|
||||
static_assert(_Den != 0, "ratio divide by 0");
|
||||
static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range");
|
||||
static const intmax_t __na = __static_abs<_Num>::value;
|
||||
static const intmax_t __da = __static_abs<_Den>::value;
|
||||
static const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
|
||||
static const intmax_t __gcd = __static_gcd<__na, __da>::value;
|
||||
static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value;
|
||||
static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value;
|
||||
static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
|
||||
static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;
|
||||
public:
|
||||
static const intmax_t num = __s * __na / __gcd;
|
||||
static const intmax_t den = __da / __gcd;
|
||||
static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
|
||||
static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
|
||||
|
||||
typedef ratio<num, den> type;
|
||||
};
|
||||
|
@ -0,0 +1,30 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <iterator>
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// constexpr istream_iterator();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
struct S { S(); }; // not constexpr
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
constexpr std::istream_iterator<S> it;
|
||||
}
|
||||
#else
|
||||
#error "C++11 only test"
|
||||
#endif
|
||||
}
|
@ -11,13 +11,20 @@
|
||||
|
||||
// class istream_iterator
|
||||
|
||||
// istream_iterator();
|
||||
// constexpr istream_iterator();
|
||||
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::istream_iterator<int> i;
|
||||
assert(i == std::istream_iterator<int>());
|
||||
{
|
||||
typedef std::istream_iterator<int> T;
|
||||
T it;
|
||||
assert(it == T());
|
||||
#if __cplusplus >= 201103L
|
||||
constexpr T it2;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,14 @@
|
||||
// typedef traits traits_type;
|
||||
// typedef basic_istream<charT,traits> istream_type;
|
||||
// ...
|
||||
//
|
||||
// If T is a literal type, then the default constructor shall be a constexpr constructor.
|
||||
// If T is a literal type, then this constructor shall be a trivial copy constructor.
|
||||
// If T is a literal type, then this destructor shall be a trivial destructor.
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -32,6 +37,9 @@ int main()
|
||||
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::istream_type, std::istream>::value), "");
|
||||
static_assert( std::is_trivially_copy_constructible<I1>::value, "");
|
||||
static_assert( std::is_trivially_destructible<I1>::value, "");
|
||||
|
||||
typedef std::istream_iterator<unsigned, wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
|
||||
@ -39,4 +47,10 @@ int main()
|
||||
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::istream_type, std::wistream>::value), "");
|
||||
static_assert( std::is_trivially_copy_constructible<I2>::value, "");
|
||||
static_assert( std::is_trivially_destructible<I2>::value, "");
|
||||
|
||||
typedef std::istream_iterator<std::string> I3;
|
||||
static_assert(!std::is_trivially_copy_constructible<I3>::value, "");
|
||||
static_assert(!std::is_trivially_destructible<I3>::value, "");
|
||||
}
|
||||
|
@ -10,8 +10,11 @@
|
||||
// <iterator>
|
||||
|
||||
// istreambuf_iterator
|
||||
|
||||
//
|
||||
// istreambuf_iterator() throw();
|
||||
//
|
||||
// All specializations of istreambuf_iterator shall have a trivial copy constructor,
|
||||
// a constexpr default constructor and a trivial destructor.
|
||||
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
@ -20,11 +23,19 @@
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::istreambuf_iterator<char> i;
|
||||
assert(i == std::istreambuf_iterator<char>());
|
||||
typedef std::istreambuf_iterator<char> T;
|
||||
T it;
|
||||
assert(it == T());
|
||||
#if __cplusplus >= 201103L
|
||||
constexpr T it2;
|
||||
#endif
|
||||
}
|
||||
{
|
||||
std::istreambuf_iterator<wchar_t> i;
|
||||
assert(i == std::istreambuf_iterator<wchar_t>());
|
||||
typedef std::istreambuf_iterator<wchar_t> T;
|
||||
T it;
|
||||
assert(it == T());
|
||||
#if __cplusplus >= 201103L
|
||||
constexpr T it2;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
// typedef basic_streambuf<charT,traits> streambuf_type;
|
||||
// typedef basic_istream<charT,traits> istream_type;
|
||||
// ...
|
||||
//
|
||||
// All specializations of istreambuf_iterator shall have a trivial copy constructor,
|
||||
// a constexpr default constructor and a trivial destructor.
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
@ -38,6 +41,9 @@ int main()
|
||||
static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
|
||||
static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
|
||||
static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
|
||||
static_assert((std::is_nothrow_default_constructible<I1>::value), "" );
|
||||
static_assert((std::is_trivially_copy_constructible<I1>::value), "" );
|
||||
static_assert((std::is_trivially_destructible<I1>::value), "" );
|
||||
|
||||
typedef std::istreambuf_iterator<wchar_t> I2;
|
||||
static_assert((std::is_convertible<I2,
|
||||
@ -48,4 +54,7 @@ int main()
|
||||
static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
|
||||
static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
|
||||
static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
|
||||
static_assert((std::is_nothrow_default_constructible<I2>::value), "" );
|
||||
static_assert((std::is_trivially_copy_constructible<I2>::value), "" );
|
||||
static_assert((std::is_trivially_destructible<I2>::value), "" );
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// test ratio: The static data members num and den shall have thcommon
|
||||
// test ratio: The static data members num and den shall have the common
|
||||
// divisor of the absolute values of N and D:
|
||||
|
||||
#include <ratio>
|
||||
|
Loading…
Reference in New Issue
Block a user