OGLplus  (0.59.0) a C++ wrapper for rendering APIs

overloaded.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_OVERLOADED_HPP
10 #define EAGINE_OVERLOADED_HPP
11 
12 #include <utility>
13 
14 namespace eagine {
15 
16 template <typename... Func>
17 struct overloaded;
18 
19 template <typename Func>
20 struct overloaded<Func> : Func {
21  overloaded(const Func& func)
22  : Func{func} {}
23 
24  overloaded(Func&& func)
25  : Func{std::move(func)} {}
26 
27  using Func::operator();
28 };
29 
30 template <typename Func, typename... Funcs>
31 struct overloaded<Func, Funcs...>
32  : Func
33  , overloaded<Funcs...> {
34  template <typename... F>
35  overloaded(const Func& func, F&&... funcs)
36  : Func{func}
37  , overloaded<Funcs...>{std::forward<Funcs>(funcs)...} {}
38 
39  template <typename... F>
40  overloaded(Func&& func, F&&... funcs)
41  : Func{std::move(func)}
42  , overloaded<Funcs...>{std::forward<Funcs>(funcs)...} {}
43 
44  using Func::operator();
45  using overloaded<Funcs...>::operator();
46 };
47 
48 template <typename... F>
49 overloaded(const F&...) -> overloaded<F...>;
50 
51 } // namespace eagine
52 
53 #endif // EAGINE_OVERLOADED_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).