Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/147.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ decltype未在mingw g+中声明+;4.7.2_C++_C++11_G++_Mingw - Fatal编程技术网

C++ decltype未在mingw g+中声明+;4.7.2

C++ decltype未在mingw g+中声明+;4.7.2,c++,c++11,g++,mingw,C++,C++11,G++,Mingw,出于某种原因,在mingw上尝试用G++编译以下代码时 #include <iostream> #include <string> #include <cctype> int main( int argc, char **argv ) { std::string s( "Hello, World!" ); decltype( s.size( ) ) punct_cnt = 0; for ( auto c : s ) {

出于某种原因,在mingw上尝试用G++编译以下代码时

#include <iostream>
#include <string>
#include <cctype>

int main( int argc, char **argv )
{
    std::string s( "Hello, World!" );

    decltype( s.size(  ) ) punct_cnt = 0;

    for ( auto c : s )
    {
        if ( ispunct( c ) )
            ++punct_cnt;
    }

    std::cout << punct_cnt << " punctuation characters in " << s << std::endl;

    return 0;
}

我已经检查过了,g++编译器的版本是4.7.2,除了将
decltype
更改为
std::string::size\u type

decltype
是c++11的一个特性之外,还有谁知道我如何解决这个问题。您需要这样调用gcc

g++ -std=c++11

@ctor尽量避免decltype,它并不像看上去那么好,基本上,当涉及到decltype时,标准并不能保证什么都没有。
g++ -std=c++11