In Clang 16, example is unable to build when C++20 or C++23, due to type MergeTask depends on CopyElements, CopyIndices, FillElements, FillIds whose structs are defined below the type definition and therefore implicitly instantiated. For this code
runs ok, but with version 20 (clang++ -std=c++20 main.cpp -o main)
In file included from main.cpp:1:
[...omitted...]
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__utility/move.h:15:
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__type_traits/is_copy_constructible.h:27:11: error: incomplete type 'rapidobj::detail::CopyIndices' used in type trait expression
__is_constructible(_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__type_traits/is_copy_constructible.h:31:49: note: in instantiation of template class 'std::is_copy_constructible<rapidobj::detail::CopyIndices>' requested here
inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/variant:1296:17: note: in instantiation of variable template specialization 'std::is_copy_constructible_v<rapidobj::detail::CopyIndices>' requested here
__all<is_copy_constructible_v<_Types>...>::value,
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/vector:549:52: note: in instantiation of template class 'std::variant<rapidobj::detail::CopyElements<unsigned char>, rapidobj::detail::CopyElements<int>, rapidobj::detail::CopyElements<float>, rapidobj::detail::CopyIndices, rapidobj::detail::FillElements<float>, rapidobj::detail::FillIds<int>, rapidobj::detail::FillIds<unsigned int>>' requested here
{return static_cast<size_type>(__end_cap() - this->__begin_);}
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/vector:763:56: note: in instantiation of member function 'std::vector<std::variant<rapidobj::detail::CopyElements<unsigned char>, rapidobj::detail::CopyElements<int>, rapidobj::detail::CopyElements<float>, rapidobj::detail::CopyIndices, rapidobj::detail::FillElements<float>, rapidobj::detail::FillIds<int>, rapidobj::detail::FillIds<unsigned int>>>::capacity' requested here
__annotate_contiguous_container(data(), data() + capacity(),
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/vector:442:18: note: in instantiation of member function 'std::vector<std::variant<rapidobj::detail::CopyElements<unsigned char>, rapidobj::detail::CopyElements<int>, rapidobj::detail::CopyElements<float>, rapidobj::detail::CopyIndices, rapidobj::detail::FillElements<float>, rapidobj::detail::FillIds<int>, rapidobj::detail::FillIds<unsigned int>>>::__annotate_delete' requested here
__vec_.__annotate_delete();
^
/opt/homebrew/opt/llvm/bin/../include/c++/v1/vector:456:67: note: in instantiation of member function 'std::vector<std::variant<rapidobj::detail::CopyElements<unsigned char>, rapidobj::detail::CopyElements<int>, rapidobj::detail::CopyElements<float>, rapidobj::detail::CopyIndices, rapidobj::detail::FillElements<float>, rapidobj::detail::FillIds<int>, rapidobj::detail::FillIds<unsigned int>>>::__destroy_vector::operator()' requested here
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector(*this)(); }
^
./rapidobj.hpp:4616:22: note: in instantiation of member function 'std::vector<std::variant<rapidobj::detail::CopyElements<unsigned char>, rapidobj::detail::CopyElements<int>, rapidobj::detail::CopyElements<float>, rapidobj::detail::CopyIndices, rapidobj::detail::FillElements<float>, rapidobj::detail::FillIds<int>, rapidobj::detail::FillIds<unsigned int>>>::~vector' requested here
auto tasks = MergeTasks();
^
./rapidobj.hpp:4582:8: note: forward declaration of 'rapidobj::detail::CopyIndices'
[...omitted...]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
I moved the implementation of Subdivide methods to below the struct definitions, and now it can be built for c++ ≥ 17.
In Clang 16, example is unable to build when C++20 or C++23, due to type
MergeTask
depends onCopyElements
,CopyIndices
,FillElements
,FillIds
whose structs are defined below the type definition and therefore implicitly instantiated. For this codewith build command
runs ok, but with version 20 (
clang++ -std=c++20 main.cpp -o main
)I moved the implementation of
Subdivide
methods to below the struct definitions, and now it can be built for c++ ≥ 17.