// https://stackoverflow.com/questions/12261915/how-to-throw-stdexceptions-with-variable-messages

#ifndef FORMATTER_H
#define FORMATTER_H

#include <sstream>
#include <stdexcept>

class Formatter {
public:
    Formatter() {};
    ~Formatter() {};

    template <typename Type> Formatter& operator<<(const Type& value) {
        stream_ << value;
        return *this;
    }

    std::string str() const { return stream_.str(); }
    operator std::string() const { return stream_.str(); }

    enum ConvertToString { to_str };
    std::string operator>>(ConvertToString) { return stream_.str(); }

private:
    std::stringstream stream_{};
    Formatter(const Formatter&);
    Formatter& operator=(Formatter&);
};

#endif
