Public Member Functions | List of all members
clang::insights::Once< VALUE > Class Template Reference

A helper object which returns a boolean value just once and toggles it after the first query. More...

#include "InsightsOnce.h"

Public Member Functions

 Once ()=default
 
 Once (bool value)
 
 operator bool ()
 

Detailed Description

template<bool VALUE>
class clang::insights::Once< VALUE >

A helper object which returns a boolean value just once and toggles it after the first query.

This allows to simplify code like this:

bool first{true};
for(... : ...) {
if(first) {
first = false;
...
} else {
...
}

into this:

OnceTrue first{};
for(... : ...) {
if(first) {
...
} else {
...
}
Once< true > OnceTrue
Returns true only once, following checks return false.
Definition: InsightsOnce.h:55

Definition at line 31 of file InsightsOnce.h.

Constructor & Destructor Documentation

◆ Once() [1/2]

template<bool VALUE>
clang::insights::Once< VALUE >::Once ( )
default

◆ Once() [2/2]

template<bool VALUE>
clang::insights::Once< VALUE >::Once ( bool  value)
inline

Definition at line 35 of file InsightsOnce.h.

Member Function Documentation

◆ operator bool()

template<bool VALUE>
clang::insights::Once< VALUE >::operator bool ( )
inline

Definition at line 40 of file InsightsOnce.h.


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