DUNE-FUNCTIONS (unstable)

type_traits.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
8#define DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
9
10#include <type_traits>
11
12#include <dune/common/hybridutilities.hh>
13#include <dune/common/typeutilities.hh>
14
15namespace Dune {
16namespace Functions {
17
18
29template<class T, class... Args>
30using enableIfConstructible = std::enable_if_t<
31 std::is_constructible_v<T, Args...>, int>;
32
33
34
42template<class T>
44 public IsIntegralConstant<decltype(Dune::Hybrid::size(std::declval<T>()))>
45{};
46
48template<class T>
49inline constexpr bool HasStaticSize_v = HasStaticSize<T>::value;
50
51
59template<class T>
61 public std::conditional_t<HasStaticSize_v<T>,
62 decltype(Dune::Hybrid::size(std::declval<T>())),
63 std::integral_constant<std::size_t,0>>
64{};
65
70template<class T>
71using StaticSize = std::enable_if_t<HasStaticSize_v<T>,
72 decltype(Dune::Hybrid::size(std::declval<T>()))>;
73
74
75}} // namespace Dune::Functions
76
77#endif // DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
std::enable_if_t< std::is_constructible_v< T, Args... >, int > enableIfConstructible
Helper to constrain forwarding constructors.
Definition: type_traits.hh:31
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:72
Definition: polynomial.hh:17
Check if type is a statically sized container.
Definition: type_traits.hh:45
Obtain size of statically sized container, or 0 if dynamic size.
Definition: type_traits.hh:64
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)