| chigraph master Systems programming language written for beginners in LLVM

Public Member Functions | List of all members
chi::Flags< Enum > Struct Template Reference

A template class for type-safe flags. More...

`#include <chi/Support/Flags.hpp>`

## Public Member Functions
| Flags ()=default
| Default constructor.
| Flags (Enum e)
| Constructor from an `Enum` type. More...
| Flags (const Flags &fl)=default
| Copy constructor. More...
| Flags (Flags &&fl)=default
| Move constructor. More...
Flags | operator & (const Flags &rhs) const
| Bitwise AND. More...
Flags & | operator &= (const Flags &rhs)
| Bitwise AND assignment. More...
| operator bool () const
| Check if the flags object isn't set to zero Useful for use after a `&` More...
bool | operator! () const
| See if one Flags object isn't equal to the other. More...
Flags & | operator= (const Flags &fl)=default
| Copy assignment. More...
Flags & | operator= (Flags &&fl)=default
| Move assignment. More...
bool | operator== (const Flags &rhs) const
| See if one Flags object is equal to the other. More...
Flags | operator| (const Flags &rhs) const
| Bitwise OR. More...
Flags & | operator|= (const Flags &rhs)
| Bitwise OR assignment. More...

## Detailed Description

### template<typename Enum>
struct chi::Flags< Enum >

A template class for type-safe flags.

Usage:

enum class MyOpts {
First = 1u,
Second = 1u << 1,
FirstAndSecond = First | Second,
};
chi::Flags<MyOpts> fl{MyOpts::First | MyOpts::Second};
assert(fl & MyOpts::First);

Definition at line 26 of file Flags.hpp.

## Constructor & Destructor Documentation

## ◆ Flags() [1/3]

template<typename Enum>

chi::Flags< Enum >::Flags | ( | Enum | e | ) |
| inline

Constructor from an `Enum` type.

Parameters

  e | The enum to copy from

Definition at line 34 of file Flags.hpp.

References chi::Flags< Enum >::Flags(), and chi::Flags< Enum >::operator=().

Here is the call graph for this function:

## ◆ Flags() [2/3]

template<typename Enum>

chi::Flags< Enum >::Flags | ( | const Flags< Enum > & | fl | ) |
| default

Copy constructor.

Parameters

  fl | The Flags object to copy from

## ◆ Flags() [3/3]

template<typename Enum>

chi::Flags< Enum >::Flags | ( | Flags< Enum > && | fl | ) |
| default

Move constructor.

Parameters

  fl | The Flags object to move from

## Member Function Documentation

## ◆ operator &()

template<typename Enum>

Flags chi::Flags< Enum >::operator& | ( | const Flags< Enum > & | rhs | ) | const
| inline

Bitwise AND.

Parameters

  rhs | The Flags object to AND with

Returns
  The new Flags object

Definition at line 76 of file Flags.hpp.

## ◆ operator &=()

template<typename Enum>

Flags& chi::Flags< Enum >::operator&= | ( | const Flags< Enum > & | rhs | ) |
| inline

Bitwise AND assignment.

Parameters

  rhs | The Flags obejct to AND `*this` with

Returns
  `*this`

Definition at line 89 of file Flags.hpp.

References chi::Flags< Enum >::Flags().

Here is the call graph for this function:

## ◆ operator bool()

template<typename Enum>

chi::Flags< Enum >::operator bool | ( |  | ) | const
| inline explicit

Check if the flags object isn't set to zero Useful for use after a `&`

Returns
  true if it's not zero

Definition at line 66 of file Flags.hpp.

## ◆ operator!()

template<typename Enum>

bool chi::Flags< Enum >::operator! | ( |  | ) | const
| inline

See if one Flags object isn't equal to the other.

Returns
  if they are equal

Definition at line 61 of file Flags.hpp.

## ◆ operator=() [1/2]

template<typename Enum>

Flags& chi::Flags< Enum >::operator= | ( | const Flags< Enum > & | fl | ) |
| default

Copy assignment.

Parameters

  fl | The Flags object to copy from

Returns
  `*this`

Referenced by chi::Flags< Enum >::Flags().

Here is the caller graph for this function:

## ◆ operator=() [2/2]

template<typename Enum>

Flags& chi::Flags< Enum >::operator= | ( | Flags< Enum > && | fl | ) |
| default

Move assignment.

Parameters

  The | Flags object to move from

Returns
  `*this`

## ◆ operator==()

template<typename Enum>

bool chi::Flags< Enum >::operator== | ( | const Flags< Enum > & | rhs | ) | const
| inline

See if one Flags object is equal to the other.

Parameters

  rhs | The Flags object to comare to

Returns
  if they are equal

Definition at line 57 of file Flags.hpp.

## ◆ operator|()

template<typename Enum>

Flags chi::Flags< Enum >::operator| | ( | const Flags< Enum > & | rhs | ) | const
| inline

Bitwise OR.

Parameters

  rhs | The Flags object to OR with

Returns
  The new Flags object

Definition at line 71 of file Flags.hpp.

## ◆ operator|=()

template<typename Enum>

Flags& chi::Flags< Enum >::operator|= | ( | const Flags< Enum > & | rhs | ) |
| inline

Bitwise OR assignment.

Parameters

  rhs | The Flags obejct to OR `*this` with

Returns
  `*this`

Definition at line 81 of file Flags.hpp.

The documentation for this struct was generated from the following file:

- lib/support/include/chi/Support/Flags.hpp