Opened 6 years ago

Closed 6 years ago

#12645 closed Bugs (fixed)

error: no match for call to ‘(const hash) (const boost::recursive_variant_&)’

Reported by: mike.gresens@… Owned by: Antony Polukhin
Milestone: Boost 1.64.0 Component: variant
Version: Boost 1.63.0 Severity: Regression
Keywords: Cc:

Description

Since boost 1.62 the recursive variant is not able to find the hash function.
Same for boost 1.63 beta.
Compiler stops with error: no match for call to ‘(const hash) (const boost::recursive_variant_&)’

code:

#include <boost/variant.hpp>
#include <unordered_set>

struct hash;

using int_t = int;

template <typename T>
using basic_set_t = std::unordered_set<T, hash>;

using value_t = boost::make_recursive_variant<
		int_t,
		basic_set_t<boost::recursive_variant_>
>::type;

using set_t = basic_set_t<value_t>;

struct hash
{
	// since boost 1.62 ... error: no match for call to ‘(const hash) (const boost::recursive_variant_&)’
	size_t operator()(const value_t& value) const
	{
		return 0;
	}
};

int main()
{
	set_t s;
	int_t i = 3;
	value_t v = i;
	s.emplace(v); // raises error above
	v = s;
	return 0;
}

gcc 6.2.0 on Linux
clang 7.0.2 on Mac

Change History (4)

in reply to:  description comment:1 by mike.gresens@…, 6 years ago

Workaround for boost >= 1.62. Not sure what changed since 1.61...

code:

#include <boost/variant.hpp>
#include <unordered_set>

struct hash;

using int_t = int;

template <typename T>
using basic_set_t = std::unordered_set<T, hash>;

using value_t = boost::make_recursive_variant<
		int_t,
		basic_set_t<boost::recursive_variant_>
>::type;

using set_t = basic_set_t<value_t>;

struct hash
{
boost::recursive_variant_&)’
	size_t operator()(const value_t& value) const
	{
		return 0;
	}
};

// This helps for boost >= 1.62
namespace std
{
	template <>
	struct __is_fast_hash<::hash> : std::false_type { };
}

int main()
{
	set_t s;
	int_t i = 3;
	value_t v = i;
	s.emplace(v);
	v = s;
	return 0;
}

comment:2 by Antony Polukhin, 6 years ago

Owner: changed from ebf to Antony Polukhin
Status: newassigned

Fixed by Mikhail Maximov in e0b65c01. Fix will appear in Boost 1.64

comment:3 by Antony Polukhin, 6 years ago

Milestone: To Be DeterminedBoost 1.64.0

comment:4 by Antony Polukhin, 6 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.