[libcxx-commits] [PATCH] D130785: [libc++] Implement P2499R0 (`string_view` range constructor should be `explicit`)
Igor Zhukov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 29 10:00:04 PDT 2022
fsb4000 created this revision.
fsb4000 added a reviewer: libc++.
fsb4000 added a project: libc++.
Herald added a project: All.
fsb4000 requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130785
Files:
libcxx/docs/ReleaseNotes.rst
libcxx/docs/Status/Cxx2bPapers.csv
libcxx/include/string_view
libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
libcxx/test/support/msvc_stdlib_force_include.h
libcxx/test/support/test_range.h
Index: libcxx/test/support/test_range.h
===================================================================
--- libcxx/test/support/test_range.h
+++ libcxx/test/support/test_range.h
@@ -14,7 +14,7 @@
#include "test_iterators.h"
#if _LIBCPP_STD_VER < 17
-#error "test/support/test_range.h" can only be included in builds supporting ranges
+//#error "test/support/test_range.h" can only be included in builds supporting ranges
#endif
struct sentinel {
Index: libcxx/test/support/msvc_stdlib_force_include.h
===================================================================
--- libcxx/test/support/msvc_stdlib_force_include.h
+++ libcxx/test/support/msvc_stdlib_force_include.h
@@ -70,12 +70,12 @@
#define _HAS_FEATURES_REMOVED_IN_CXX20 1
// Silence warnings about the unspecified complex<non-floating-point>
- #define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
+ //#define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
// Silence warnings about features that are deprecated in non-default language modes.
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS
- #define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
+ //define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
#endif // _LIBCXX_IN_DEVCRT
#include <version>
Index: libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
===================================================================
--- libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
+++ libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp
@@ -186,6 +186,9 @@
}
#endif
+// P2499R0 string_view Range Constructor Should Be explicit
+static_assert(!std::is_convertible_v<std::vector<char>, std::string_view>);
+
int main(int, char**) {
test();
static_assert(test());
Index: libcxx/include/string_view
===================================================================
--- libcxx/include/string_view
+++ libcxx/include/string_view
@@ -331,7 +331,7 @@
typename remove_reference_t<_Range>::traits_type;
} || is_same_v<typename remove_reference_t<_Range>::traits_type, _Traits>)
)
- constexpr _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit _LIBCPP_HIDE_FROM_ABI
basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {}
#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
Index: libcxx/docs/Status/Cxx2bPapers.csv
===================================================================
--- libcxx/docs/Status/Cxx2bPapers.csv
+++ libcxx/docs/Status/Cxx2bPapers.csv
@@ -79,7 +79,7 @@
"`P2467R1 <https://wg21.link/P2467R1>`__","LWG","Support exclusive mode for ``fstreams``","July 2022","",""
"`P2474R2 <https://wg21.link/P2474R2>`__","LWG","``views::repeat``","July 2022","",""
"`P2494R2 <https://wg21.link/P2494R2>`__","LWG","Relaxing range adaptors to allow for move only types","July 2022","",""
-"`P2499R0 <https://wg21.link/P2499R0>`__","LWG","``string_view`` range constructor should be ``explicit``","July 2022","",""
+"`P2499R0 <https://wg21.link/P2499R0>`__","LWG","``string_view`` range constructor should be ``explicit``","July 2022","|Complete|","16.0"
"`P2502R2 <https://wg21.link/P2502R2>`__","LWG","``std::generator``: Synchronous Coroutine Generator for Ranges","July 2022","",""
"`P2508R1 <https://wg21.link/P2508R1>`__","LWG","Exposing ``std::basic-format-string``","July 2022","",""
"`P2513R4 <https://wg21.link/P2513R4>`__","LWG","``char8_t`` Compatibility and Portability Fixes","July 2022","",""
Index: libcxx/docs/ReleaseNotes.rst
===================================================================
--- libcxx/docs/ReleaseNotes.rst
+++ libcxx/docs/ReleaseNotes.rst
@@ -37,6 +37,7 @@
Implemented Papers
------------------
+- Implemented P2499R0 (``string_view`` range constructor should be ``explicit``)
Improvements and New Features
-----------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130785.448668.patch
Type: text/x-patch
Size: 3965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220729/d13c557c/attachment-0001.bin>
More information about the libcxx-commits
mailing list