I want a class which "has nothing" and you can't "do anything with it", but has something interesting happen when an instance of it is constructed. Now, sure, I can code that, e.g. something like
class MyIdiom final {
MyIdiom() { /* magic goes here */ }
/* maybe unnecessary? */
MyIdiom(const MyIdiom&) = delete;
operator=(const MyIdiom& other) = delete;
}
but I wonder if there isn't part of some commonly-used library, alongside other such "degenerate classes".
Note: Since people seem to be overly concerned with the use of such a class, suppose it's something like
template <typename F> class MyIdiom final {
MyIdiom(F f) { f(); }
}
#define STATIC_BLOCK(_f) \
auto MyIdiom<decltype(_f)> _myidiom_ # _f # _ # __LINE__ (_f);