-1

私は以下のコードをコンパイルしました:

typedef unsigned char uint8;

template <uint8 N> inline uint8 g(uint8 x) { return x > N ? 1 : 0; }

template <size_t stride, size_t boxsize, class T, class F>
  inline void boxfilt(size_t width, size_t size, T * inout, const F & f) {

  }
  template <class T> inline T self(const T & x) { return x; }
  template <size_t stride, size_t boxsize, class T>
  inline void boxfilt(size_t width, size_t size, T * inout) {
    return boxfilt<stride, boxsize>(width, size, inout, self<T>);
  }

int main(int argc, char* argv[])
{
    uint8 *out = NULL;
    boxfilt<3,4>(10,29,out,g<4>);

    return 0;
}

g ++コンパイラでは、正常に動作します。Visual Studio 2008コンパイラで同じコードをコンパイルしようとすると、次のエラーが表示されます。

Error   1   error C2780: 'void boxfilt(size_t,size_t,T *)' : expects 3 arguments - 4 provided   g:\testfjx\test\test.cpp    
Error   2   error C2784: 'void boxfilt(size_t,size_t,T *,const F &)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'    g:\testfjx\test\test.cpp    
Error   3   error C2784: 'void boxfilt(size_t,size_t,T *,const F &)' : could not deduce template argument for 'T *' from 'uint8 *'  g:\testfjx\test\test.cpp

この問題を解決するにはどうすればよいですか?

4

1 に答える 1

1

Visual C++ 2008 でもOKです。

VC++2008 と G++4.7.2 の両方がコードを受け入れ、VC++2005 が受け入れない場合、VC++2005 にバグがあるか、C++ 仕様を完全に実装していない可能性があります。

于 2013-03-11T11:27:47.033 に答える