[libcxx-commits] [libcxx] df73e36 - [libcxx] [NFC] fpos Requirements (p0759r1).

via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 7 14:03:15 PDT 2020


Author: zoecarver
Date: 2020-05-07T14:02:42-07:00
New Revision: df73e36dc6ffd2ede500189b075f7ac52794b3ad

URL: https://github.com/llvm/llvm-project/commit/df73e36dc6ffd2ede500189b075f7ac52794b3ad
DIFF: https://github.com/llvm/llvm-project/commit/df73e36dc6ffd2ede500189b075f7ac52794b3ad.diff

LOG: [libcxx] [NFC] fpos Requirements (p0759r1).

Implements p0759r1. Test-only change. Adds explicit test for table 106 and type checking.

Differential Review: https://reviews.llvm.org/D60491

Added: 
    libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/fpos.pass.cpp

Modified: 
    libcxx/www/cxx2a_status.html

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/fpos.pass.cpp b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/fpos.pass.cpp
new file mode 100644
index 000000000000..37f7c88d3ce9
--- /dev/null
+++ b/libcxx/test/std/input.output/iostreams.base/fpos/fpos.operations/fpos.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "test_macros.h"
+
+#include <string>
+#include <cassert>
+#include <type_traits>
+
+// <string>
+
+// template <class stateT>
+// class fpos;
+
+template<class T, class = void>
+struct is_equality_comparable : std::false_type { };
+
+template<class T>
+struct is_equality_comparable
+<T, typename std::enable_if<true, decltype(std::declval<T const&>() == std::declval<T const&>(),
+                                           (void)0)>::type
+> : std::true_type { };
+
+template<class T>
+void test_traits()
+{
+    static_assert(std::is_default_constructible <std::fpos<T> >::value, "");
+    static_assert(std::is_copy_constructible    <std::fpos<T> >::value, "");
+    static_assert(std::is_copy_assignable       <std::fpos<T> >::value, "");
+    static_assert(std::is_destructible          <std::fpos<T> >::value, "");
+    static_assert(is_equality_comparable        <std::fpos<T> >::value, "");
+
+    static_assert(std::is_trivially_copy_constructible<T>::value ==
+                  std::is_trivially_copy_constructible<std::fpos<T> >::value, "");
+    static_assert(std::is_trivially_copy_assignable<T>::value ==
+                  std::is_trivially_copy_assignable<std::fpos<T> >::value, "");
+    static_assert(std::is_trivially_destructible<T>::value ==
+                  std::is_trivially_destructible<std::fpos<T> >::value, "");
+}
+
+struct Foo { };
+
+int main(int, char**)
+{
+    test_traits<std::mbstate_t>();
+    test_traits<int>();
+    test_traits<Foo>();
+
+    // Position type requirements table 106 (in order):
+
+    std::streampos p1(42);
+    std::streamoff o1(p1);
+
+    {
+        assert(o1 == 42);
+    }
+    {
+        std::streampos p2(42);
+        std::streampos q1(43);
+        std::streampos const p3(44);
+        std::streampos const q2(45);
+        assert(p2 != q1);
+        assert(p3 != q2);
+        assert(p2 != q2);
+        assert(p3 != q1);
+    }
+    {
+        std::streampos p2 = p1 + o1;
+        assert(p2 == 84);
+    }
+    {
+        std::streampos& p2 = p1 += o1;
+        assert(p2 == 84);
+        assert(p1 == 84);
+    }
+    {
+        std::streampos p2 = p1 - o1;
+        assert(p2 == 42);
+    }
+    {
+        std::streampos& p2 = p1 -= o1;
+        assert(p2 == 42);
+        assert(p1 == 42);
+    }
+    {
+        std::streampos p2 = o1 + p1;
+        assert(p2 == 84);
+    }
+    {
+        std::streampos q1(42);
+        std::streamoff o2 = q1 - p1;
+        assert(o2 == 0);
+    }
+
+    return 0;
+}

diff  --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html
index 9f1ff469be0b..4b715e7a40f3 100644
--- a/libcxx/www/cxx2a_status.html
+++ b/libcxx/www/cxx2a_status.html
@@ -93,7 +93,7 @@ <h3>Paper Status</h3>
 	<tr><td><a href="https://wg21.link/P0646R1">P0646R1</a></td><td>LWG</td><td>Improving the Return Value of Erase-Like Algorithms</td><td>Rapperswil</td><td>Complete</td><td>10.0</td></tr>
 	<tr><td><a href="https://wg21.link/P0722R3">P0722R3</a></td><td>CWG</td><td>Efficient sized delete for variable sized classes</td><td>Rapperswil</td><td>Complete</td><td>9.0</td></tr>
 	<tr><td><a href="https://wg21.link/P0758R1">P0758R1</a></td><td>LWG</td><td>Implicit conversion traits and utility functions</td><td>Rapperswil</td><td>Complete</td><td></td></tr>
-	<tr><td><a href="https://wg21.link/P0759R1">P0759R1</a></td><td>LWG</td><td>fpos Requirements</td><td>Rapperswil</td><td></td><td></td></tr>
+	<tr><td><a href="https://wg21.link/P0759R1">P0759R1</a></td><td>LWG</td><td>fpos Requirements</td><td>Rapperswil</td><td>Complete</td><td>11.0</td></tr>
 	<tr><td><a href="https://wg21.link/P0769R2">P0769R2</a></td><td>LWG</td><td>Add shift to <algorithm></td><td>Rapperswil</td><td></td><td></td></tr>
 	<tr><td><a href="https://wg21.link/P0788R3">P0788R3</a></td><td>LWG</td><td>Standard Library Specification in a Concepts and Contracts World</td><td>Rapperswil</td><td></td><td></td></tr>
 	<tr><td><a href="https://wg21.link/P0879R0">P0879R0</a></td><td>LWG</td><td>Constexpr for swap and swap related functions Also resolves LWG issue 2800.</td><td>Rapperswil</td><td></td><td></td></tr>


        


More information about the libcxx-commits mailing list