As far as I am aware at the moment it is not possible to do a typedef
of the C++11 enum class
. I would like to know if there is any other way I can reduce the length of the name of an enum variable when referring to it outside of the encapsulating class. Here is an example:
// I would like to do something along the lines of:
class SegmentActivityState;
using SegmentActivityType = SegmentActivityState::ActivityStateType;
// ...However, this results in the compile time error:
// 'SegmentActivityState' does not name a type.
// Enumeration class definition
class SegmentActivityState
{
public:
enum class ActivityStateType : Index
{
PreExecution = 0, /**< Pre-execution state. */
Execution = 1, /**< Execution state. */
PostExecution = 2 /**< Post-execution state. */
};
private:
ActivityStateType ActivityState;
/**< unique object identifier tag. */
public:
// ... Methods that work on the ActivityState
}
The most important issue is the length of the name by which I have to refer to the enum outside of SegmentActivityType. For example, in order to do a type comparison I need to write SegmentActivity.getState() == SegmentActivityState::ActivityStateType::PreExecution
, which is very verbose. Two things that I do not want to do are:
- Do a
typedef
onSegmentActivityState
. - Move the
enum class ActivityStateType
outside of the classSegmentActivityState
definition.
Aucun commentaire:
Enregistrer un commentaire