serge-sans-paille/frozen

frozen::map of std::variant compilation error

alex31 opened this issue · 4 comments

when trying to have a map of variant with std::pair or frozen::set in the variant, compilation fail

Compiler : gcc 9.2.1 with -std=c++2a

`
#include
#include
#include <frozen/map.h>
#include <frozen/string.h>
#include <frozen/set.h>

using test_variant_t = std::variant<float , frozen::set<int, 2> >;

constexpr auto conf_dict =
frozen::make_map<frozen::string, test_variant_t> ({
{"A", 10.0f}
});

int main (void) {}

`

compilation fail with :
_
frozen/include/frozen/bits/algorithms.h:89:5: error: use of deleted function 'std::variant<_Types>& std::variant<_Types>::operator=(const std::variant<_Types>&) [with _Types = {float, frozen::set<int, 2, std::less >}]'
89 | a = b;
_

Can you confirm #82 fixes your issue?

Unfortunately, it's not.

I am afraid that the problem is in std::variant, and we do not have frozen::variant.

error message is :
In file included from /home/alex/DEV/STM32/frozen/include/frozen/map.h:28, from /tmp/testFrozen.cpp:3: /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h: In instantiation of ‘constexpr void frozen::bits::cswap(T&, T&) [with T = std::variant<float, frozen::set<int, 2, std::less<int> > >]’: /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h:96:8: required from ‘constexpr void frozen::bits::cswap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&) [with T = frozen::string; U = std::variant<float, frozen::set<int, 2, std::less<int> > >]’ /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h:114:8: required from ‘constexpr Iterator frozen::bits::partition(Iterator, Iterator, const Compare&) [with Iterator = std::pair<frozen::string, std::variant<float, frozen::set<int, 2, std::less<int> > > >*; Compare = frozen::impl::CompareKey<std::less<frozen::string> >]’ /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h:128:37: required from ‘constexpr void frozen::bits::quicksort(Iterator, Iterator, const Compare&) [with Iterator = std::pair<frozen::string, std::variant<float, frozen::set<int, 2, std::less<int> > > >*; Compare = frozen::impl::CompareKey<std::less<frozen::string> >]’ /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h:138:12: required from here /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h:89:5: error: use of deleted function ‘std::variant<_Types>& std::variant<_Types>::operator=(const std::variant<_Types>&) [with _Types = {float, frozen::set<int, 2, std::less<int> >}]’ a = b; ~~^~~ In file included from /tmp/testFrozen.cpp:2: /usr/include/c++/8/variant:1083:16: note: ‘std::variant<_Types>& std::variant<_Types>::operator=(const std::variant<_Types>&) [with _Types = {float, frozen::set<int, 2, std::less<int> >}]’ is implicitly deleted because the default definition would be ill-formed: variant& operator=(const variant&) = default; ^~~~~~~~ /usr/include/c++/8/variant:1083:16: error: use of deleted function ‘std::_Enable_copy_move<true, false, true, false, _Tag>& std::_Enable_copy_move<true, false, true, false, _Tag>::operator=(const std::_Enable_copy_move<true, false, true, false, _Tag>&) [with _Tag = std::variant<float, frozen::set<int, 2, std::less<int> > >]’ In file included from /usr/include/c++/8/variant:38, from /tmp/testFrozen.cpp:2: /usr/include/c++/8/bits/enable_special_members.h:244:5: note: declared here operator=(_Enable_copy_move const&) noexcept = delete; ^~~~~~~~ In file included from /home/alex/DEV/STM32/frozen/include/frozen/map.h:28, from /tmp/testFrozen.cpp:3: /home/alex/DEV/STM32/frozen/include/frozen/bits/algorithms.h:90:5: error: use of deleted function ‘std::variant<_Types>& std::variant<_Types>::operator=(const std::variant<_Types>&) [with _Types = {float, frozen::set<int, 2, std::less<int> >}]’ b = tmp; ~~^~~~~

Sorry, it works, I was thinking that the fix was already in master. Using set_of_set branch, it works !

Thanks a lot !