Opened 5 years ago

#13225 new Bugs

operator != fails in classes derived from boost::rational

Reported by: Michael Hanrath <Michael.Hanrath@…> Owned by: Jonathan Turkanis
Milestone: To Be Determined Component: rational
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc:

Description

In a class derived from boost::rational operator != seems to return "false" always.

#include <iostream>
#include <boost/rational.hpp>

struct RationalNumber : public boost::rational<int> {
	RationalNumber(int n, int d) : boost::rational<int>(n, d) {}
};

using namespace std;

template <typename T>	void	check()
{
T	r(2, 3);
T	q(2, 3);
T	s(2, 4);
	cout << (r!=q) << " " << (r!=s) << endl;
}

int	main()
{
	check<boost::rational<long long>>(); // works
	cout << "---------------" << endl;
	check<RationalNumber>(); // fails for boost version > 1_63_0
	return 0;
}

Bug appears since boost version 1_64_0 and is present in current development trunk (git repository on 20170921) still.

Change History (0)

Note: See TracTickets for help on using tickets.