// ---------------------------------------------------------------------- // // methspec.cc - Do we support method specialization? // // History: // 23-Sep-1999 WEB Initial draft, adapted from STLport // 24-Sep-1999 WEB Employ symbolic results // 25-Apr-2001 WEB s//"ISOcxx\/ISOcxxSyntax.hh"/ // // ---------------------------------------------------------------------- #include "ISOcxx/ISOcxxSyntax.hh" // ---------------------------------------------------------------------- // define generic template class: // ---------------------------------------------------------------------- const int GENERAL( 1 ); template< class T > struct C { int f() { return GENERAL; } }; // C // ---------------------------------------------------------------------- // specialize the template's member function: // ---------------------------------------------------------------------- #if ! defined DEFECT_NO_METHOD_SPECIALIZATION /* compliant */ const int SPECIALIZED( 2 ); template<> int C::f() { return SPECIALIZED; } #else /* ------------------------------------ defective */ const int SPECIALIZED( GENERAL ); #endif /* ------------------------------------ */ // ---------------------------------------------------------------------- // test driver: // ---------------------------------------------------------------------- int main() { return C().f() == GENERAL && C< int >().f() == SPECIALIZED ? 0 : 1 ; } // main()