Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: ‘defaultfloat’ is not a member of ‘std’

Tags:

c++11

debian

std::defaultfloat doesn't seem to be defined in GCC, despite being in the standard (I think it's §27.5.6.4). I've isolated it to this simple program:

// test.cpp
#include <iostream>                                                             

int main()                                                                      
{                                                                               
    std::cout << std::defaultfloat << 1.3;                                      
    return 0;                                                                   
}

This compiles in VC++11. I tried compiling this with g++ 4.7.2 and g++ 4.9.0 using both of these commands:

g++ test.cpp g++ test.cpp -std=c++11

I also tried an online compile on GCC 4.8.1 here, always with the same result:

user@office-debian:~/Documents/test$ g++ test.cpp -std=c++11
test.cpp: In function ‘int main()’:
test.cpp:5:15: error: ‘defaultfloat’ is not a member of ‘std’
  std::cout << std::defaultfloat << 1.3;

Why am I getting this error?

like image 307
quant Avatar asked Apr 27 '14 05:04

quant


1 Answers

GCC libstdc++ just doesn't support these C++11 manipulators in any of the versions you've compiled against. A patch was submitted exactly one month ago

like image 200
Mike Kinghan Avatar answered Nov 12 '22 11:11

Mike Kinghan