2017-01-04 4 views
0

私の理解では、新しいものオペレータである私が使用しているパラメータを使用して宣言するとき...(テンプレート化することはできません(size_tの)テンプレート友人オペレーター新しいMINGW32

以下は、他のプラットフォーム上でMINGW32とDUE Arduinoの上OKコンパイルではなく、例えばLinuxの。

はMINGW32にバグがあるのか​​、これはあまりにも他のターゲット上で許可する必要があります?私はMingwを最新のものに更新

class t_other_class 
{ 
    public: 

    // This form of operator new is ***NOT*** allowed to be templated. 
    void*     operator new  (size_t   arg1 ) ; 

    // This form of operator new CAN be templated, and IS. 
    template<typename TF> 
    void*     operator new  (size_t   arg1 
              , int    arg2 
             ) ; 

    // This form of operator new CAN be templated, but IS NOT. 
    void*     operator new  (size_t   arg1 
              , int    arg2 
              , int    arg3 
             ) ; 
}; 



template <typename TCLASS> 
class t_class 
{ 
    public: 

    // This form of operator new can NOT be templated, but is ALLOWED in mingw32 
    template<typename TF> // THIS SHOULD GENERATE AN ERROR 
    friend 
    void* t_other_class::operator new (size_t   arg1 ) ; 


    // Examples of templating.. 
    template<typename TF> 
    friend /* IS templated in t_other_class*/ 
    void* t_other_class::operator new (size_t   arg1 
              , int    arg2 
             ) ; 
    template<typename TF> 
    friend /* IS NOT templated in t_other_class*/ 
    void*     operator new (size_t   arg1 
              , int    arg2 
              , int    arg3 
             ) ; 
} ; 


/* 
OK 
==== 
windows 
GNU C++ (GCC) version 4.8.2 (i686-w64-mingw32) 
DUE 
gcc version 4.8.3 20140228 (release) [ARM/embedded-4_8-branch revision 208322] (GNU Tools for ARM Embedded Processors) 

Error 
==== 
linux 
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) version 4.8.4 (i686-linux-gnu) 
*/ 
+0

"mingw32"とはmingw32-gccを意味していますか? "linux"には、複数のLinux用コンパイラがあります。 –

+0

コンパイラのバージョンを表示するために私の質問を編集しました –

+0

異なるターゲットに加えて、gccの異なるマイナーバージョン(すべて古いもの)を比較しています。現在のリリース(5.4または6.3)を入手してください。 –

答えて

0

、それが正しく、他の通り(テンプレート宣言の悪用を報告しますコンパイラ)。oldのように見えるmingwのバージョンが問題でした。

関連する問題