I am creating an component, generalization of a template. For creation must be used string identifier.
I am replacing:
#define MYCOMPONENT_CONSTANT_IDENTIFIER "ID value"
with
namespace myComponent
{
static const QString constant_identifier = "ID value"
}
to follow some codding standards (MISRA,...).
This should work regarding C++. And I checked it up at Constants-only header file C++.
This constant is defined in a header of a component "myComponent" and included in a header where my Indexer is initialized and component is created. This has not been changed at replacement time.
Replacement builds successfully, but fails on attempt to run. Segmentation fault hapends at:
template<>
inline void TMyIndexer::Init()
{
Map(...)
//before
//Map( ENUM_VAL, QSharedPointer<ITableFieldDefs>(new myComponent::TTableFieldDefs(MYCOMPONENT_CONSTANT_IDENTIFIER)) );
Map( ENUM_VAL, QSharedPointer<ITableFieldDefs>(new myComponent::TTableFieldDefs(myComponent::constant_identifier)) );
Map(...)
}
Where:
// TStaticFieldDefs<> implements ITableFieldDefs
typedef TStaticFieldDefs<myComponent::Fields> TTableFieldDefs;
//constructor
TStaticFieldDefs(QString id) : fId(id) {}
If I go up the the stack:
2.) qstring.h: inline QString::QString(const QString &other) : d(other.d) { Q_ASSERT(&other != this); d->ref.ref(); }
1.) qatomic_x86_64.h: inline bool QBasicAtomicInt::ref()
I suppose there something wrong in template generalization, inline definition in the constructor or something else I am not aware.
Any explanation is welcome.
I am out of ideas and am kindly asking for help.