Я определил расширение для макроса boost_outcome_try для типа llvm :: eriror . В приложении для тестирования это не может компилироваться, создавая сообщение об ошибке, которое я честно не знаю, как интерпретировать.
Код: Выделить всё
#include
#include
namespace outcome = BOOST_OUTCOME_V2_NAMESPACE;
BOOST_OUTCOME_V2_NAMESPACE_BEGIN
template
inline bool try_operation_has_value(const llvm::ErrorOr& v)
{
return static_cast(v);
}
template
inline auto try_return_as(const llvm::ErrorOr& v)
{
if (!v) {
return failure(v->getError());
}
}
template
inline auto try_operation_extract_value(
const llvm::ErrorOr& v)
{
return (*v).get();
}
BOOST_OUTCOME_V2_NAMESPACE_END
int test_stdin()
{
BOOST_OUTCOME_TRY(const auto& ibuff, llvm::MemoryBuffer::getSTDIN());
return 0;
}
Код: Выделить всё
no instance of overloaded function "boost::outcome_v2::try_operation_return_as" matches the argument listC/C++(304)
main.cpp(78, 3): argument types are: (llvm::ErrorOr)
< /code>
Второй элемент: < /p>
no matching function for call to 'try_operation_return_as'GCC
try.hpp(375, 32): expanded from macro 'BOOST_OUTCOME_TRY'
try.hpp(191, 35): expanded from macro 'BOOST_OUTCOME_TRY_CALL_OVERLOAD'
try.hpp(188, 55): expanded from macro 'BOOST_OUTCOME_TRY_OVERLOAD_MACRO'
try.hpp(375, 32): skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all
try.hpp(316, 36): expanded from macro 'BOOST_OUTCOME_TRYA'
try.hpp(251, 3): expanded from macro 'BOOST_OUTCOME_TRY2_SUCCESS_LIKELY'
try.hpp(236, 21): expanded from macro 'BOOST_OUTCOME_TRYV2_SUCCESS_LIKELY'
try.hpp(129, 33): candidate template ignored: requirement 'detail::has_as_failure(5)' was not satisfied [with T = decltype(_outcome_try_unique_name_temporary0)]
try.hpp(138, 33): candidate template ignored: requirement 'detail::has_assume_error(5)' was not satisfied [with T = decltype(_outcome_try_unique_name_temporary0)]
try.hpp(147, 33): candidate template ignored: requirement 'detail::has_error(5)' was not satisfied [with T = decltype(_outcome_try_unique_name_temporary0)]
< /code>
, который, кажется, появляется в выводе компилятора следующим образом: < /p>
[build] /projects/sandbox/cpp_sandbox_10/source/main.cpp:78:3: error: no matching function for call to 'try_operation_return_as'
[build] 78 | BOOST_OUTCOME_TRY(const auto& ibuff, llvm::MemoryBuffer::getSTDIN());
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:375:32: note: expanded from macro 'BOOST_OUTCOME_TRY'
[build] 375 | #define BOOST_OUTCOME_TRY(...) BOOST_OUTCOME_TRY_CALL_OVERLOAD(BOOST_OUTCOME_TRY_INVOKE_TRY, __VA_ARGS__)
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:191:35: note: expanded from macro 'BOOST_OUTCOME_TRY_CALL_OVERLOAD'
[build] 191 | BOOST_OUTCOME_TRY_OVERLOAD_GLUE(BOOST_OUTCOME_TRY_OVERLOAD_MACRO(name, BOOST_OUTCOME_TRY_COUNT_ARGS_MAX8(__VA_ARGS__)), (__VA_ARGS__))
[build] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:188:55: note: expanded from macro 'BOOST_OUTCOME_TRY_OVERLOAD_MACRO'
[build] 188 | #define BOOST_OUTCOME_TRY_OVERLOAD_MACRO(name, count) BOOST_OUTCOME_TRY_OVERLOAD_MACRO1(name, count)
[build] | ^
[build] note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:316:36: note: expanded from macro 'BOOST_OUTCOME_TRYA'
[build] 316 | #define BOOST_OUTCOME_TRYA(v, ...) BOOST_OUTCOME_TRY2_SUCCESS_LIKELY(BOOST_OUTCOME_TRY_UNIQUE_NAME, return, v, __VA_ARGS__)
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:251:3: note: expanded from macro 'BOOST_OUTCOME_TRY2_SUCCESS_LIKELY'
[build] 251 | BOOST_OUTCOME_TRYV2_SUCCESS_LIKELY(unique, retstmt, var, __VA_ARGS__); \
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:236:21: note: expanded from macro 'BOOST_OUTCOME_TRYV2_SUCCESS_LIKELY'
[build] 236 | auto unique##_f(::BOOST_OUTCOME_V2_NAMESPACE::try_operation_return_as(static_cast(unique))); \
[build] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:129:33: note: candidate template ignored: requirement 'detail::has_as_failure(5)' was not satisfied [with T = decltype(_outcome_try_unique_name_temporary0)]
[build] 129 | constexpr inline decltype(auto) try_operation_return_as(T &&v, detail::as_failure_overload = {})
[build] | ^
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:138:33: note: candidate template ignored: requirement 'detail::has_assume_error(5)' was not satisfied [with T = decltype(_outcome_try_unique_name_temporary0)]
[build] 138 | constexpr inline decltype(auto) try_operation_return_as(T &&v, detail::assume_error_overload = {})
[build] | ^
[build] /opt/miniforge3/envs/cpp_sandbox_10/include/boost/outcome/try.hpp:147:33: note: candidate template ignored: requirement 'detail::has_error(5)' was not satisfied [with T = decltype(_outcome_try_unique_name_temporary0)]
[build] 147 | constexpr inline decltype(auto) try_operation_return_as(T &&v, detail::error_overload = {})
[build] | ^
Подробнее здесь: https://stackoverflow.com/questions/794 ... vmerrorort
Мобильная версия