Skip to content

Conversation

@smdn
Copy link
Owner

@smdn smdn commented Jan 10, 2026

Description

文字列から数値への変換において、std::stodの代わりにstd::from_charsを使用する。
これによって、例外ハンドリングの必要がない実装に簡略化する。

同時に、引数の型をstd::stringからstd::string_viewに変える。

ただし、GitHub Actions macOSランナーイメージのデフォルトのツールセットでは、まだstd::from_charsdoubleへの変換をサポートしていないようなので、サポートされ次第マージする。

Considerations

以下のように、まだstd::from_charsがサポートされていないので、デフォルトのツールセットでコンパイルできるようになるまでマージを控える。

Run tests with an implementation of C++ (GitHub Actions, make + G++) ...
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Applications/Xcode_16.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
g++ -std=c++2a -O2 -Wall -c polish.cpp
polish.cpp:398:39: error: call to deleted function 'from_chars'
  398 |     [[maybe_unused]] auto [ptr, ec] = std::from_chars(
      |                                       ^~~~~~~~~~~~~~~
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/from_chars_integral.h:38:19: note: candidate function has been explicitly deleted
   38 | from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
      |                   ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/from_chars_integral.h:224:1: note: candidate template ignored: requirement 'is_integral<double>::value' was not satisfied [with _Tp = double]
  224 | from_chars(const char* __first, const char* __last, _Tp& __value) {
      | ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/from_chars_integral.h:230:1: note: candidate function template not viable: requires 4 arguments, but 3 were provided
  230 | from_chars(const char* __first, const char* __last, _Tp& __value, int __base) {
      | ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [polish.o] Error 1
Run tests with an implementation of C++ (GitHub Actions, make + Clang) ...
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Applications/Xcode_16.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang++ -std=c++2a -O2 -Wall -c polish.cpp
polish.cpp:398:39: error: call to deleted function 'from_chars'
  398 |     [[maybe_unused]] auto [ptr, ec] = std::from_chars(
      |                                       ^~~~~~~~~~~~~~~
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/from_chars_integral.h:38:19: note: candidate function has been explicitly deleted
   38 | from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete;
      |                   ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/from_chars_integral.h:224:1: note: candidate template ignored: requirement 'is_integral<double>::value' was not satisfied [with _Tp = double]
  224 | from_chars(const char* __first, const char* __last, _Tp& __value) {
      | ^
/Applications/Xcode_16.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__charconv/from_chars_integral.h:230:1: note: candidate function template not viable: requires 4 arguments, but 3 were provided
  230 | from_chars(const char* __first, const char* __last, _Tp& __value, int __base) {
      | ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [polish.o] Error 1
Operating System
  macOS
  15.7.3
  24G419
Runner Image
  Image: macos-15-arm64
  Version: 20260105.0094.1
  Included Software: https://github.com/actions/runner-images/blob/macos-15-arm64/20260105.0094/images/macos/macos-15-arm64-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/macos-15-arm64%2F20260105.0094

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.

2 participants