#include #include class Base { public: virtual ~Base() = default; protected: virtual int func() const = 0; }; class OtherDerived : public Base { protected: int func() const override { return 42; } }; class ExtensionPoint : public Base { protected: int func() const override = 0; friend int do_func(const ExtensionPoint& ext); }; class my_wrapper : public ExtensionPoint, private OtherDerived { protected: int func() const override { return OtherDerived::func(); } }; int do_func(const ExtensionPoint& ext) { return ext.func(); } void test_case() { assert(do_func(my_wrapper{}) == 42); std::cout << "Got here!\n"; } class One { One() {} friend One impl_get_one(One*) { return {}; } } one = impl_get_one(static_cast(nullptr)); struct pos { int x; int y; }; template bool inrange(const T& val, const T& min, const T& max) { return min <= val && val <= max; } struct S { pos start; enum dir { up = 0, upleft = 1, left = 2, downleft = 3, down = 4, downright = 5, right = 6, upright = 7 } rot; short rotYComp() const noexcept { switch (rot) { case up: case upleft: case upright: return 1; case down: case downleft: case downright: return -1; default: return 0; } } short rotXComp() const noexcept { switch (rot) { case left: case upleft: case downleft: return -1; case right: case upright: case downright: return -1; default: return 0; } } short xPosOf(short n) const { // if rot = 0,1, or 7, then n will be above the word's position // else if rot is in [3,5] then n will be below word's position // otherwise, rot is horizontal, meaning y is constant for the word. return static_cast( start.x + ((rot < 2 || rot == 7) ? -n : (inrange(+rot, 3, 5)) ? n : 0)); return (rot < 2 || rot == 7) ? static_cast(start.x - n) : (rot > 2 && rot < 6) ? static_cast(start.x + n) : static_cast(start.x); } };