Boost logo

Boost Users :

From: Alan Barr (a.barr_at_[hidden])
Date: 2021-03-24 23:06:26


Hi,

I'm a little confused about the following statement in the docs for
scoped enum:

> The emulated scoped enum can not be used in switch nor in
> template arguments.

https://www.boost.org/doc/libs/1_75_0/libs/core/doc/html/core/scoped_enum.html

I understand the rationale for the switch statement part (and indeed it
won't compile in C++03).

However, I'm struggling to grasp the template argument part (and I'll be
the first to admit I'm not particularly strong with templates).
Unlike the switch case, any basic scenario I've thrown at it compiles.
So I'm not sure if this is a case of "should not" vs "can not".

When would using a "scoped_enum_type" in a template argument as opposed
to "BOOST_SCOPED_ENUM_NATIVE(scoped_enum_type)" become a problem?

Or, why should I use
     "boost::optional<BOOST_SCOPED_ENUM_NATIVE(future_errc)>"
over
     "boost::optional<future_errc>"
?

I've got a compiler explorer link with some test code here if it helps:
https://godbolt.org/z/dfr6M6vrW

Regards,
Alan


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