KiCad PCB EDA Suite
Loading...
Searching...
No Matches
enum_vector.h File Reference
#include <iterator>
#include <type_traits>

Go to the source code of this file.

Classes

class  ENUM_ITERATOR< T, beginVal, endVal >
 

Macros

#define DEFINE_ENUM_VECTOR(enumName, ...)
 Macro to create const vectors containing enum values to enable easy iteration. More...
 
#define DECLARE_ENUM_VECTOR(className, enumName)    constexpr className::enumName className::enumName##_vector[];
 
#define DEFINE_ENUM_CLASS_WITH_ITERATOR(enumName, beginVal, ...)
 Macro to create const vectors containing enum class values to enable easy iteration. More...
 

Macro Definition Documentation

◆ DECLARE_ENUM_VECTOR

#define DECLARE_ENUM_VECTOR (   className,
  enumName 
)     constexpr className::enumName className::enumName##_vector[];

Definition at line 49 of file enum_vector.h.

◆ DEFINE_ENUM_CLASS_WITH_ITERATOR

#define DEFINE_ENUM_CLASS_WITH_ITERATOR (   enumName,
  beginVal,
  ... 
)
Value:
enum class enumName : int { beginVal, __VA_ARGS__, _ENUM_END }; \

Macro to create const vectors containing enum class values to enable easy iteration.

Usage: [header] A { DEFINE_ENUM_CLASS_WITH_ITERATOR( COLOR, RED, GREEN, BLUE ) };

[source] for( COLOR color : COLOR_ITERATOR() ) { // do sth with color }

Definition at line 67 of file enum_vector.h.

◆ DEFINE_ENUM_VECTOR

#define DEFINE_ENUM_VECTOR (   enumName,
  ... 
)
Value:
enum enumName __VA_ARGS__; \
static constexpr enumName enumName##_vector[] = __VA_ARGS__;

Macro to create const vectors containing enum values to enable easy iteration.

Do not use in new code. Use the DEFINE_ENUM_CLASS_WITH_ITERATOR and DECLARE_ENUM_CLASS_ITERATOR macros instead (unless they don't work ;) ).

Usage: [header] A { DEFINE_ENUM_VECTOR( COLOR, { RED, GREEN, BLUE } ) };

[source] for( COLOR color : COLOR_vector ) { // do sth with color }

DECLARE_ENUM_VECTOR( COLORS );

Definition at line 45 of file enum_vector.h.