today I found that boost::hana
's map
and set
aren't default constructable, while the tuple
is. Is there any particular reason for this because it is quite annoying.
This
#include <boost/hana/set.hpp>
// ^^^ or map
constexpr boost::hana::set<> a{};
// ^^^ or map
int main(){}
fails with the following error:
main.cpp:3:30: error: no matching constructor for initialization of 'const boost::hana::set<>'
constexpr boost::hana::set<> a{};
^~~
/home/russellg/Documents/boost/hana-0.6.0/include/boost/hana/set.hpp:65:28: note: candidate constructor not viable: requires single argument 'xs', but no arguments were provided
explicit constexpr set(tuple<Xs...> const& xs)
^
/home/russellg/Documents/boost/hana-0.6.0/include/boost/hana/set.hpp:69:28: note: candidate constructor not viable: requires single argument 'xs', but no arguments were provided
explicit constexpr set(tuple<Xs...>&& xs)
^
/home/russellg/Documents/boost/hana-0.6.0/include/boost/hana/set.hpp:57:12: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were
provided
struct set
^
/home/russellg/Documents/boost/hana-0.6.0/include/boost/hana/set.hpp:57:12: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were
provided
1 error generated.
even though it is perfectly valid to have an empty map or set:
#include <boost/hana/set.hpp>
// ^^^ or map
constexpr auto a = boost::hana::make_set();
// ^^^ or map
int main(){}
Which compiles flawlessly.
Any help is appreciated.
EDIT:
It doesn't actually matter if it is empty, it is always illegal to default construct map
s and set
s.