From 85edee7ee1594ad438772a158783c6a49cbbbe56 Mon Sep 17 00:00:00 2001 From: vincent-hui Date: Tue, 4 Feb 2025 13:15:22 +0800 Subject: [PATCH] Fix compilation error when targeting C++23 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compilation fails if cxx_std_17 is changed to cxx_std_23 because expected_lite namespace is not defined. Commit fixes this. /home/vincent/BehaviorTree.CPP/include/behaviortree_cpp/json_export.h:117: error: ‘nonstd::expected_lite’ has not been declared; did you mean ‘nonstd::unexpected_type’? [-Wtemplate-body] In file included from /home/vincent/BehaviorTree.CPP/src/blackboard.cpp:3: /home/vincent/BehaviorTree.CPP/include/behaviortree_cpp/json_export.h: In member function ‘BT::Expected BT::JsonExporter::fromJson(const nlohmann::json_abi_v3_11_3::json&) const’: /home/vincent/BehaviorTree.CPP/include/behaviortree_cpp/json_export.h:117:20: error: ‘nonstd::expected_lite’ has not been declared; did you mean ‘nonstd::unexpected_type’? [-Wtemplate-body] 117 | return nonstd::expected_lite::make_unexpected(res.error()); | ^~~~~~~~~~~~~ --- include/behaviortree_cpp/json_export.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/behaviortree_cpp/json_export.h b/include/behaviortree_cpp/json_export.h index 9274ad788..1d47b0877 100644 --- a/include/behaviortree_cpp/json_export.h +++ b/include/behaviortree_cpp/json_export.h @@ -114,12 +114,12 @@ inline Expected JsonExporter::fromJson(const nlohmann::json& source) const auto res = fromJson(source); if(!res) { - return nonstd::expected_lite::make_unexpected(res.error()); + return nonstd::make_unexpected(res.error()); } auto casted = res->first.tryCast(); if(!casted) { - return nonstd::expected_lite::make_unexpected(casted.error()); + return nonstd::make_unexpected(casted.error()); } return *casted; }