Skip to content

fix(en/cpp11): sync xmake.lua with zh + add missing cpp11-15-variadic-templates#42

Merged
Sunrisepeak merged 1 commit intomainfrom
fix/issue-37-en-cpp11-sync
Apr 25, 2026
Merged

fix(en/cpp11): sync xmake.lua with zh + add missing cpp11-15-variadic-templates#42
Sunrisepeak merged 1 commit intomainfrom
fix/issue-37-en-cpp11-sync

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

  • Fix 练习: 08-literal-type-0 英文(en) 没有设置C++17 导致报错 - non-constexpr function 'operator[]' cannot be used in a constant expression #37 — the en version of dslings/en/cpp11/xmake.lua was missing set_languages("c++17") for the cpp11-08-literal-type-0 target that the zh version already had. With C++11 default, the practice file errored on non-constexpr operator[] of std::array, obscuring the actual teaching errors about constexpr std::string not being a literal type.
  • Also synced 3 other zh/en drift items found during the fix:
    • cpp11-04-rvalue-references: set_optimize("none") and add_cxxflags("-fno-elide-constructors") were unindented in en, leaking to file scope. Indented them to match zh.
    • cpp11-07-constexpr-0: add_cxxflags("-Wpedantic -Werror") had the same indentation issue. Fixed.
    • cpp11-15-variadic-templates-0/1: targets + source files were missing entirely from en. Added the xmake targets and English-translated source files.

After this PR, dslings/cpp11/xmake.lua and dslings/en/cpp11/xmake.lua are byte-identical.

Test plan

  • xmake f --lang=en && xmake build cpp11-08-literal-type-0 now produces the same 3 teaching errors as zh ('const std::string' ... is not literal, etc.) instead of the prior non-constexpr operator[] error.
  • xmake build cpp11-04-rvalue-references and cpp11-07-constexpr-0 still build (and stop at their respective D2X_YOUR_ANSWER placeholder errors as expected).
  • xmake build cpp11-15-variadic-templates-0 and cpp11-15-variadic-templates-1 resolve to the new English source files (and stop at D2X_YOUR_ANSWER placeholder errors as expected).
  • diff dslings/cpp11/xmake.lua dslings/en/cpp11/xmake.lua returns nothing.

Closes #37

…plates

- Add set_languages("c++17") to cpp11-08-literal-type-0 to match zh
  (fixes #37: 'non-constexpr operator[]' compile error swallowing the
  intended teaching errors about constexpr std::string)
- Fix indentation of set_optimize / -fno-elide-constructors in
  cpp11-04-rvalue-references and -Wpedantic -Werror in
  cpp11-07-constexpr-0 so they correctly scope to the surrounding
  target instead of leaking to file scope
- Add cpp11-15-variadic-templates-0/1 targets and English-translated
  source files (previously zh-only — en users had no way to run
  cpp11-15 exercises)

After this commit, dslings/cpp11/xmake.lua and
dslings/en/cpp11/xmake.lua are byte-identical.

Local verification: with `xmake f --lang=en` and the new
set_languages("c++17") line, building cpp11-08-literal-type-0 now
produces the same 3 teaching errors as the zh version
("const std::string ... is not literal", etc.), instead of the
C++11-era 'non-constexpr operator[]' error that obscured the lesson.

Closes #37
@Sunrisepeak Sunrisepeak merged commit 059b25c into main Apr 25, 2026
@Sunrisepeak Sunrisepeak deleted the fix/issue-37-en-cpp11-sync branch April 25, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

练习: 08-literal-type-0 英文(en) 没有设置C++17 导致报错 - non-constexpr function 'operator[]' cannot be used in a constant expression

1 participant