Closed emmenlau closed 1 year ago
CC @N-Dekker
@emmenlau Thanks Mario, I did not know about this issue.
Apparently we should add a feature test on __cpp_lib_smart_ptr_for_overwrite
. Right?
https://en.cppreference.com/w/cpp/feature_test#Library_features
Hey @N-Dekker no worries I could hack my way around it on Apple. But yes, the feature test seems the correct thing, and maybe with the feature check, there may not even be a need for the C++20 check anymore...
Thanks. I thought about it again, maybe it's better to just remove the #if
entirely, and use the ITK implementation unconditionally. Because otherwise I'm afraid there is a risk of violating the C++ One Definition Rule (ODR), when ITK library and the user code do not have exactly the same compiler settings. Specifically, the ITK library could be compiled in C++14 mode, while the user code could use C++20. Things may then become dodgy when ITK library functions that are defined in "itk.hxx" or "itk.h" files call make_unique_for_overwrite
.
Because otherwise I'm afraid there is a risk of violating the C++ One Definition Rule (ODR), when ITK library and the user code do not have exactly the same compiler settings. Specifically, the ITK library could be compiled in C++14 mode, while the user code could use C++20.
@N-Dekker good idea :-). I ran into this issue myself recently in itk-wasm.
Closed via #3856 , thanks @N-Dekker
I have a problem building current latest ITK on MacOS with current latest XCode with C++20. The error I get is:
I think this is due to the following check being too liberal: https://github.com/InsightSoftwareConsortium/ITK/blob/15d09d6c756b46b4d1c296d8bb13b85f82654ef9/Modules/Core/Common/include/itkMakeUniqueForOverwrite.h#L24
As far as I can see, not many compilers currently support
std::make_unique_for_overwrite
: https://en.cppreference.com/w/cpp/compiler_support