Skip to content

Fix #206: Supporting of std::wstring#684

Open
leftibot wants to merge 2 commits into
ChaiScript:developfrom
leftibot:fix/issue-206-supporting-of-std-wstring
Open

Fix #206: Supporting of std::wstring#684
leftibot wants to merge 2 commits into
ChaiScript:developfrom
leftibot:fix/issue-206-supporting-of-std-wstring

Conversation

@leftibot
Copy link
Copy Markdown
Contributor

Automated fix by @leftibot.

What changed

Fix #206: Make internal string type a template parameter
Add a StringType template parameter (defaulting to std::string) to
ChaiScript_Parser, Bootstrap::bootstrap(), and Std_Lib::library(),
flowing through to the ChaiScript_Impl convenience class. This allows
users to instantiate ChaiScript with std::wstring (via ChaiScript_WString)
or other string types. String literals, escape sequences (including
unicode for wide chars via if constexpr), to_string conversions, and
string operations all respect the parameterized type.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Files

 CMakeLists.txt                                    |   4 +
 include/chaiscript/chaiscript.hpp                 |  12 ++-
 include/chaiscript/chaiscript_stdlib.hpp          |   5 +-
 include/chaiscript/dispatchkit/bootstrap.hpp      |  25 ++++-
 include/chaiscript/language/chaiscript_parser.hpp | 126 +++++++++++++++-------
 unittests/string_type_param_test.cpp              |  47 ++++++++
 6 files changed, 172 insertions(+), 47 deletions(-)

Closes #206

Triggered by @lefticus.

Add a StringType template parameter (defaulting to std::string) to
ChaiScript_Parser, Bootstrap::bootstrap(), and Std_Lib::library(),
flowing through to the ChaiScript_Impl convenience class. This allows
users to instantiate ChaiScript with std::wstring (via ChaiScript_WString)
or other string types. String literals, escape sequences (including
unicode for wide chars via if constexpr), to_string conversions, and
string operations all respect the parameterized type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
namespace chaiscript {
class Std_Lib {
public:
template<typename StringType = std::string>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leftibot don't default the newly added template parameters

…ters

Remove `= std::string` defaults from the StringType template parameter
on ChaiScript_Parser, Bootstrap::bootstrap(), Std_Lib::library(), and
ChaiScript_Impl. All call sites now specify the string type explicitly.

Requested by @lefticus in PR ChaiScript#684 review.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@leftibot
Copy link
Copy Markdown
Contributor Author

Addressed review feedback from @lefticus. New commits:

e25ce224 Address review: remove default values from StringType template parameters

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.

Supporting of std::wstring

2 participants