I am getting the following error message:
main.cpp: No viable constructor copying variable of type 'communal'
On the second constructor,communal( const T& instance )
, the following message is given:
data.h: Candidate constructor not viable: no known conversion from 'communal' to 'const int &' for 1st argument
The conversion appears to be going backwards. I want the conversion to go from const int& to communal. Is there a way to get implicit conversion to work here? Thanks for any help.
main.cpp:
communal<int> test_communal1 = 123; // Implicit initialization triggers error
data.cpp:
template<typename T>
struct communal : general_type::communal<T>
{
using super = general_type::communal<T>;
communal() : super( nullptr ) {}
communal( const T& instance ) : super( new T( instance ) ) {}
communal( const T* instance ) : super( new T( instance ) ) {}
communal( communal<T>& instance ) : super( instance ) {}
communal( communal<T>* instance ) : super( instance ) {}
~communal()
{
this->counter->deallocate( [this]()
{
delete this->counter;
delete this->instance;
});
}
};
Aucun commentaire:
Enregistrer un commentaire