
Looking at the type_erasure example: typedef any<boost::mpl::vector<copy_constructible<>, typeid_<>, addable<>>
any_type;
any_type x(1.1); any_type y(1); any_type z(x + y); Apparently, without placeholders for x and y, this is undefined behavior. Am I interpreting it right? If so, shouldn't it fail to compile or at least throw an exception at runtime? Thanks, Alex

AMDG On 04/07/2013 08:40 AM, Aleksandar Fabijanic wrote:
Looking at the type_erasure example:
typedef any<boost::mpl::vector<copy_constructible<>, typeid_<>, addable<>>
any_type;
any_type x(1.1); any_type y(1); any_type z(x + y);
Apparently, without placeholders for x and y, this is undefined behavior. Am I interpreting it right? If so, shouldn't it fail to compile or at least throw an exception at runtime?
It's impossible to make this fail to compile. Undefined behavior does not mean throw an exception; it means all bets are off. If you add relaxed to the concept, then you'll get an exception. In Christ, Steven Watanabe

On Sun, 07 Apr 2013 11:22:17 -0700, Steven Watanabe <watanabesj@gmail.com> wrote:
Undefined behavior does not mean throw an exception; it means all bets are off.
A general thought: Many C/C++ programmmers are still unaware of what undefined/unspecified/implementation-defined behaviour means. IMO, it would very helpful and educational if there were boost-wide definitions of such standardese terms that each boost library documentation would link to. (In my experience, if documentation is not sufficiently informative and well-organized then it's very hard to get programmer teams to adopt some library, and if they do adopt it then most likely it won't be used properly due to to ignorance.) My 2 cents, Mostafa

On Sun, Apr 7, 2013 at 1:22 PM, Steven Watanabe <watanabesj@gmail.com>wrote: Undefined behavior does not mean throw an exception;
it means all bets are off.
I did not mean to imply it does. I meant to say that's what a user would intuitively expect.
If you add relaxed to the concept, then you'll get an exception.
OK, that works as advertised. Thanks, Alex
participants (3)
-
Aleksandar Fabijanic
-
Mostafa
-
Steven Watanabe