What’s a use case for overloading member functions on reference qualifiers?

In a class that provides reference-getters, ref-qualifier overloading can activate move semantics when extracting from an rvalue. E.g.: class some_class { huge_heavy_class hhc; public: huge_heavy_class& get() & { return hhc; } huge_heavy_class const& get() const& { return hhc; } huge_heavy_class&& get() && { return std::move(hhc); } }; some_class factory(); auto hhc = factory().get(); This does … Read more

Explicit move constructor?

An explicit move constructors can affect compatibility with e.g. Standard algorithms. For instance, std::swap<T> requires that T be MoveConstructible. In turn, MoveConstructible is specified in terms of an expression, namely T u = rv; (where rv is an rvalue of type T). If there is neither a non-explicit copy constructor nor a non-explicit move constructor … Read more

Bit wise ‘&’ with signed vs unsigned operand

That’s indeed an interesting corner case. It only occurs here because you use uint16_t for the unsigned type when you architecture use 32 bits for ìnt Here is a extract from Clause 5 Expressions from draft n4296 for C++14 (emphasize mine): 10 Many binary operators that expect operands of arithmetic or enumeration type cause conversions … Read more

Does C++11 change the behavior of explicitly calling std::swap to ensure ADL-located swap’s are found, like boost::swap?

I would have had to vote against your proof-of-concept implementation had it been proposed. I fear it would break the following code, which I’m pretty sure I’ve seen in the wild at least once or twice over the past dozen years. namespace oops { struct foo { foo() : i(0) {} int i; void swap(foo& … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)