开发者

Compiler complains about wrong number of template arguments even if its correct in a boost library file

There is a file in the boost library called has_new_operator.hpp. I am getting the following error when i complile the file using GCC 4.3.1

type_traits/has_new_operator.hpp:45: error: wrong number of template arguments (1, should be 2) type_traits/has_new_operator.hpp:24: error: provided for 'template struct boost::detail::test'

as per line 24 it expects 2 arguments and that is what is been passed in line 42. Also if you observe line 31, the same has been done but the compiler does not complain about it.

21: namespace boost {
22: namespace detail {
23: template <class U, U x> 
24:    struct test;
25:
26: template <typename T>
27: struct has_new_operator_impl {
28开发者_C百科:    template<class U>
29:    static type_traits::yes_type check_sig1(
30:        U*, 
31:        test<
32:        void *(*)(std::size_t),
33:            &U::operator new
34:        >* = NULL
35:    );
36:    template<class U>
37:    static type_traits::no_type check_sig1(...);

39:    template<class U>
40:    static type_traits::yes_type check_sig2(
41:        U*, 
42:        test<
43:        void *(*)(std::size_t, const std::nothrow_t&),
44:            &U::operator new
45:        >* = NULL
    );


It seems that std::size_t is not visible to your current code. You can try #include<iostream> before this code.

Simulating your error.

Fixing your error.


The problem is with std::nothrow_t (line:43) being not visible. I included a file which contained nothrow_t in the std namespace and it worked fine. Thanks for your responses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜