]> git.proxmox.com Git - ceph.git/blame - ceph/src/common/function_signature.h
update sources to v12.1.0
[ceph.git] / ceph / src / common / function_signature.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Copied from:
5 * https://github.com/exclipy/inline_variant_visitor/blob/master/function_signature.hpp
6 * which apparently copied it from
7 * http://stackoverflow.com/questions/4771417/how-to-get-the-signature-of-a-c-bind-expression
8 */
9
10#ifndef FUNCTION_SIGNATURE_H
11#define FUNCTION_SIGNATURE_H
12
13#include <boost/mpl/pop_front.hpp>
14#include <boost/mpl/push_front.hpp>
7c673cae
FG
15#include <boost/function_types/function_type.hpp>
16#include <boost/function_types/result_type.hpp>
17#include <boost/function_types/parameter_types.hpp>
18
7c673cae
FG
19template <typename F>
20struct signature_of_member
21{
22 typedef typename boost::function_types::result_type<F>::type result_type;
23 typedef typename boost::function_types::parameter_types<F>::type parameter_types;
24 typedef typename boost::mpl::pop_front<parameter_types>::type base;
25 typedef typename boost::mpl::push_front<base, result_type>::type L;
26 typedef typename boost::function_types::function_type<L>::type type;
27};
28
29template <typename F, bool is_class>
30struct signature_of_impl
31{
32 typedef typename boost::function_types::function_type<F>::type type;
33};
34
35template <typename F>
36struct signature_of_impl<F, true>
37{
38 typedef typename signature_of_member<decltype(&F::operator())>::type type;
39};
40
41template <typename F>
42struct signature_of
43{
44 typedef typename signature_of_impl<F, boost::is_class<F>::value>::type type;
45};
46
47#endif