11/*
2- * ver. 1.3.0
2+ * ver. 1.3.1
33 * (c) Проект "SimStr", Александр Орефков orefkov@gmail.com
44 * База для строковых конкатенаций через выражения времени компиляции
55 * (c) Project "SimStr", Aleksandr Orefkov orefkov@gmail.com
@@ -49,10 +49,10 @@ using u32s = char32_t;
4949using uu8s = std::make_unsigned<u8s>::type;
5050
5151template <typename K>
52- inline constexpr bool is_one_of_char_v = std::is_same_v<K, u8s> || std::is_same_v<K, wchar_t > || std::is_same_v<K, u16s> || std::is_same_v<K, u32s>;
52+ constexpr bool is_one_of_char_v = std::is_same_v<K, u8s> || std::is_same_v<K, wchar_t > || std::is_same_v<K, u16s> || std::is_same_v<K, u32s>;
5353
5454template <typename K>
55- inline constexpr bool is_one_of_std_char_v = std::is_same_v<K, u8s> || std::is_same_v<K, wchar_t > || std::is_same_v<K, wchar_type>;
55+ constexpr bool is_one_of_std_char_v = std::is_same_v<K, u8s> || std::is_same_v<K, wchar_t > || std::is_same_v<K, wchar_type>;
5656
5757template <typename From>
5858requires (is_one_of_std_char_v<From>)
@@ -143,15 +143,15 @@ template<typename K, size_t N>
143143class const_lit_to_array {
144144
145145 template <size_t Idx>
146- size_t find (K s) const {
146+ constexpr size_t find (K s) const {
147147 if constexpr (Idx < N) {
148148 return s == symbols_[Idx] ? Idx : find<Idx + 1 >(s);
149149 }
150150 return -1 ;
151151 }
152152
153153 template <size_t Idx>
154- bool exist (K s) const {
154+ constexpr bool exist (K s) const {
155155 if constexpr (Idx < N) {
156156 return s == symbols_[Idx] || exist<Idx + 1 >(s);
157157 }
@@ -412,8 +412,8 @@ struct strexprjoin {
412412 * expressions, which are then “materialized” into the final result in one call.
413413 */
414414template <StrExpr A, StrExprForType<typename A::symb_type> B>
415- inline auto operator +(const A& a, const B& b) {
416- return strexprjoin<A, B> {a, b};
415+ constexpr strexprjoin<A, B> operator +(const A& a, const B& b) {
416+ return {a, b};
417417}
418418
419419/* !
@@ -566,8 +566,8 @@ struct expr_char {
566566 * ```
567567 */
568568template <typename K, StrExprForType<K> A>
569- constexpr inline auto operator +(const A& a, K s) {
570- return strexprjoin_c<A, expr_char<K>> {a, s};
569+ constexpr strexprjoin_c<A, expr_char<K>> operator +(const A& a, K s) {
570+ return {a, s};
571571}
572572
573573/* !
@@ -581,8 +581,8 @@ constexpr inline auto operator+(const A& a, K s) {
581581 * @return string expression for a single character string.
582582 */
583583template <typename K>
584- constexpr inline auto e_char (K s) {
585- return expr_char<K> {s};
584+ constexpr expr_char<K> e_char (K s) {
585+ return {s};
586586}
587587
588588template <typename K, size_t N>
@@ -652,8 +652,8 @@ struct expr_literal {
652652 * All these methods work and give the same result. Which one to use is a matter of taste.
653653 */
654654template <typename T, size_t N = const_lit<T>::Count>
655- constexpr inline auto e_t (T&& s) {
656- return expr_literal< typename const_lit<T>::symb_type, static_cast < size_t >(N - 1 )> {s};
655+ constexpr expr_literal< typename const_lit<T>::symb_type, static_cast < size_t >(N - 1 )> e_t (T&& s) {
656+ return {s};
657657}
658658
659659template <bool first, typename K, size_t N, typename A>
@@ -692,8 +692,8 @@ struct expr_literal_join {
692692 * @return A string expression concatenating the operands.
693693 */
694694template <StrExpr A, typename K = typename A::symb_type, typename T, size_t N = const_lit_for<K, T>::Count>
695- constexpr inline auto operator +(const A& a, T&& s) {
696- return expr_literal_join< false , K, (N - 1 ), A> {s, a};
695+ constexpr expr_literal_join< false , K, (N - 1 ), A> operator +(const A& a, T&& s) {
696+ return {s, a};
697697}
698698
699699/* !
@@ -704,8 +704,8 @@ constexpr inline auto operator+(const A& a, T&& s) {
704704 * @return A string expression concatenating the operands.
705705 */
706706template <StrExpr A, typename K = typename A::symb_type, typename T, size_t N = const_lit_for<K, T>::Count>
707- constexpr inline auto operator +(T&& s, const A& a) {
708- return expr_literal_join< true , K, (N - 1 ), A> {s, a};
707+ constexpr expr_literal_join< true , K, (N - 1 ), A> operator +(T&& s, const A& a) {
708+ return {s, a};
709709}
710710
711711/* !
@@ -748,8 +748,8 @@ struct expr_spaces {
748748 * ```
749749 */
750750template <size_t N>
751- constexpr inline auto e_spca () {
752- return expr_spaces<u8s, N>() ;
751+ constexpr expr_spaces<u8s, N> e_spca () {
752+ return {} ;
753753}
754754
755755/* !
@@ -766,8 +766,8 @@ constexpr inline auto e_spca() {
766766 * ```
767767 */
768768template <size_t N>
769- constexpr inline auto e_spcw () {
770- return expr_spaces<uws, N>() ;
769+ constexpr expr_spaces<uws, N> e_spcw () {
770+ return {} ;
771771}
772772
773773/* !
@@ -810,8 +810,8 @@ struct expr_pad {
810810 * @return a string expression that generates a string of l characters k.
811811 */
812812template <typename K>
813- constexpr inline auto e_c (size_t l, K s) {
814- return expr_pad<K> { l, s };
813+ constexpr expr_pad<K> e_c (size_t l, K s) {
814+ return { l, s };
815815}
816816
817817template <typename K, size_t N>
@@ -861,8 +861,8 @@ struct expr_repeat_expr {
861861 * @return a string expression generating a string of l strings s
862862 */
863863template <typename T, typename K = const_lit<T>::symb_type, size_t M = const_lit<T>::Count> requires (M > 0 )
864- constexpr inline auto e_repeat(T&& s, size_t l) {
865- return expr_repeat_lit<K, M - 1 > { l, s };
864+ constexpr expr_repeat_lit<K, M - 1> e_repeat(T&& s, size_t l) {
865+ return { l, s };
866866}
867867
868868/* !
@@ -879,8 +879,8 @@ constexpr inline auto e_repeat(T&& s, size_t l) {
879879 * @return a string expression generating a string of l string expressions s
880880 */
881881template <StrExpr A>
882- constexpr inline auto e_repeat (const A& s, size_t l) {
883- return expr_repeat_expr<A> { l, s };
882+ constexpr expr_repeat_expr<A> e_repeat (const A& s, size_t l) {
883+ return { l, s };
884884}
885885
886886/* !
@@ -1103,8 +1103,8 @@ struct expr_choice_two_lit {
11031103 * which is not optimal and will reduce performance. (This is checked in the "Build Full Func Name" benchmark)
11041104 */
11051105template <StrExpr A, StrExprForType<typename A::symb_type> B>
1106- inline constexpr auto e_choice (bool c, const A& a, const B& b) {
1107- return expr_choice<A, B> {a, b, c};
1106+ constexpr expr_choice<A, B> e_choice (bool c, const A& a, const B& b) {
1107+ return {a, b, c};
11081108}
11091109
11101110/* !
@@ -1113,8 +1113,8 @@ inline constexpr auto e_choice(bool c, const A& a, const B& b) {
11131113 * @en @brief Overload e_choice when the third argument is a string literal.
11141114 */
11151115template <StrExpr A, typename T, size_t N = const_lit_for<typename A::symb_type, T>::Count>
1116- inline constexpr auto e_choice (bool c, const A& a, T&& str) {
1117- return expr_choice_one_lit<A, N - 1 , true > {str, a, c};
1116+ constexpr expr_choice_one_lit<A, N - 1 , true > e_choice (bool c, const A& a, T&& str) {
1117+ return {str, a, c};
11181118}
11191119
11201120/* !
@@ -1123,17 +1123,17 @@ inline constexpr auto e_choice(bool c, const A& a, T&& str) {
11231123 * @en @brief Overload e_choice when the second argument is a string literal.
11241124 */
11251125template <StrExpr A, typename T, size_t N = const_lit_for<typename A::symb_type, T>::Count>
1126- inline constexpr auto e_choice (bool c, T&& str, const A& a) {
1127- return expr_choice_one_lit<A, N - 1 , false > {str, a, c};
1126+ constexpr expr_choice_one_lit<A, N - 1 , false > e_choice (bool c, T&& str, const A& a) {
1127+ return {str, a, c};
11281128}
11291129/* !
11301130 * @ingroup StrExprs
11311131 * @ru @brief Перегрузка e_choice, когда второй и третий аргумент - строковые литералы.
11321132 * @en @brief Overload e_choice when the second and third arguments are string literals.
11331133 */
11341134template <typename T, typename L, size_t N = const_lit<T>::Count, size_t M = const_lit_for<typename const_lit<T>::symb_type, L>::Count>
1135- inline constexpr auto e_choice (bool c, T&& str_a, L&& str_b) {
1136- return expr_choice_two_lit< typename const_lit<T>::symb_type, N - 1 , M - 1 > {str_a, str_b, c};
1135+ constexpr expr_choice_two_lit< typename const_lit<T>::symb_type, N - 1 , M - 1 > e_choice (bool c, T&& str_a, L&& str_b) {
1136+ return {str_a, str_b, c};
11371137}
11381138
11391139/* !
@@ -1179,16 +1179,16 @@ inline constexpr auto e_choice(bool c, T&& str_a, L&& str_b) {
11791179 * which is not optimal and will reduce performance. (This example is tested in the "Build Full Func Name" benchmark)
11801180 */
11811181template <StrExpr A>
1182- inline constexpr auto e_if (bool c, const A& a) {
1183- return expr_if<A> {a, c};
1182+ constexpr expr_if<A> e_if (bool c, const A& a) {
1183+ return {a, c};
11841184}
11851185/* !
11861186 * @ingroup StrExprs
11871187 * @ru @brief Перегрузка e_if, когда второй аргумент - строковый литерал.
11881188 * @en @brief Overload e_if when the second argument is a string literal.
11891189 */
11901190template <typename T, size_t N = const_lit<T>::Count>
1191- inline constexpr auto e_if (bool c, T&& str) {
1191+ constexpr auto e_if (bool c, T&& str) {
11921192 const typename const_lit<T>::symb_type empty[1 ] = {0 };
11931193 return expr_choice_two_lit<typename const_lit<T>::symb_type, N - 1 , 0 >{str, empty, c};
11941194}
@@ -1225,8 +1225,8 @@ struct expr_stdstr {
12251225 * @en @brief Addition operator for char string expression and std::string.
12261226 */
12271227template <StrExprForType<u8s> A>
1228- auto operator +(const A& a, const std::string& s) {
1229- return strexprjoin_c<A, expr_stdstr<u8s, std::string>, true > {a, s};
1228+ constexpr strexprjoin_c<A, expr_stdstr<u8s, std::string>, true > operator +(const A& a, const std::string& s) {
1229+ return {a, s};
12301230}
12311231
12321232/* !
@@ -1235,8 +1235,8 @@ auto operator+(const A& a, const std::string& s) {
12351235 * @en @brief Addition operator for std::string and char string expression.
12361236 */
12371237template <StrExprForType<u8s> A>
1238- auto operator +(const std::string& s, const A& a) {
1239- return strexprjoin_c<A, expr_stdstr<u8s, std::string>, false > {a, s};
1238+ constexpr strexprjoin_c<A, expr_stdstr<u8s, std::string>, false > operator +(const std::string& s, const A& a) {
1239+ return {a, s};
12401240}
12411241
12421242/* !
@@ -1245,8 +1245,8 @@ auto operator+(const std::string& s, const A& a) {
12451245 * @en @brief Addition operator for char string expression and std::string_view.
12461246 */
12471247template <StrExprForType<u8s> A>
1248- auto operator +(const A& a, const std::string_view& s) {
1249- return strexprjoin_c<A, expr_stdstr<u8s, std::string_view>, true > {a, s};
1248+ constexpr strexprjoin_c<A, expr_stdstr<u8s, std::string_view>, true > operator +(const A& a, const std::string_view& s) {
1249+ return {a, s};
12501250}
12511251
12521252/* !
@@ -1255,8 +1255,8 @@ auto operator+(const A& a, const std::string_view& s) {
12551255 * @en @brief Addition operator for std::string_view and char string expression.
12561256 */
12571257template <StrExprForType<u8s> A>
1258- auto operator +(const std::string_view& s, const A& a) {
1259- return strexprjoin_c<A, expr_stdstr<u8s, std::string_view>, false > {a, s};
1258+ constexpr strexprjoin_c<A, expr_stdstr<u8s, std::string_view>, false > operator +(const std::string_view& s, const A& a) {
1259+ return {a, s};
12601260}
12611261
12621262/* !
@@ -1265,8 +1265,8 @@ auto operator+(const std::string_view& s, const A& a) {
12651265 * @en @brief Addition operator for wchar_t string expression and std::wstring.
12661266 */
12671267template <StrExprForType<uws> A>
1268- auto operator +(const A& a, const std::wstring& s) {
1269- return strexprjoin_c<A, expr_stdstr<uws, std::wstring>, true > {a, s};
1268+ constexpr strexprjoin_c<A, expr_stdstr<uws, std::wstring>, true > operator +(const A& a, const std::wstring& s) {
1269+ return {a, s};
12701270}
12711271
12721272/* !
@@ -1275,8 +1275,8 @@ auto operator+(const A& a, const std::wstring& s) {
12751275 * @en @brief Addition operator for std::wstring and wchar_t string expression.
12761276 */
12771277template <StrExprForType<uws> A>
1278- auto operator +(const std::wstring& s, const A& a) {
1279- return strexprjoin_c<A, expr_stdstr<uws, std::wstring>, false > {a, s};
1278+ constexpr strexprjoin_c<A, expr_stdstr<uws, std::wstring>, false > operator +(const std::wstring& s, const A& a) {
1279+ return {a, s};
12801280}
12811281
12821282/* !
@@ -1285,8 +1285,8 @@ auto operator+(const std::wstring& s, const A& a) {
12851285 * @en @brief Addition operator for wchar_t string expression and std::wstring_view.
12861286 */
12871287template <StrExprForType<uws> A>
1288- auto operator +(const A& a, const std::wstring_view& s) {
1289- return strexprjoin_c<A, expr_stdstr<uws, std::wstring_view>, true > {a, s};
1288+ constexpr strexprjoin_c<A, expr_stdstr<uws, std::wstring_view>, true > operator +(const A& a, const std::wstring_view& s) {
1289+ return {a, s};
12901290}
12911291
12921292/* !
@@ -1295,8 +1295,8 @@ auto operator+(const A& a, const std::wstring_view& s) {
12951295 * @en @brief Addition operator for std::wstring_view and wchar_t string expression.
12961296 */
12971297template <StrExprForType<uws> A>
1298- auto operator +(const std::wstring_view& s, const A& a) {
1299- return strexprjoin_c<A, expr_stdstr<uws, std::wstring_view>, false > {a, s};
1298+ constexpr strexprjoin_c<A, expr_stdstr<uws, std::wstring_view>, false > operator +(const std::wstring_view& s, const A& a) {
1299+ return {a, s};
13001300}
13011301
13021302/* !
@@ -1307,8 +1307,8 @@ auto operator+(const std::wstring_view& s, const A& a) {
13071307 * char32_t, depending on the compiler) and std::wstring.
13081308 */
13091309template <StrExprForType<wchar_type> A>
1310- auto operator +(const A& a, const std::wstring& s) {
1311- return strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring>, true > {a, s};
1310+ constexpr strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring>, true > operator +(const A& a, const std::wstring& s) {
1311+ return {a, s};
13121312}
13131313
13141314/* !
@@ -1319,8 +1319,8 @@ auto operator+(const A& a, const std::wstring& s) {
13191319 * (char16_t or char32_t, depending on the compiler).
13201320 */
13211321template <StrExprForType<wchar_type> A>
1322- auto operator +(const std::wstring& s, const A& a) {
1323- return strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring>, false > {a, s};
1322+ constexpr strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring>, false > operator +(const std::wstring& s, const A& a) {
1323+ return {a, s};
13241324}
13251325
13261326/* !
@@ -1331,8 +1331,8 @@ auto operator+(const std::wstring& s, const A& a) {
13311331 * char32_t, depending on the compiler) and std::wstring_view.
13321332 */
13331333template <StrExprForType<wchar_type> A>
1334- auto operator +(const A& a, const std::wstring_view& s) {
1335- return strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring_view>, true > {a, s};
1334+ constexpr strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring_view>, true > operator +(const A& a, const std::wstring_view& s) {
1335+ return {a, s};
13361336}
13371337
13381338/* !
@@ -1343,8 +1343,8 @@ auto operator+(const A& a, const std::wstring_view& s) {
13431343 * (char16_t or char32_t, depending on the compiler).
13441344 */
13451345template <StrExprForType<wchar_type> A>
1346- auto operator +(const std::wstring_view& s, const A& a) {
1347- return strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring_view>, false > {a, s};
1346+ constexpr strexprjoin_c<A, expr_stdstr<wchar_type, std::wstring_view>, false > operator +(const std::wstring_view& s, const A& a) {
1347+ return {a, s};
13481348}
13491349
13501350}// namespace simstr
0 commit comments