コンストラクタで static

次の様なクラスで,VC 14 ではコンストラクタ内の static を呼出した段階で止まってしまう?
VC 12 まででは OK .


  class T_static {
  public:
    T_static () ;
    } ;
  T_static::T_static ()
  {
    {
      static T_static root ;
      }
    std::tout << _T("T_static") << std::endl ;
    }


コンストラクタの初期化動作を次の様に変更.
  T_static::T_static ()
  {
    static bool Initialized = false ;
    if (!Initialized) {
      Initialized = true ;
      static T_static root ;
      }
    std::tout << _T("T_static") << std::endl ;
    }

カテゴリー: VC, メモ パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です