What's your practice on using noncopyable mixins vs. explicit memer deletion?

I can make a a class Foo move-only by

class Foo
{
public:
  Foo(const Foo &) = delete;
  Foo & operator=(const Foo &) = delete;
};

that's not too bad and almost idiomatic, but the class name is repeated 5 times, and there are minor details (& vs. const &) to get wrong in a hurry.

(yes, technically, the operator= return type doesn't matter and could be void, but that's likely to trip up readers, reviewers and style checks)

Even before move semantics and explicitely deleted special functions, there were noncopyable mixins like boost::noncopyable to make the intent explicit and brief.

What's your take on this? Do you regularly mark classes as non-copyable explicitely, and which way to you prefer?

reddit.com
u/elperroborrachotoo — 1 hour ago

Evaluate enum class in a boolean context (type-safe enum flags)

I've been toying around with type safe flags from enums, but instead of a separate class flag_set<T>, I've tried to

  • overload required operators (like &, | etc.)
  • a method to "tag" enum types to make the feature opt-in

(godbolt example here)

The core idea is not to introduce a separate type, but to use "standard" syntax but make it type safe (e.g., fail when mixing distinct flag sets).

I think I have everything covered except one very common thing:

enum class EFlags { Read = 1, Write = 2, Sleep = 4 };

void enable_bitset_enum(EFlags); // opt-in

EFlags a = ....;

if (!(a & EFlags::Read)) { }  // ok
if (a & EFlags::Read) { }     // doesn't compile

This boils down to evaluating EFlags in a boolean context, which... I have no idea how to enable.

(It's making me unecessarily angry because everything else works, just nto that)

Any ideas?

u/elperroborrachotoo — 3 days ago
▲ 21 r/dresden

"Ermüdung von der Freiheit"

Dresden hat eine neue Stadtschreiberin, der Satz hat mir gefallen.

Was ist das?
Als Stadtschreiber:in bekommst du ein Stipendium (€1500/Monat und eine Wohnung), und ... schreibst. Mit Bezug zur Stadt, oft mit einem Auftrag, aber im großen und ganzen sehr frei.

Wird von der Sparkasse gestiftet (Danke Omi für deine Gebühren!)

mdr.de
u/elperroborrachotoo — 19 days ago

Abschied von einem treuen Begleiter

Über 30 Jahre, viel Sonne, viel Wüste, viel Staub. Du warst auf meinem ersten Flug dabei und meinem ersten Solo-Trip, du wurdest auf Busdächer geworfen und du würdest gequetscht und herumgezerrt und in Luxuslimousinen verstaut, von französischen und russischen und iranischen Beamten ausgeräumt. Du hast mir immer ein Lächeln auf die Lippen gezaubert, wenn das Gepäckband dich ausgespuckt hat, du warst - geschunden und verblichen - einzigartig und nicht zu verkennen.

Man könnte dich noch einmal flicken, aber das Material ist mürbe, und hier und da schaut die Sonne rein ..

Gute Nacht, mein Prinz.

u/elperroborrachotoo — 20 days ago

Beginner Lore/Game Mechanics Question: Don't seals stay?

Okay, I'm fairly new to the game (rather, it finally clicked...)

I've rebuilt my first bronze seal, then the big flood came... and the seal is gone again?

So mechanics-wise all is the bonus fronm the seal ("Consequences: cycle duration permanently increased by 8") level-up unlocks, and the upgrades we buy. Is that so?

Which brings me to the lore question: why do we even go out there and rebuild seals?

reddit.com
u/elperroborrachotoo — 27 days ago