W·Oct 24C++ 11struct Gadget { Gadget(Gadget&&)=default; Gadget(const Gadget&)=default; }; const Gadget g=build(); Gadget h = std::move(g); Which…
W·Oct 24C++ 10Given struct Wrapper { Wrapper(int); Wrapper(const Wrapper&); Wrapper(Wrapper&&); }; and Wrapper make(int x) { return Wrapper{x}; }…
W·Oct 24C++ 9For a local variable T x;, what does decltype((x)) y = x; declare, and why is it a classic interview gotcha?
W·Oct 22C++ 8Which standard synchronization primitive is a one-shot downward counter that unblocks waiting threads when its counter reaches zero and…
W·Oct 22C++ 7Consider: struct Widget { int id; void ping(); }; alignas(Widget) unsigned char buf[sizeof(Widget)]; new (buf) Widget{42}; Widget* q =…
W·Oct 22C++ 5Two templates: template <typename T> auto a(T t) -> decltype(t.size(), int{}) { return t.size(); } // (A) template <typename T> int b(T t)…
W·Oct 22C++ 4Consider: template <typename T> void log(T&& value) { /* … */ } log(42); // (A) log({1, 2, 3}); // (B) What is true about (B), and what…
W·Oct 22C++ 3In std::vector<std::string> v; v.push_back(std::string("hi"));, which overload is selected and why does it matter? Answer: The string&&…
W·Oct 22C++ 2Your copy-assignment does delete[] data; data = new char[n]; /* copy */. What exception safety does it provide? Answer: Only the basic…