4255471e   
   From: daniel.kruegler@googlemail.com   
      
   On 2011-09-21 15:29, ptyxs wrote:   
   > On 21 sep, 00:10, Daniel Krügler   
   > wrote:   
   >> Am 20.09.2011 15:42, schrieb ptyxs:   
   >> It is unspecified, whether this program produces a diagnostic, but for   
   >> different reasons as you expect. The reason is the lack of the std:: in   
   >> front of sqrt after making it available via the cmath header (see   
   >> [using.linkage] p2). Once fixed this way, this program should be   
   >> well-formed in C++11 based on [c.math] p11:   
   >   
   > Thanks to all for the interesting answers.   
   >   
   > In fact, such a program as the following (with std:: in front of   
   > sqrt) :   
   >   
   >   
   > #include   
   > #include   
   >   
   >   
   > int main()   
   > {   
   > int a = 25;   
   > std::cout<< std::sqrt(a)<< std::endl;   
   > }   
   >   
   >   
   > doesn't compile (as expected), and outputs the following error   
   > message :   
      
   Why do you say that this failure is expected? It is not.   
      
   > [toto@localhost ~]$ g++ -std=c++0x -Wall -pedantic sqrtmy3.cpp   
   > sqrtmy3.cpp: In function ‘int main()’:   
   > sqrtmy3.cpp:8:18: error: ‘sqrt’ is not a member of ‘std’   
   > sqrtmy3.cpp:8:18: note: suggested alternative:   
   > /usr/include/bits/mathcalls.h:157:1: note: ‘sqrt’   
      
   This must be a defect in the library implementation, because it violates   
   [headers] p5:   
      
   "In the C++ standard library, however, the declarations (except for   
   names which are defined as macros in C) are within namespace scope (3.3.6) of   
   the namespace std. It is unspecified whether these names are first declared   
   within the global namespace scope and are then injected   
   into namespace std by explicit using-declarations (7.3.3)."   
      
   But sqrt is no macro in the C library, therefore std::sqrt must be available   
   when including .   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|