SPH
Classes | Namespaces | Macros | Functions
Object.h File Reference

Common macros and basic objects. More...

#include <cstdint>
#include <utility>

Go to the source code of this file.

Classes

struct  Noncopyable
 Object with deleted copy constructor and copy operator. More...
 
struct  Immovable
 Object with deleted copy and move constructor and copy and move operator. More...
 
class  Local
 Object intended to only be constructed on stack. More...
 
struct  Polymorphic
 Base class for all polymorphic objects. More...
 
class  Badge< T >
 Helper class used to allow calling a function only from within T. More...
 
struct  Detail::StaticForType< N1, N2 >
 
struct  Detail::StaticForType< N, N >
 
struct  Detail::SelectNthType< I, N >
 
struct  Detail::SelectNthType< N, N >
 

Namespaces

 Detail
 

Macros

#define NAMESPACE_SPH_BEGIN   namespace Sph {
 
#define NAMESPACE_SPH_END   }
 
#define INLINE   __attribute__((always_inline)) inline
 Macros for conditional compilation based on selected compiler. More...
 
#define INL   __attribute__((always_inline))
 
#define NO_INLINE   __attribute__((noinline))
 
#define UNUSED(x)
 
#define MARK_USED(x)   (void)sizeof(x)
 Silences the "unused variable" warning for given variable. More...
 
#define SPH_FALLTHROUGH   [[fallthrough]];
 
#define DEPRECATED   __attribute__((deprecated))
 
#define SPH_LIKELY(x)   __builtin_expect(bool(x), 1)
 Branch prediction hints. More...
 
#define SPH_UNLIKELY(x)   __builtin_expect(bool(x), 0)
 

Functions

template<std::size_t N1, std::size_t N2, typename TVisitor >
INLINE void staticFor (TVisitor &&visitor)
 
template<typename... TArgs>
void Detail::expandPack (TArgs &&...)
 
template<typename TVisitor , typename... TArgs>
INLINE void staticForEach (TVisitor &&visitor, TArgs &&... args)
 
template<std::size_t N, typename TValue , typename... TOthers>
decltype(auto) INLINE selectNth (TValue &&value, TOthers &&... others)
 

Detailed Description

Common macros and basic objects.

Author
Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file Object.h.

Macro Definition Documentation

◆ DEPRECATED

#define DEPRECATED   __attribute__((deprecated))

Definition at line 46 of file Object.h.

◆ INL

#define INL   __attribute__((always_inline))

Definition at line 32 of file Object.h.

◆ INLINE

#define INLINE   __attribute__((always_inline)) inline

Macros for conditional compilation based on selected compiler.

Force inline for gcc

Definition at line 31 of file Object.h.

◆ MARK_USED

#define MARK_USED (   x)    (void)sizeof(x)

Silences the "unused variable" warning for given variable.

Note
sizeof is used to make sure x is not evaluated.

Definition at line 42 of file Object.h.

◆ NAMESPACE_SPH_BEGIN

#define NAMESPACE_SPH_BEGIN   namespace Sph {

Definition at line 11 of file Object.h.

◆ NAMESPACE_SPH_END

#define NAMESPACE_SPH_END   }

Definition at line 12 of file Object.h.

◆ NO_INLINE

#define NO_INLINE   __attribute__((noinline))

Definition at line 35 of file Object.h.

◆ SPH_FALLTHROUGH

#define SPH_FALLTHROUGH   [[fallthrough]];

Definition at line 44 of file Object.h.

◆ SPH_LIKELY

#define SPH_LIKELY (   x)    __builtin_expect(bool(x), 1)

Branch prediction hints.

Definition at line 49 of file Object.h.

◆ SPH_UNLIKELY

#define SPH_UNLIKELY (   x)    __builtin_expect(bool(x), 0)

Definition at line 50 of file Object.h.

◆ UNUSED

#define UNUSED (   x)

Definition at line 37 of file Object.h.

Function Documentation

◆ selectNth()

template<std::size_t N, typename TValue , typename... TOthers>
decltype(auto) INLINE selectNth ( TValue &&  value,
TOthers &&...  others 
)

Returns N-th argument from an argument list. The type of the returned argument matches the type of the input argument.

Definition at line 159 of file Object.h.

◆ staticFor()

template<std::size_t N1, std::size_t N2, typename TVisitor >
INLINE void staticFor ( TVisitor &&  visitor)

Static for loop from n1 to n2, including both values. Takes an object as an argument that must implement templated method template<int n> visit(); for loop will pass the current index as a template parameter, so that it can be used as a constant expression.

Definition at line 123 of file Object.h.

◆ staticForEach()

template<typename TVisitor , typename... TArgs>
INLINE void staticForEach ( TVisitor &&  visitor,
TArgs &&...  args 
)

Definition at line 134 of file Object.h.