DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
pushBack.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: pushBack.hpp
5// Author: crdrisko
6// Date: 01/21/2021-09:09:57
7// Description:
8
9#ifndef PUSHBACK_HPP
10#define PUSHBACK_HPP
11
12#include <cstddef>
13#include <tuple>
14#include <utility>
15
17
18namespace CppUtils::Meta
19{
20 namespace details
21 {
26 template<typename... Elements, typename NewElement, std::size_t... Indices>
27 constexpr auto push_back_impl(
28 const std::tuple<Elements...>& tuple, NewElement newElement, std::index_sequence<Indices...>)
29 {
30 return std::make_tuple(std::get<Indices>(tuple)..., newElement);
31 }
32 } // namespace details
33
38 template<typename... Elements, typename NewElement>
39 constexpr auto push_back(const std::tuple<Elements...>& tuple, NewElement newElement)
40 {
41 return details::push_back_impl(tuple, newElement, std::make_index_sequence<sizeof...(Elements)> {});
42 }
43} // namespace CppUtils::Meta
44
45#endif
Definition pushBack.hpp:21
constexpr auto push_back_impl(const std::tuple< Elements... > &tuple, NewElement newElement, std::index_sequence< Indices... >)
Definition pushBack.hpp:27
Definition frontList.hpp:13
constexpr auto push_back(const std::tuple< Elements... > &tuple, NewElement newElement)
Definition pushBack.hpp:39