Skip to content

File staticif.h

File List > code_source > templat > include > TempLat > util > staticif.h

Go to the documentation of this file

#ifndef TEMPLAT_UTIL_STATICIF_H
#define TEMPLAT_UTIL_STATICIF_H

/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
   Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
   Released under the MIT license, see LICENSE.md. */

// File info: Main contributor(s): Adrien Florio, Year: 2019

namespace TempLat
{

#define IfElse(condition, ifExpr, elseExpr)                                                                            \
  [&]() {                                                                                                              \
    if constexpr (condition) {                                                                                         \
      return ifExpr;                                                                                                   \
    } else {                                                                                                           \
      return elseExpr;                                                                                                 \
    }                                                                                                                  \
  }()
#define If(condition, ifExpr)                                                                                          \
  [&]() {                                                                                                              \
    if constexpr (condition) {                                                                                         \
      return ifExpr;                                                                                                   \
    } else {                                                                                                           \
      return ZeroType();                                                                                               \
    }                                                                                                                  \
  }()

#define IfElseStatement(condition, ifExpr, elseExpr)                                                                   \
  [&]() {                                                                                                              \
    if constexpr (condition) {                                                                                         \
      ifExpr;                                                                                                          \
    } else {                                                                                                           \
      elseExpr;                                                                                                        \
    }                                                                                                                  \
  }()
#define IfStatement(condition, ifExpr)                                                                                 \
  if constexpr (condition) {                                                                                           \
    ifExpr;                                                                                                            \
  }
} // namespace TempLat

#endif