, and attempt to turn IconLoader::IconLoadedCallback and IconManager::IconRequestCallback into OnceCallbacks.
If you compile it, you find a series of issues that are easily run across and incredibly difficult to make sense of. If you fail to std::move() the callback before you .Run() it, the error message makes no sense and it is extremely difficult to figure out what's wrong. If you accidentally have a constant callback, the error message makes no sense and it is extremely difficult to figure out what's wrong. If you use base::Passed rather than std::move in base::BindOnce, the error message makes no sense and it is extremely difficult to figure out what's wrong.
My line to wrap a OnceCallback with another OnceCallback in IconManager::LoadIcon now looks like:
Does that look reasonable? The error message you get when trying to compile it is incomprehensible:
../../base/bind_internal.h:478:9: error: no matching constructor for initialization of 'std::tuple<Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating>, Callback<void (Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once> >'
bound_args_(std::forward<ForwardBoundArgs>(bound_args)...) {
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/bind_internal.h:444:9: note: in instantiation of function template specialization 'base::internal::BindState<void (*)(const base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, gfx::Image *), base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating>, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once> >::BindState<void (*)(const base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, gfx::Image *), base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, const base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once> >' requested here
: BindState(IsCancellable{},
^
../../base/bind.h:43:27: note: in instantiation of function template specialization 'base::internal::BindState<void (*)(const base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, gfx::Image *), base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating>, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once> >::BindState<void (*)(const base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, gfx::Image *), base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, const base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once> >' requested here
return CallbackType(new BindState(
^
../../chrome/browser/icon_manager.cc:69:47: note: in instantiation of function template specialization 'base::BindOnce<void (*)(const base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, gfx::Image *), base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, const base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once> >' requested here
IconRequestCallback callback_runner = base::BindOnce(
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:624:9: note: candidate template ignored: disabled by 'enable_if' [with _AllocArgT = base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating>, _Alloc = base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, _Dummy = true]
__lazy_and<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:639:26: note: candidate template ignored: disabled by 'enable_if' [with _Dummy = true]
_CheckArgsConstructor<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:657:26: note: candidate template ignored: disabled by 'enable_if' [with _Dummy = true]
_CheckArgsConstructor<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:715:26: note: candidate template ignored: disabled by 'enable_if' [with _Up = <base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, const base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>>, _PackIsTuple = false]
_CheckArgsConstructor<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:747:26: note: candidate template ignored: disabled by 'enable_if' [with _Up = <base::Callback<bool (), base::internal::CopyMode::Copyable, base::internal::RepeatMode::Repeating> &, const base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>>]
_CheckArgsConstructor<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:780:26: note: candidate template ignored: disabled by 'enable_if' [with _Alloc = base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, _Up = <>]
_CheckArgsConstructor<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:799:26: note: candidate template ignored: disabled by 'enable_if' [with _Alloc = base::Callback<void (gfx::Image *), base::internal::CopyMode::MoveOnly, base::internal::RepeatMode::Once>, _Up = <>]
_CheckArgsConstructor<
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:617:23: note: candidate constructor template not viable: requires 0 arguments, but 2 were provided
_LIBCPP_CONSTEXPR tuple()
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:682:7: note: candidate constructor template not viable: requires 4 arguments, but 2 were provided
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:702:7: note: candidate constructor template not viable: requires 4 arguments, but 2 were provided
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:827:9: note: candidate constructor template not viable: requires single argument '__t', but 2 arguments were provided
tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:842:9: note: candidate constructor template not viable: requires single argument '__t', but 2 arguments were provided
tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:855:9: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:869:9: note: candidate constructor template not viable: requires 3 arguments, but 2 were provided
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:620:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
tuple(tuple const&) = default;
^
/Volumes/src/chrome-git/src/third_party/llvm-build/Release+Asserts/bin/../include/c++/v1/tuple:621:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided
tuple(tuple&&) = default;
^
1 error generated.
I'm not asking for help here; I am abandoning this CL and telling my reviewer that I refuse to use OnceCallback because I am simply not smart enough to make it work. The problem is that I watch CppCon videos. I keep a copy of the C++ spec around to language lawyer people into submission. If I can't make it work, who can?