Top new questions this week: Union of 2 sets does not contain all items How come when I change the order of the two sets in the unions below, I get different results? set1 = {1, 2, 3} set2 = {True, False} print(set1 | set2) # {False, 1, 2, 3} print(set2 | set1) … python python-3.x set equivalence-classes   asked by Blueplastic 51 votes answered by Raymond Hettinger 53 votes Is struct packing deterministic? For example, say I have two equivalent structs a and b in different projects: typedef struct _a { int a; double b; char c; } a; typedef struct _b { int d; double e; char f; } … c padding   asked by Govind Parmar 25 votes answered by rici 35 votes Why does the compiler not give an ambiguous reference error? With reference to the following code #include #include #include #include using std::cout; using std::endl; using std::string; … c++ c++11 templates gcc clang   asked by Curious 22 votes answered by RustyX 5 votes Stack Overflow Jobs puts developers first. No recruiter spam or fake listings Browse Jobs Is this-> mandatory to access Base identifiers from derived classes? This code compiles with MSVC 2015, but doesn’t compile with Clang 5.0.0 (trunk 304874): template struct Base { T data; }; template struct Derived : … c++ templates inheritance language-lawyername-lookup   asked by Mr.C64 20 votes answered by songyuanyao 20 votes Why is declaration order important for passing a member function pointer as a template argument? Look at this code: template struct Testee {}; class Tester { private: void foo() {} public: using type_t = Testee; }; … c++ templates member-pointers   asked by ikh 19 votes answered by aschepler 25 votes Overload resolution for multiply inherited operator()

Top new questions this week:

Union of 2 sets does not contain all items

How come when I change the order of the two sets in the unions below, I get different results? set1 = {1, 2, 3} set2 = {True, False} print(set1 | set2) # {False, 1, 2, 3} print(set2 | set1) …

python python-3.x set equivalence-classes
asked by Blueplastic 51 votes
answered by Raymond Hettinger 53 votes

Is struct packing deterministic?

For example, say I have two equivalent structs a and b in different projects: typedef struct _a { int a; double b; char c; } a; typedef struct _b { int d; double e; char f; } …

c padding
asked by Govind Parmar 25 votes
answered by rici 35 votes

Why does the compiler not give an ambiguous reference error?

With reference to the following code #include <iostream> #include <tuple> #include <string> #include <type_traits> using std::cout; using std::endl; using std::string; …

c++ c++11 templates gcc clang
asked by Curious 22 votes
answered by RustyX 5 votes

Is this-> mandatory to access Base<T> identifiers from derived classes?

This code compiles with MSVC 2015, but doesn’t compile with Clang 5.0.0 (trunk 304874): template <typename T> struct Base { T data; }; template <typename T> struct Derived : …

c++ templates inheritance language-lawyername-lookup
asked by Mr.C64 20 votes
answered by songyuanyao 20 votes

Why is declaration order important for passing a member function pointer as a template argument?

Look at this code: template <typename T, void (T::*pfn)()> struct Testee {}; class Tester { private: void foo() {} public: using type_t = Testee<Tester, &Tester::foo>; }; …

c++ templates member-pointers
asked by ikh 19 votes
answered by aschepler 25 votes

Overload resolution for multiply inherited operator()

First, consider this C++ code: #include <stdio.h> struct foo_int { void print(int x) { printf(“int %d\n”, x); } }; struct foo_str { void print(const char* x) { …

c++ lambda language-lawyer multiple-inheritanceoverload-resolution
asked by Pavel Minaev 19 votes
answered by T.C. 4 votes

Is there a way to list the attributes of a class without instantiating an object?

In Python 3.5, say I have: class Foo: def __init__(self, bar, barbar): self.bar = bar self.barbar = barbar I want to get the list [“bar”, “barbar”] from the class. I know I can …

python python-3.x
asked by vwrobel 18 votes
answered by Lærne 20 votes

Greatest hits from previous weeks:

Is Java “pass-by-reference” or “pass-by-value”?

I always thought Java was pass-by-reference; however I’ve seen a couple of blog posts (For example, this blog) that claim it’s not. I don’t think I understand the distinction they’re making. What is …

java methods parameter-passing pass-by-referencepass-by-value
asked by user4315 4325 votes
answered by erlando 3623 votes

Validate email address in JavaScript?

How can an email address be validated in JavaScript?

javascript regex validation email email-validation
asked by pix0r 2477 votes
answered by sectrean 2935 votes

Can you answer these?

angular-pickadate timezone – selectedDate is one day before from modal date for other timezones

angular-pickadate works for my local time. To check global Times, I have changed my time zone to “America/Denver”. Now selected date is taken one day before today’s date (passed modal date), so it …

angularjs datetime timezone
asked by Kishor 5 votes

Cross-referencing not working in rmarkdown beamer presentation

I would like to link section headers in a beamer_presentation via Rmarkdown (ie., creating cross-references or Pandoc’s internal links). For example, I would like to have a link such as “see …

r knitr rmarkdown beamer cross-reference
asked by Sebastian Sauer 4 votes

Serializing to a byte array threw an IOException (should never happen)

I have this new error from one user. This happened when I pushed the app with the new 11.0.0 Play