⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boost_no_is_abstract.ipp

📁 C++的一个好库。。。现在很流行
💻 IPP
字号:
//  (C) Copyright John Maddock and Dave Abrahams 2002. 
//  Use, modification and distribution are subject to the 
//  Boost Software License, Version 1.0. (See accompanying file 
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/config for most recent version.

//  MACRO:         BOOST_NO_IS_ABSTRACT
//  TITLE:         is_abstract implementation technique
//  DESCRIPTION:   Some compilers can't handle the code used for is_abstract even if they support SFINAE.


namespace boost_no_is_abstract{

template<class T>
struct is_abstract_test
{
   // Deduction fails if T is void, function type, 
   // reference type (14.8.2/2)or an abstract class type 
   // according to review status issue #337
   //
   template<class U>
   static double check_sig(U (*)[1]);
   template<class U>
   static char check_sig(...);

#ifdef __GNUC__
   enum{ s1 = sizeof(is_abstract_test<T>::template check_sig<T>(0)) };
#else
   enum{ s1 = sizeof(check_sig<T>(0)) };
#endif
    
   enum{ value = (s1 == sizeof(char)) };
};

struct non_abstract{};
struct abstract{ virtual void foo() = 0; };

int test()
{
   return is_abstract_test<non_abstract>::value == is_abstract_test<abstract>::value;
}

}








⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -