HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
arguments.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#pragma once
10
11namespace hi::inline v1 {
12
13template<std::size_t I, typename FirstArg, typename... Args>
14constexpr decltype(auto) get_argument_impl(FirstArg &&first_arg, Args &&...args) noexcept
15{
16 if constexpr (I == 0) {
17 return std::forward<FirstArg>(first_arg);
18 } else {
19 return get_argument_impl<I - 1>(std::forward<Args>(args)...);
20 }
21}
22
23template<std::size_t I, typename... Args>
24constexpr decltype(auto) get_argument(Args &&...args) noexcept
25{
26 static_assert(I < sizeof...(Args), "Index to high for number of arguments");
27 return get_argument_impl<I>(std::forward<Args>(args)...);
28}
29
30template<typename... Args>
31constexpr decltype(auto) get_last_argument(Args &&...args) noexcept
32{
33 return get_argument_impl<sizeof...(Args) - 1>(std::forward<Args>(args)...);
34}
35
36} // namespace hi::inline v1