[Core] scoped_enum and template arguments

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Core] scoped_enum and template arguments

Boost - Users mailing list
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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users