Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions include/boost/url/decode_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,4 +1074,20 @@ make_decode_view(

#include <boost/url/impl/decode_view.hpp>

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::decode_view> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/params_encoded_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,4 +1005,20 @@ class BOOST_URL_DECL params_encoded_ref
//
// #include <boost/url/impl/params_encoded_ref.hpp>

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::params_encoded_ref> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/params_encoded_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,20 @@ class BOOST_URL_DECL params_encoded_view
} // urls
} // boost

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::params_encoded_view> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/params_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,4 +961,20 @@ class BOOST_URL_DECL params_ref
//
// #include <boost/url/impl/params_ref.hpp>

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::params_ref> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/params_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,20 @@ class params_view
} // urls
} // boost

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::params_view> = true;
} // std::ranges
#endif

#endif
10 changes: 10 additions & 0 deletions include/boost/url/pct_string_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,14 @@ to_sv(pct_string_view const& s) noexcept
// Ensure decode_view is complete for operator*()
#include <boost/url/decode_view.hpp>

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::pct_string_view> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/segments_encoded_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,4 +794,20 @@ class segments_encoded_ref
//
// #include <boost/url/impl/segments_encoded_ref.hpp>

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::segments_encoded_ref> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/segments_encoded_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,20 @@ class segments_encoded_view
} // urls
} // boost

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::segments_encoded_view> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/segments_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,20 @@ class segments_ref
//
// #include <boost/url/impl/segments_ref.hpp>

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::segments_ref> = true;
} // std::ranges
#endif

#endif
16 changes: 16 additions & 0 deletions include/boost/url/segments_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,20 @@ class segments_view
} // urls
} // boost

//------------------------------------------------
//
// std::ranges::enable_borrowed_range
//
//------------------------------------------------

#ifdef BOOST_URL_HAS_CONCEPTS
#include <ranges>
namespace std::ranges {
template<>
inline constexpr bool
enable_borrowed_range<
boost::urls::segments_view> = true;
} // std::ranges
#endif

#endif
20 changes: 20 additions & 0 deletions test/unit/decode_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,25 @@ struct decode_view_test
}
}

void
testBorrowedRange()
{
#ifdef BOOST_URL_HAS_CONCEPTS
// decode_view is a borrowed range
BOOST_CORE_STATIC_ASSERT(
std::ranges::borrowed_range<decode_view>);

// iterators remain valid after the view is destroyed
decode_view::iterator it;
{
decode_view dv("hello%20world");
it = dv.begin();
}
// iterator is still valid (points to external buffer)
BOOST_TEST_EQ(*it, 'h');
#endif
}

void
run()
{
Expand All @@ -365,6 +384,7 @@ struct decode_view_test
testCompare();
testStream();
testPR127Cases();
testBorrowedRange();
}
};

Expand Down
22 changes: 22 additions & 0 deletions test/unit/params_encoded_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,35 @@ struct params_encoded_ref_test
}
}

void
testBorrowedRange()
{
#ifdef BOOST_URL_HAS_CONCEPTS
// params_encoded_ref is a borrowed range
BOOST_CORE_STATIC_ASSERT(
std::ranges::borrowed_range<params_encoded_ref>);

// iterators remain valid after the ref is destroyed
// (as long as the underlying url stays alive)
url u("?first=John&last=Doe");
params_encoded_ref::iterator it;
{
params_encoded_ref p = u.encoded_params();
it = p.begin();
}
// ref is destroyed, but iterator is still valid
BOOST_TEST_EQ((*it).key, "first");
#endif
}

void
run()
{
testSpecial();
testObservers();
testModifiers();
testJavadocs();
testBorrowedRange();
}
};

Expand Down
20 changes: 20 additions & 0 deletions test/unit/params_encoded_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,32 @@ struct params_encoded_view_test
}
}

void
testBorrowedRange()
{
#ifdef BOOST_URL_HAS_CONCEPTS
// params_encoded_view is a borrowed range
BOOST_CORE_STATIC_ASSERT(
std::ranges::borrowed_range<params_encoded_view>);

// iterators remain valid after the view is destroyed
params_encoded_view::iterator it;
{
params_encoded_view qp("first=John&last=Doe");
it = qp.begin();
}
// iterator is still valid (points to external buffer)
BOOST_TEST_EQ((*it).key, "first");
#endif
}

void
run()
{
testMembers();
testRange();
testJavadocs();
testBorrowedRange();
}
};

Expand Down
23 changes: 23 additions & 0 deletions test/unit/params_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,28 @@ struct params_ref_test
}
}

static
void
testBorrowedRange()
{
#ifdef BOOST_URL_HAS_CONCEPTS
// params_ref is a borrowed range
BOOST_CORE_STATIC_ASSERT(
std::ranges::borrowed_range<params_ref>);

// iterators remain valid after the ref is destroyed
// (as long as the underlying url stays alive)
url u("?first=John&last=Doe");
params_ref::iterator it;
{
params_ref p = u.params();
it = p.begin();
}
// ref is destroyed, but iterator is still valid
BOOST_TEST_EQ((*it).key, "first");
#endif
}

static
void
testAll()
Expand All @@ -1041,6 +1063,7 @@ struct params_ref_test
testModifiers();
testJavadocs();
testSpaceAsPlus();
testBorrowedRange();
}

void
Expand Down
20 changes: 20 additions & 0 deletions test/unit/params_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,31 @@ struct params_view_test
}
}

void
testBorrowedRange()
{
#ifdef BOOST_URL_HAS_CONCEPTS
// params_view is a borrowed range
BOOST_CORE_STATIC_ASSERT(
std::ranges::borrowed_range<params_view>);

// iterators remain valid after the view is destroyed
params_view::iterator it;
{
params_view qp("first=John&last=Doe");
it = qp.begin();
}
// iterator is still valid (points to external buffer)
BOOST_TEST_EQ((*it).key, "first");
#endif
}

void
run()
{
testMembers();
testJavadocs();
testBorrowedRange();
}
};

Expand Down
Loading
Loading