[ create a new paste ] login | about

Link: http://codepad.org/90Bhin59    [ raw code | output | fork ]

C++, pasted on May 8:
#include "boost/static_assert.hpp"

template <class T, T, T> struct is_eq
{
	static const bool value = false;
};

template <class T, T t> struct is_eq<T, t, t>
{
	static const bool value = true;
};

void fack(void);

template <void(&F)(void) = fack> struct hoge
{
	void fuga(void)
	{
		BOOST_STATIC_ASSERT((!is_eq<void(&)(void), F, fack>::value));
	}
};

void good(void);

int main(void)
{
	hoge<good> hg;
	hoge<fack> hf;
	
//	hg.fuga();
	hf.fuga();

	return 0;
}


Output:
1
2
3
4
t.cpp: In member function 'void hoge<F>::fuga() [with void (& F)() = ((void (&)())fack)]':
t.cpp:32:   instantiated from here
Line 19: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' 
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: