Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Traits.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_TRAITS_H
9 #define INCLUDE_MOLASSEMBLER_TEMPLE_TRAITS_H
10 
11 #include <vector>
12 
13 namespace Scine {
14 namespace Molassembler {
15 namespace Temple {
16 
18 namespace Traits {
19 
20 // Get the base type a container holds via the begin iterator
21 namespace Detail {
22  template<class ContainerType>
23  struct getValueTypeImpl {
24  using type = typename std::remove_const<
25  typename std::remove_reference<
26  decltype(
27  *std::begin(
28  std::declval<ContainerType>()
29  )
30  )
31  >::type
32  >::type;
33  };
34 
35  // Specialization for std::vector<bool>, which returns an awkward proxy object
36  template<>
37  struct getValueTypeImpl<std::vector<bool>> {
38  using type = bool;
39  };
40 } // namespace Detail
41 
42 template<class ContainerType>
43 using getValueType = typename Detail::getValueTypeImpl<ContainerType>::type;
44 
45 template<class Function, typename ...Args>
46 using functionReturnType = std::result_of_t<Function(Args...)>;
47 
48 template<class F>
50 
51 template<class ReturnType, typename ...Args>
52 struct FunctionPointerReturnType<ReturnType (*)(Args...)> {
53  using type = ReturnType;
54 };
55 
56 } // namespace Traits
57 } // namespace Temple
58 } // namespace Molassembler
59 } // namespace Scine
60 
61 #endif
std::result_of_t< Function(Args...)> functionReturnType
Figure out the return type of calling a function.
Definition: Containers.h:26
typename Detail::getValueTypeImpl< ContainerType >::type getValueType
Figures out the value type of a container via its iterators.
Definition: Containers.h:424