File complexfieldget.h
File List > algebra > complexalgebra > helpers > complexfieldget.h
Go to the documentation of this file
#ifndef COSMOINTERFACE_COMPLEXFIELDALGEBRA_HELPERS_COMPLEXFIELDGET_H
#define COSMOINTERFACE_COMPLEXFIELDALGEBRA_HELPERS_COMPLEXFIELDGET_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
#include "TempLat/util/rangeiteration/tag.h"
#include "TempLat/lattice/algebra/complexalgebra/helpers/hascomplexfieldget.h"
#include "TempLat/lattice/algebra/helpers/iscomplextype.h"
namespace TempLat
{
class ComplexFieldGetter
{
public:
template <typename R>
requires IsComplexType<R>
static auto get(R &&r, Tag<0> t)
{
// Inlined from Real(r) to avoid a real.h -> ascomplexfield.h -> complexfieldget.h include cycle;
// for a complex value the HasComplexFieldGet Real overload never applies, so this is Real's only body.
return r.real();
}
template <typename R>
requires IsComplexType<R>
static auto get(R &&r, Tag<1> t)
{
// Inlined from Imag(r); see the note on the Tag<0> overload above.
return r.imag();
}
template <typename R, int N>
requires(!IsComplexType<R> && HasComplexFieldGet<R>)
static auto get(R &&r, Tag<N> t)
{
return r.ComplexFieldGet(t);
}
};
} // namespace TempLat
#endif