Opened 6 years ago

Last modified 6 years ago

#12884 new Bugs

to_string()

Reported by: Olaf <olafvdspek@…> Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost 1.63.0 Severity: Problem
Keywords: Cc:

Description

Hi,

Is to_string() here supposed to match to_string() in boost\exception\to_string.hpp?

class shared_array2 : public boost::iterator_range<T*> {};

typedef shared_array2<unsigned char> shared_data;

to_string(shared_data());

I really didn't expect this to_string() to be found here.. is it a feature or is it a bug?

Change History (7)

comment:1 by Emil Dotchevski, 6 years ago

What's the context of this problem? Boost Exception defines to_string but *only* for types that define operator<< for std::ostream (using enable_if). The Boost Exception definition, if available is generic, so if there is another suitable to_string overload it will be more specific and will be preferred by any overload resolution.

comment:2 by anonymous, 6 years ago

I was expecting a compile-time error, I was not expecting some to_string() from Boost being called.

comment:3 by Emil Dotchevski, 6 years ago

I'm guessing that you get this because your type defines operator<< for std::ostream, which enables boost::to_string. Can you confirm? If that's the case it may be possible to fix this, since the to_string overload is not documented.

comment:4 by anonymous, 6 years ago

Yes, boost::iterator_range defines operator<< and my type derives from it.

Is to_string() supposed to be a private interface? If so, shouldn't it be in a private namespace?

comment:5 by Emil Dotchevski, 6 years ago

No, it is not a private interface. What I meant is that the documentation doesn't specify that Boost Exception defines a to_string overload, only that it will call it if it can find it: www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information.html

comment:6 by anonymous, 6 years ago

It does: "for which Boost Exception defines a generic overload."

comment:7 by Emil Dotchevski, 6 years ago

Indeed, I stand corrected.

Note: See TracTickets for help on using tickets.