Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3403,6 +3403,28 @@ export class CPlusPlusRenderer extends ConvenienceRenderer {
);
this.superThis.ensureBlankLine();

if (this.superThis.haveOptionalProperties) {
this.superThis.emitLine(
"template<typename TF, typename TT>",
);
this.superThis.emitBlock(
[
"static toType convert(tag<",
this.superThis._optionalType,
"<TF> >, tag<",
this.superThis._optionalType,
"<TT> >, fromType opt)",
],
false,
() => {
this.superThis.emitLine(
"if (!opt) return toType(); else return toType(Utf16_Utf8<TF,TT>::convert(*opt));",
);
},
);
this.superThis.ensureBlankLine();
}

this.superThis.emitLine("template<typename TF, typename TT>");
this.superThis.emitBlock(
[
Expand Down
4 changes: 3 additions & 1 deletion test/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,9 @@ export const CPlusPlusLanguage: Language = {
quickTestRendererOptions: [
{ "source-style": "multi-source" },
{ "code-format": "with-struct" },
{ wstring: "use-wstring" },
// bug2521.json has an optional string, exercising UTF conversion
// through std::optional.
["bug2521.json", { wstring: "use-wstring" }],
{ "const-style": "east-const" },
// The default is boost=false (C++17); this keeps the boost code
// path covered. Pinned to specific inputs because the default
Expand Down
Loading