standards

Does postfix increment perform increment not on returned value?

只愿长相守 提交于 2019-12-11 18:26:39
问题 Again, a silly question. #include <stdio.h> #include <iostream> using namespace std; int main() { int i = 0; i = i++; cout<<i; return 0; } I get 1 printed as a result of this program though I expected 0: first a temp object created eing equal 0, then i is incremented, then temp object is returned and assigned to i. Just according to: 5.2.6 Increment and decrement [expr.post.incr] 1 The value obtained by applying a postfix ++ is the value that the operand had before applying the operator.

Should Django Migration (makemigrations) commited separately than creating model?

混江龙づ霸主 提交于 2019-12-11 17:55:39
问题 It's vague for me which strategy is better in Version controlling of django or any other web framework: Commit separately for creating model and running makemigrations . Commit both tasks together. I think myself first strategy is better, because of migration files which creating after running makemigrations . But I need to be sure which one in better. Is there any certain standard for this? 回答1: Both the strategies you list can work. But option one is better. You can commit Django Migration

AsyncFunction is not defined, yet MDN documents it's usage

为君一笑 提交于 2019-12-11 17:28:23
问题 There is an article AsyncFunction - JavaScript on MDN. It shows the following snippet: new AsyncFunction([arg1[, arg2[, ...argN]],] functionBody) Yet in both Mozzila Firefox 55 and Google Chrome, this constructor is not defined at all: I found out that (async function() {}).constructor really is AsyncFunction , but why can't I see it in global scope? 回答1: As mentioned in the Mozilla docs "Note that AsyncFunction is not a global object." Therefore you can't access it as a property of the

C++ redeclaration inconsistency/interestingness

♀尐吖头ヾ 提交于 2019-12-11 14:49:17
问题 I was answering this question when I thought of this example: #include <iostream> void func(int i); void func(); int main (){ func(); return 0; } void func(){} In the above example, the code compiles fine. However, in the below example, the code does not compile correctly: #include <iostream> void func(); int func(); int main (){ func(); return 0; } void func(){} This is the error that occurs when this code is compiled (in clang++): file.cpp:4:5: error: functions that differ only in their

front and back Proposal for iterators Library

ぃ、小莉子 提交于 2019-12-11 13:56:09
问题 In C++17 the iterator library received size, empty, and data allowing statically constructed arrays to behave like containers. But I don't see a front or back function in the iterator library, which was added to the other containers in C++14: http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=front&button= Is this something that has been proposed? 回答1: N4017 originally proposed front / back . The Library Evolution Working Group voted to remove front / back : Do we want

Portability of Array.prototype.* on array like objects or ever native/host objects

谁说我不能喝 提交于 2019-12-11 13:26:49
问题 ESMA 262 5.1 for many Array.prototype functions say that they are intentionally generic and described in terms of [[Get]] , [[Put]] , etc operations on Object , but also require length property. So them allowed to work on build-in objects, like: obj = {"a":true, "length":10}; Array.prototype.push.call(obj, -1); console.log(obj); // Object { 10: -1, a: true, length: 11 } For native objects standard have note: Whether the push function can be applied successfully to a host object is

ANSI C functions namespace in ISO C++ [duplicate]

那年仲夏 提交于 2019-12-11 11:45:34
问题 This question already has answers here : When using C headers in C++, should we use functions from std:: or the global namespace? (8 answers) Closed 3 years ago . Consider the following small program: #include <cstdio> int main() { printf("%d\n", 1); std::printf("%d\n", 2); return 0; } What does C++ standard say about importing C library functions into global namespace by default ? Can you point me to the relevant C++ standard section? What is the reason ANSI C functions are in std namespace

REST and links: middle ground?

天大地大妈咪最大 提交于 2019-12-11 10:45:24
问题 I've been wondering about how far to go with links in REST. Consider books which have authors, but there is obviously a many-to-many relationship between books an authors (a book can be written by multiple authors, and authors can write multiple books). So let's say we have a rest call http://server/book/21 , which will return a book XML, containing information about an author. Now since the book is a resource, and the author is a resource, the XML should not straight up include all the

Convert double to struct tm

心不动则不痛 提交于 2019-12-11 10:36:08
问题 I have a double containing seconds. I would like to convert this into a struct tm . I can't find a standard function which accomplishes this. Do I have to fill out the struct tm by hand? I just accidentally asked this about converting to a time_t and http://www.StackOverflow.com will not let me post unless I link it. 回答1: Well, you accidentally asked the right question before. Convert double to time_t , and then convert that to a struct tm . There's no subsecond field in struct tm anyway. 回答2

Is XML's root closing tag mandatory?

北战南征 提交于 2019-12-11 08:26:26
问题 I serialized an object in Java, and I got the following XML: <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_92" class="java.beans.XMLDecoder"> <object class="...." id="SmartLayout0"> <!-- ... --> </object> As you see, the root tag <java> is not closed. Is it legal in XML to not close this root tag? Does the XML standard explicitly allow such shortcut? 回答1: Yes, unlike in the non-XHTML versions of HTML, all tags in XML must be closed or be self-closing. All elements in XML must be