[Bug c++/24847] Instantiates un-called copy constructor

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 2 09:14:06 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24847

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Ivan Godard from comment #0)
> The second constructor is intended to catch the case: "foo<T, 5, A>(foo<T,
> 0, A>", i.e. to convert an instance of foo with second argument zero to a
> foo with any other second argument.

You can define that as:

explicit    foo(const foo<T, 0, x>&);

Or:

template<int N, typename = std::enable_if_t<N == 0 && i != 0>
explicit    foo(foo<T, N, x>);

Or in C++20:

explicit    foo(foo<T, 0, x>) requires (i != 0);


More information about the Gcc-bugs mailing list