DUNE PDELab (git)

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#ifndef DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
4#define DUNE_FUNCTIONS_COMMON_TYPE_TRAITS_HH
5
6#include <type_traits>
7
8#include <dune/common/hybridutilities.hh>
10
11namespace Dune {
12namespace Functions {
13
14
25template<class T, class... Args>
26using enableIfConstructible = std::enable_if_t<
27 std::is_constructible_v<T, Args...>, int>;
28
29
30
38template<class T>
40 public IsIntegralConstant<decltype(Dune::Hybrid::size(std::declval<T>()))>
41{};
42
44template<class T>
45inline constexpr bool HasStaticSize_v = HasStaticSize<T>::value;
46
47
55template<class T>
57 public std::conditional_t<HasStaticSize_v<T>,
58 decltype(Dune::Hybrid::size(std::declval<T>())),
59 std::integral_constant<std::size_t,0>>
60{};
61
66template<class T>
67using StaticSize = std::enable_if_t<HasStaticSize_v<T>,
68 decltype(Dune::Hybrid::size(std::declval<T>()))>;
69
70
71}} // namespace Dune::Functions
72
73#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:27
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:68
Dune namespace.
Definition: alignedallocator.hh:13
Check if type is a statically sized container.
Definition: type_traits.hh:41
Obtain size of statically sized container, or 0 if dynamic size.
Definition: type_traits.hh:60
Check if T is an std::integral_constant<I, i>
Definition: typetraits.hh:384
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)