standards

compliant variable length struct in C++

别说谁变了你拦得住时间么 提交于 2019-12-07 02:56:42
问题 In standard C you can end a struct with an array of size 0 and then over allocate it to add a variable length dimension to the array: struct var { int a; int b[]; } struct var * x=malloc(sizeof(var+27*sizeof(int))); How can you do that in C++ in a standard (portable) way? It is okay to have a constraint of max posible size and obviously doesn't have to work on the stack I was thinking of: class var { ... private: int a; int b[MAX]; }; and then use allocators or overload new/delete to under

How to use Fortran statement labels well?

一个人想着一个人 提交于 2019-12-07 02:54:56
问题 I'm working on a model written in Fortran 95, which I am completely new to. The concept of statement labels seems strange, and I've so far only found the explanation that the labels can be arbitrarily decided by the author, usually incrementing by 10's. Are there any practical uses of these labels, other than picking out more easily where a statement is ending? AND a generally accepted standard on how to label. 回答1: The only way I can think of statement labels being useful in modern Fortran

Where are ioctl parameters (such as 0x1268 / BLKSSZGET) actually specified?

安稳与你 提交于 2019-12-07 02:47:08
问题 This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . I am looking for a definitive specification describing the expected arguments and behavior of ioctl 0x1268 (BLKSSZGET). This number is declared in many places (none of which contain a definitive reference source), such as linux/fs.h , but I can find no specification for it. Surely, somebody at some point in the past decided that 0x1268 would get the physical sector

Structure member alignment with _Alignas

拥有回忆 提交于 2019-12-07 02:39:33
问题 I was wondering about the following: is the new _Alignas alignment specifier in C11 applicable to structure members? I've always assumed that much, but a thorough reading of the N1570 public draft seems to indicate that an alignment-specifier cannot appear in a specifier-qualifier-list , which is where I'd expect it to be, if it were supported. I've read the grammar a couple of times but can't figure out how _Alignas is supposed to be permitted in a structure member declaration. However, it

C++ Standard Layout and References

我与影子孤独终老i 提交于 2019-12-07 02:19:52
问题 According to the C++ standard: A standard-layout class is a class that: —has no non-static data members of type non-standard-layout class (or array of such types) or reference. What property(ies) of references prevent classes with reference members from being included in the definition of a standard layout class? 回答1: A standard layout class is all about having a well defined layout for a particular type in memory . In C++, references aren't objects so don't have any storage that can be

Protected properties prefixed with underscores

て烟熏妆下的殇ゞ 提交于 2019-12-07 00:39:24
问题 Like: public $foo = null, $bar = 10; protected $_stuff = null, $_moreStuff = 5; A lot of people seem to do this. Why? Isn't this inconsistent naming (like some PHP functions are :))? 回答1: It really comes down to one thing: personal preference. I, personally, am also one who uses that naming convention. Prefixing anything that is protected or private with an underscore, be it a variable or a function, lets myself and any other programmer who I regularly work with know that that variable is

AmazonS3: custom error pages

你。 提交于 2019-12-06 22:12:17
问题 I am planning to share URLs (time limited) for private objects. Is there a way to set custom error pages for 404/403 http responses ? 回答1: Yes, it's possible, see this announcement. In the Developer guide there is a paragraph about "Custom Error Document Support" where I read the following sentence. You can optionally provide a custom error document with a user-friendly error message and with additional help. You provide this custom error document as part of adding website configuration to

Is there a standard way to store XY data in python?

拟墨画扇 提交于 2019-12-06 21:35:22
问题 Is there a standard way to store (x,y), (x,y,z), or (x,y,z,t) data in python? I know numpy arrays are used often for things like this, but I suppose you could do it also with numpy matrices. I've seen the use of 2 lists zipped together, which side steps the use of numpy altogether. XY_data = zip( [x for x in range(0,10)] , [y for y in range(0,10)] ) Is there a standard ? If not, what is your favorite way, or the one which you have seen the most? 回答1: One nice way is with a structured array.

In proper HTML, must an <input> be in a <form>?

江枫思渺然 提交于 2019-12-06 17:30:50
问题 I need a few input elements, but their values won't be submitted anywhere - they're just going to be manipulated by some client-side JavaScript. Do I have to place them in a <form> to have legit HTML, or can they just be free-standing? 回答1: For additional information, in xhtml strict you have to place in one of these elements: "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset" 回答2: No. You only need a form if you're submitting to a server. 来源: https:/

Why does std::exception have extra constructors in VC++?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 16:45:00
问题 Something I noticed just now. Definition of exception in the standard (18.6.1): class exception { public : exception() throw(); exception(const exception &) throw(); exception& operator=(const exception&) throw(); virtual ~exception() throw(); virtual const char* what() const throw(); }; Definition of exception in MSDN: class exception { public: exception(); exception(const char *const&); exception(const char *const&, int); exception(const exception&); exception& operator=(const exception&);