Skip to content

Conversation

@alandefreitas
Copy link
Member

@alandefreitas alandefreitas commented Jan 3, 2023

fix #648, #650

@cppalliance-bot
Copy link

@alandefreitas alandefreitas force-pushed the issue_648_implicit_ctor branch from 3579b27 to ad7a93a Compare January 3, 2023 21:31
@alandefreitas alandefreitas linked an issue Jan 3, 2023 that may be closed by this pull request
@alandefreitas alandefreitas changed the title parsing constructors are implicit string constructors and conversions are implicit Jan 3, 2023
@cppalliance-bot
Copy link

@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Merging #649 (646bf7b) into develop (af8aa03) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #649      +/-   ##
===========================================
- Coverage    96.88%   96.87%   -0.02%     
===========================================
  Files          147      147              
  Lines         7924     7929       +5     
===========================================
+ Hits          7677     7681       +4     
- Misses         247      248       +1     
Impacted Files Coverage Δ
include/boost/url/url_view.hpp 100.00% <100.00%> (ø)
include/boost/url/url_view_base.hpp 100.00% <100.00%> (ø)
include/boost/url/impl/url_view.ipp 91.66% <0.00%> (-4.17%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af8aa03...646bf7b. Read the comment docs.

@alandefreitas
Copy link
Member Author

@klemens-morgenstern is this ok?

#endif
>
url_view(
String const& s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now you have two overloads which are the same no? string_view is convertible to string_view. Does this compile?

string_view s = "";
url_view u( s );

Isn't this ambiguous?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works fine. It's exactly the same pattern as pct_string_view:

  • the compiler picks up the string_view overload because it's not templated
  • the compiler picks up the String overload when it's convertible to string_view but not string_view

If all things were directly convertible to string_view, we would just need the first overload. But we have two implicit conversion steps sometimes.

I included your test to ensure that's OK. The test is somewhat redundant because most other tests already construct these url_views from string_views, but that's not explicit..

// url_view(string_view) no ambiguous
{
string_view s = "";
BOOST_TEST_NO_THROW(url_view( s ));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the template overload has a lower priority than the string_view overload?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

@cppalliance-bot
Copy link

@klemens-morgenstern
Copy link

I would have thought a ctor from stringview is eny, but I will trust your judgement. looks good.

@cppalliance-bot
Copy link

@alandefreitas alandefreitas merged commit 61b830a into boostorg:develop Jan 19, 2023
@alandefreitas alandefreitas deleted the issue_648_implicit_ctor branch July 24, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conversions to string_view should be implicit parsing ctors should be implicit

4 participants