Skip to content

Commit 543f901

Browse files
committed
[C++] Add nodiscard attributes.
1 parent 4425f97 commit 543f901

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/cpp/CppGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ private void generateVarDataDescriptors(
668668
sizeOfLengthField);
669669

670670
new Formatter(sb).format("\n" +
671-
indent + " %4$s %1$sLength() const\n" +
671+
indent + " SBE_NODISCARD %4$s %1$sLength() const\n" +
672672
indent + " {\n" +
673673
"%2$s" +
674674
indent + " %4$s length;\n" +
@@ -1524,7 +1524,7 @@ private void generateArrayProperty(
15241524
if (encodingToken.encoding().primitiveType() == PrimitiveType.CHAR)
15251525
{
15261526
new Formatter(sb).format("\n" +
1527-
indent + " std::string get%1$sAsString() const\n" +
1527+
indent + " SBE_NODISCARD std::string get%1$sAsString() const\n" +
15281528
indent + " {\n" +
15291529
indent + " const char *buffer = m_buffer + m_offset + %2$d;\n" +
15301530
indent + " size_t length = 0;\n\n" +
@@ -1542,7 +1542,7 @@ private void generateArrayProperty(
15421542

15431543
new Formatter(sb).format("\n" +
15441544
indent + " #if __cplusplus >= 201703L\n" +
1545-
indent + " std::string_view get%1$sAsStringView() const SBE_NOEXCEPT\n" +
1545+
indent + " SBE_NODISCARD std::string_view get%1$sAsStringView() const SBE_NOEXCEPT\n" +
15461546
indent + " {\n" +
15471547
indent + " const char *buffer = m_buffer + m_offset + %2$d;\n" +
15481548
indent + " size_t length = 0;\n\n" +

0 commit comments

Comments
 (0)