TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
callable_traits.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Olivier Parcollet, Nils Wentzell
19
24
25#pragma once
26
27#include <cstddef>
28#include <tuple>
29#include <type_traits>
30
31namespace triqs::utility {
32
33 namespace detail {
34
35 template <typename F> struct callable_traits_impl;
36
37 template <typename ClassType, typename ReturnType, typename... Args> struct callable_traits_impl<ReturnType (ClassType::*)(Args...) const> {
38 static constexpr int arity = sizeof...(Args);
39 using result_type = ReturnType;
40 template <std::size_t N> using arg_t = std::tuple_element_t<N, std::tuple<Args...>>;
41 template <std::size_t N> using decay_arg_t = std::decay_t<arg_t<N>>;
42 };
43
44 template <typename ClassType, typename ReturnType, typename... Args>
45 struct callable_traits_impl<ReturnType (ClassType::*)(Args...)> : callable_traits_impl<ReturnType (ClassType::*)(Args...) const> {};
46
47 } // namespace detail
48
63 template <typename F> struct callable_traits : public detail::callable_traits_impl<decltype(&F::operator())> {};
64
65} // namespace triqs::utility
Type trait for a callable type with a single, non-overloaded operator().