Skip to content

Commit ad86893

Browse files
fix: use sizeof pack expansion operator instead of custom lambda
1 parent 2bf74e9 commit ad86893

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

include/cstringpp/core.hpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,11 @@ template<size_t... Lengths>
157157
[[nodiscard]] constexpr auto strcat(const String<Lengths>&... strings) {
158158
// We need to strip null terminators from every string except the last
159159
// Also resize the result array so it doesn't have extra chars at the end
160-
constexpr int NumArgsMinus1 = (Lengths + ...) + 1 - [] {
161-
int numArgs = 0;
162-
((Lengths, numArgs++), ...);
163-
return numArgs;
164-
}();
165-
std::array<char, NumArgsMinus1> result;
160+
constexpr int CombinedLength = (Lengths + ...) + 1 - sizeof...(strings);
161+
std::array<char, CombinedLength> result;
166162
size_t index = 0;
167163
((std::copy_n(strings.begin(), Lengths, result.begin() + index), index += Lengths - 1), ...);
168-
return String<NumArgsMinus1>{result};
164+
return String<CombinedLength>{result};
169165
}
170166

171167
template<size_t Length1, size_t Length2>

0 commit comments

Comments
 (0)