[libcxx] r289708 - Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 14 13:22:49 PST 2016
Author: ericwf
Date: Wed Dec 14 15:22:48 2016
New Revision: 289708
URL: http://llvm.org/viewvc/llvm-project?rev=289708&view=rev
Log:
Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator.
No code changes were needed, but I updated a few tests.
Also resolved P0509 and P0521, which required no changes to the library or tests.
This patch was reverted due to llvm.org/PR31016. There is a bug in Clang 3.7
which causes default.pass.cpp to fails. That test is now marked as XFAIL for that
clang version.
This patch was originally authored by Marshall Clow.
Modified:
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
libcxx/trunk/www/cxx1z_status.html
Modified: libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp?rev=289708&r1=289707&r2=289708&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp Wed Dec 14 15:22:48 2016
@@ -12,11 +12,15 @@
// class istream_iterator
// istream_iterator(const istream_iterator& x);
+// C++17 says: If is_trivially_copy_constructible_v<T> is true, then
+// this constructor shall beis a trivial copy constructor.
#include <iterator>
#include <sstream>
#include <cassert>
+#include "test_macros.h"
+
int main()
{
{
Modified: libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp?rev=289708&r1=289707&r2=289708&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp Wed Dec 14 15:22:48 2016
@@ -7,17 +7,41 @@
//
//===----------------------------------------------------------------------===//
+// Usage of is_trivially_constructible is broken with these compilers.
+// See https://llvm.org/bugs/show_bug.cgi?id=31016
+// XFAIL: clang-3.7
+
// <iterator>
// class istream_iterator
// constexpr istream_iterator();
+// C++17 says: If is_trivially_default_constructible_v<T> is true, then this
+// constructor shall beis a constexpr constructor.
#include <iterator>
#include <cassert>
+#include <string>
#include "test_macros.h"
+struct S { S(); }; // not constexpr
+
+#if TEST_STD_VER > 14
+template <typename T, bool isTrivial = std::is_trivially_default_constructible_v<T>>
+struct test_trivial {
+void operator ()() const {
+ constexpr std::istream_iterator<T> it;
+ }
+};
+
+template <typename T>
+struct test_trivial<T, false> {
+void operator ()() const {}
+};
+#endif
+
+
int main()
{
{
@@ -29,4 +53,11 @@ int main()
#endif
}
+#if TEST_STD_VER > 14
+ test_trivial<int>()();
+ test_trivial<char>()();
+ test_trivial<double>()();
+ test_trivial<S>()();
+ test_trivial<std::string>()();
+#endif
}
Modified: libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp?rev=289708&r1=289707&r2=289708&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp Wed Dec 14 15:22:48 2016
@@ -23,9 +23,18 @@
// typedef basic_istream<charT,traits> istream_type;
// ...
//
+// Before C++17, we have:
// 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.
+// C++17 says:
+// If is_trivially_default_constructible_v<T> is true, then
+// this constructor (the default ctor) shall beis a constexpr constructor.
+// If is_trivially_copy_constructible_v<T> is true, then
+// this constructor (the copy ctor) shall beis a trivial copy constructor.
+// If is_trivially_destructible_v<T> is true, then this
+// destructor shall beis a trivial destructor.
+// Testing the C++17 ctors for this are in the ctor tests.
#include <iterator>
#include <type_traits>
@@ -33,7 +42,7 @@
int main()
{
- typedef std::istream_iterator<double> I1;
+ typedef std::istream_iterator<double> I1; // double is trivially destructible
static_assert((std::is_convertible<I1,
std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
const double*, const double&> >::value), "");
@@ -43,7 +52,7 @@ int main()
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;
+ typedef std::istream_iterator<unsigned, wchar_t> I2; // unsigned is trivially destructible
static_assert((std::is_convertible<I2,
std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
const unsigned*, const unsigned&> >::value), "");
@@ -53,7 +62,7 @@ int main()
static_assert( std::is_trivially_copy_constructible<I2>::value, "");
static_assert( std::is_trivially_destructible<I2>::value, "");
- typedef std::istream_iterator<std::string> I3;
+ typedef std::istream_iterator<std::string> I3; // string is NOT trivially destructible
static_assert(!std::is_trivially_copy_constructible<I3>::value, "");
static_assert(!std::is_trivially_destructible<I3>::value, "");
}
Modified: libcxx/trunk/www/cxx1z_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=289708&r1=289707&r2=289708&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Wed Dec 14 15:22:48 2016
@@ -130,16 +130,16 @@
<tr><td><a href="http://wg21.link/P0426R1">P0426R1</a></td><td>LWG</td><td>Constexpr for <tt>std::char_traits</tt></td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0435R1">P0435R1</a></td><td>LWG</td><td>Resolving LWG Issues re <tt>common_type</tt></td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0502R0">P0502R0</a></td><td>LWG</td><td>Throwing out of a parallel algorithm terminates - but how?</td><td>Issaquah</td><td></td><td></td></tr>
- <tr><td><a href="http://wg21.link/P0503R0">P0503R0</a></td><td>LWG</td><td>Correcting library usage of "literal type"</td><td>Issaquah</td><td></td><td></td></tr>
+ <tr><td><a href="http://wg21.link/P0503R0">P0503R0</a></td><td>LWG</td><td>Correcting library usage of "literal type"</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0504R0">P0504R0</a></td><td>LWG</td><td>Revisiting in-place tag types for any/optional/variant</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0505R0">P0505R0</a></td><td>LWG</td><td>Wording for GB 50 - constexpr for chrono</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0508R0">P0508R0</a></td><td>LWG</td><td>Wording for GB 58 - structured bindings for node_handles</td><td>Issaquah</td><td></td><td></td></tr>
- <tr><td><a href="http://wg21.link/P0509R1">P0509R1</a></td><td>LWG</td><td>Updating âRestrictions on exception handlingâ</td><td>Issaquah</td><td></td><td></td></tr>
+ <tr><td><a href="http://wg21.link/P0509R1">P0509R1</a></td><td>LWG</td><td>Updating âRestrictions on exception handlingâ</td><td>Issaquah</td><td><i>Nothing to do</i></td><td>n/a</td></tr>
<tr><td><a href="http://wg21.link/P0510R0">P0510R0</a></td><td>LWG</td><td>Disallowing references, incomplete types, arrays, and empty variants</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0513R0">P0513R0</a></td><td>LWG</td><td>Poisoning the Hash</td><td>Issaquah</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0516R0">P0516R0</a></td><td>LWG</td><td>Clarify That shared_futureâs Copy Operations have Wide Contracts</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0517R0">P0517R0</a></td><td>LWG</td><td>Make future_error Constructible</td><td>Issaquah</td><td>Complete</td><td>4.0</td></tr>
- <tr><td><a href="http://wg21.link/P0521R0">P0521R0</a></td><td>LWG</td><td>Proposed Resolution for CA 14 (shared_ptr use_count/unique)</td><td>Issaquah</td><td></td><td></td></tr>
+ <tr><td><a href="http://wg21.link/P0521R0">P0521R0</a></td><td>LWG</td><td>Proposed Resolution for CA 14 (shared_ptr use_count/unique)</td><td>Issaquah</td><td><i>Nothing to do</i></td><td>n/a</td></tr>
<!-- <tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> -->
</table>
More information about the cfe-commits
mailing list