StormByte C++ Library 0.0.9999
StormByte is a comprehensive, cross-platform C++ library aimed at easing system programming, configuration management, logging, and database handling tasks. This library provides a unified API that abstracts away the complexities and inconsistencies of different platforms (Windows, Linux).
Loading...
Searching...
No Matches
helpers.hxx
1#pragma once
2
3#include <StormByte/type_traits.hxx>
4#include <StormByte/visibility.h>
5
6#include <span>
7#include <vector>
8#include <version>
9
17namespace StormByte {
18 template<typename T, typename U>
19 void append_vector(std::vector<T>& dest, std::span<U> src) noexcept requires Type::ConvertibleTo<T, U> {
20 dest.reserve(dest.size() + src.size());
21#ifdef __cpp_lib_containers_ranges
22 dest.append_range(src);
23#else
24 dest.insert(dest.end(), src.begin(), src.end());
25#endif
26 }
27
40 template<typename T>
41 void append_vector(std::vector<T>& dest, const std::vector<T>& src) noexcept {
42 return append_vector(dest, std::span<const T>(src.data(), src.size()));
43 }
44
57 template<typename T>
58 void append_vector(std::vector<T>& dest, std::vector<T>&& src) noexcept {
59 dest.reserve(dest.size() + src.size());
60#ifdef __cpp_lib_containers_ranges
61 dest.append_range(std::move(src));
62#else
63 dest.insert(dest.end(), std::make_move_iterator(src.begin()), std::make_move_iterator(src.end()));
64#endif
65 }
66}
Main namespace for the StormByte library.