1

std::remove_pointerVS2012 で const volatile 関数ポインタを削除できません。これは vs2012 の buf ですか?

#include "iostream"
#include <typeinfo>
using namespace std;

int main()
{
    typedef void (* const cfunp_t) ();

    cout<<typeid(cfunp_t).name()<<endl;
    cout<<typeid(std::remove_pointer<cfunp_t>::type).name()<<endl;

    return 0;
}

vs2012 による出力ビルド:

void (__cdecl*)(void)
void (__cdecl*)(void)         // can not remove the const function pointer

mingw gcc 4.7.2 による出力ビルド

PFvvE
FvvE                          // can remove the const function pointer
4

1 に答える 1

0

ありがとう

テストコードを変更します:

#include "iostream"
#include <typeinfo>
using namespace std;

typedef void fun_t();
typedef fun_t* funp_t;
typedef const funp_t cfunp_t;

template<typename T>
void print_type()
{
    cout<<"unknow"<<endl;
}

template<>
void print_type<fun_t>()
{
    cout<<"is a function"<<endl;
}

template<>
void print_type<funp_t>()
{
    cout<<"is a function pointer"<<endl;
}

template<>
void print_type<cfunp_t>()
{
    cout<<"is a const function pointer"<<endl;
}

int main()
{
    print_type<cfunp_t>();
    print_type<std::remove_pointer<cfunp_t>::type>();

    return 0;
}

出力:

vs2012で

is a const function pointer

is a const function pointer     

gccで

is a const function pointer

is a function
于 2012-12-08T15:02:05.297 に答える