standards

Console Application Structure

十年热恋 提交于 2019-12-10 16:39:26
问题 I've written several .Net Console Applications over the past 6 months and we have many more throughout different projects in our organization. I generally stick to the same standard format/structure for my Console Applications. Unfortunately, many of our console applications do not. I have been looking into ways of standardizing the structure of these Console Applications. I would also like to provide a framework for the basic structure of a Console Application and provide easy access to

reinterpret_cast to the same type

て烟熏妆下的殇ゞ 提交于 2019-12-10 16:01:44
问题 Consider following program: struct A{}; int main() { A a; A b = a; A c = reinterpret_cast<A>(a); } The compiler(g++14) throws an error about invalid cast from type 'A' to type 'A' . Why is casting to the same type invalid? 回答1: It is not allowed, because the standard says so. There is a rather limited set of allowed conversion that you can do with reinterpret_cast . See eg cppreference. For example the first point listed there is: 1) An expression of integral, enumeration, pointer, or pointer

In what authorative specification is the onChange event exhaustively defined?

不羁的心 提交于 2019-12-10 16:01:07
问题 I was slightly surprised to find out that the onChange event in an html document is fired on a text input or textarea not at the very moment when its value actually changes, but only when focus leaves the element (if its value has changed, of course). So I was looking for the specification that states that, and I can't find it. I can find millions of tutorials explaining that, including W3Schools' ones, but I can't find the standard that defines when the event is expected to be fired. In the

Rules about disabling or hiding menu items

天大地大妈咪最大 提交于 2019-12-10 15:46:51
问题 Have you ever been in a situation where a menu function you really really want to use but can't cause it's disabled or worse gone all together? There is an argument for always leaving menus enabled and then display a message to a user explaining why a menu function can not be activated when they click on it. I think there is merit in this but maybe there is a cleverer way of addressing this issue. I would be interested to hear what others think. 回答1: If you're refering to Joel's post Don't

How does the last integer promotion rule ever get applied in C?

谁说胖子不能爱 提交于 2019-12-10 15:34:38
问题 6.3.1.8p1: Otherwise, the integer promotions are performed on both operands. Then the following rules are applied to the promoted operands: If both operands have the same type, then no further conversion is needed. Otherwise, if both operands have signed integer types or both have unsigned integer types, the operand with the type of lesser integer conversion rank is converted to the type of the operand with greater rank. Otherwise, if the operand that has unsigned integer type has rank

why initializer list cannot be main's parameter? how to propose it?

大兔子大兔子 提交于 2019-12-10 14:49:01
问题 The valid C++ main signatures are the following: int main() int main(int argc, char *argv[]) int main(int argc, char **argv) But isn't allowed to declare main taking an initializer list: int main(std::initializer_list<char *> args) AFAIK the initializer list could be implemented as a pair of pointers or a pointer (this could be the argv parameter) plus a length (this could be deduced from the argc parameter), and its storage could be automatic, temporary, or static read-only memory depending

const pointers in overload resolution

浪尽此生 提交于 2019-12-10 14:44:09
问题 GCC treats these two function declarations as equivalent: void F(int* a) { } void F(int* const a) { } test.cpp: In function 'void F(int*)': test.cpp:235: error: redefinition of 'void F(int*)' test.cpp:234: error: 'void F(int*)' previously defined here This makes some sense because a caller will always ignore the const in this case... it only affects the usage of the parameter 'a' inside of the function. What I'm wondering is where (if anywhere) the standard says that it's specifically OK to

Can an ANSI C compiler remove a delay loop?

一世执手 提交于 2019-12-10 14:22:37
问题 Consider a while loop in ANSI C whose only purpose is to delay execution: unsigned long counter = DELAY_COUNT; while(counter--); I've seen this used a lot to enforce delays on embedded systems, where eg. there is no sleep function and timers or interrupts are limited. My reading of the ANSI C standard is that this can be completely removed by a conforming compiler. It has none of the side effects described in 5.1.2.3 : Accessing a volatile object, modifying an object, modifying a file, or

Should I use EventArgs or a simple data type?

五迷三道 提交于 2019-12-10 13:35:54
问题 I'm currently creating a library for fun and practice and I was wondering, when raising an event, how to choose between passing your own EventArgs derivative or just the data type. For example, in my library I have something like this: public delegate void LostConnectionEventHandler(string address); public delegate void MessageReceieved(byte[] bytes); What is the standard practice for this? Should I replace string address with ConnectionEventArgs and byte[] bytes with MessageEventArgs ? I

What is the “char-sequence” argument to NaN generating functions for?

≡放荡痞女 提交于 2019-12-10 12:51:37
问题 Aside from the NAN macro, C99 has two ways to generate a NaN value for a floating point number, the nanf(const char *tagp) function and strtof("NAN(char-sequence)") . Both of these methods of generating a NaN take an optional string argument (*tagp in nanf() and the char-sequence in the strtof method). What exactly does this string argument do? I haven't been able to find any concrete examples of how you'd use it. From cppreference.com we have: The call nan("string") is equivalent to the call