eyalz800 / serializer

A single header standard C++ serialization framework.
MIT License
189 stars 24 forks source link

fail to compile with cxx 17 but works with cxx 14 #10

Closed photoszzt closed 3 years ago

photoszzt commented 3 years ago

I hit the following error when I compile with cxx 17 but without error using cxx 14.

/source/worker/../common/import/serializer.h: In lambda function:
/source/worker/../common/import/serializer.h:2209:19: error: parameter packs not expanded with '...':
     if constexpr (std::is_default_constructible_v<Types>) {
                   ^~~
/source/worker/../common/import/serializer.h:2209:19: note:         'Types'
/source/worker/../common/import/serializer.h:2211:11: error: parameter packs not expanded with '...':
       if (!std::get_if<Types>(&variant)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/source/worker/../common/import/serializer.h:2211:11: note:         'Types'
/source/worker/../common/import/serializer.h:2212:17: error: parameter packs not expanded with '...':
         variant = Types{};
         ~~~~~~~~^~~~~~~~~
/source/worker/../common/import/serializer.h:2212:17: note:         'Types'
/source/worker/../common/import/serializer.h:2216:21: error: parameter packs not expanded with '...':
       return archive(*std::get_if<Types>(&variant));
              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/source/worker/../common/import/serializer.h:2216:21: note:         'Types'
/source/worker/../common/import/serializer.h:2219:61: error: parameter packs not expanded with '...':
       std::aligned_storage_t<sizeof(Types), alignof(Types)> storage;
                                                             ^~~~~~~
/source/worker/../common/import/serializer.h:2219:61: note:         'Types'
/source/worker/../common/import/serializer.h:2222:64: error: parameter packs not expanded with '...':
       std::unique_ptr<Types, void (*)(Types *)> object(access::placement_new<Types>(std::addressof(storage)),
                                                                ^~~~~~~~~~~~~~~~~~~~
/source/worker/../common/import/serializer.h:2222:64: note:         'Types'
/source/worker/../common/import/serializer.h:2223:104: error: parameter packs not expanded with '...':
                                                        [](auto pointer) { access::destruct(*pointer); });
                                                                                                        ^
/source/worker/../common/import/serializer.h:2223:104: note:         'Types'
/source/worker/../common/import/serializer.h: In function 'auto zpp::serializer::serialize(Archive&, std::variant<_Types ...>&)':
/source/worker/../common/import/serializer.h:2237:4: error: expansion pattern '<lambda>' contains no argument packs
   }...};
    ^~~
eyalz800 commented 3 years ago

Can you send me the compiler version and flags?

photoszzt commented 3 years ago

compiler version:

c++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

flags: (they are generated by cmake. I exclude the -I parts)

/usr/bin/c++  -O3 -DNDEBUG -fPIE -g -Wall -Wextra -pedantic -Wno-write-strings -std=c++1z -MD -MT worker/demo/CMakeFiles/demo-manager.dir/manager.cpp.o -MF CMakeFiles/demo-manager.dir/manager.cpp.o.d -o CMakeFiles/demo-manager.dir/manager.cpp.o -c /source/worker/demo/manager.cpp
eyalz800 commented 3 years ago

I'm guessing it may be a bug or too old compiler, can you try with version 10 just to be sure?

eyalz800 commented 3 years ago

Isee that you are running ubuntu 18 so:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install g++-10
photoszzt commented 3 years ago

Thanks. g++-10 solves the problem.