Goby3  3.1.5a
2024.05.23
type_helpers.h
Go to the documentation of this file.
1 // Copyright 2009-2021:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef GOBY_MIDDLEWARE_TRANSPORT_DETAIL_TYPE_HELPERS_H
26 #define GOBY_MIDDLEWARE_TRANSPORT_DETAIL_TYPE_HELPERS_H
27 
28 namespace goby
29 {
30 namespace middleware
31 {
32 namespace detail
33 {
34 template <typename Ret, typename Arg, typename... Rest>
35 Arg first_argument_helper(Ret (*)(Arg, Rest...));
36 
37 template <typename Ret, typename F, typename Arg, typename... Rest>
38 Arg first_argument_helper(Ret (F::*)(Arg, Rest...));
39 
40 template <typename Ret, typename F, typename Arg, typename... Rest>
41 Arg first_argument_helper(Ret (F::*)(Arg, Rest...) const);
42 
43 template <typename F> decltype(first_argument_helper(&F::operator())) first_argument_helper(F);
44 
45 // deduce the first argument for a variety of function-like things
46 template <typename T> using first_argument = decltype(first_argument_helper(std::declval<T>()));
47 
48 // template <typename F> struct first_argument
49 // {
50 // using type = decltype(first_argument_helper(std::declval<T>()));
51 // using decayed_type = typename std::decay<type>::type;
52 // };
53 
54 } // namespace detail
55 } // namespace middleware
56 } // namespace goby
57 
58 #endif
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
detail
detail namespace with internal helper functions
Definition: json.hpp:246
goby::middleware::detail::first_argument
decltype(first_argument_helper(std::declval< T >())) first_argument
Definition: type_helpers.h:46
goby::middleware::detail::first_argument_helper
decltype(first_argument_helper(&F::operator())) first_argument_helper(F)
Definition: type_helpers.h:43