standards

Atomicity of the simple assignment operator

这一生的挚爱 提交于 2019-12-01 02:15:56
问题 C11 Standard says that for atomic types (_Atomic), prefix and postfix ++ and -- operations are atomic (6.5.2.4.,p2), as are compound assignments: op= (6.5.16.2,p3). I haven't found anything written about a simple assignment = . Is it also atomic? Let's says E1, E2 are int , but only E1 is defined with the specifier _Atomic. My assumption is that this: E1 = E2; is equivalent to: atomic_store( &E1 , E2 ); It my assumption correct? 回答1: Following the example in this Dr Dobbs article, simple

Source line length limit

*爱你&永不变心* 提交于 2019-12-01 02:10:55
What's the maximum length of a source line all compilers are required to accept? Did it change in C++11? If so, what was the old value? I'm asking this question because I'm doing some heavy preprocessor voodoo (unfortunately, templates won't cut it), and doing so has a tendency to make the lines big very quickly. I want to stay on the safe side, so I won't have to worry about the possibility of compiler X on platform Y rejecting my code because of too long lines. C++2003, Annex B, (informative) Implementation quantities (sorry, don't have C++2011 handy) 2) The limits may constrain quantities

HTML5 Compliant - Trailing Space in Class Attribute

那年仲夏 提交于 2019-12-01 01:59:09
问题 I know that technically HTML5 is a 'living spec' but I'm wondering if it's compliant to have trailing spaces inside of a class name. I didn't see any reference to this scenario in the spec, but one of my teammates said it was invalid. Maybe I missed something? It'd be a pain to trim those spaces (I'm working inside of a large Java ecom application) and I want to know if it's worth doing for SEO, validation or any other purpose. I get the feeling it's not... haha 回答1: As we can see in the link

Why is using exit() considered bad? [duplicate]

穿精又带淫゛_ 提交于 2019-12-01 01:19:59
问题 This question already has answers here : How to end C++ code (14 answers) Closed 4 years ago . I'm reading this question and there is an answer that explains why using exit() is bad because: You will end up having multiple exit points from the program It makes code more convoluted (like using goto) It cannot release memory allocated at runtime I should clarify that I'm using Qt, so the code is already a bit "convoluted" since I'm taking advantage of signals and slots. That being said, for

How are the private destructors of static objects called? [duplicate]

拈花ヽ惹草 提交于 2019-12-01 00:59:06
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Cannot access private member in singleton class destructor I'm implementing a singleton as below. class A { public: static A& instance(); private: A(void) { cout << "In the constructor" << endl; } ~A(void) { cout << "In the destructor" << endl; } }; A& A::instance() { static A theMainInstance; return theMainInstance; } int main() { A& a = A::instance(); return 0; } The destructor is private . Will this get

Where should the definition of an explicit specialization of a class template be placed in C++?

萝らか妹 提交于 2019-12-01 00:17:06
问题 According to [temp.spec]/5: For a given template and a given set of template-arguments, ... an explicit specialization shall be defined at most once in a program (according to [basic.def.odr]), and ... the definition of an explicit (full) specialization of a class template cannot be placed in a header (otherwise there is one definition in each translation unit containing this header, thus there will be more than one definition in the whole program). In addition, as another evidence, the

What does “char (*a)[12]” mean?

我只是一个虾纸丫 提交于 2019-12-01 00:15:26
Is this from the C standard? Because declarations in C follow the operator precedence rules (ie array subscription is evaluated before indirection), you'll need parens to declare pointers to array types. In many use cases, there's not really any practical benefit over using a plain char * , except that it's a way to enforce the array size, especially when used as a function parameter: void foo(char bar[42]); is equivalent to void foo(char *bar); and accepts any char * , whereas void foo(char (*bar)[42]); will only accept pointers to arrays of size 42 . As accessing the elements of bar in the

Standards on behaviour of nested labels

喜欢而已 提交于 2019-11-30 23:50:28
问题 I was wondering what would happen if I'd nest 2 <label> tags, and it turns out, in all the most recent versions of all browsers, except for Opera , clicking the inner label results in only that label being clicked. Here's a demo of nested label tags' behaviour. My question is: Are there any standards on the behaviour of browsers when handling click events in nested labels? All I could find was this MDN section about Gecko's behaviour, but I couldn't find anything about the other browsers. The

Where can I find the OFFICIAL Java Coding/Style Standards? [closed]

三世轮回 提交于 2019-11-30 23:09:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I use CheckStyle plugin for Eclipse and it does a wonderful job. I would like to know if there an official Code/Style standard (and there should be!) out there by Sun/Oracle... The ones I am finding are so out-dated, they don't even include any Java 1.6 specific syntax, etc... Here is what I found so far: http:/

Why can't the first pattern in a shell case statement be a multiple pattern?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 21:03:09
The standard description of the case statement says: The format for the case construct is as follows: case word in [(]pattern1) compound-list;; [[(]pattern[ | pattern] ... ) compound-list;;] ... [[(]pattern[ | pattern] ... ) compound-list] esac The ";;" is optional for the last compound-list. Why can't be pattern1 be a multiple pattern as well? It seems rather arbitrary, though I'm pretty sure it must not be. Thanks! I think you're misinterpreting what they're saying. The grammar on the page you link to does not show such a distinction: case_clause : Case WORD linebreak in linebreak case_list