/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2017-2018 Danny Robson */ #ifndef CRUFT_UTIL_VARIADIC_HPP #define CRUFT_UTIL_VARIADIC_HPP #include #include #include #include namespace util::variadic { /////////////////////////////////////////////////////////////////////////// /// do nothing with a set of parameters. /// /// useful for temporarily silencing unused argument warnings in parameter /// packs, or for avoiding assignment of [[gnu::warn_unused_result]] to a /// temporary value we'd just cast to void anyway (GCC#66425). /// /// it is guaranteed that this function will never be defined out in /// debug/release/whatever builds. so it is safe to use to guarantee /// parameter evaluation. template void ignore (const Args&...) noexcept ((std::is_nothrow_destructible_v && ...)) { ; } /////////////////////////////////////////////////////////////////////////// /// Returns the argument at index `IndexV', as if we called: /// std::get (std::make_tuple (...)) template auto get (HeadT &&head, TailT &&...tail) noexcept ((std::is_nothrow_move_constructible_v && ...)) { static_assert (IndexV < sizeof... (TailT) + 1, "Index is out of bounds"); if constexpr (IndexV == 0) return std::forward (head); else return get (std::forward (tail)...); } /////////////////////////////////////////////////////////////////////////// /// returns a tuple of all arguments that satisfy the trait QueryT template