diff --git a/include/errors/error.hpp b/include/errors/error.hpp index 8c158a9..ea42138 100644 --- a/include/errors/error.hpp +++ b/include/errors/error.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include namespace errors { @@ -27,7 +28,7 @@ class Error { * std::cout << err << std::endl; * @endcode */ - std::string message() const; + std::string_view message() const; friend Error make(const std::string& msg); diff --git a/src/error.cpp b/src/error.cpp index 6eb82c7..44d040f 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -4,7 +4,7 @@ namespace errors { Error::Error(const std::shared_ptr& message_ptr) : message_ptr(message_ptr) {} -std::string Error::message() const { +std::string_view Error::message() const { if (!message_ptr) return "no error"; return *message_ptr; }