Is there a way to instantiate an object and have a string member take the object's name? I would also not mind for a gcc builtin.
Here's an example:
#include <string>
class A
{
std::string obj_name_ = /* set to the objects name (very_descriptive_name) somehow */ ;
};
A very_descriptive_name; // naming the *object* should be enough, do we really have to initialize the string with exactly the same name?
The string is later used for recognisability.
A& a_completely_different_name = very_descriptive_name;, now the two refer to the same object via completely different names. You can doA a("very descriptive name");very_descriptive_name.str()?