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 #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>
9 #include <dune/common/typeutilities.hh>
10 
11 namespace Dune {
12 namespace Functions {
13 
14 
25 template<class T, class... Args>
26 using enableIfConstructible = std::enable_if_t<
27  std::is_constructible_v<T, Args...>, int>;
28 
29 
30 
38 template<class T>
39 struct HasStaticSize :
40  public IsIntegralConstant<decltype(Dune::Hybrid::size(std::declval<T>()))>
41 {};
42 
44 template<class T>
45 inline constexpr bool HasStaticSize_v = HasStaticSize<T>::value;
46 
47 
55 template<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 
66 template<class T>
67 using 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
Definition: polynomial.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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)