#239 Given the following in C++:
constexpr const char *x = "Hello World";
constexpr const char *y = "Hello World";
constexpr bool b = x == y;
Without checking, is this well-formed?
A. Yes
B. No
C. Show results
#237 Given the following in C++:
struct A{};
using T = auto() -> auto(*)() -> auto(*)() -> A;
Without checking, is this well-formed?
A. Yes
B. No
C. Show results
#236 Given the following in C++:
struct A {int a;};
struct B : public A {int x;};
void f() {
B b{{},.x=1}; // Aggregate init base
// and designted init x
// Well-formed?
}
A. Yes
B. No
C. Show results
#235 Given the following in C++:
struct A {void f();};
struct B {void f(int);};
struct C : A, B {};
void g() {
C c;
c.f(); // Ambiguous?
}
Without checking:
A. Yes
B. No
C. Show results
#234 Given the following in C++:
struct A {int a;};
struct B : public A {int x;};
void f() {
B b{.a=1,.x=1}; // Well-formed?
}
Without checking:
A. Yes
B. No
C. Show results
#233 Given the following in C++:
struct A {} ;
void f() {
new struct A{}; // Well-formed?
}
Without checking:
A. Yes
B. No
C. Show results
#232 Given the following in C++:
template <typename T>
concept C [[deprecated]]= true; // Can we deprecate a concept?
Without checking:
A. Yes
B. No
C. Show results
#231 Given the following in C++:
struct S {
union {
union { // Nested anon union, valid?
int x = 1;
float f;
};
void *p ;
};
};
Without checking:
A. Yes
B. No
C. Show results
#230 Given the following in C++:
struct X {int a, b;};
struct Y {int c; double d;};
union U {X x; Y y;};
constexpr int f(){
U u = {{1,2}};
return u.y.c; // Common initial sequence,ok?
}
constexpr int x=f();
Without checking:
A. Yes
B. No
C. Show results
#229 Given the following in C++:
void f() {
union {
int x=1;
float y;
};
[x]() {}; // Allowed to capture x?
}
Without checking:
A. Yes
B. No
C. Show results
I have two good options for next weeks quiz.
Neither one will make most folks happy.
#226 Given the following in C and C++
struct A {
int y : (int)(double)10.f;
};
Without checking, valid code?
C | C++
=========
A. No | No
B. No| Yes
C. Yes | No
D. Yes | Yes
#cplusplus #cpppolls #programming
#225 Given the following in C++:
int x{3};
int y{x};
template <typename T>
static const int z{y};
int main() {
return z<void>; // What is the value returned?
}
Without checking:
A. 3
B. 0
C. Something else
D. Show results
#224 Given the following in C++:
union U {
int x;
float y;
};
void f() {
U u{.x=2,.y=1}; // Well-formed? Initialize x and then override and initialize y?
}
Without checking:
A. Yes
B. No
C. Show results
#223 Given the following in C++:
class A{};
using B = A;
void f() {
class B a2; // Well-formed?
}
Without checking:
A. Yes
B. No
C. Show results
#222 Given the following in C++:
struct A {
bool operator[](int);
};
void f() {
A a;
int arr[2]{};
1[arr]; // Same as arr[1]
1[a]; // Same as a[1]??
}
Without checking:
A. Yes
B. No
C. Show results
#221 Given the following in C++:
void f() {
float f = 1f; // Well-formed?
}
A. Yes
B. No
C. Show results
#220 Given the following in C++:
void f() {
auto h = [y=0]<typename y>(y) // Does the 2nd y shadow or ill-formed?
{ return 0; };
}
A. Shadow
B. Ill-formed
C. Show results
#219 Given the following in C++:
#include <type_traits>
template <typename T>
void f(std::add_rvalue_reference_t<T>){}
Without checking, is this well-formed?
A. Yes
B. No
C. Show results