[Bug c++/42272] derived template default argument

redi at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Dec 4 17:31:00 GMT 2009



------- Comment #4 from redi at gcc dot gnu dot org  2009-12-04 17:31 -------
(In reply to comment #3)
> the pb is on line :
> template < typename X , typename XT2 =T , typename X2 = typename XT2 :: 
> X > SMART(SMART<X> & value) : data(value.CastUp) {} ;


I don't understand, that line did not appear in your original report.

The error you originally posted is caused by the problem I pointed out.

> if i replace the line by
> > template < typename XT2 = T , typename X2 = typename XT2 :: X > 
> > SMART(SMART<X2> & value) : data(value.CastUp()) {} ;
> the constructor is find but i want an unherited constraint on X => X2 is 
> T::X

I have no idea what an unherited constraint is.

> sh-3.2$ gcc-4.5-20091126/bin/g++ -std=c++0x 
-c main.cc
> main.cc: In constructor ‘SMART<T>::SMART(SMART<X2>&) [with XT2 = B, X2 = 
> A, T = B]Â’:
> main.cc:45:13: instantiated from here
> main.cc:17:118: erreur: no matching function for call to 
> ‘SMART<A>::CastUp()’

CastUp is a template function but the template parameters cannot be deduced, so
you need to say value.CastUp<foo>() for some type "foo"

The bug is in your code, not GCC.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42272



More information about the Gcc-bugs mailing list