c++03

How do I get the member function pointer of a destructor?

[亡魂溺海] 提交于 2019-11-30 17:27:45
问题 Assume I have struct X { ~X() {} }; What's the type of and how do I get the member function pointer of X::~X() in C++03? I don't want to actually call it, just use in SFINAE to figure if there exists a destructor for a given type. 回答1: You can't get the function pointer of a destructor nor a constructor. Nevertheless a destructor always exist for a type, and you can't detect if its private with as access specifiers are not considered by SFINAE . On the subject of invoking what would be the

Perfect Forwarding in C++03

巧了我就是萌 提交于 2019-11-30 10:55:02
If you have this function template<typename T> f(T&); And then try to call it with, let's say an rvalue like f(1); Why isn't T just be deduced to be const int, making the argument a const int& and thus bindable to an rvalue? GManNickG This is mentioned as a potential solution in the document I linked in the recent C++0x forwarding question . It would work fairly well, but it breaks existing code. Consider (straight from the document): template<class A1> void f(A1 & a1) { std::cout << 1 << std::endl; } void f(long const &) { std::cout << 2 << std::endl; } int main() { f(5); // prints 2 under

Is this a singular iterator and, if so, can I compare it to another one?

谁都会走 提交于 2019-11-30 08:26:50
问题 I always thought that a "singular" iterator was one that has been default-initialised, and these could serve as comparable sentinel values of sorts: typedef std::vector<Elem>::iterator I; I start = I(); std::vector<Elem> container = foo(); for (I it = container.begin(), end = container.end(); it != end; ++it) { if ((start == I()) && bar(it)) { // Does something only the first time bar(it) is satisfied // ... start = it; } } But this answer suggests not only that my definition of "singular" is

Is C++03 a new version of the C++ Standard or just a Technical Corrigendum (TC) of C++98?

痴心易碎 提交于 2019-11-30 06:34:26
I'm pretty sure I read on an authoritative source somewhere (I believe it was on the WG21 pages) that C++03 was not a technical corrigendum of C++98 but that it was a new release of the C++ Standard. But nontheless I see only -std=c++98 switch in GCC and others compilers and Alf P Steinbach made a few comments hinting at that it may indeed be a TC of C++98. So when I'm writing about "C++03", does it suffice mentioning C++98? As a related question, is it even wrong to use the term "C++03"? Because I think if it is really C++98 TC1, then it seems to me it cannot be called C++03. Just as I've

Why do inline functions have external linkage by default?

只愿长相守 提交于 2019-11-30 06:29:35
The standard says that given a declaration of inline void foo(); that foo is an inline function with external linkage (because by default all function declarations have external linkage). This strikes me as odd. because the one definition rule section 3.2 (in both C++03 and C++11) say: 3 ... An inline function shall be defined in every translation unit in which it is used. 5 There can be more than one definition of a[n] ... inline function with external linkage (7.1.2) ... Given such an entity named D defined in more than one translation unit ... each definition of D shall consist of the same

Does “potentially-evaluated” means the same as “odr-used” in C++03?

可紊 提交于 2019-11-30 05:11:28
问题 Given an example: #include <iostream> class A { public: static const int numberOfWheels = 4; }; // const int A::numberOfWheels; int main() { std::cout << A::numberOfWheels << std::endl; } Is it formally undefined behavior( UB ) since A::numberOfWheels is used without its definition? (see also here). As C++03 states: The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition shall not contain an initializer. I found that definition of

How can I deploy a C++11 program (with dependencies) on CentOS 6, whose GCC is C++03?

蓝咒 提交于 2019-11-30 04:52:12
GCC is great with ABI-compatibility as long as you use the same C++ standard [ 1 ]. But it strikes me that if a shared library compiled by GCC 4.3 in C++03 mode exposes, say, a std::string , this is going to be a different std::string than that understood by an executable compiled by GCC 4.8 in C++11 mode. The reason I ask is that I am planning to deploy a program compiled by GCC 4.8 in C++11 mode on CentOS 6, whose maximum packaged GCC is 4.3... and some of the shared libraries (be they third-party C++ libraries or more system-level stuff) will presumably therefore all be C++03. But if that

What is the C++03 memory model for concurrency?

﹥>﹥吖頭↗ 提交于 2019-11-29 20:37:57
What is the memory model for concurrency in C++03? (And, does C++11 change the memory model to support concurrency better?) bltxd The C++ memory model is the specification of when and why physical memory is read/written with respect to C++ code. Until the next C++ standard, the C++ memory model is the same as C. In the C++0x standard, a proper memory model for multithreading is expected to be included (see here ), and it will be part possibly of the next revision of the C standard, C1X. The current one is rudimentary: it only specifies the behavior of memory operations observable by the

Is `double` guaranteed by C++03 to represent small integers exactly?

好久不见. 提交于 2019-11-29 13:24:54
Does the C++03 standard guarantee that sufficiently small non-zero integers are represented exactly in double ? If not, what about C++11? Note, I am not assuming IEEE compliance here. I suspect that the answer is no , but I would love to be proved wrong. When I say sufficiently small , I mean, bounded by some value that can be derived from the guarantees of C++03, and maybe even be calculated from values made available via std::numeric_limits<double> . EDIT: It is clear (now that I have checked) that std::numeric_limits<double>::digits is the same thing as DBL_MANT_DIG , and std::numeric

C++98/03 std::is_constructible implementation

时光毁灭记忆、已成空白 提交于 2019-11-29 10:20:52
The base components of my hobby library has to work with C++98 and C++11 compilers. To learn and to enjoy myself I created the C++98 implementations of several type support functionality (like enable_if , conditional , is_same , is_integral etc. ...) in order to use them when there is no C++11 support. However while I was implementing is_constructible I got stuck. Is there any kind of template magic (some kind of SFINAE) with which I can implement it without C++11 support ( declval )? Of course there is no variadic template support in C++03, so I will specialise the implementation till some