diff --git a/src/ConvenienceRenderer.ts b/src/ConvenienceRenderer.ts index e44a92f3..0507b1c4 100644 --- a/src/ConvenienceRenderer.ts +++ b/src/ConvenienceRenderer.ts @@ -331,6 +331,10 @@ export abstract class ConvenienceRenderer extends Renderer { return !this._namedUnions.isEmpty(); } + protected get haveNamedTypes(): boolean { + return !this._namedTypes.isEmpty(); + } + protected get haveUnions(): boolean { return this._haveUnions; } diff --git a/src/Language/CPlusPlus.ts b/src/Language/CPlusPlus.ts index 21904113..36db2026 100644 --- a/src/Language/CPlusPlus.ts +++ b/src/Language/CPlusPlus.ts @@ -754,6 +754,7 @@ inline ${optionalType} get_optional(const json &j, const char *property) { this.emitNamespace(this._namespaceName, this.emitTypes); } if (this._justTypes) return; + if (!this.haveNamedTypes) return; this.ensureBlankLine(); this.emitNamespace("nlohmann", () => {