Commit b95d96aa authored by Dominik Charousset's avatar Dominik Charousset

Switch to string_view in make_error

parent 04ba5ea6
......@@ -18,7 +18,9 @@
#pragma once
#include <cstddef>
#include <cstdint>
#include <string>
#include "caf/fwd.hpp"
......@@ -74,7 +76,7 @@ error make_error(pec code, size_t line, size_t column);
/// Returns an error object from given error code with additional context
/// information for where the parser stopped in the argument.
error make_error(pec code, std::string argument);
error make_error(pec code, string_view argument);
/// @relates pec
const char* to_string(pec x);
......
......@@ -21,6 +21,7 @@
#include "caf/config_value.hpp"
#include "caf/error.hpp"
#include "caf/make_message.hpp"
#include "caf/string_view.hpp"
namespace {
......@@ -61,9 +62,9 @@ error make_error(pec code, size_t line, size_t column) {
make_message(std::move(context))};
}
error make_error(pec code, std::string argument) {
error make_error(pec code, string_view argument) {
config_value::dictionary context;
context["argument"] = std::move(argument);
context["argument"] = std::string{argument.begin(), argument.end()};
return {static_cast<uint8_t>(code), atom("parser"),
make_message(std::move(context))};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment