Skip to content

Commit

Permalink
constexpr literals
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Jun 18, 2024
1 parent d9cb919 commit ccd4108
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/extensions/cpp/freemarker/Constant.h.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<#if withCodeComments && docComments??>
<@doc_comments docComments/>
</#if>
const ${typeInfo.typeFullName} ${name} = ${value};
constexpr ${typeInfo.typeFullName} ${name} = ${value};
<@namespace_end package.path/>

<@include_guard_end package.path, name/>
7 changes: 7 additions & 0 deletions test/language/literals/cpp/LiteralsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,11 @@ TEST(LiteralsTest, String)
ASSERT_EQ("String with escaped values \x31 \x32 \063 \n \t \f \r \\ \""_sv, STRING);
}

TEST(LiteralsTest, constexprLiteral)
{
static_assert(BINARY_POSITIVE == 0xff, "BINARY_POSITIVE fail");
static_assert(DECIMAL_NEGATIVE == -255, "DECIMAL_NEGATIVE fail");
static_assert(STRING.size() == 44, "STRING fail");
}

} // namespace literals

0 comments on commit ccd4108

Please sign in to comment.