$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] Flags for strongly typed enum?
From: TONGARI J (tongari95_at_[hidden])
Date: 2014-12-11 04:14:21
Hi there,
Is there any library in Boost that provides type-safe enum bit flags?
Something like below:
enum class option
{
a = 1, b = 2, c = 4, ....
};
DEFINE_FLAGS(options, option);
options set1 = option::a | option::b;
options set2 = set1 | option::c;
options err1 = option::a | 2; // error
options err2 = set2 | 2; // error
if (set1 & option::a) {...}
if (set1 & 2) {...} // error
Thanks.