From 6c6011ba4266a54504727db7414461df7bafb6a9 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Mon, 25 Dec 2023 16:20:48 +0700 Subject: [PATCH 1/2] feat: modify `Error::message` to return `std::string_view` --- include/errors/error.hpp | 3 ++- src/error.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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; } From 5caa4fbc656e5b1f2236bcfab0f458c229ccb848 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Mon, 25 Dec 2023 16:37:37 +0700 Subject: [PATCH 2/2] build: set `CMAKE_CXX_STANDARD` to `17` --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c804d..297eb90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,9 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(NOT_SUBPROJECT TRUE) endif() +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # Initialize CPM.cmake include(cmake/CPM.cmake)