Badge

Run Settings
LanguageC++
Language Version
Run Command
// The Badge can only be constructed by T. template <typename T> class Badge{ private: friend T; Badge() {} }; // RestrictedFunc can only be called with a AllowedCaller Badge. class AllowedCaller; void RestrictedFunc(Badge<AllowedCaller>); // AllowedCaller calls the RestrictedFunc with a Badge constructed using {}. class AllowedCaller { public: void CallSite() { RestrictedFunc({}); } }; void RestrictedFunc(Badge<AllowedCaller>) {}; // DisallowedCaller will not be able to construct the Badge with {}. // class DisallowedCaller { // public: // void CallSite() { // RestrictedFunc({}); // } // }; int main() { AllowedCaller caller; caller.CallSite(); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines