From my understanding, if you declare any sort of
constructors, (excluding copy ctor), the default will not be
included by default. Is this correct?
No. Any user defined constructor, including a copy constructor,
inhibits automatic generation of the default constructor.
class Foo{
public:
Foo(int); // no Foo() is included, i believe.
};
Under which conditions a default copy ctor and default
assignment operator are not included?
A copy constructor is generated any time there is no user
declared copy construtor. A copy assignment operator is
generated any time there is no user declared copy assignment
operator. A copy constructor for a class X is a non-template
constructor having an X&, X const&, X volatile& or X const
volatile& as its first parameter, and having default arguments
for all other parameters, if any. A copy assignment operator is
a non-template assignment operator having an X, X&, X const&, X
volatile& or X const volatile& as parameter. Note that:
-- a member function template template is never considered a
copy constructor or copy assignment operator (and thus will
never prevent the compiler from generating one);
-- you can declare more than one copy constructor or copy
assignment operator; and
-- operator overload resolution is *always* used when deciding
what constructor to call, even when "copying", and operator
overload resolution can choose a constructor which is not a
copy constructor to copy.
Consider:
class C
{
public:
template< typename T >
C( T& other ) ;
} ;
The compiler will generate a C::C( C const& ) copy constructor,
which will participate in operator overload resolution:
C c1 ;
C c2( c1 ) ; // calls the template constructor.
C c3( C() ) ; // calls the compiler generated copy
// constructor.