standards

Can a lambda capturing nothing access global variables?

﹥>﹥吖頭↗ 提交于 2019-12-03 22:32:33
int n; int main() { [](){ n = 0; }(); // clang says "ok" int m; [](){ m = 0; }(); // clang says "not ok" } I just wonder: If the lambda captures nothing, is it allowed to access global variables as per the C++ standard? Yes, sure. Normal name lookup rules apply. [expr.prim.lambda]/7 ... for purposes of name lookup ... the compound-statement is considered in the context of the lambda-expression . Re: why local variables are treated differently from global ones. [expr.prim.lambda]/13 ... If a lambda-expression or an instantiation of the function call operator template of a generic lambda odr

What is the Relationship Between the C and C++ Standards?

雨燕双飞 提交于 2019-12-03 22:02:55
I was writing this answer and I quoted from http://en.cppreference.com/w/cpp/string/byte/tolower#Parameters Is not representable as unsigned char and does not equal EOF, the behavior is undefined When I went to inspect the edit that had added this phrase I found that the author's comment: Can't use negative signed chars with any ctype.h function per C99 7.4/1 The author is citing from the C99 standard in C++ documentation. Is that valid? I couldn't find anything on the definition of this function in the C++ standard, so I must assume that it is valid. But this concerns me for 2 reasons: How

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

放肆的年华 提交于 2019-12-03 20:58:00
问题 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! 回答1: I think you're misinterpreting what they're saying. The grammar on the

Which browsers support the <embed> and <object> tags?

我们两清 提交于 2019-12-03 20:37:37
问题 I am working on a department website that needs to be standards compliant (xhtml 1.0 transitional), but embedded flash keeps breaking the validation. We use the <embed> tag because we need to support most major browsers. We can't use external tools, since the site is managed through a system and the admins don't like us putting extra tools (like JavaScript libraries etc) that could interfere with their template engine. How widely supported is the object tag? Is it safe to use only the <object

Difference between default-initialize and value-initialize in C++03?

好久不见. 提交于 2019-12-03 19:59:50
问题 I had always thought that creating a new object would always call the default constructor on an object, and whether the constructor was explicit or automatically generated by the compiler made no difference. According to this highly regarded answer to a different question, this changed in a subtle way between C++98 and C++03 and now works like so: struct B { ~B(); int m; }; // non-POD, compiler generated default ctor new B; // default-initializes (leaves B::m uninitialized) new B(); // value

Status of ranges for C++1z? [closed]

落花浮王杯 提交于 2019-12-03 19:56:21
问题 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 5 years ago . There is a study group on ranges in the C++ committee: but I have not followed the history of this study group and I am not sure of what kind of delivery is expected for C++1z (furthermore I do not use boost.range so I do not have a clear view of existing practices). Will we have: ranges as a pair of first/last

Database Engines and ANSI SQL Compliance

北城余情 提交于 2019-12-03 18:59:04
问题 I've been searching for half an hour and can't find any resources stating what level of the SQL ANSI standard is supported on various database engines. It looks like some level of support is provided by most engines, but I'd like to know exactly what level is officially supported. I'm primarily interested in MySQL, PostgreSQL, SQL Server, and Oracle. EDIT: PostgreSQL has a great page on compliance, exactly what I was looking for regarding the other engines: http://www.postgresql.org/docs

Why is operator% referred to as the “modulus” operator instead of the “remainder” operator?

我与影子孤独终老i 提交于 2019-12-03 18:01:34
问题 Today at work I had an interesting discussion with one of my coworkers. He was surprised when he had the following happen to him: assert(-1 % 10 == -1) //Expecting 9 So when he came to ask me about it, I told him "well, that makes sense. When you divide -1 by 10, you get 0 with -1 remaining. His argument however was that the modulus operator is supposed to hold true to the "always positive" model. I did a little research and found that the modulus he was referring to looks like this: Let q be

H1 tags, SEO and semantics

微笑、不失礼 提交于 2019-12-03 15:28:30
I'm using the H1 tag in my document as the main title, as you do. The text in the H1 is the title of the company, which needs to be shown on every page. I'm using the H2 tag for the title of the main content on each page. So the H1 is the same on every page, and the H2 changes. Example http://dev.darrenhall.info/temp/stackoverflow/h1/h1.gif I know that a lot of sites use the H1 to do what I'm doing with the H2, am I losing out by not doing this? I know that semantically I can't make the H1 into a H2 and vice versa, so I'm wondering what the best option is. Does it matter that my H1 is always

Python: How to read stdout of subprocess in a nonblocking way

孤人 提交于 2019-12-03 15:22:51
I am trying to make a simple python script that starts a subprocess and monitors its standard output. Here is a snippet from the code: process = subprocess.Popen([path_to_exe, os.path.join(temp_dir,temp_file)], stdout=subprocess.PIPE) while True: output=process.stdout.readline() print "test" The problem is that the script hangs on output=process.stdout.readline() and that the line print "test" only executes after the subprocess is terminated. Is there a way to read standard output and print it without having to wait for the subprocess to terminate? The subprocess which I am starting is a