DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
pushFront.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2025 Cody R. Drisko. All rights reserved.
2// Licensed under the MIT License. See the LICENSE file in the project root for more information.
3//
4// Name: pushFront.hpp
5// Author: crdrisko
6// Date: 01/21/2021-09:10:03
7// Description:
8
9#ifndef PUSHFRONT_HPP
10#define PUSHFRONT_HPP
11
12#include <tuple>
13#include <utility>
14
16
17namespace CppUtils::Meta
18{
19 namespace details
20 {
25 template<typename... Elements, typename NewElement, std::size_t... Indices>
26 constexpr auto push_front_impl(
27 const std::tuple<Elements...>& tuple, NewElement newElement, std::index_sequence<Indices...>)
28 {
29 return std::make_tuple(newElement, std::get<Indices>(tuple)...);
30 }
31 } // namespace details
32
37 template<typename... Elements, typename NewElement>
38 constexpr auto push_front(const std::tuple<Elements...>& tuple, NewElement newElement)
39 {
40 return details::push_front_impl(tuple, newElement, std::make_index_sequence<sizeof...(Elements)> {});
41 }
42} // namespace CppUtils::Meta
43
44
45#endif
Definition pushBack.hpp:21
constexpr auto push_front_impl(const std::tuple< Elements... > &tuple, NewElement newElement, std::index_sequence< Indices... >)
Definition pushFront.hpp:26
Definition frontList.hpp:13
constexpr auto push_front(const std::tuple< Elements... > &tuple, NewElement newElement)
Definition pushFront.hpp:38