I was recently modifying some code, and found a pre-existing bug on one line within a function:
std:;string x = y;
This code still compiles and has been working as expected.
The string definition works because this file is using namespace std;
, so the std::
was unnecessary in the first place.
The question is, why is std:;
compiling and what, if anything, is it doing?
Basically STD is short for standard (in c++ only. If your doctor mentions it it's definitely not standard) and it's just a set of data types and commands prepackaged with the language. The reason you have to include them is because they're actually .c and .h files tucked into the compiler.
Class template std::function is a general-purpose polymorphic function wrapper. Instances of std::function can store, copy, and invoke any Callable target -- functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members.
All C++ standard library names, including the C library names, if you include them, are defined in the namespace std . This means that you must qualify all the library names using one of the following methods: Specify the standard namespace, for example: std::printf("example\n");
It doesn't affect the runtime performance at all.
std:
its a label, usable as a target for goto
.
As pointed by @Adam Rosenfield in a comment, it is a legal label name.
C++03 §6.1/1:
Labels have their own name space and do not interfere with other identifiers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With