Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Useless constructor with const not_null<U>& parameter #535

Closed
gedamial opened this issue Jul 21, 2017 · 2 comments
Closed

Useless constructor with const not_null<U>& parameter #535

gedamial opened this issue Jul 21, 2017 · 2 comments
Assignees

Comments

@gedamial
Copy link

gedamial commented Jul 21, 2017

The constructor

constexpr not_null(const not_null<U>& other) : not_null(other.get())

was introduced in this commit with the purpose of facilitating the conversion, and thus avoiding a call to operator T()

The problem is the constness of the parameter, which prevents this code from taking advantage of this constructor

not_null<Derived*> pd { new Derived{} } ;    
not_null<Base*> pb {pd};

not_null<int*> _i1 { new int{5} };
not_null<int*> _i2 {_i1};

// This will call it
const not_null<Slider*> sl { new Slider{} };
not_null<Box*> box { sl };

Is there any reason in particular?

@xaxxon
Copy link
Contributor

xaxxon commented Apr 13, 2018

It seems fine to me: https://godbolt.org/g/zgK7zA

@hsutter hsutter self-assigned this Oct 28, 2020
@hsutter
Copy link
Collaborator

hsutter commented Dec 17, 2020

Sorry for the lag... following @xaxxon, I tried this repro and pasing the code seems to work: https://msvc.godbolt.org/z/hPM4E8
I'll close this as no-repro for now, but if I missed anything please let me know and we can reopen it. Thanks!

@hsutter hsutter closed this as completed Dec 17, 2020
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

No branches or pull requests

3 participants