Loading...
Searching...
No Matches
type_traits.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
#ifndef DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
#define DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
#include <type_traits>
#include <dune/common/hybridutilities.hh>
#include <dune/common/typeutilities.hh>
namespace Dune {
namespace Functions {
template<class T, class... Args>
using enableIfConstructible = std::enable_if_t<
std::is_constructible_v<T, Args...>, int>;
template<class T>
struct HasStaticSize :
public IsIntegralConstant<decltype(Dune::Hybrid::size(std::declval<T>()))>
{};
template<class T>
inline constexpr bool HasStaticSize_v = HasStaticSize<T>::value;
template<class T>
struct StaticSizeOrZero :
public std::conditional_t<HasStaticSize_v<T>,
decltype(Dune::Hybrid::size(std::declval<T>())),
std::integral_constant<std::size_t,0>>
{};
template<class T>
using StaticSize = std::enable_if_t<HasStaticSize_v<T>,
decltype(Dune::Hybrid::size(std::declval<T>()))>;
}} // namespace Dune::Functions
#endif // DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
Dune::Functions::StaticSize
std::enable_if_t< HasStaticSize_v< T >, decltype(Dune::Hybrid::size(std::declval< T >()))> StaticSize
Obtain size of statically sized container as integral_constant, or fail.
Definition type_traits.hh:71
Dune::Functions::enableIfConstructible
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition type_traits.hh:30
Dune
Definition monomialset.hh:19
Dune::Functions
Definition monomialset.hh:19
Dune::Functions::HasStaticSize_v
constexpr bool HasStaticSize_v
A variable template representing the value of HasStaticSize.
Definition type_traits.hh:49
Dune::Functions::HasStaticSize
Check if type is a statically sized container.
Definition type_traits.hh:45
Dune::Functions::StaticSizeOrZero
Obtain size of statically sized container, or 0 if dynamic size.
Definition type_traits.hh:64