Commit d9fd5f23 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook GitHub Bot

tell the range-v3 library that folly::Range satisfies the view concept

Summary: Upstream range-v3 has changed in accordance with C++20's standard ranges such that view types now need to explicitly opt-in to the `view` concept. This diff adds the hook needed so that the latest version of the range library will recognize `folly::Range` as a view.

Reviewed By: yfeldblum

Differential Revision: D20569727

fbshipit-source-id: 2f8bca017b2f8036b02568997a0b7c76d9c41646
parent 9d715f1f
...@@ -1556,3 +1556,13 @@ constexpr Range<wchar_t const*> operator"" _sp( ...@@ -1556,3 +1556,13 @@ constexpr Range<wchar_t const*> operator"" _sp(
FOLLY_POP_WARNING FOLLY_POP_WARNING
FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(folly::Range) FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(folly::Range)
// Tell the range-v3 library that this type should satisfy
// the view concept (a lightweight, non-owning range).
namespace ranges {
template <class T>
extern const bool enable_view;
template <class Iter>
FOLLY_INLINE_VARIABLE constexpr bool enable_view<::folly::Range<Iter>> = true;
} // namespace ranges
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
#include <folly/portability/SysMman.h> #include <folly/portability/SysMman.h>
#include <range/v3/range/concepts.hpp>
using namespace folly; using namespace folly;
using namespace folly::detail; using namespace folly::detail;
using namespace std; using namespace std;
...@@ -45,6 +47,11 @@ static_assert(std::is_literal_type<StringPiece>::value, ""); ...@@ -45,6 +47,11 @@ static_assert(std::is_literal_type<StringPiece>::value, "");
BOOST_CONCEPT_ASSERT((boost::RandomAccessRangeConcept<StringPiece>)); BOOST_CONCEPT_ASSERT((boost::RandomAccessRangeConcept<StringPiece>));
// Check conformance with the C++20 range concepts as specified
// by the range-v3 library.
CPP_assert(ranges::range<StringPiece>);
CPP_assert(ranges::view_<StringPiece>);
TEST(StringPiece, All) { TEST(StringPiece, All) {
const char* foo = "foo"; const char* foo = "foo";
const char* foo2 = "foo"; const char* foo2 = "foo";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment