struct A
{
// clang 3.8 error : cannot combine with previous 'static' declaration specifier
static mutable int n;
};
私は、static mutable int n;
は明確なセマンティクスを持っていることがあると思います。 なぜC++で許可されていないのですか?なぜ静的可変int n;ですか? C++では許可されていませんか?
更新:
別の例clear semantics
を示す:
class SharedValue
{
public:
void Set(int n)
{
std::lock_guard lock(_mtx);
_n = n;
}
int Get() const
{
std::lock_guard lock(_mtx);
//
// _mtx should be mutable,
// because this is in const member function
//
return _n;
}
private:
static mutable std::mutex _mtx;
int _n;
};
_ "場合によっては明確なセマンティクスを持っています" _これらのことを詳しく教えてください。私はあなたが何を意味するかは分かりません。 'static'は' const'や 'mutable'とは何の関係もありません。 –