#ifndef wg_LOC_HPP #define wg_LOC_HPP #include "commons.hpp" #include namespace wg { class Loc { public: explicit Loc(std::filesystem::path origin = "???", int line = 0); virtual ~Loc(); std::filesystem::path origin() const { return m_origin; } int line() const { return m_line; } template void error(std::string const& what); template void error(std::stringstream const& what); private: std::filesystem::path m_origin; int m_line = 0; }; template void Loc::error(std::string const& what) { std::stringstream ss; ss << m_origin.string() << ": ERROR " << what; throw T {ss.str() }; } template void Loc::error(std::stringstream const& what) { error(what.str()); } } #endif