fork download
#include 
#include 

struct A
{
    A() { std::cout << "A:: default constructor\n" ; }

    A( const char* aa ) : a(aa) { std::cout << "A:: one arg constructor\n" ; }

    A ( const A& that ) : a(that.a) { std::cout << "A:: copy constructor\n" ; }

    A& operator= ( const A& that )
    {
        std::cout << "A:: assignment\n" ;
        a = that. a ;
        return *this ;
    }

    std::string a ;
};

#include 

int main()
{
    std::map< int, A > map ;

    {
        // possibly only if A is DefaultConstructible
        map[1] = "hello world" ;
        /*
        A:: one arg constructor
        A:: default constructor
        A:: assignment
        */
    }
    std::cout << "------------------------\n" ;
    {
        // possibly only if A is CopyConstructible
        map.insert( { 2, "hello again" } ) ;
        /*
        A:: one arg constructor
        A:: copy constructor
        */
    }
    std::cout << "------------------------\n" ;
    {
        map.emplace( 3, "hello for a third time" ) ;
        // A:: one arg constructor
    }
}
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
A:: one arg constructor
A:: default constructor
A:: assignment
------------------------
A:: one arg constructor
A:: copy constructor
------------------------
A:: one arg constructor