Conversation
cpp/core/image_helpers.h
Outdated
| template <typename OtherType> FORCE_INLINE value_type operator=(Value<OtherType> &&V) { | ||
| return set(typename OtherType::value_type(V)); | ||
| template <typename OtherImageType> FORCE_INLINE value_type operator=(Value<OtherImageType> &&V) { | ||
| return set(static_cast<value_type>(static_cast<typename OtherImageType::value_type>(V))); |
There was a problem hiding this comment.
warning: call to deleted constructor of 'MR::Helper::Value<MR::(anonymous namespace)::TmpImageEigen::half>' [clang-diagnostic-error]
return set(static_cast<value_type>(static_cast<typename OtherImageType::value_type>(V)));
^Additional context
cpp/core/algo/threaded_copy.h:28: in instantiation of function template specialization 'MR::Helper::Value<MR::ImageEigen::half>::operator=<MR::(anonymous namespace)::TmpImageEigen::half>' requested here
out.value() = in.value();
^/usr/include/c++/13/bits/invoke.h:60: in instantiation of function template specialization 'MR::(anonymous namespace)::__copy_func::operator()<MR::(anonymous namespace)::TmpImageEigen::half, MR::ImageEigen::half>' requested here
{ return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); }
^cpp/core/algo/threaded_loop.h:314: in instantiation of member function 'MR::(anonymous namespace)::ThreadedLoopRunInner<2, MR::(anonymous namespace)::__copy_func, MR::(anonymous namespace)::TmpImageEigen::half, MR::ImageEigen::half>::operator()' requested here
^cpp/core/algo/threaded_loop.h:368: in instantiation of function template specialization 'MR::(anonymous namespace)::ThreadedLoopRunOuterMR::LoopAlongDynamicAxesProgress::run_outer<MR::(anonymous namespace)::ThreadedLoopRunInner<2, MR::(anonymous namespace)::__copy_func, MR::(anonymous namespace)::TmpImageEigen::half, MR::ImageEigen::half> &>' requested here
^cpp/core/algo/threaded_copy.h:69: in instantiation of function template specialization 'MR::(anonymous namespace)::ThreadedLoopRunOuterMR::LoopAlongDynamicAxesProgress::run<MR::(anonymous namespace)::__copy_func, MR::(anonymous namespace)::TmpImageEigen::half &, MR::ImageEigen::half &>' requested here
ThreadedLoop(message, source, from_axis, to_axis, num_axes_in_thread).run(__copy_func(), source, destination);
^cpp/core/image.h:351: in instantiation of function template specialization 'MR::threaded_copy_with_progress_message<MR::(anonymous namespace)::TmpImageEigen::half, MR::ImageEigen::half>' requested here
threaded_copy_with_progress_message("writing back direct IO buffer for \"" + name() + "\"", src, dest);
^cpp/core/image_helpers.h:493: 'Value' has been explicitly marked deleted here
Value(const Value &) = delete;
^_deps/eigen3-src/Eigen/src/Core/arch/Default/Half.h:180: passing argument to parameter 'val' here
explicit EIGEN_DEVICE_FUNC half(T val)
^|
I had thought that: template <typename OtherImageType> FORCE_INLINE value_type operator=(Value<OtherImageType> &&V) {
return set(static_cast<value_type>(static_cast<typename OtherImageType::value_type>(std::forward<Value<OtherImageType>>(V))));
}might get it, but it seems Eigen doesn't like copy-constructing half-floats from half-floats: The |
|
This is quite tricky C++. The statement |
|
Personally I'd like to proceed with this: the prior |
|
clang-tidy review says "All clean, LGTM! 👍" |
Closes #3180.
I had an initial unsuccessful go at this; pushing draft as I need to switch to other tasks and don't want it to disappear.
Initially looked like it would be a fairly trivial switchout, but was having trouble getting
template <class ImageType> class Valueto work. Here's my current compilation issue:, where the relevant code in aa0d8b6 is:
So despite an explicit
static_cast<>, it's still trying to construct anEigen::halffrom aValue<ImageType>. Presumably it's due to the use of an rvalue reference, which I have almost zero experience with; I couldn't getstd::remove_reference()to work for me as any attempt would involve invoking the deletedValue<ImageType>copy-constructor. If there's no trivial way around it, could define a class that inherits fromEigen::halfand provides the requisite interface. Content to do that effort byt will first await if @daljit46 or @jdtournier can immediately see a fix.