Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct_pack is not compatible with vs2017 c++17 #523

Closed
1 of 2 tasks
romanholidaypancakes opened this issue Dec 11, 2023 · 17 comments
Closed
1 of 2 tasks

struct_pack is not compatible with vs2017 c++17 #523

romanholidaypancakes opened this issue Dec 11, 2023 · 17 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@romanholidaypancakes
Copy link

romanholidaypancakes commented Dec 11, 2023

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

i get an error when compiling with vs2017 c++17

Reproduction way

  • test code
struct MyStruct {
    unsigned int test{};
};

int main(int argc, char* argv[]) {
    MyStruct test{};
    auto     out1 = struct_pack::serialize(test);
    auto     out2 = struct_pack::deserialize<MyStruct>(out1);
    return 0;
}
  • compiler configuration

    • Visual Studio 2017 (v141)
      image

    • ISO C++17 Standard (/std:c++17)
      image

  • first time error

    1>------ Build started: Project: ConsoleApplication1, Configuration: Release x64 ------
    1>ConsoleApplication1.cpp
    1>d:\\superthirdparty\yalantinglibs\include\ylt\struct_pack\marco.h(34): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\superthirdparty\yalantinglibs\include\ylt\struct_pack\marco.h(42): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\superthirdparty\yalantinglibs\include\ylt\struct_pack\endian_wrapper.hpp(17): fatal error C1083: Cannot open include file: 'bit': No such file or directory
    1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
    
  • maybe vs2017 c++17 didn't implement it and then I used a higher version of the bit header file and still got the error

    1>------ Build started: Project: ConsoleApplication1, Configuration: Release x64 ------
    1>ConsoleApplication1.cpp
    1>d:\\yalantinglibs\include\ylt\struct_pack\marco.h(34): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\yalantinglibs\include\ylt\struct_pack\marco.h(42): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2825: 'T': must be a class or namespace when followed by '::'
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(364): note: see reference to class template instantiation 'struct_pack::detail::get_array_element<unsigned int>' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(346): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl_helper<18446744073709551615,unsigned int,>(void)' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(487): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl<18446744073709551615,U,,0>(std::integer_sequence<unsigned __int64,0>)' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(492): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist<T,18446744073709551615>(void)' being compiled
    1>        with
    1>        [
    1>            T=std::tuple<unsigned int>
    1>        ]
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(671): note: see reference to variable template 'const bool exist_compatible_member<MyStruct,-1>' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\calculate_size.hpp(405): note: see reference to class template instantiation 'struct_pack::detail::serialize_static_config<Type>' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack.hpp(144): note: see reference to function template instantiation 'struct_pack::serialize_buffer_size struct_pack::detail::get_serialize_runtime_info<0,MyStruct>(const MyStruct &)' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack.hpp(205): note: see reference to function template instantiation 'void struct_pack::serialize_to<0,Buffer,MyStruct>(Writer &,const MyStruct &)' being compiled
    1>        with
    1>        [
    1>            Buffer=std::vector<char,std::allocator<char>>,
    1>            Writer=std::vector<char,std::allocator<char>>
    1>        ]
    1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(18): note: see reference to function template instantiation 'Buffer struct_pack::serialize<std::vector<char,std::allocator<char>>,MyStruct>(const MyStruct &)' being compiled
    1>        with
    1>        [
    1>            Buffer=std::vector<char,std::allocator<char>>
    1>        ]
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2510: 'T': left of '::' must be a class/struct/union
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2061: syntax error: identifier 'value_type'
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
    1>        with
    1>        [
    1>            _Ty=unsigned int
    1>        ]
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
    1>        with
    1>        [
    1>            _Ty=unsigned int
    1>        ]
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(429): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
    1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

Anything else

  • the visual studio installer allows you to quickly install the vs2017 c++ toolchain.

image

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!
@poor-circle
Copy link
Collaborator

image

You need at least MSVC14.20(aks visual studio 2019) to compile struct_pack.

Now we don't have plan to support vs2017, because it didn't finish some c++17 feature.

@romanholidaypancakes
Copy link
Author

Well, I forgot to check, I just remembered that there was support for c++17 some time ago. Everything was fine with struct_pack in our new project, but we wanted to use it in our old project as well had this problem, we couldn't upgrade the compiler version of our old project.

@romanholidaypancakes
Copy link
Author

Is there any simple fix for this, we don't need bit related operations, just use serialization and deserialization of some simple structures and stl containers like (stirng)

@poor-circle
Copy link
Collaborator

Well, I think it's possible to fix the problem, I check the cpprefence and it seems that the highest version of VS2017 support almost all c++17 feature.

@poor-circle
Copy link
Collaborator

could you try to remove

template <typename T>
struct get_array_element {
  using type = typename T::value_type;
};

template <typename T, std::size_t sz>
struct get_array_element<T[sz]> {
  using type = T;
};

and instead it by:

template <typename T>
struct get_array_element {
  using type = remove_cvref_t<decltype(std::declval<T>()[0])>;
};

@poor-circle
Copy link
Collaborator

could you try to remove

template <typename T>
struct get_array_element {
  using type = typename T::value_type;
};

template <typename T, std::size_t sz>
struct get_array_element<T[sz]> {
  using type = T;
};

and instead it by:

template <typename T>
struct get_array_element {
  using type = remove_cvref_t<decltype(std::declval<T>()[0])>;
};

I have no environment of VS2017. So I no sure if it can fix all the problem.

@romanholidaypancakes
Copy link
Author

got errors

1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2109: subscript requires array or pointer type
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(359): note: see reference to class template instantiation 'struct_pack::detail::get_array_element<unsigned int>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(341): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl_helper<18446744073709551615,unsigned int,>(void)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(482): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl<18446744073709551615,U,,0>(std::integer_sequence<unsigned __int64,0>)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(106): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist<T,18446744073709551615>(void)' being compiled
1>        with
1>        [
1>            T=std::tuple<unsigned int>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(282): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(286): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(403): note: see reference to function template instantiation 'struct_pack::errc struct_pack::deserialize_to<0,U,,View,void>(T &,const View &)' being compiled
1>        with
1>        [
1>            U=MyStruct,
1>            View=std::vector<char,std::allocator<char>>,
1>            T=MyStruct
1>        ]
1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): note: see reference to function template instantiation 'tl::expected<MyStruct,struct_pack::errc> struct_pack::deserialize<MyStruct,Buffer,void>(const View &)' being compiled
1>        with
1>        [
1>            Buffer=std::vector<char,std::allocator<char>>,
1>            View=std::vector<char,std::allocator<char>>
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(424): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2676: binary '[': 'T' does not define this operator or a conversion to a type acceptable to the predefined operator
1>        with
1>        [
1>            T=T
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(512): note: see reference to class template instantiation 'struct_pack::detail::get_array_element<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(458): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<T,>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(468): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(476): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(157): note: see reference to variable template 'const auto compatible_version_number<MyStruct>' being compiled
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(571): note: see reference to variable template 'const size_t variant_size_v<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(83): error C2338: not allow empty input!
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(470): note: see reference to function template instantiation 'void struct_pack::detail::compile_time_unique<uint64_t,0,0>(const std::array<uint64_t,0> &,std::array<uint64_t,0> &)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(458): note: see reference to class template instantiation 'std::array<uint64_t,0>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(468): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(476): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(476): error C2131: expression did not evaluate to a constant
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: see usage of 'std::array<uint64_t,0>::operator []'

@poor-circle
Copy link
Collaborator

emmm. Could you try this?

template <typename T, typename enable = void>
struct get_array_element {
  using type = void;
};

template <typename T>
struct get_array_element<T,std::enable_if_t<array<T>>> {
  using type = typename T::value_type;
};

template <typename T, std::size_t sz>
struct get_array_element<T[sz]> {
  using type = T;
};

@romanholidaypancakes
Copy link
Author

1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(434): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(351): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl_helper<18446744073709551615,unsigned int,>(void)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(492): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl<18446744073709551615,U,,0>(std::integer_sequence<unsigned __int64,0>)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(106): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist<T,18446744073709551615>(void)' being compiled
1>        with
1>        [
1>            T=std::tuple<unsigned int>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(282): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(286): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(403): note: see reference to function template instantiation 'struct_pack::errc struct_pack::deserialize_to<0,U,,View,void>(T &,const View &)' being compiled
1>        with
1>        [
1>            U=MyStruct,
1>            View=std::vector<char,std::allocator<char>>,
1>            T=MyStruct
1>        ]
1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): note: see reference to function template instantiation 'tl::expected<MyStruct,struct_pack::errc> struct_pack::deserialize<MyStruct,Buffer,void>(const View &)' being compiled
1>        with
1>        [
1>            Buffer=std::vector<char,std::allocator<char>>,
1>            View=std::vector<char,std::allocator<char>>
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(581): note: see reference to variable template 'const size_t variant_size_v<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(468): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<T,>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(486): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(157): note: see reference to variable template 'const auto compatible_version_number<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(83): error C2338: not allow empty input!
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(480): note: see reference to function template instantiation 'void struct_pack::detail::compile_time_unique<uint64_t,0,0>(const std::array<uint64_t,0> &,std::array<uint64_t,0> &)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(468): note: see reference to class template instantiation 'std::array<uint64_t,0>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(486): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(486): error C2131: expression did not evaluate to a constant
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: see usage of 'std::array<uint64_t,0>::operator []'

@poor-circle
Copy link
Collaborator

poor-circle commented Dec 11, 2023

Well, fix one problem then jump aonther one. I afraid The VS2017 has a poor support for if-constexpr statment.
Try add:

template <typename T, typename enable = void>
struct get_varint_size {
  static constexpr std::size_t size = 0;
};

template <typename T>
struct get_varint_size<T, std::enable_if_t<is_variant_v<T>>> {
  static constexpr std::size_t size = std::variant_size_v<T>;
};

Then replace the code

    else if constexpr (id == type_id::variant_t) {
      return check_if_compatible_element_exist_impl_variant<version, T, T,
                                                            ParentArgs...>(
          std::make_index_sequence<std::variant_size_v<T>>{});
    }

with:

    else if constexpr (id == type_id::variant_t) {
      return check_if_compatible_element_exist_impl_variant<version, T, T,
                                                            ParentArgs...>(
          std::make_index_sequence<get_varint_size<T>::size>{});
    }

@poor-circle
Copy link
Collaborator

poor-circle commented Dec 11, 2023

I afraid the poor support of if-constexpr statement could cause a lot of compile errors. If the compile error still exists, It's hard to fix all if-constexpr statement.

@romanholidaypancakes
Copy link
Author

here are the changes i've made

image

1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(591): note: see reference to variable template 'const size_t variant_size_v<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<T,>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(488): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(157): note: see reference to variable template 'const auto compatible_version_number<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(282): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(286): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(403): note: see reference to function template instantiation 'struct_pack::errc struct_pack::deserialize_to<0,U,,View,void>(T &,const View &)' being compiled
1>        with
1>        [
1>            U=MyStruct,
1>            View=std::vector<char,std::allocator<char>>,
1>            T=MyStruct
1>        ]
1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): note: see reference to function template instantiation 'tl::expected<MyStruct,struct_pack::errc> struct_pack::deserialize<MyStruct,Buffer,void>(const View &)' being compiled
1>        with
1>        [
1>            Buffer=std::vector<char,std::allocator<char>>,
1>            View=std::vector<char,std::allocator<char>>
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(591): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(516): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<unsigned int,T>(void)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(532): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<subArgs,T,0>(std::integer_sequence<unsigned __int64,0>)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<T,>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(83): error C2338: not allow empty input!
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(490): note: see reference to function template instantiation 'void struct_pack::detail::compile_time_unique<uint64_t,0,0>(const std::array<uint64_t,0> &,std::array<uint64_t,0> &)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to class template instantiation 'std::array<uint64_t,0>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(488): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): error C2131: expression did not evaluate to a constant
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: see usage of 'std::array<uint64_t,0>::operator []'
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

@poor-circle
Copy link
Collaborator

here are the changes i've made

image

1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(591): note: see reference to variable template 'const size_t variant_size_v<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<T,>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(488): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(157): note: see reference to variable template 'const auto compatible_version_number<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(282): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(286): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(403): note: see reference to function template instantiation 'struct_pack::errc struct_pack::deserialize_to<0,U,,View,void>(T &,const View &)' being compiled
1>        with
1>        [
1>            U=MyStruct,
1>            View=std::vector<char,std::allocator<char>>,
1>            T=MyStruct
1>        ]
1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): note: see reference to function template instantiation 'tl::expected<MyStruct,struct_pack::errc> struct_pack::deserialize<MyStruct,Buffer,void>(const View &)' being compiled
1>        with
1>        [
1>            Buffer=std::vector<char,std::allocator<char>>,
1>            View=std::vector<char,std::allocator<char>>
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(591): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(516): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<unsigned int,T>(void)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(532): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<subArgs,T,0>(std::integer_sequence<unsigned __int64,0>)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to function template instantiation 'size_t struct_pack::detail::calculate_compatible_version_size<T,>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(83): error C2338: not allow empty input!
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(490): note: see reference to function template instantiation 'void struct_pack::detail::compile_time_unique<uint64_t,0,0>(const std::array<uint64_t,0> &,std::array<uint64_t,0> &)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to class template instantiation 'std::array<uint64_t,0>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(488): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): error C2131: expression did not evaluate to a constant
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: see usage of 'std::array<uint64_t,0>::operator []'
1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.

Use get_variant_size instead of std::variant_size_v in line 591.

@romanholidaypancakes
Copy link
Author

romanholidaypancakes commented Dec 11, 2023

image

1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(679): note: see reference to variable template 'const size_t variant_size_v<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(480): note: see reference to function template instantiation 'void struct_pack::detail::get_compatible_version_numbers<std::array<uint64_t,0>,T,>(Buffer &,size_t &)' being compiled
1>        with
1>        [
1>            T=MyStruct,
1>            Buffer=std::array<uint64_t,0>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(488): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): note: see reference to function template instantiation 'auto struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(157): note: see reference to variable template 'const auto compatible_version_number<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(282): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(286): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(403): note: see reference to function template instantiation 'struct_pack::errc struct_pack::deserialize_to<0,U,,View,void>(T &,const View &)' being compiled
1>        with
1>        [
1>            U=MyStruct,
1>            View=std::vector<char,std::allocator<char>>,
1>            T=MyStruct
1>        ]
1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): note: see reference to function template instantiation 'tl::expected<MyStruct,struct_pack::errc> struct_pack::deserialize<MyStruct,Buffer,void>(const View &)' being compiled
1>        with
1>        [
1>            Buffer=std::vector<char,std::allocator<char>>,
1>            View=std::vector<char,std::allocator<char>>
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
1>        with
1>        [
1>            _Ty=unsigned int
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(679): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(600): note: see reference to function template instantiation 'void struct_pack::detail::get_compatible_version_numbers<Buffer,unsigned int,T>(Buffer &,size_t &)' being compiled
1>        with
1>        [
1>            Buffer=std::array<uint64_t,0>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(619): note: see reference to function template instantiation 'void struct_pack::detail::get_compatible_version_numbers<Buffer,subArgs,T,0>(Buffer &,size_t &,std::integer_sequence<unsigned __int64,0>)' being compiled
1>        with
1>        [
1>            Buffer=std::array<uint64_t,0>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(480): note: see reference to function template instantiation 'void struct_pack::detail::get_compatible_version_numbers<std::array<uint64_t,0>,T,>(Buffer &,size_t &)' being compiled
1>        with
1>        [
1>            T=MyStruct,
1>            Buffer=std::array<uint64_t,0>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(83): error C2338: not allow empty input!
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(490): note: see reference to function template instantiation 'void struct_pack::detail::compile_time_unique<uint64_t,0,0>(const std::array<uint64_t,0> &,std::array<uint64_t,0> &)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to class template instantiation 'std::array<uint64_t,0>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): error C2131: expression did not evaluate to a constant
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: see usage of 'std::array<uint64_t,0>::operator []'

@poor-circle
Copy link
Collaborator

poor-circle commented Dec 11, 2023

You can replace all variant_size_v<T> by get_variant_size<T>::size. But I'm afraid their still has other problem. We need fix a lots of code.

@romanholidaypancakes
Copy link
Author

1>d:\yalantinglibs\include\ylt\struct_pack\util.h(83): error C2338: not allow empty input!
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(490): note: see reference to function template instantiation 'void struct_pack::detail::compile_time_unique<uint64_t,0,0>(const std::array<uint64_t,0> &,std::array<uint64_t,0> &)' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(478): note: see reference to class template instantiation 'std::array<uint64_t,0>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(488): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): note: see reference to function template instantiation 'std::array<uint64_t,0> struct_pack::detail::get_sorted_and_uniqued_compatible_version_numbers<T>(void)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\unpacker.hpp(157): note: see reference to variable template 'const std::array<uint64_t,0> compatible_version_number<MyStruct>' being compiled
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(282): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(286): note: see reference to function template instantiation 'struct_pack::errc struct_pack::detail::unpacker<struct_pack::detail::memory_reader,0>::deserialize<T,>(T &)' being compiled
1>        with
1>        [
1>            T=MyStruct
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack.hpp(403): note: see reference to function template instantiation 'struct_pack::errc struct_pack::deserialize_to<0,U,,View,void>(T &,const View &)' being compiled
1>        with
1>        [
1>            U=MyStruct,
1>            View=std::vector<char,std::allocator<char>>,
1>            T=MyStruct
1>        ]
1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(19): note: see reference to function template instantiation 'tl::expected<MyStruct,struct_pack::errc> struct_pack::deserialize<MyStruct,Buffer,void>(const View &)' being compiled
1>        with
1>        [
1>            Buffer=std::vector<char,std::allocator<char>>,
1>            View=std::vector<char,std::allocator<char>>
1>        ]
1>d:\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(496): error C2131: expression did not evaluate to a constant
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'
1>d:\yalantinglibs\include\ylt\struct_pack\util.h(84): note: see usage of 'std::array<uint64_t,0>::operator []'

@poor-circle
Copy link
Collaborator

I'm afraid it's no a simple problem. Maybe I will fix it later when I have time.

@poor-circle poor-circle added bug Something isn't working wontfix This will not be worked on labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants