Hi!
I may have posted the first half of this question once, sorry for that! : )
The question in short: which boost library enables me to get the "wider"
datatype of two, such that
get_wider::type will be float, and
get_wider::type will also be float.
Hopefully
get_wider::type will generate a compile-time error, since the
two are not convertible to each other.
More verbosely:
Let's take a look at this simple functor class:
template
struct mixed_plus :
public binary_function
// result_type: bad solution!
{
result_type operator()
(first_argument_type left, second_argument_type right)
const
{
return left + right;
}
};
All is fine if I write this:
cout << mixed_plus()(5.5, 5) << endl;
OUTPUT: 11.5 (as expected)
But when I write this:
cout << mixed_plus()(5, 5.5) << endl;
OUTPUT: 10 (as expected but not as intended)
I vaguely remember that there is a boost library that is able to generate
the "wider" data type of two data type, with the help of which I would be
able to have the result_type typedef always the appropriate one.