standards-compliance

Must a C++ Standard Library be implemented in C++?

自作多情 提交于 2019-12-06 19:00:35
问题 Must a conforming C++ Standard Library Implementation be implemented in C++? If not, is it allowed to do magic things that are not doable in pure C++ & Standard Library & some implementation defined behaviour? I am aware that there are parallel implementations that rely on extensions (in pre C++11 at least), but are they really conforming? I couldn't find any requirement in the standard, but maybe my standard-fu is weak today 回答1: No. Actually, it is even prescribed by the Standard that

C++ crazy typedef : what is the point of allowing this syntax by the Standard?

依然范特西╮ 提交于 2019-12-06 18:38:14
问题 The old familiar one: typedef int cute_int; //cute : common and familiar syntax. This syntax is perfect. No problem. Now, when we can write typedefs like above, then what is the point of allowing this syntax: int typedef crazy_int; //crazy : uncommon and unfamiliar syntax. Just to confuse programmers? Is this syntax even needed anywhere (when in fact we've the previous one)? What do you think from the compilers' point of view? Do they find it cute or crazy? Or it doesn't matter to the

Do I have the guarantee that sizeof(type) == sizeof(unsigned type)?

偶尔善良 提交于 2019-12-06 16:44:51
问题 The sizeof char, int, long double... can vary from one compiler to another. But do I have the guarantee according to the C++11 or C11 standard that the size of any signed and unsigned fundamental integral type is the same ? 回答1: The C++11 Standard says about integer types: (§3.9.1/3) For each of the standard signed integer types, there exists a corresponding (but different) standard unsigned integer type: “unsigned char”, “unsigned short int”, “unsigned int”, “unsigned long int”, and

Are Keyboard shortcuts mandatory for 508 compliance

心不动则不痛 提交于 2019-12-05 16:09:12
问题 I researched a lot on this and seem to be getting conflicting answers on SO and all of the web. I understand that with Section 508 that compliance DOES NOT equal accessibility. Biggest thing is that the UI/UX designer is being told that keyboard shortcuts for the dropdown menu NEEDS to have keyboard shortcuts to be 508 compliant. I see Windows Forms applications having this, but for web development I do not think that is mandatory to be "compliant" My other question that was answered is here:

Is std::vector::push_back permitted to throw for any reason other than failed reallocation or construction?

帅比萌擦擦* 提交于 2019-12-05 02:15:33
Consider: std::vector<int> v; v.reserve(1); v.push_back(1); // is this statement guaranteed not to throw? I've chosen int because it has no constructors that could throw - obviously if some copy constructor of T throws, then that exception escapes vector<T>::push_back . This question applies as much to insert as push_back , but it was inspired by Is it safe to push_back 'dynamically allocated object' to vector? , which happens to ask about push_back . In the C++03 and C++0x standard/FCD, the descriptions of vector::insert say that if no reallocation happens, iterators/references before the

Is this method of pointer tagging in C standard-compliant?

ぐ巨炮叔叔 提交于 2019-12-05 00:45:47
(Recap on pointer tagging: where the size of an object means that a limited number of bits in its pointer will always go unused and can be re-purposed for other uses, such as marking the object's type.) An excellent answer to my previous question on this subject confirmed that the naive method of converting pointers to integers and doing things to those integers cannot technically be relied upon to work (disregarding its popularity in practice). Upon thinking about it some more, I think I have a solution that works for the specific case described in the original question (all objects are the

Do I have the guarantee that sizeof(type) == sizeof(unsigned type)?

試著忘記壹切 提交于 2019-12-04 23:49:36
The sizeof char, int, long double... can vary from one compiler to another. But do I have the guarantee according to the C++11 or C11 standard that the size of any signed and unsigned fundamental integral type is the same ? The C++11 Standard says about integer types: (§3.9.1/3) For each of the standard signed integer types, there exists a corresponding (but different) standard unsigned integer type: “unsigned char”, “unsigned short int”, “unsigned int”, “unsigned long int”, and “unsigned long long int”, each of which occupies the same amount of storage and has the same alignment requirements

Dependencies in Initialization Lists

独自空忆成欢 提交于 2019-12-04 17:01:20
问题 Is this behavior well-defined? class Foo { int A, B; public: Foo(int Bar): B(Bar), A(B + 123) { } }; int main() { Foo MyFoo(0); return 0; } 回答1: No, it's undefined. A will be initialized first (it's first in the class definition), and it uses uninitialized B . Class members are initialized in the order they appear in the class definition, irrespective of their order in the initialization list. Indeed, it is bad practice to mismatch the member definition order with the initialization list

Is XHTML compliance pointless?

十年热恋 提交于 2019-12-04 16:41:48
问题 I'm building a site right now, so far I've painfully forced everything to be compliant and it looks pretty much the same across browsers. However, I'm starting to implement some third party/free javascripts which do things like add attributes (eg. order=2). I could work around this but it's a pain, and I'm starting to lose my principals of making sure everything is valid. Really, is there any point to working around something like this? I got the HTMLValidator plugin for firefox, and looking

Non-ASCII characters in C

限于喜欢 提交于 2019-12-04 03:24:28
问题 I was looking at google go's runtime source code (at https://go.googlecode.com/hg/src/pkg/runtime/ ), and it seems they use a special character for their function names, · . (Look for example at https://go.googlecode.com/hg/src/pkg/runtime/cgocall.c ). Is this accepted across major compilers? It's not ANSI C, is it? Or is it just some macro magic? Thank you! 回答1: C90 doesn't allow additional character in identifier (over those in the basic characters set), C99 do (both with the universal