- Template specialization works with g but not with Visual C
- unsigned int GetCharacterSize() const;
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2440: 'specialization' : cannot convert from 'unsigned int (__thiscall ag::ui::TextArea::* )(void) const' to 'unsigned int *(__thiscall ag::ui::TextArea::* const )(void) const'
- 2> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2973: 'luaU_get' : invalid template argument 'unsigned int (__thiscall ag::ui::TextArea::* )(void) const'
- 2> C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcexternLuaWrapperLuaWrapperUtil.hpp(147) : see declaration of 'luaU_get'
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2440: 'specialization' : cannot convert from 'unsigned int (__thiscall ag::ui::TextArea::* )(void) const' to 'unsigned int *ag::ui::TextArea::* const '
- 2> There is no context in which this conversion is possible
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2973: 'luaU_get' : invalid template argument 'unsigned int (__thiscall ag::ui::TextArea::* )(void) const'
- 2> C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcexternLuaWrapperLuaWrapperUtil.hpp(131) : see declaration of 'luaU_get'
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2440: 'specialization' : cannot convert from 'unsigned int (__thiscall ag::ui::TextArea::* )(void) const' to 'unsigned int ag::ui::TextArea::* const '
- 2> There is no context in which this conversion is possible
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2973: 'luaU_get' : invalid template argument 'unsigned int (__thiscall ag::ui::TextArea::* )(void) const'
- 2> C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcexternLuaWrapperLuaWrapperUtil.hpp(123) : see declaration of 'luaU_get'
- 2>C:UsersAlexDocumentsVisual Studio 2010ProjectsgamedevsrcgameluaLuaTextArea.cpp(103): error C2440: 'initializing' : cannot convert from 'overloaded-function' to 'lua_CFunction'
- 2> None of the functions with this name in scope match the target type
- #include <iostream>
- struct TextArea
- {
- unsigned GetCharacterSize() const { return 0; }
- };
- template<typename T, typename U, U (T::*)() const>
- int foo()
- {
- return 1;
- }
- template<typename T, typename U, U* (T::*)() const>
- int foo()
- {
- return 2;
- }
- int main()
- {
- std::cout << foo<TextArea, unsigned, &TextArea::GetCharacterSize>() << 'n';
- }
- #include <iostream>
- struct WithPointer
- {
- unsigned* GetCharacterSize() const { return nullptr; }
- };
- struct WithoutPointer
- {
- unsigned GetCharacterSize() const { return 0u; }
- };
- template<bool UsePointerImplB>
- struct kludge
- {
- template<typename T, typename U, U (T::*Getter)() const>
- static int foo() { return 1; }
- };
- template<>
- struct kludge<true>
- {
- template<typename T, typename U, U* (T::*Getter)() const>
- static int foo() { return 2; }
- };
- int main()
- {
- std::cout
- << kludge<false>::foo<WithoutPointer, unsigned, &WithoutPointer::GetCharacterSize>() << 'n'
- << kludge<true>::foo<WithPointer, unsigned, &WithPointer::GetCharacterSize>() << 'n';
- }
- #include <iostream>
- struct FooBar
- {
- int Foo( void ) const
- {
- std::cout << "FooBar::Foo()" << std::endl;
- return ( 0 );
- }
- int * Bar( void ) const
- {
- std::cout << "FooBar::Bar()" << std::endl;
- return ( 0 );
- }
- };
- template< typename P00, typename P01, P01(P00::*p02)( void ) const >
- void Call()
- {
- P00 lT;
- ( lT.*p02 )();
- }
- int main( void )
- {
- Call< FooBar, int, &FooBar::Foo > ();
- Call< FooBar, int*, &FooBar::Bar > ();
- return( 0 );
- }
- FooBar::Foo()
- FooBar::Bar()