samedi 5 février 2022

How to use std::chrono::duration in RTTR with Visual Studio >= 2019?

I am using RTTR for reflection and I'd like to use Chrono for certain types. However the following fails on >= Visual Studio 2019

  using microsecDouble = std::chrono::duration<double, std::micro>;
  auto microsecDoubleType = ::rttr::type::get<microsecDouble>();

with

  foo.cpp
c:\workspace\rttr\include\rttr/detail/type/type_data.h(331,1): error C2752: 'rttr::detail::template_type_trait<T>': more than one partial specialization matches the template argument list [c:\workspace\test\build\foo.vcxproj]
          with
          [
              T=non_ref_type
          ]
c:\workspace\rttr\include\rttr/detail/misc/template_type_trait_impl.h(135,1): message : could be 'rttr::detail::template_type_trait<T<Args...>>' [c:\workspace\test\build\foo.vcxproj]
c:\workspace\rttr\include\rttr/detail/misc/template_type_trait_impl.h(136,1): message : or       'rttr::detail::template_type_trait<T<Args...>>' [c:\workspace\test\build\foo.vcxproj]
c:\workspace\rttr\include\rttr/detail/misc/template_type_trait_impl.h(137,1): message : or       'rttr::detail::template_type_trait<T<Args...>>' [c:\workspace\test\build\foo.vcxproj]
c:\workspace\rttr\include\rttr/detail/misc/template_type_trait_impl.h(138,1): message : or       'rttr::detail::template_type_trait<T<Args...>>' [c:\workspace\test\build\foo.vcxproj]
c:\workspace\rttr\include\rttr/detail/type/type_impl.h(304): message : see reference to function template instantiation 'std::unique_ptr<rttr::detail::type_data,std::default_delete<rttr::detail::type_data>> rttr::detail::make_type_data<T>(void)' being compiled [c:\workspace\test\build\foo.vcxproj]
          with
          [
              T=non_ref_type
          ]
c:\workspace\rttr\include\rttr/detail/type/type_impl.h(371): message : see reference to function template instantiation 'rttr::type rttr::detail::create_or_get_type<non_ref_type>(void) noexcept' being compiled [c:\workspace\test\build\foo.vcxproj]
c:\workspace\rttr\include\rttr/detail/misc/template_type_trait_impl.h(44): message : see reference to function template instantiation 'rttr::type rttr::type::get<std::micro>(void) noexcept' being compiled [c:\workspace\test\build\foo.vcxproj]
c:\workspace\rttr\include\rttr/detail/misc/template_type_trait_impl.h(44): message : while compiling class template member function 'std::vector<rttr::type,std::allocator<rttr::type>> rttr::detail::template_type_trait<T>::get_template_arguments(void)' [c:\workspace\test\build\foo.vcxproj]
          with
          [
              T=non_ref_type
          ]
c:\workspace\rttr\include\rttr/detail/type/type_data.h(301): message : see reference to function template instantiation 'std::vector<rttr::type,std::allocator<rttr::type>> rttr::detail::template_type_trait<T>::get_template_arguments(void)' being compiled [c:\workspace\test\build\foo.vcxproj]
          with
          [
              T=non_ref_type
          ]
c:\workspace\rttr\include\rttr/detail/type/type_data.h(331): message : see reference to class template instantiation 'rttr::detail::template_type_trait<T>' being compiled [c:\workspace\test\build\foo.vcxproj]
          with
          [
              T=non_ref_type
          ]
c:\workspace\rttr\include\rttr/detail/type/type_impl.h(304): message : see reference to function template instantiation 'std::unique_ptr<rttr::detail::type_data,std::default_delete<rttr::detail::type_data>> rttr::detail::make_type_data<T>(void)' being compiled [c:\workspace\test\build\foo.vcxproj]
          with
          [
              T=non_ref_type
          ]
c:\workspace\rttr\include\rttr/detail/type/type_impl.h(371): message : see reference to function template instantiation 'rttr::type rttr::detail::create_or_get_type<non_ref_type>(void) noexcept' being compiled [c:\workspace\test\build\foo.vcxproj]
c:\workspace\test\foo.cpp(7): message : see reference to function template instantiation 'rttr::type rttr::type::get<microsecDouble>(void) noexcept' being compiled [c:\workspace\test\build\foo.vcxproj]

When compiling with VS 2017, or with Linux, everything is fine. Has anyone bumped into this or knows how to get around this?

Thanks,





Aucun commentaire:

Enregistrer un commentaire