I came across this thread in which one of the upvoted answers suggested using constexpr
Since C++11 it can be done inside a class with constexpr.
class stat {
public:
// init inside class
static constexpr double inlineStaticVar = 22;
};
The variable can now be accessed with:
stat::inlineStaticVar
so in my case I have something like this
namespace LG_Wrapper
{
template <LG_Thread Thread>
class LG_Wrapper_API EffectApplication : public ktApplication
{
public:
static EffectApplication<Thread>& GetInstance();
protected:
.....
.....
static boost::recursive_mutex mResource;
}
}
so instead of attempting to initialize the variable outside the class I would like to do it inside the class like this
static constexpr boost::recursive_mutex mResource ;
However when I do this I get the following error
error: constexpr static data member 'mResource' must have an initializer|
Any suggestions ?
I am using Mingw GCC 64 bit.
Aucun commentaire:
Enregistrer un commentaire