Skip to content

Commit

Permalink
subview assignments are ref-qualified
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas authored and vinniefalco committed Feb 25, 2022
1 parent 6741530 commit 78ffe4f
Show file tree
Hide file tree
Showing 17 changed files with 158 additions and 2 deletions.
15 changes: 14 additions & 1 deletion include/boost/url/params.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,21 @@ class params
<!-- @{ -->
*/

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
params&
operator=(params const&) & = default;

/** Assignment from initializer list
Assigns @ref params from a list of @ref params::value_type.
Each instance of @ref params::value_type is a view of a query <key, value> pair.
@return Pointer to this instance of @ref params
@return Reference to this instance of @ref params
@param init Initializer list with query parameters
Expand Down Expand Up @@ -338,6 +346,11 @@ class params
bool
empty() const noexcept;

/** Return the number of elements
@return Number of elements in the container
*/
inline
std::size_t
size() const noexcept;
Expand Down
8 changes: 8 additions & 0 deletions include/boost/url/params_encoded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ class params_encoded
* <!-- @{ -->
*/

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
params_encoded&
operator=(params_encoded const&) & = default;

/** Assignment from initializer list
Assign params from a list of param value_type.
Expand Down
8 changes: 8 additions & 0 deletions include/boost/url/params_encoded_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ class params_encoded_view
params_view
decoded(Allocator const& alloc = {}) const;

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
params_encoded_view&
operator=(params_encoded_view const&) & = default;

//--------------------------------------------
//
// Element Access
Expand Down
8 changes: 8 additions & 0 deletions include/boost/url/params_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class params_view
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
params_view&
operator=(params_view const&) & = default;

//--------------------------------------------
//
// Element Access
Expand Down
2 changes: 1 addition & 1 deletion include/boost/url/query_param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct query_param_view
`has_value == true`.
A value that is present with an empty string
is distinct from a value that is absent.
Whether the strings are precent-encoded
Whether the strings are percent-encoded
is determined by the container from which
the value is obtained.
*/
Expand Down
8 changes: 8 additions & 0 deletions include/boost/url/segments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ class segments
bool
is_absolute() const noexcept;

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
segments&
operator=(segments const&) & = default;

/** Replace the contents of the container
This function replaces the contents with
Expand Down
8 changes: 8 additions & 0 deletions include/boost/url/segments_encoded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ class segments_encoded
segments
decoded(Allocator const& alloc = {}) const;

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
segments_encoded&
operator=(segments_encoded const&) & = default;

/** Replace the contents of the container
This function replaces the contents
Expand Down
8 changes: 8 additions & 0 deletions include/boost/url/segments_encoded_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ class segments_encoded_view
inline
segments_encoded_view() noexcept;

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
segments_encoded_view&
operator=(segments_encoded_view const&) & = default;

/** Return a view of this container as percent-decoded segments
This function returns a new view over the
Expand Down
9 changes: 9 additions & 0 deletions include/boost/url/segments_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ class segments_view
inline
segments_view() noexcept;

/** Assignment
After the assignment, both views will point to
the same underlying object.
*/
segments_view&
operator=(segments_view const& other) & = default;


/** Returns true if this contains an absolute path.
Absolute paths always start with a
Expand Down
10 changes: 10 additions & 0 deletions test/unit/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class params_test
void
testMembers()
{
// operator=(params const&)
{
url u1;
url u2;
params p1 = u1.params();
params p2 = u2.params();
p2 = p1;
BOOST_TEST(p1.begin() == p2.begin());
}

// operator=
// assign(initializer_list)
// assign(FwdIt, FwdIt)
Expand Down
10 changes: 10 additions & 0 deletions test/unit/params_encoded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ class params_encoded_test
void
testMembers()
{
// operator=(params_encoded const&)
{
url u1;
url u2;
params_encoded p1 = u1.encoded_params();
params_encoded p2 = u2.encoded_params();
p2 = p1;
BOOST_TEST(p1.begin() == p2.begin());
}

// operator=
// assign(initializer_list)
// assign(FwdIt, FwdIt)
Expand Down
15 changes: 15 additions & 0 deletions test/unit/params_encoded_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ namespace urls {
class params_encoded_view_test
{
public:
void
testMembers()
{
// operator=(params_encoded_view const&)
{
url_view u1;
url_view u2;
params_encoded_view p1 = u1.encoded_params();
params_encoded_view p2 = u2.encoded_params();
p2 = p1;
BOOST_TEST(p1.begin() == p2.begin());
}
}

void
testElements()
{
Expand Down Expand Up @@ -190,6 +204,7 @@ class params_encoded_view_test
void
run()
{
testMembers();
testElements();
testCapacity();
testLookup();
Expand Down
15 changes: 15 additions & 0 deletions test/unit/params_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ class params_view_test
using pool_t = static_pool<4096>;
pool_t pa;

void
testMembers()
{
// operator=(params_view const&)
{
url_view u1;
url_view u2;
params_view p1 = u1.params();
params_view p2 = u2.params();
p2 = p1;
BOOST_TEST(p1.begin() == p2.begin());
}
}

void
testElements()
{
Expand Down Expand Up @@ -181,6 +195,7 @@ class params_view_test
void
run()
{
testMembers();
testElements();
testCapacity();
testLookup();
Expand Down
10 changes: 10 additions & 0 deletions test/unit/segments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class segments_test
void
testMembers()
{
// operator=(segments const&)
{
url u1;
url u2;
segments p1 = u1.segments();
segments p2 = u2.segments();
p2 = p1;
BOOST_TEST(p1.begin() == p2.begin());
}

url_view const u0 = parse_uri(
"x://y/path/to/the/file.txt?q#f").value();

Expand Down
10 changes: 10 additions & 0 deletions test/unit/segments_encoded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ class segments_encoded_test
void
testMembers()
{
// operator=(segments const&)
{
url u1;
url u2;
segments_encoded p1 = u1.encoded_segments();
segments_encoded p2 = u2.encoded_segments();
p2 = p1;
BOOST_TEST(p1.begin() == p2.begin());
}

url_view const u0 = parse_uri(
"x://y/path/to/the/file.txt?q#f").value();

Expand Down
8 changes: 8 additions & 0 deletions test/unit/segments_encoded_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ class segments_encoded_view_test
sv.begin() == sv.end());
}

// operator=(segments_view const&)
{
segments_encoded_view s1;
segments_encoded_view s2;
s1 = s2;
BOOST_TEST(s1.begin() == s2.begin());
}

// decoded
{
segments_encoded_view sev = parse_path(
Expand Down
8 changes: 8 additions & 0 deletions test/unit/segments_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ class segments_view_test
sv.begin() == sv.end());
}

// operator=(segments_view const&)
{
segments_view s1;
segments_view s2;
s1 = s2;
BOOST_TEST(s1.begin() == s2.begin());
}

// decoded
{
segments_view sv = parse_path(
Expand Down

0 comments on commit 78ffe4f

Please sign in to comment.