Skip to content

Commit 76279f5

Browse files
committed
fix: incorrect noexcept in segments_base::front() and back()
1 parent 42c8fe7 commit 76279f5

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

include/boost/url/impl/segments_base.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ size() const noexcept
180180
inline
181181
std::string
182182
segments_base::
183-
front() const noexcept
183+
front() const
184184
{
185185
BOOST_ASSERT(! empty());
186186
return *begin();
@@ -189,7 +189,7 @@ front() const noexcept
189189
inline
190190
std::string
191191
segments_base::
192-
back() const noexcept
192+
back() const
193193
{
194194
BOOST_ASSERT(! empty());
195195
return *--end();

include/boost/url/segments_base.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class BOOST_SYMBOL_VISIBLE segments_base
244244
@return The first segment.
245245
*/
246246
std::string
247-
front() const noexcept;
247+
front() const;
248248

249249
/** Return the last segment
250250
@@ -277,7 +277,7 @@ class BOOST_SYMBOL_VISIBLE segments_base
277277
@return The last segment.
278278
*/
279279
std::string
280-
back() const noexcept;
280+
back() const;
281281

282282
/** Return an iterator to the beginning
283283

test/unit/segments_base.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,30 @@ struct segments_base_test
273273
}
274274
}
275275

276+
void
277+
testFrontBackNonEmpty()
278+
{
279+
// front()/back() on single-element segments
280+
// (noexcept removal regression)
281+
{
282+
auto rv = parse_uri_reference("/only");
283+
BOOST_TEST(rv.has_value());
284+
if(rv.has_value())
285+
{
286+
segments_base const& ps(
287+
segments_view(rv->encoded_segments()));
288+
BOOST_TEST_EQ(ps.front(), "only");
289+
BOOST_TEST_EQ(ps.back(), "only");
290+
}
291+
}
292+
}
293+
276294
void
277295
run()
278296
{
279297
testObservers();
280298
testRange();
299+
testFrontBackNonEmpty();
281300
testJavadoc();
282301
}
283302
};

0 commit comments

Comments
 (0)