// // Created by grimmauld on 03.03.24. // https://stackoverflow.com/questions/12261915/how-to-throw-stdexceptions-with-variable-messages // #ifndef IPCSWAYTEST_FORMATTER_H #define IPCSWAYTEST_FORMATTER_H #include #include class Formatter { public: Formatter() = default; ~Formatter() = default; template Formatter & operator << (const Type & value) { stream_ << value; return *this; } std::string str() const { return stream_.str(); } explicit operator std::string () const { return stream_.str(); } enum ConvertToString { to_str }; std::string operator >> (ConvertToString) { return stream_.str(); } Formatter(const Formatter &) = delete; private: std::stringstream stream_; // Formatter & operator = (Formatter &); }; #endif //IPCSWAYTEST_FORMATTER_H