arg_router  1.4.0
C++ command line argument parsing and routing
string_view_ops.hpp
1 // Copyright (C) 2022 by Camden Mannett.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
4 
5 #pragma once
6 
7 #include "arg_router/basic_types.hpp"
8 
9 #include <string_view>
10 
13 {
24 template <typename CharT,
25  typename Traits = std::char_traits<CharT>,
26  typename Allocator = config::allocator<CharT>>
27 [[nodiscard]] constexpr std::basic_string<CharT, Traits, Allocator> operator+(
28  std::basic_string<CharT, Traits, Allocator> lhs,
29  std::basic_string_view<CharT, Traits> rhs)
30 {
31  return lhs += rhs;
32 }
33 
44 template <typename CharT,
45  typename Traits = std::char_traits<CharT>,
46  typename Allocator = config::allocator<CharT>>
47 [[nodiscard]] constexpr std::basic_string<CharT, Traits, Allocator> operator+(
48  std::basic_string_view<CharT, Traits> lhs,
49  std::basic_string<CharT, Traits, Allocator> rhs)
50 {
51  rhs.insert(rhs.begin(), lhs.begin(), lhs.end());
52  return rhs;
53 }
54 
64 template <typename CharT, typename Traits = std::char_traits<CharT>>
65 [[nodiscard]] constexpr std::basic_string<CharT, Traits, config::allocator<CharT>> operator+(
66  std::basic_string_view<CharT, Traits> lhs,
67  std::basic_string_view<CharT, Traits> rhs)
68 {
69  return std::basic_string<CharT, Traits, config::allocator<CharT>>{lhs} += rhs;
70 }
71 } // namespace arg_router::utility::string_view_ops
std::allocator< T > allocator
Definition: config.hpp:70
constexpr std::basic_string< CharT, Traits, Allocator > operator+(std::basic_string< CharT, Traits, Allocator > lhs, std::basic_string_view< CharT, Traits > rhs)