#menubar_google_AdSense?(ca-pub-3866735605426144,5022755888,728,90)

error: expected primary-expression before '>' token
template<typename T1>
class TemplateClass
{
public:
	template<typename T2> T2 func() { return T2(); }
};


template<typename T1, typename T2>
void templateFunction()
{
	TemplateClass<T1>	t;

}


void main()
{
	templateFunction<int,float>();
}
hoge.cpp: In function 'void templateFunction()':
hoge.cpp:xxx:xxx: error: expected primary-expression before '>' token
   t.func<T2>();
            ^
hoge.cpp:xxx:xxx: error: expected primary-expression before ')' token
   t.func<T2>();
              ^
t.func<T2>();
t.template func<T2>();


http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords

Hoge.h

class Hoge {
public:
	static func();
private:
	static std::vector<int>	m_vector;
	static std::bitset<16>	m_bitset;
	static int		m_array[16];
};

Hoge.cpp

Hoge::func()
{
	m_vector.clear();
	m_bitset.reset();
	m_array[0] = 0;
}



std::vector<int>	Hoge::m_vector;
std::bitset<16>	Hoge::m_bitset;
int			Hoge::m_array[16];

class FuncClassBase;
typedef void			(FuncClassBase::*FuncClassCallback)();
class FuncClassBase {
public:
	FuncClassCallback	m_callback;
};
 
class FuncClassA : public FuncClassBase {
	int		a;
public:
	FuncClassA()
	{
		a = 99;
	}
	void			funcA()
	{
		printf( "funcA %d\n", a );
	}
};
FuncClassBase	funcClassBase;
FuncClassA	funcClassA;


FuncClassCallback fc = static_cast<FuncClassCallback>(&FuncClassA::funcA);





funcClassA.m_callback = static_cast<FuncClassCallback>(&FuncClassA::funcA);
(funcClassA.*funcClassA.m_callback)();

class Hoge
{
public:
	void	(Hoge::*m_func)(void);
	void Call()
	{
		this->m_func = &Hoge::Func;

		(this->*m_func)();
	}
	void Func(void)
	{
		printf("func\n");
	}
};
error C3867: 'Hoge::Func': function call missing argument list; use '&Hoge::Func' to create a pointer to member
this->m_func = Func;
this->m_func = &Hoge::Func;

template <typename T1>
class Hoge1
{
  template< typename T2 >
  class Hoge2
  {

  };
};
template<typename T1>
template<typename T2>
int Hoge1<T1>::Hoge2<T2>::id_ = (sizeof(T1) * sizeof(T2));

TIPS

#menubar_google_AdSense?(ca-pub-3866735605426144,8440263803,728,90)

#menubar_google_AdSense?(ca-pub-3866735605426144,5022755888,728,90)


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2018-08-09 (木) 00:56:41