Template class implicit copy constructor issues

Posted by Nate on Stack Overflow See other posts from Stack Overflow or by Nate
Published on 2010-04-17T01:03:15Z Indexed on 2010/04/17 1:13 UTC
Read the original article Hit count: 246

Filed under:
|

Stepping through my program in gdb, line 108 returns right back to the calling function, and doesn't call the copy constructor in class A, like (I thought) it should:

template <class S> class A{
    //etc...
    A( const A & old ){
        //do stuff...
    }
    //etc...
};

template <class T> class B{
    //etc...
    A<T> ReturnsAnA(){
        A<T> result;
        // do some stuff with result
        return result; //line 108
    }
    //etc...
};

Any hints? I've banged my head against the wall about this for 4 hours now, and can't seem to come up with what's happening here.

© Stack Overflow or respective owner

Related posts about templates

Related posts about copy-constructor