Skip to content

Commit 65b0e6a

Browse files
committed
[Ref] mpt/string/buffer.hpp: Make mpt::charbuf more constexpr-friendly.
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22589 56274372-70c3-4bfc-bfc3-4c3a0b034d27
1 parent c86e676 commit 65b0e6a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mpt/string/buffer.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
#include "mpt/base/detect.hpp"
9-
#include "mpt/base/macros.hpp"
109
#include "mpt/base/namespace.hpp"
1110
#include "mpt/base/saturate_cast.hpp"
1211
#include "mpt/detect/mfc.hpp"
@@ -308,11 +307,13 @@ struct charbuf {
308307
}
309308

310309
public:
311-
Tchar buf[len];
310+
Tchar buf[len]{};
312311

313312
public:
314-
MPT_CONSTEXPR20_FUN charbuf() {
315-
std::fill(std::begin(buf), std::end(buf), char_constants<Tchar>::null);
313+
constexpr charbuf() {
314+
for (std::size_t i = 0; i < len; ++i) {
315+
buf[i] = char_constants<Tchar>::null;
316+
}
316317
}
317318
constexpr charbuf(const charbuf &) = default;
318319
constexpr charbuf(charbuf &&) = default;

0 commit comments

Comments
 (0)