[libcxx-commits] [PATCH] D140911: [In Progress][libc++] Implement P2505R5(Monadic operations for std::expected)
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 7 03:30:40 PST 2023
philnik added inline comments.
================
Comment at: libcxx/include/__expected/expected.h:637
+ template <class _Func>
+ requires is_copy_constructible_v<_Err> _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
+ using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;
----------------
yronglin wrote:
> philnik wrote:
> > This formatting seems very weird. Does clang-format produce this? If yes, which version are you using? Maybe you have to upgrade.
> > This formatting seems very weird. Does clang-format produce this? If yes, which version are you using? Maybe you have to upgrade.
>
> Yes, I think so too, when I use vscode + clangd plugin, the formatted code looks like:
> ```
> // [expected.void.monadic], monadic
> template <class _Func>
> requires is_copy_constructible_v<_Err>
> _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
> using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;
> static_assert(
> __expected::__is_expected<_Up>::value, "result of f(value()) must be a specialization of std::expected");
> static_assert(is_same_v<typename _Up::error_type, _Err>,
> "std::remove_cvref_t<decltype(f(value()))>>::error_type must same as error_type");
> if (has_value()) {
> return std::invoke(std::forward<_Func>(__f), value());
> }
> return _Up(unexpect, error());
> }
> ```
> but this code can not pass CI `Format` check, therefore, according to the error message generated by CI, I manually modified the format of the code.
> my clangd version is:
> ```
> ➜ llvm-project git:(main) ✗ clangd --version
> clangd version 16.0.0 (https://mirrors.tuna.tsinghua.edu.cn/git/llvm-project.git 2f08872d81fd324bf3532e0919f256d475f21729)
> Features: mac+xpc
> Platform: arm64-apple-darwin21.6.0
> ```
Then go with the formatting you get locally. The formatting CI is just soft-failing, so you can ignore it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140911/new/
https://reviews.llvm.org/D140911
More information about the libcxx-commits
mailing list