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

📄 indirect_traits_test.cpp

📁 boost库提供标准的C++ API 配合dev c++使用,功能更加强大
💻 CPP
字号:
//#include <stdio.h>
#include <cassert>
#include <boost/python/detail/indirect_traits.hpp>

//#define print(expr) printf("%s ==> %s\n", #expr, expr)

// not all the compilers can handle an incomplete class type here.
struct X {};

int main()
{
    using namespace boost::python::detail;

    typedef void (X::*pmf)();

    assert(is_reference_to_function<int (&)()>::value);
    assert(!is_reference_to_function<int (*)()>::value);
    assert(!is_reference_to_function<int&>::value);
    assert(!is_reference_to_function<pmf>::value);
    
    assert(!is_pointer_to_function<int (&)()>::value);
    assert(is_pointer_to_function<int (*)()>::value);
    assert(!is_pointer_to_function<int (*&)()>::value);
    assert(!is_pointer_to_function<int (*const&)()>::value);
    assert(!is_pointer_to_function<pmf>::value);
    
    assert(!is_reference_to_function_pointer<int (&)()>::value);
    assert(!is_reference_to_function_pointer<int (*)()>::value);
    assert(!is_reference_to_function_pointer<int&>::value);
    assert(is_reference_to_function_pointer<int (*&)()>::value);
    assert(is_reference_to_function_pointer<int (*const&)()>::value);
    assert(!is_reference_to_function_pointer<pmf>::value);

    assert(is_reference_to_pointer<int*&>::value);
    assert(is_reference_to_pointer<int* const&>::value);
    assert(is_reference_to_pointer<int*volatile&>::value);
    assert(is_reference_to_pointer<int*const volatile&>::value);
    assert(is_reference_to_pointer<int const*&>::value);
    assert(is_reference_to_pointer<int const* const&>::value);
    assert(is_reference_to_pointer<int const*volatile&>::value);
    assert(is_reference_to_pointer<int const*const volatile&>::value);
    assert(!is_reference_to_pointer<pmf>::value);
    
    assert(!is_reference_to_pointer<int const volatile>::value);
    assert(!is_reference_to_pointer<int>::value);
    assert(!is_reference_to_pointer<int*>::value);

    assert(!is_reference_to_const<int*&>::value);
    assert(is_reference_to_const<int* const&>::value);
    assert(!is_reference_to_const<int*volatile&>::value);
    assert(is_reference_to_const<int*const volatile&>::value);
    
    assert(!is_reference_to_const<int const volatile>::value);
    assert(!is_reference_to_const<int>::value);
    assert(!is_reference_to_const<int*>::value);

    assert(is_reference_to_non_const<int*&>::value);
    assert(!is_reference_to_non_const<int* const&>::value);
    assert(is_reference_to_non_const<int*volatile&>::value);
    assert(!is_reference_to_non_const<int*const volatile&>::value);
    
    assert(!is_reference_to_non_const<int const volatile>::value);
    assert(!is_reference_to_non_const<int>::value);
    assert(!is_reference_to_non_const<int*>::value);
    
    assert(!is_reference_to_volatile<int*&>::value);
    assert(!is_reference_to_volatile<int* const&>::value);
    assert(is_reference_to_volatile<int*volatile&>::value);
    assert(is_reference_to_volatile<int*const volatile&>::value);
    
    assert(!is_reference_to_volatile<int const volatile>::value);
    assert(!is_reference_to_volatile<int>::value);
    assert(!is_reference_to_volatile<int*>::value);

    assert(!is_reference_to_class<int>::value);
    assert(!is_reference_to_class<int&>::value);
    assert(!is_reference_to_class<int*>::value);
    
    assert(!is_reference_to_class<X>::value);
    assert(is_reference_to_class<X&>::value);
    assert(is_reference_to_class<X const&>::value);
    assert(is_reference_to_class<X volatile&>::value);
    assert(is_reference_to_class<X const volatile&>::value);
    
    assert(!is_pointer_to_class<int>::value);
    assert(!is_pointer_to_class<int*>::value);
    assert(!is_pointer_to_class<int&>::value);
    
    assert(!is_pointer_to_class<X>::value);
    assert(!is_pointer_to_class<X&>::value);
    assert(is_pointer_to_class<X*>::value);
    assert(is_pointer_to_class<X const*>::value);
    assert(is_pointer_to_class<X volatile*>::value);
    assert(is_pointer_to_class<X const volatile*>::value);

    assert(is_reference_to_member_function_pointer<pmf&>::value);
    assert(is_reference_to_member_function_pointer<pmf const&>::value);
    assert(is_reference_to_member_function_pointer<pmf volatile&>::value);
    assert(is_reference_to_member_function_pointer<pmf const volatile&>::value);
    assert(!is_reference_to_member_function_pointer<pmf[2]>::value);
    assert(!is_reference_to_member_function_pointer<pmf(&)[2]>::value);
    assert(!is_reference_to_member_function_pointer<pmf>::value);
    
    return 0;
}

⌨️ 快捷键说明

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