Boost logo

Boost Users :

Subject: [Boost-users] [Variant] Bug assigning similar, but different concrete types during assignment / ctor relay
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2018-11-18 23:00:59


Hello,

I've got a Boost.Variant confusion going on during ctor relay.

I have two types participating in the Variant, an Integer type and a
Floating Point type. Both are Numeric as a base class. i.e. something
like:

template<typename T>
struct numeric {};

struct integer : numeric<long> {};

struct floating_point : numeric<double> {};

Then:

using constant_value = boost::variant<..., floating_point, integer, ...>;

Somewhere during the handling, I have a test case in which I have a
constant_value{} starting out in life as an integer{}.

However, somewhere during handling, variant is misinterpreting integer
(which=3) as a floating_point (which=2).

This is incorrect, of course.

I could force the issue, I suppose and re-set the value to the
integer, but I'd like to understand the issue. I think it's a bug in
variant, or perhaps a "feature" confusing integer with floating_point
along base class numeric lines?

Any ideas


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net