The compiler complains about the wrong number of template arguments, even if it is correct in the boost library file

The boost library has a has_new_operator.hpp file. I get the following error when I complicate a file using GCC 4.3.1

type_traits / has_new_operator.hpp: 45: error: invalid template number arguments (1, must be 2) type_traits / has_new_operator.hpp: 24: error: for "template struct boost :: detail :: test"

on line 24, it expects 2 arguments, and this is what was passed on line 42. Also, if you observe line 31, the same thing was 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: 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 ); 
+4
source share
2 answers

It seems that std::size_t not showing up in your current code. You can try #include<iostream> before this code.

Imitation of your mistake .

Fixing your mistake .

+2
source

The problem is that std :: nothrow_t (line: 43) is not displayed. I included a file that contained nothrow_t in the std namespace and it worked fine. Thank you for your responses.

0
source

All Articles