diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27903c48..1ae0e4ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: - run: cd test && pip install -r requirements.txt && pip install cmake - name: Build run: | - cmake -DCMAKE_BUILD_TYPE=Debug -DTEST=on -DMLLM_BUILD_XNNPACK_BACKEND=OFF -Bbuild && cmake --build build --target all -j $(nproc) + cmake -DCMAKE_BUILD_TYPE=Debug -DTEST=on -DMLLM_BUILD_XNNPACK_BACKEND=ON -Bbuild && cmake --build build --target all -j $(nproc) - name: Make Data run: cd test && bash test.sh diff --git a/third_party/fmt/.github/dependabot.yml b/third_party/fmt/.github/dependabot.yml deleted file mode 100644 index f74783d9..00000000 --- a/third_party/fmt/.github/dependabot.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" # Necessary to update action hashes. - directory: "/" - schedule: - interval: "monthly" - # Allow up to 3 opened pull requests for github-actions versions. - open-pull-requests-limit: 3 diff --git a/third_party/fmt/.github/issue_template.md b/third_party/fmt/.github/issue_template.md deleted file mode 100644 index 8e39c5ba..00000000 --- a/third_party/fmt/.github/issue_template.md +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/third_party/fmt/.github/pull_request_template.md b/third_party/fmt/.github/pull_request_template.md deleted file mode 100644 index e8774133..00000000 --- a/third_party/fmt/.github/pull_request_template.md +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/third_party/fmt/.github/workflows/cifuzz.yml b/third_party/fmt/.github/workflows/cifuzz.yml deleted file mode 100644 index 56dfae80..00000000 --- a/third_party/fmt/.github/workflows/cifuzz.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: CIFuzz -on: [pull_request] - -permissions: - contents: read - -jobs: - Fuzzing: - runs-on: ubuntu-latest - steps: - - name: Build fuzzers - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@92182553173581f871130c71c71b17f003d47b0a # master - with: - oss-fuzz-project-name: 'fmt' - dry-run: false - language: c++ - - name: Run fuzzers - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@92182553173581f871130c71c71b17f003d47b0a # master - with: - oss-fuzz-project-name: 'fmt' - fuzz-seconds: 300 - dry-run: false - language: c++ - - name: Upload crash - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - if: failure() && steps.build.outcome == 'success' - with: - name: artifacts - path: ./out/artifacts diff --git a/third_party/fmt/.github/workflows/doc.yml b/third_party/fmt/.github/workflows/doc.yml deleted file mode 100644 index 3098d458..00000000 --- a/third_party/fmt/.github/workflows/doc.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: doc - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - build: - # Use Ubuntu 20.04 because doxygen 1.8.13 from Ubuntu 18.04 is broken. - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - - name: Add Ubuntu mirrors - run: | - # Github Actions caching proxy is at times unreliable - # see https://github.com/actions/runner-images/issues/7048 - printf 'http://azure.archive.ubuntu.com/ubuntu\tpriority:1\n' | sudo tee /etc/apt/mirrors.txt - curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt - sudo sed -i 's~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:/etc/apt/mirrors.txt~' /etc/apt/sources.list - - - name: Create build environment - run: | - sudo apt update - sudo apt install doxygen - pip install mkdocs-material==9.5.25 mkdocstrings==0.25.1 mike==2.1.1 - cmake -E make_directory ${{runner.workspace}}/build - # Workaround https://github.com/actions/checkout/issues/13: - git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" - git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" - - - name: Build - working-directory: ${{runner.workspace}}/build - run: $GITHUB_WORKSPACE/support/mkdocs deploy dev - - - name: Deploy - env: - KEY: "${{secrets.KEY}}" - if: env.KEY != '' && github.ref == 'refs/heads/master' - working-directory: ${{runner.workspace}}/fmt/build/fmt.dev - run: git push https://$KEY@github.com/fmtlib/fmt.dev.git diff --git a/third_party/fmt/.github/workflows/lint.yml b/third_party/fmt/.github/workflows/lint.yml deleted file mode 100644 index 0792356f..00000000 --- a/third_party/fmt/.github/workflows/lint.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: lint - -on: - pull_request: - paths: - - '**.h' - - '**.cc' - -permissions: - contents: read - pull-requests: write - -jobs: - format_code: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - - name: Install clang-format - uses: aminya/setup-cpp@290824452986e378826155f3379d31bce8753d76 # v0.37.0 - with: - clangformat: 17.0.5 - - - name: Run clang-format - id: clang_format - run: | - find include src -name '*.h' -o -name '*.cc' | xargs clang-format -i -style=file -fallback-style=none - git diff | tee fmt.patch - if [ -s fmt.patch ]; then - exit 1 - fi - - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - if: failure() && steps.clang_format.outcome == 'failure' - with: - github-token: ${{ secrets.KEY }} - script: | - const fs = require('fs'); - const patch = fs.readFileSync('fmt.patch', { encoding: 'utf8' }); - const comment = `clang-format 17.0.5 found issues in the formatting in your code: -
- - View the diff from clang-format: - - - \`\`\`diff - ${patch} - \`\`\` - -
- `; - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: comment - }); diff --git a/third_party/fmt/.github/workflows/linux.yml b/third_party/fmt/.github/workflows/linux.yml deleted file mode 100644 index 5b4e213a..00000000 --- a/third_party/fmt/.github/workflows/linux.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: linux - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-20.04 - strategy: - matrix: - cxx: [g++-4.8, g++-10, clang++-9] - build_type: [Debug, Release] - std: [11] - include: - - cxx: g++-4.8 - install: sudo apt install g++-4.8 - - cxx: g++-8 - build_type: Debug - std: 14 - install: sudo apt install g++-8 - - cxx: g++-8 - build_type: Debug - std: 17 - install: sudo apt install g++-8 - - cxx: g++-9 - build_type: Debug - std: 17 - - cxx: g++-10 - build_type: Debug - std: 17 - - cxx: g++-11 - build_type: Debug - std: 20 - install: sudo apt install g++-11 - - cxx: clang++-8 - build_type: Debug - std: 17 - cxxflags: -stdlib=libc++ - install: sudo apt install clang-8 libc++-8-dev libc++abi-8-dev - - cxx: clang++-9 - install: sudo apt install clang-9 - - cxx: clang++-9 - build_type: Debug - fuzz: -DFMT_FUZZ=ON -DFMT_FUZZ_LINKMAIN=ON - std: 17 - install: sudo apt install clang-9 - - cxx: clang++-11 - build_type: Debug - std: 20 - - cxx: clang++-11 - build_type: Debug - std: 20 - cxxflags: -stdlib=libc++ - install: sudo apt install libc++-11-dev libc++abi-11-dev - - shared: -DBUILD_SHARED_LIBS=ON - - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - - name: Set timezone - run: sudo timedatectl set-timezone 'Asia/Yekaterinburg' - - - name: Add repositories for older GCC - run: | - # Below two repos provide GCC 4.8, 5.5 and 6.4 - sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic main' - sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic universe' - # Below two repos additionally update GCC 6 to 6.5 - # sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic-updates main' - # sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic-updates universe' - if: ${{ matrix.cxx == 'g++-4.8' }} - - - name: Add repositories for newer GCC - run: | - sudo apt-add-repository ppa:ubuntu-toolchain-r/test - if: ${{ matrix.cxx == 'g++-11' }} - - - name: Add Ubuntu mirrors - run: | - # Github Actions caching proxy is at times unreliable - # see https://github.com/actions/runner-images/issues/7048 - printf 'http://azure.archive.ubuntu.com/ubuntu\tpriority:1\n' | sudo tee /etc/apt/mirrors.txt - curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt - sudo sed -i 's~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:/etc/apt/mirrors.txt~' /etc/apt/sources.list - - - name: Create Build Environment - run: | - sudo apt update - ${{matrix.install}} - sudo apt install locales-all - cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure - working-directory: ${{runner.workspace}}/build - env: - CXX: ${{matrix.cxx}} - CXXFLAGS: ${{matrix.cxxflags}} - run: | - cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.fuzz}} ${{matrix.shared}} \ - -DCMAKE_CXX_STANDARD=${{matrix.std}} -DFMT_DOC=OFF \ - -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \ - -DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE - - - name: Build - working-directory: ${{runner.workspace}}/build - run: | - threads=`nproc` - cmake --build . --config ${{matrix.build_type}} --parallel $threads - - - name: Test - working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.build_type}} - env: - CTEST_OUTPUT_ON_FAILURE: True diff --git a/third_party/fmt/.github/workflows/macos.yml b/third_party/fmt/.github/workflows/macos.yml deleted file mode 100644 index 1972cce5..00000000 --- a/third_party/fmt/.github/workflows/macos.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: macos - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - build: - strategy: - matrix: - os: [macos-13, macos-14] - build_type: [Debug, Release] - std: [11, 17, 20] - exclude: - - { os: macos-13, std: 11 } - - { os: macos-13, std: 17 } - include: - - shared: -DBUILD_SHARED_LIBS=ON - - runs-on: '${{ matrix.os }}' - - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - - name: Set timezone - run: sudo systemsetup -settimezone 'Asia/Yekaterinburg' - - - name: Select Xcode 14.3 (macOS 13) - run: sudo xcode-select -s "/Applications/Xcode_14.3.app" - if: ${{ matrix.os == 'macos-13' }} - - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure - working-directory: ${{runner.workspace}}/build - run: | - cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \ - -DCMAKE_CXX_STANDARD=${{matrix.std}} \ - -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \ - -DFMT_DOC=OFF -DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE - - - name: Build - working-directory: ${{runner.workspace}}/build - run: | - threads=`sysctl -n hw.logicalcpu` - cmake --build . --config ${{matrix.build_type}} --parallel $threads - - - name: Test - working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.build_type}} - env: - CTEST_OUTPUT_ON_FAILURE: True diff --git a/third_party/fmt/.github/workflows/scorecard.yml b/third_party/fmt/.github/workflows/scorecard.yml deleted file mode 100644 index 15582407..00000000 --- a/third_party/fmt/.github/workflows/scorecard.yml +++ /dev/null @@ -1,65 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. They are provided -# by a third-party and are governed by separate terms of service, privacy -# policy, and support documentation. - -name: Scorecard supply-chain security -on: - # For Branch-Protection check. Only the default branch is supported. See - # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection - branch_protection_rule: - # To guarantee Maintained check is occasionally updated. See - # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained - schedule: - - cron: '26 14 * * 5' - push: - branches: [ "master" ] - -# Declare default permissions as read only. -permissions: read-all - -jobs: - analysis: - name: Scorecard analysis - runs-on: ubuntu-latest - permissions: - # Needed to upload the results to code-scanning dashboard. - security-events: write - # Needed to publish results and get a badge (see publish_results below). - id-token: write - - steps: - - name: "Checkout code" - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - persist-credentials: false - - - name: "Run analysis" - uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 - with: - results_file: results.sarif - results_format: sarif - # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: - # - you want to enable the Branch-Protection check on a *public* repository, or - # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. - # repo_token: ${{ secrets.SCORECARD_TOKEN }} - - # Public repositories: - # - Publish results to OpenSSF REST API for easy access by consumers - # - Allows the repository to include the Scorecard badge. - # - See https://github.com/ossf/scorecard-action#publishing-results. - publish_results: true - - # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF - # format to the repository Actions tab. - - name: "Upload artifact" - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 - with: - name: SARIF file - path: results.sarif - retention-days: 5 - - # Upload the results to GitHub's code scanning dashboard. - - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3.25.11 - with: - sarif_file: results.sarif diff --git a/third_party/fmt/.github/workflows/windows.yml b/third_party/fmt/.github/workflows/windows.yml deleted file mode 100644 index 014396b9..00000000 --- a/third_party/fmt/.github/workflows/windows.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: windows - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - build: - runs-on: ${{matrix.os}} - strategy: - matrix: - # windows-2019 has MSVC 2019 installed; - # windows-2022 has MSVC 2022 installed: - # https://github.com/actions/virtual-environments. - os: [windows-2019] - platform: [Win32, x64] - toolset: [v140, v141, v142] - standard: [14, 17, 20] - shared: ["", -DBUILD_SHARED_LIBS=ON] - build_type: [Debug, Release] - exclude: - - { toolset: v140, standard: 17 } - - { toolset: v140, standard: 20 } - - { toolset: v141, standard: 14 } - - { toolset: v141, standard: 20 } - - { toolset: v142, standard: 14 } - - { platform: Win32, toolset: v140 } - - { platform: Win32, toolset: v141 } - - { platform: Win32, standard: 14 } - - { platform: Win32, standard: 20 } - - { platform: x64, toolset: v140, shared: -DBUILD_SHARED_LIBS=ON } - - { platform: x64, toolset: v141, shared: -DBUILD_SHARED_LIBS=ON } - - { platform: x64, standard: 14, shared: -DBUILD_SHARED_LIBS=ON } - - { platform: x64, standard: 20, shared: -DBUILD_SHARED_LIBS=ON } - include: - - os: windows-2022 - platform: x64 - toolset: v143 - build_type: Debug - standard: 20 - - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - - name: Set timezone - run: tzutil /s "Ekaterinburg Standard Time" - - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure - # Use a bash shell for $GITHUB_WORKSPACE. - shell: bash - working-directory: ${{runner.workspace}}/build - run: | - cmake -A ${{matrix.platform}} -T ${{matrix.toolset}} \ - -DCMAKE_CXX_STANDARD=${{matrix.standard}} \ - ${{matrix.shared}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ - $GITHUB_WORKSPACE - - - name: Build - working-directory: ${{runner.workspace}}/build - run: | - $threads = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors - cmake --build . --config ${{matrix.build_type}} --parallel $threads - - - name: Test - working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.build_type}} -V - env: - CTEST_OUTPUT_ON_FAILURE: True - - mingw: - runs-on: windows-latest - defaults: - run: - shell: msys2 {0} - strategy: - matrix: - sys: [ mingw64, ucrt64 ] - steps: - - name: Set timezone - run: tzutil /s "Ekaterinburg Standard Time" - shell: cmd - - uses: msys2/setup-msys2@d0e80f58dffbc64f6a3a1f43527d469b4fc7b6c8 # v2.23.0 - with: - release: false - msystem: ${{matrix.sys}} - pacboy: cc:p cmake:p ninja:p lld:p - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - name: Configure - run: cmake -B ../build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug - env: { LDFLAGS: -fuse-ld=lld } - - name: Build - run: cmake --build ../build - - name: Test - run: ctest -j `nproc` --test-dir ../build - env: - CTEST_OUTPUT_ON_FAILURE: True diff --git a/third_party/fmt/doc/ChangeLog-old.md b/third_party/fmt/doc/ChangeLog-old.md deleted file mode 100644 index 3f31d1e9..00000000 --- a/third_party/fmt/doc/ChangeLog-old.md +++ /dev/null @@ -1,3290 +0,0 @@ -# 7.1.3 - 2020-11-24 - -- Fixed handling of buffer boundaries in `format_to_n` - (https://github.com/fmtlib/fmt/issues/1996, - https://github.com/fmtlib/fmt/issues/2029). -- Fixed linkage errors when linking with a shared library - (https://github.com/fmtlib/fmt/issues/2011). -- Reintroduced ostream support to range formatters - (https://github.com/fmtlib/fmt/issues/2014). -- Worked around an issue with mixing std versions in gcc - (https://github.com/fmtlib/fmt/issues/2017). - -# 7.1.2 - 2020-11-04 - -- Fixed floating point formatting with large precision - (https://github.com/fmtlib/fmt/issues/1976). - -# 7.1.1 - 2020-11-01 - -- Fixed ABI compatibility with 7.0.x - (https://github.com/fmtlib/fmt/issues/1961). -- Added the `FMT_ARM_ABI_COMPATIBILITY` macro to work around ABI - incompatibility between GCC and Clang on ARM - (https://github.com/fmtlib/fmt/issues/1919). -- Worked around a SFINAE bug in GCC 8 - (https://github.com/fmtlib/fmt/issues/1957). -- Fixed linkage errors when building with GCC\'s LTO - (https://github.com/fmtlib/fmt/issues/1955). -- Fixed a compilation error when building without `__builtin_clz` or - equivalent (https://github.com/fmtlib/fmt/pull/1968). - Thanks @tohammer. -- Fixed a sign conversion warning - (https://github.com/fmtlib/fmt/pull/1964). Thanks @OptoCloud. - -# 7.1.0 - 2020-10-25 - -- Switched from - [Grisu3](https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf) - to [Dragonbox](https://github.com/jk-jeon/dragonbox) for the default - floating-point formatting which gives the shortest decimal - representation with round-trip guarantee and correct rounding - (https://github.com/fmtlib/fmt/pull/1882, - https://github.com/fmtlib/fmt/pull/1887, - https://github.com/fmtlib/fmt/pull/1894). This makes {fmt} - up to 20-30x faster than common implementations of - `std::ostringstream` and `sprintf` on - [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) and - faster than double-conversion and Ryū: - - ![](https://user-images.githubusercontent.com/576385/95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png) - - It is possible to get even better performance at the cost of larger - binary size by compiling with the `FMT_USE_FULL_CACHE_DRAGONBOX` - macro set to 1. - - Thanks @jk-jeon. - -- Added an experimental unsynchronized file output API which, together - with [format string - compilation](https://fmt.dev/latest/api.html#compile-api), can give - [5-9 times speed up compared to - fprintf](https://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html) - on common platforms ([godbolt](https://godbolt.org/z/nsTcG8)): - - ```c++ - #include - - int main() { - auto f = fmt::output_file("guide"); - f.print("The answer is {}.", 42); - } - ``` - -- Added a formatter for `std::chrono::time_point` - (https://github.com/fmtlib/fmt/issues/1819, - https://github.com/fmtlib/fmt/pull/1837). For example - ([godbolt](https://godbolt.org/z/c4M6fh)): - - ```c++ - #include - - int main() { - auto now = std::chrono::system_clock::now(); - fmt::print("The time is {:%H:%M:%S}.\n", now); - } - ``` - - Thanks @adamburgess. - -- Added support for ranges with non-const `begin`/`end` to `fmt::join` - (https://github.com/fmtlib/fmt/issues/1784, - https://github.com/fmtlib/fmt/pull/1786). For example - ([godbolt](https://godbolt.org/z/jP63Tv)): - - ```c++ - #include - #include - - int main() { - using std::literals::string_literals::operator""s; - auto strs = std::array{"a"s, "bb"s, "ccc"s}; - auto range = strs | ranges::views::filter( - [] (const std::string &x) { return x.size() != 2; } - ); - fmt::print("{}\n", fmt::join(range, "")); - } - ``` - - prints \"accc\". - - Thanks @tonyelewis. - -- Added a `memory_buffer::append` overload that takes a range - (https://github.com/fmtlib/fmt/pull/1806). Thanks @BRevzin. - -- Improved handling of single code units in `FMT_COMPILE`. For - example: - - ```c++ - #include - - char* f(char* buf) { - return fmt::format_to(buf, FMT_COMPILE("x{}"), 42); - } - ``` - - compiles to just ([godbolt](https://godbolt.org/z/5vncz3)): - - ```asm - _Z1fPc: - movb $120, (%rdi) - xorl %edx, %edx - cmpl $42, _ZN3fmt2v76detail10basic_dataIvE23zero_or_powers_of_10_32E+8(%rip) - movl $3, %eax - seta %dl - subl %edx, %eax - movzwl _ZN3fmt2v76detail10basic_dataIvE6digitsE+84(%rip), %edx - cltq - addq %rdi, %rax - movw %dx, -2(%rax) - ret - ``` - - Here a single `mov` instruction writes `'x'` (`$120`) to the output - buffer. - -- Added dynamic width support to format string compilation - (https://github.com/fmtlib/fmt/issues/1809). - -- Improved error reporting for unformattable types: now you\'ll get - the type name directly in the error message instead of the note: - - ```c++ - #include - - struct how_about_no {}; - - int main() { - fmt::print("{}", how_about_no()); - } - ``` - - Error ([godbolt](https://godbolt.org/z/GoxM4e)): - - `fmt/core.h:1438:3: error: static_assert failed due to requirement 'fmt::v7::formattable()' "Cannot format an argument. To make type T formattable provide a formatter specialization: https://fmt.dev/latest/api.html#udt" ...` - -- Added the - [make_args_checked](https://fmt.dev/7.1.0/api.html#argument-lists) - function template that allows you to write formatting functions with - compile-time format string checks and avoid binary code bloat - ([godbolt](https://godbolt.org/z/PEf9qr)): - - ```c++ - void vlog(const char* file, int line, fmt::string_view format, - fmt::format_args args) { - fmt::print("{}: {}: ", file, line); - fmt::vprint(format, args); - } - - template - void log(const char* file, int line, const S& format, Args&&... args) { - vlog(file, line, format, - fmt::make_args_checked(format, args...)); - } - - #define MY_LOG(format, ...) \ - log(__FILE__, __LINE__, FMT_STRING(format), __VA_ARGS__) - - MY_LOG("invalid squishiness: {}", 42); - ``` - -- Replaced `snprintf` fallback with a faster internal IEEE 754 `float` - and `double` formatter for arbitrary precision. For example - ([godbolt](https://godbolt.org/z/dPhWvj)): - - ```c++ - #include - - int main() { - fmt::print("{:.500}\n", 4.9406564584124654E-324); - } - ``` - - prints - - `4.9406564584124654417656879286822137236505980261432476442558568250067550727020875186529983636163599237979656469544571773092665671035593979639877479601078187812630071319031140452784581716784898210368871863605699873072305000638740915356498438731247339727316961514003171538539807412623856559117102665855668676818703956031062493194527159149245532930545654440112748012970999954193198940908041656332452475714786901472678015935523861155013480352649347201937902681071074917033322268447533357208324319360923829e-324`. - -- Made `format_to_n` and `formatted_size` part of the [core - API](https://fmt.dev/latest/api.html#core-api) - ([godbolt](https://godbolt.org/z/sPjY1K)): - - ```c++ - #include - - int main() { - char buffer[10]; - auto result = fmt::format_to_n(buffer, sizeof(buffer), "{}", 42); - } - ``` - -- Added `fmt::format_to_n` overload with format string compilation - (https://github.com/fmtlib/fmt/issues/1764, - https://github.com/fmtlib/fmt/pull/1767, - https://github.com/fmtlib/fmt/pull/1869). For example - ([godbolt](https://godbolt.org/z/93h86q)): - - ```c++ - #include - - int main() { - char buffer[8]; - fmt::format_to_n(buffer, sizeof(buffer), FMT_COMPILE("{}"), 42); - } - ``` - - Thanks @Kurkin and @alexezeder. - -- Added `fmt::format_to` overload that take `text_style` - (https://github.com/fmtlib/fmt/issues/1593, - https://github.com/fmtlib/fmt/issues/1842, - https://github.com/fmtlib/fmt/pull/1843). For example - ([godbolt](https://godbolt.org/z/91153r)): - - ```c++ - #include - - int main() { - std::string out; - fmt::format_to(std::back_inserter(out), - fmt::emphasis::bold | fg(fmt::color::red), - "The answer is {}.", 42); - } - ``` - - Thanks @Naios. - -- Made the `'#'` specifier emit trailing zeros in addition to the - decimal point (https://github.com/fmtlib/fmt/issues/1797). - For example ([godbolt](https://godbolt.org/z/bhdcW9)): - - ```c++ - #include - - int main() { - fmt::print("{:#.2g}", 0.5); - } - ``` - - prints `0.50`. - -- Changed the default floating point format to not include `.0` for - consistency with `std::format` and `std::to_chars` - (https://github.com/fmtlib/fmt/issues/1893, - https://github.com/fmtlib/fmt/issues/1943). It is possible - to get the decimal point and trailing zero with the `#` specifier. - -- Fixed an issue with floating-point formatting that could result in - addition of a non-significant trailing zero in rare cases e.g. - `1.00e-34` instead of `1.0e-34` - (https://github.com/fmtlib/fmt/issues/1873, - https://github.com/fmtlib/fmt/issues/1917). - -- Made `fmt::to_string` fallback on `ostream` insertion operator if - the `formatter` specialization is not provided - (https://github.com/fmtlib/fmt/issues/1815, - https://github.com/fmtlib/fmt/pull/1829). Thanks @alexezeder. - -- Added support for the append mode to the experimental file API and - improved `fcntl.h` detection. - (https://github.com/fmtlib/fmt/pull/1847, - https://github.com/fmtlib/fmt/pull/1848). Thanks @t-wiser. - -- Fixed handling of types that have both an implicit conversion - operator and an overloaded `ostream` insertion operator - (https://github.com/fmtlib/fmt/issues/1766). - -- Fixed a slicing issue in an internal iterator type - (https://github.com/fmtlib/fmt/pull/1822). Thanks @BRevzin. - -- Fixed an issue in locale-specific integer formatting - (https://github.com/fmtlib/fmt/issues/1927). - -- Fixed handling of exotic code unit types - (https://github.com/fmtlib/fmt/issues/1870, - https://github.com/fmtlib/fmt/issues/1932). - -- Improved `FMT_ALWAYS_INLINE` - (https://github.com/fmtlib/fmt/pull/1878). Thanks @jk-jeon. - -- Removed dependency on `windows.h` - (https://github.com/fmtlib/fmt/pull/1900). Thanks @bernd5. - -- Optimized counting of decimal digits on MSVC - (https://github.com/fmtlib/fmt/pull/1890). Thanks @mwinterb. - -- Improved documentation - (https://github.com/fmtlib/fmt/issues/1772, - https://github.com/fmtlib/fmt/pull/1775, - https://github.com/fmtlib/fmt/pull/1792, - https://github.com/fmtlib/fmt/pull/1838, - https://github.com/fmtlib/fmt/pull/1888, - https://github.com/fmtlib/fmt/pull/1918, - https://github.com/fmtlib/fmt/pull/1939). - Thanks @leolchat, @pepsiman, @Klaim, @ravijanjam, @francesco-st and @udnaan. - -- Added the `FMT_REDUCE_INT_INSTANTIATIONS` CMake option that reduces - the binary code size at the cost of some integer formatting - performance. This can be useful for extremely memory-constrained - embedded systems - (https://github.com/fmtlib/fmt/issues/1778, - https://github.com/fmtlib/fmt/pull/1781). Thanks @kammce. - -- Added the `FMT_USE_INLINE_NAMESPACES` macro to control usage of - inline namespaces - (https://github.com/fmtlib/fmt/pull/1945). Thanks @darklukee. - -- Improved build configuration - (https://github.com/fmtlib/fmt/pull/1760, - https://github.com/fmtlib/fmt/pull/1770, - https://github.com/fmtlib/fmt/issues/1779, - https://github.com/fmtlib/fmt/pull/1783, - https://github.com/fmtlib/fmt/pull/1823). - Thanks @dvetutnev, @xvitaly, @tambry, @medithe and @martinwuehrer. - -- Fixed various warnings and compilation issues - (https://github.com/fmtlib/fmt/pull/1790, - https://github.com/fmtlib/fmt/pull/1802, - https://github.com/fmtlib/fmt/pull/1808, - https://github.com/fmtlib/fmt/issues/1810, - https://github.com/fmtlib/fmt/issues/1811, - https://github.com/fmtlib/fmt/pull/1812, - https://github.com/fmtlib/fmt/pull/1814, - https://github.com/fmtlib/fmt/pull/1816, - https://github.com/fmtlib/fmt/pull/1817, - https://github.com/fmtlib/fmt/pull/1818, - https://github.com/fmtlib/fmt/issues/1825, - https://github.com/fmtlib/fmt/pull/1836, - https://github.com/fmtlib/fmt/pull/1855, - https://github.com/fmtlib/fmt/pull/1856, - https://github.com/fmtlib/fmt/pull/1860, - https://github.com/fmtlib/fmt/pull/1877, - https://github.com/fmtlib/fmt/pull/1879, - https://github.com/fmtlib/fmt/pull/1880, - https://github.com/fmtlib/fmt/issues/1896, - https://github.com/fmtlib/fmt/pull/1897, - https://github.com/fmtlib/fmt/pull/1898, - https://github.com/fmtlib/fmt/issues/1904, - https://github.com/fmtlib/fmt/pull/1908, - https://github.com/fmtlib/fmt/issues/1911, - https://github.com/fmtlib/fmt/issues/1912, - https://github.com/fmtlib/fmt/issues/1928, - https://github.com/fmtlib/fmt/pull/1929, - https://github.com/fmtlib/fmt/issues/1935, - https://github.com/fmtlib/fmt/pull/1937, - https://github.com/fmtlib/fmt/pull/1942, - https://github.com/fmtlib/fmt/issues/1949). - Thanks @TheQwertiest, @medithe, @martinwuehrer, @n16h7hunt3r, @Othereum, - @gsjaardema, @AlexanderLanin, @gcerretani, @chronoxor, @noizefloor, - @akohlmey, @jk-jeon, @rimathia, @rglarix, @moiwi, @heckad, @MarcDirven. - @BartSiwek and @darklukee. - -# 7.0.3 - 2020-08-06 - -- Worked around broken `numeric_limits` for 128-bit integers - (https://github.com/fmtlib/fmt/issues/1787). -- Added error reporting on missing named arguments - (https://github.com/fmtlib/fmt/issues/1796). -- Stopped using 128-bit integers with clang-cl - (https://github.com/fmtlib/fmt/pull/1800). Thanks @Kingcom. -- Fixed issues in locale-specific integer formatting - (https://github.com/fmtlib/fmt/issues/1782, - https://github.com/fmtlib/fmt/issues/1801). - -# 7.0.2 - 2020-07-29 - -- Worked around broken `numeric_limits` for 128-bit integers - (https://github.com/fmtlib/fmt/issues/1725). -- Fixed compatibility with CMake 3.4 - (https://github.com/fmtlib/fmt/issues/1779). -- Fixed handling of digit separators in locale-specific formatting - (https://github.com/fmtlib/fmt/issues/1782). - -# 7.0.1 - 2020-07-07 - -- Updated the inline version namespace name. -- Worked around a gcc bug in mangling of alias templates - (https://github.com/fmtlib/fmt/issues/1753). -- Fixed a linkage error on Windows - (https://github.com/fmtlib/fmt/issues/1757). Thanks @Kurkin. -- Fixed minor issues with the documentation. - -# 7.0.0 - 2020-07-05 - -- Reduced the library size. For example, on macOS a stripped test - binary statically linked with {fmt} [shrank from \~368k to less than - 100k](http://www.zverovich.net/2020/05/21/reducing-library-size.html). - -- Added a simpler and more efficient [format string compilation - API](https://fmt.dev/7.0.0/api.html#compile-api): - - ```c++ - #include - - // Converts 42 into std::string using the most efficient method and no - // runtime format string processing. - std::string s = fmt::format(FMT_COMPILE("{}"), 42); - ``` - - The old `fmt::compile` API is now deprecated. - -- Optimized integer formatting: `format_to` with format string - compilation and a stack-allocated buffer is now [faster than - to_chars on both libc++ and - libstdc++](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html). - -- Optimized handling of small format strings. For example, - - ```c++ - fmt::format("Result: {}: ({},{},{},{})", str1, str2, str3, str4, str5) - ``` - - is now \~40% faster - (https://github.com/fmtlib/fmt/issues/1685). - -- Applied extern templates to improve compile times when using the - core API and `fmt/format.h` - (https://github.com/fmtlib/fmt/issues/1452). For example, - on macOS with clang the compile time of a test translation unit - dropped from 2.3s to 0.3s with `-O2` and from 0.6s to 0.3s with the - default settings (`-O0`). - - Before (`-O2`): - - % time c++ -c test.cc -I include -std=c++17 -O2 - c++ -c test.cc -I include -std=c++17 -O2 2.22s user 0.08s system 99% cpu 2.311 total - - After (`-O2`): - - % time c++ -c test.cc -I include -std=c++17 -O2 - c++ -c test.cc -I include -std=c++17 -O2 0.26s user 0.04s system 98% cpu 0.303 total - - Before (default): - - % time c++ -c test.cc -I include -std=c++17 - c++ -c test.cc -I include -std=c++17 0.53s user 0.06s system 98% cpu 0.601 total - - After (default): - - % time c++ -c test.cc -I include -std=c++17 - c++ -c test.cc -I include -std=c++17 0.24s user 0.06s system 98% cpu 0.301 total - - It is still recommended to use `fmt/core.h` instead of - `fmt/format.h` but the compile time difference is now smaller. - Thanks @alex3d for the suggestion. - -- Named arguments are now stored on stack (no dynamic memory - allocations) and the compiled code is more compact and efficient. - For example - - ```c++ - #include - - int main() { - fmt::print("The answer is {answer}\n", fmt::arg("answer", 42)); - } - ``` - - compiles to just ([godbolt](https://godbolt.org/z/NcfEp_)) - - ```asm - .LC0: - .string "answer" - .LC1: - .string "The answer is {answer}\n" - main: - sub rsp, 56 - mov edi, OFFSET FLAT:.LC1 - mov esi, 23 - movabs rdx, 4611686018427387905 - lea rax, [rsp+32] - lea rcx, [rsp+16] - mov QWORD PTR [rsp+8], 1 - mov QWORD PTR [rsp], rax - mov DWORD PTR [rsp+16], 42 - mov QWORD PTR [rsp+32], OFFSET FLAT:.LC0 - mov DWORD PTR [rsp+40], 0 - call fmt::v6::vprint(fmt::v6::basic_string_view, - fmt::v6::format_args) - xor eax, eax - add rsp, 56 - ret - - .L.str.1: - .asciz "answer" - ``` - -- Implemented compile-time checks for dynamic width and precision - (https://github.com/fmtlib/fmt/issues/1614): - - ```c++ - #include - - int main() { - fmt::print(FMT_STRING("{0:{1}}"), 42); - } - ``` - - now gives a compilation error because argument 1 doesn\'t exist: - - In file included from test.cc:1: - include/fmt/format.h:2726:27: error: constexpr variable 'invalid_format' must be - initialized by a constant expression - FMT_CONSTEXPR_DECL bool invalid_format = - ^ - ... - include/fmt/core.h:569:26: note: in call to - '&checker(s, {}).context_->on_error(&"argument not found"[0])' - if (id >= num_args_) on_error("argument not found"); - ^ - -- Added sentinel support to `fmt::join` - (https://github.com/fmtlib/fmt/pull/1689) - - ```c++ - struct zstring_sentinel {}; - bool operator==(const char* p, zstring_sentinel) { return *p == '\0'; } - bool operator!=(const char* p, zstring_sentinel) { return *p != '\0'; } - - struct zstring { - const char* p; - const char* begin() const { return p; } - zstring_sentinel end() const { return {}; } - }; - - auto s = fmt::format("{}", fmt::join(zstring{"hello"}, "_")); - // s == "h_e_l_l_o" - ``` - - Thanks @BRevzin. - -- Added support for named arguments, `clear` and `reserve` to - `dynamic_format_arg_store` - (https://github.com/fmtlib/fmt/issues/1655, - https://github.com/fmtlib/fmt/pull/1663, - https://github.com/fmtlib/fmt/pull/1674, - https://github.com/fmtlib/fmt/pull/1677). Thanks @vsolontsov-ll. - -- Added support for the `'c'` format specifier to integral types for - compatibility with `std::format` - (https://github.com/fmtlib/fmt/issues/1652). - -- Replaced the `'n'` format specifier with `'L'` for compatibility - with `std::format` - (https://github.com/fmtlib/fmt/issues/1624). The `'n'` - specifier can be enabled via the `FMT_DEPRECATED_N_SPECIFIER` macro. - -- The `'='` format specifier is now disabled by default for - compatibility with `std::format`. It can be enabled via the - `FMT_DEPRECATED_NUMERIC_ALIGN` macro. - -- Removed the following deprecated APIs: - - - `FMT_STRING_ALIAS` and `fmt` macros - replaced by `FMT_STRING` - - `fmt::basic_string_view::char_type` - replaced by - `fmt::basic_string_view::value_type` - - `convert_to_int` - - `format_arg_store::types` - - `*parse_context` - replaced by `*format_parse_context` - - `FMT_DEPRECATED_INCLUDE_OS` - - `FMT_DEPRECATED_PERCENT` - incompatible with `std::format` - - `*writer` - replaced by compiled format API - -- Renamed the `internal` namespace to `detail` - (https://github.com/fmtlib/fmt/issues/1538). The former is - still provided as an alias if the `FMT_USE_INTERNAL` macro is - defined. - -- Improved compatibility between `fmt::printf` with the standard specs - (https://github.com/fmtlib/fmt/issues/1595, - https://github.com/fmtlib/fmt/pull/1682, - https://github.com/fmtlib/fmt/pull/1683, - https://github.com/fmtlib/fmt/pull/1687, - https://github.com/fmtlib/fmt/pull/1699). Thanks @rimathia. - -- Fixed handling of `operator<<` overloads that use `copyfmt` - (https://github.com/fmtlib/fmt/issues/1666). - -- Added the `FMT_OS` CMake option to control inclusion of OS-specific - APIs in the fmt target. This can be useful for embedded platforms - (https://github.com/fmtlib/fmt/issues/1654, - https://github.com/fmtlib/fmt/pull/1656). Thanks @kwesolowski. - -- Replaced `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` with the - `FMT_FUZZ` macro to prevent interfering with fuzzing of projects - using {fmt} (https://github.com/fmtlib/fmt/pull/1650). - Thanks @asraa. - -- Fixed compatibility with emscripten - (https://github.com/fmtlib/fmt/issues/1636, - https://github.com/fmtlib/fmt/pull/1637). Thanks @ArthurSonzogni. - -- Improved documentation - (https://github.com/fmtlib/fmt/issues/704, - https://github.com/fmtlib/fmt/pull/1643, - https://github.com/fmtlib/fmt/pull/1660, - https://github.com/fmtlib/fmt/pull/1681, - https://github.com/fmtlib/fmt/pull/1691, - https://github.com/fmtlib/fmt/pull/1706, - https://github.com/fmtlib/fmt/pull/1714, - https://github.com/fmtlib/fmt/pull/1721, - https://github.com/fmtlib/fmt/pull/1739, - https://github.com/fmtlib/fmt/pull/1740, - https://github.com/fmtlib/fmt/pull/1741, - https://github.com/fmtlib/fmt/pull/1751). - Thanks @senior7515, @lsr0, @puetzk, @fpelliccioni, Alexey Kuzmenko, @jelly, - @claremacrae, @jiapengwen, @gsjaardema and @alexey-milovidov. - -- Implemented various build configuration fixes and improvements - (https://github.com/fmtlib/fmt/pull/1603, - https://github.com/fmtlib/fmt/pull/1657, - https://github.com/fmtlib/fmt/pull/1702, - https://github.com/fmtlib/fmt/pull/1728). - Thanks @scramsby, @jtojnar, @orivej and @flagarde. - -- Fixed various warnings and compilation issues - (https://github.com/fmtlib/fmt/pull/1616, - https://github.com/fmtlib/fmt/issues/1620, - https://github.com/fmtlib/fmt/issues/1622, - https://github.com/fmtlib/fmt/issues/1625, - https://github.com/fmtlib/fmt/pull/1627, - https://github.com/fmtlib/fmt/issues/1628, - https://github.com/fmtlib/fmt/pull/1629, - https://github.com/fmtlib/fmt/issues/1631, - https://github.com/fmtlib/fmt/pull/1633, - https://github.com/fmtlib/fmt/pull/1649, - https://github.com/fmtlib/fmt/issues/1658, - https://github.com/fmtlib/fmt/pull/1661, - https://github.com/fmtlib/fmt/pull/1667, - https://github.com/fmtlib/fmt/issues/1668, - https://github.com/fmtlib/fmt/pull/1669, - https://github.com/fmtlib/fmt/issues/1692, - https://github.com/fmtlib/fmt/pull/1696, - https://github.com/fmtlib/fmt/pull/1697, - https://github.com/fmtlib/fmt/issues/1707, - https://github.com/fmtlib/fmt/pull/1712, - https://github.com/fmtlib/fmt/pull/1716, - https://github.com/fmtlib/fmt/pull/1722, - https://github.com/fmtlib/fmt/issues/1724, - https://github.com/fmtlib/fmt/pull/1729, - https://github.com/fmtlib/fmt/pull/1738, - https://github.com/fmtlib/fmt/issues/1742, - https://github.com/fmtlib/fmt/issues/1743, - https://github.com/fmtlib/fmt/pull/1744, - https://github.com/fmtlib/fmt/issues/1747, - https://github.com/fmtlib/fmt/pull/1750). - Thanks @gsjaardema, @gabime, @johnor, @Kurkin, @invexed, @peterbell10, - @daixtrose, @petrutlucian94, @Neargye, @ambitslix, @gabime, @erthink, - @tohammer and @0x8000-0000. - -# 6.2.1 - 2020-05-09 - -- Fixed ostream support in `sprintf` - (https://github.com/fmtlib/fmt/issues/1631). -- Fixed type detection when using implicit conversion to `string_view` - and ostream `operator<<` inconsistently - (https://github.com/fmtlib/fmt/issues/1662). - -# 6.2.0 - 2020-04-05 - -- Improved error reporting when trying to format an object of a - non-formattable type: - - ```c++ - fmt::format("{}", S()); - ``` - - now gives: - - include/fmt/core.h:1015:5: error: static_assert failed due to requirement - 'formattable' "Cannot format argument. To make type T formattable provide a - formatter specialization: - https://fmt.dev/latest/api.html#formatting-user-defined-types" - static_assert( - ^ - ... - note: in instantiation of function template specialization - 'fmt::v6::format' requested here - fmt::format("{}", S()); - ^ - - if `S` is not formattable. - -- Reduced the library size by \~10%. - -- Always print decimal point if `#` is specified - (https://github.com/fmtlib/fmt/issues/1476, - https://github.com/fmtlib/fmt/issues/1498): - - ```c++ - fmt::print("{:#.0f}", 42.0); - ``` - - now prints `42.` - -- Implemented the `'L'` specifier for locale-specific numeric - formatting to improve compatibility with `std::format`. The `'n'` - specifier is now deprecated and will be removed in the next major - release. - -- Moved OS-specific APIs such as `windows_error` from `fmt/format.h` - to `fmt/os.h`. You can define `FMT_DEPRECATED_INCLUDE_OS` to - automatically include `fmt/os.h` from `fmt/format.h` for - compatibility but this will be disabled in the next major release. - -- Added precision overflow detection in floating-point formatting. - -- Implemented detection of invalid use of `fmt::arg`. - -- Used `type_identity` to block unnecessary template argument - deduction. Thanks Tim Song. - -- Improved UTF-8 handling - (https://github.com/fmtlib/fmt/issues/1109): - - ```c++ - fmt::print("┌{0:─^{2}}┐\n" - "│{1: ^{2}}│\n" - "└{0:─^{2}}┘\n", "", "Прывітанне, свет!", 21); - ``` - - now prints: - - ┌─────────────────────┐ - │ Прывітанне, свет! │ - └─────────────────────┘ - - on systems that support Unicode. - -- Added experimental dynamic argument storage - (https://github.com/fmtlib/fmt/issues/1170, - https://github.com/fmtlib/fmt/pull/1584): - - ```c++ - fmt::dynamic_format_arg_store store; - store.push_back("answer"); - store.push_back(42); - fmt::vprint("The {} is {}.\n", store); - ``` - - prints: - - The answer is 42. - - Thanks @vsolontsov-ll. - -- Made `fmt::join` accept `initializer_list` - (https://github.com/fmtlib/fmt/pull/1591). Thanks @Rapotkinnik. - -- Fixed handling of empty tuples - (https://github.com/fmtlib/fmt/issues/1588). - -- Fixed handling of output iterators in `format_to_n` - (https://github.com/fmtlib/fmt/issues/1506). - -- Fixed formatting of `std::chrono::duration` types to wide output - (https://github.com/fmtlib/fmt/pull/1533). Thanks @zeffy. - -- Added const `begin` and `end` overload to buffers - (https://github.com/fmtlib/fmt/pull/1553). Thanks @dominicpoeschko. - -- Added the ability to disable floating-point formatting via - `FMT_USE_FLOAT`, `FMT_USE_DOUBLE` and `FMT_USE_LONG_DOUBLE` macros - for extremely memory-constrained embedded system - (https://github.com/fmtlib/fmt/pull/1590). Thanks @albaguirre. - -- Made `FMT_STRING` work with `constexpr` `string_view` - (https://github.com/fmtlib/fmt/pull/1589). Thanks @scramsby. - -- Implemented a minor optimization in the format string parser - (https://github.com/fmtlib/fmt/pull/1560). Thanks @IkarusDeveloper. - -- Improved attribute detection - (https://github.com/fmtlib/fmt/pull/1469, - https://github.com/fmtlib/fmt/pull/1475, - https://github.com/fmtlib/fmt/pull/1576). - Thanks @federico-busato, @chronoxor and @refnum. - -- Improved documentation - (https://github.com/fmtlib/fmt/pull/1481, - https://github.com/fmtlib/fmt/pull/1523). - Thanks @JackBoosY and @imba-tjd. - -- Fixed symbol visibility on Linux when compiling with - `-fvisibility=hidden` - (https://github.com/fmtlib/fmt/pull/1535). Thanks @milianw. - -- Implemented various build configuration fixes and improvements - (https://github.com/fmtlib/fmt/issues/1264, - https://github.com/fmtlib/fmt/issues/1460, - https://github.com/fmtlib/fmt/pull/1534, - https://github.com/fmtlib/fmt/issues/1536, - https://github.com/fmtlib/fmt/issues/1545, - https://github.com/fmtlib/fmt/pull/1546, - https://github.com/fmtlib/fmt/issues/1566, - https://github.com/fmtlib/fmt/pull/1582, - https://github.com/fmtlib/fmt/issues/1597, - https://github.com/fmtlib/fmt/pull/1598). - Thanks @ambitslix, @jwillikers and @stac47. - -- Fixed various warnings and compilation issues - (https://github.com/fmtlib/fmt/pull/1433, - https://github.com/fmtlib/fmt/issues/1461, - https://github.com/fmtlib/fmt/pull/1470, - https://github.com/fmtlib/fmt/pull/1480, - https://github.com/fmtlib/fmt/pull/1485, - https://github.com/fmtlib/fmt/pull/1492, - https://github.com/fmtlib/fmt/issues/1493, - https://github.com/fmtlib/fmt/issues/1504, - https://github.com/fmtlib/fmt/pull/1505, - https://github.com/fmtlib/fmt/pull/1512, - https://github.com/fmtlib/fmt/issues/1515, - https://github.com/fmtlib/fmt/pull/1516, - https://github.com/fmtlib/fmt/pull/1518, - https://github.com/fmtlib/fmt/pull/1519, - https://github.com/fmtlib/fmt/pull/1520, - https://github.com/fmtlib/fmt/pull/1521, - https://github.com/fmtlib/fmt/pull/1522, - https://github.com/fmtlib/fmt/issues/1524, - https://github.com/fmtlib/fmt/pull/1530, - https://github.com/fmtlib/fmt/issues/1531, - https://github.com/fmtlib/fmt/pull/1532, - https://github.com/fmtlib/fmt/issues/1539, - https://github.com/fmtlib/fmt/issues/1547, - https://github.com/fmtlib/fmt/issues/1548, - https://github.com/fmtlib/fmt/pull/1554, - https://github.com/fmtlib/fmt/issues/1567, - https://github.com/fmtlib/fmt/pull/1568, - https://github.com/fmtlib/fmt/pull/1569, - https://github.com/fmtlib/fmt/pull/1571, - https://github.com/fmtlib/fmt/pull/1573, - https://github.com/fmtlib/fmt/pull/1575, - https://github.com/fmtlib/fmt/pull/1581, - https://github.com/fmtlib/fmt/issues/1583, - https://github.com/fmtlib/fmt/issues/1586, - https://github.com/fmtlib/fmt/issues/1587, - https://github.com/fmtlib/fmt/issues/1594, - https://github.com/fmtlib/fmt/pull/1596, - https://github.com/fmtlib/fmt/issues/1604, - https://github.com/fmtlib/fmt/pull/1606, - https://github.com/fmtlib/fmt/issues/1607, - https://github.com/fmtlib/fmt/issues/1609). - Thanks @marti4d, @iPherian, @parkertomatoes, @gsjaardema, @chronoxor, - @DanielaE, @torsten48, @tohammer, @lefticus, @ryusakki, @adnsv, @fghzxm, - @refnum, @pramodk, @Spirrwell and @scramsby. - -# 6.1.2 - 2019-12-11 - -- Fixed ABI compatibility with `libfmt.so.6.0.0` - (https://github.com/fmtlib/fmt/issues/1471). -- Fixed handling types convertible to `std::string_view` - (https://github.com/fmtlib/fmt/pull/1451). Thanks @denizevrenci. -- Made CUDA test an opt-in enabled via the `FMT_CUDA_TEST` CMake - option. -- Fixed sign conversion warnings - (https://github.com/fmtlib/fmt/pull/1440). Thanks @0x8000-0000. - -# 6.1.1 - 2019-12-04 - -- Fixed shared library build on Windows - (https://github.com/fmtlib/fmt/pull/1443, - https://github.com/fmtlib/fmt/issues/1445, - https://github.com/fmtlib/fmt/pull/1446, - https://github.com/fmtlib/fmt/issues/1450). - Thanks @egorpugin and @bbolli. -- Added a missing decimal point in exponent notation with trailing - zeros. -- Removed deprecated `format_arg_store::TYPES`. - -# 6.1.0 - 2019-12-01 - -- {fmt} now formats IEEE 754 `float` and `double` using the shortest - decimal representation with correct rounding by default: - - ```c++ - #include - #include - - int main() { - fmt::print("{}", M_PI); - } - ``` - - prints `3.141592653589793`. - -- Made the fast binary to decimal floating-point formatter the - default, simplified it and improved performance. {fmt} is now 15 - times faster than libc++\'s `std::ostringstream`, 11 times faster - than `printf` and 10% faster than double-conversion on - [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark): - - | Function | Time (ns) | Speedup | - | ------------- | --------: | ------: | - | ostringstream | 1,346.30 | 1.00x | - | ostrstream | 1,195.74 | 1.13x | - | sprintf | 995.08 | 1.35x | - | doubleconv | 99.10 | 13.59x | - | fmt | 88.34 | 15.24x | - - ![](https://user-images.githubusercontent.com/576385/69767160-cdaca400-112f-11ea-9fc5-347c9f83caad.png) - -- {fmt} no longer converts `float` arguments to `double`. In - particular this improves the default (shortest) representation of - floats and makes `fmt::format` consistent with `std::format` specs - (https://github.com/fmtlib/fmt/issues/1336, - https://github.com/fmtlib/fmt/issues/1353, - https://github.com/fmtlib/fmt/pull/1360, - https://github.com/fmtlib/fmt/pull/1361): - - ```c++ - fmt::print("{}", 0.1f); - ``` - - prints `0.1` instead of `0.10000000149011612`. - - Thanks @orivej. - -- Made floating-point formatting output consistent with - `printf`/iostreams - (https://github.com/fmtlib/fmt/issues/1376, - https://github.com/fmtlib/fmt/issues/1417). - -- Added support for 128-bit integers - (https://github.com/fmtlib/fmt/pull/1287): - - ```c++ - fmt::print("{}", std::numeric_limits<__int128_t>::max()); - ``` - - prints `170141183460469231731687303715884105727`. - - Thanks @denizevrenci. - -- The overload of `print` that takes `text_style` is now atomic, i.e. - the output from different threads doesn\'t interleave - (https://github.com/fmtlib/fmt/pull/1351). Thanks @tankiJong. - -- Made compile time in the header-only mode \~20% faster by reducing - the number of template instantiations. `wchar_t` overload of - `vprint` was moved from `fmt/core.h` to `fmt/format.h`. - -- Added an overload of `fmt::join` that works with tuples - (https://github.com/fmtlib/fmt/issues/1322, - https://github.com/fmtlib/fmt/pull/1330): - - ```c++ - #include - #include - - int main() { - std::tuple t{'a', 1, 2.0f}; - fmt::print("{}", t); - } - ``` - - prints `('a', 1, 2.0)`. - - Thanks @jeremyong. - -- Changed formatting of octal zero with prefix from \"00\" to \"0\": - - ```c++ - fmt::print("{:#o}", 0); - ``` - - prints `0`. - -- The locale is now passed to ostream insertion (`<<`) operators - (https://github.com/fmtlib/fmt/pull/1406): - - ```c++ - #include - #include - - struct S { - double value; - }; - - std::ostream& operator<<(std::ostream& os, S s) { - return os << s.value; - } - - int main() { - auto s = fmt::format(std::locale("fr_FR.UTF-8"), "{}", S{0.42}); - // s == "0,42" - } - ``` - - Thanks @dlaugt. - -- Locale-specific number formatting now uses grouping - (https://github.com/fmtlib/fmt/issues/1393, - https://github.com/fmtlib/fmt/pull/1394). Thanks @skrdaniel. - -- Fixed handling of types with deleted implicit rvalue conversion to - `const char**` (https://github.com/fmtlib/fmt/issues/1421): - - ```c++ - struct mystring { - operator const char*() const&; - operator const char*() &; - operator const char*() const&& = delete; - operator const char*() && = delete; - }; - mystring str; - fmt::print("{}", str); // now compiles - ``` - -- Enums are now mapped to correct underlying types instead of `int` - (https://github.com/fmtlib/fmt/pull/1286). Thanks @agmt. - -- Enum classes are no longer implicitly converted to `int` - (https://github.com/fmtlib/fmt/issues/1424). - -- Added `basic_format_parse_context` for consistency with C++20 - `std::format` and deprecated `basic_parse_context`. - -- Fixed handling of UTF-8 in precision - (https://github.com/fmtlib/fmt/issues/1389, - https://github.com/fmtlib/fmt/pull/1390). Thanks @tajtiattila. - -- {fmt} can now be installed on Linux, macOS and Windows with - [Conda](https://docs.conda.io/en/latest/) using its - [conda-forge](https://conda-forge.org) - [package](https://github.com/conda-forge/fmt-feedstock) - (https://github.com/fmtlib/fmt/pull/1410): - - conda install -c conda-forge fmt - - Thanks @tdegeus. - -- Added a CUDA test (https://github.com/fmtlib/fmt/pull/1285, - https://github.com/fmtlib/fmt/pull/1317). - Thanks @luncliff and @risa2000. - -- Improved documentation - (https://github.com/fmtlib/fmt/pull/1276, - https://github.com/fmtlib/fmt/issues/1291, - https://github.com/fmtlib/fmt/issues/1296, - https://github.com/fmtlib/fmt/pull/1315, - https://github.com/fmtlib/fmt/pull/1332, - https://github.com/fmtlib/fmt/pull/1337, - https://github.com/fmtlib/fmt/issues/1395 - https://github.com/fmtlib/fmt/pull/1418). - Thanks @waywardmonkeys, @pauldreik and @jackoalan. - -- Various code improvements - (https://github.com/fmtlib/fmt/pull/1358, - https://github.com/fmtlib/fmt/pull/1407). - Thanks @orivej and @dpacbach. - -- Fixed compile-time format string checks for user-defined types - (https://github.com/fmtlib/fmt/issues/1292). - -- Worked around a false positive in `unsigned-integer-overflow` sanitizer - (https://github.com/fmtlib/fmt/issues/1377). - -- Fixed various warnings and compilation issues - (https://github.com/fmtlib/fmt/issues/1273, - https://github.com/fmtlib/fmt/pull/1278, - https://github.com/fmtlib/fmt/pull/1280, - https://github.com/fmtlib/fmt/issues/1281, - https://github.com/fmtlib/fmt/issues/1288, - https://github.com/fmtlib/fmt/pull/1290, - https://github.com/fmtlib/fmt/pull/1301, - https://github.com/fmtlib/fmt/issues/1305, - https://github.com/fmtlib/fmt/issues/1306, - https://github.com/fmtlib/fmt/issues/1309, - https://github.com/fmtlib/fmt/pull/1312, - https://github.com/fmtlib/fmt/issues/1313, - https://github.com/fmtlib/fmt/issues/1316, - https://github.com/fmtlib/fmt/issues/1319, - https://github.com/fmtlib/fmt/pull/1320, - https://github.com/fmtlib/fmt/pull/1326, - https://github.com/fmtlib/fmt/pull/1328, - https://github.com/fmtlib/fmt/issues/1344, - https://github.com/fmtlib/fmt/pull/1345, - https://github.com/fmtlib/fmt/pull/1347, - https://github.com/fmtlib/fmt/pull/1349, - https://github.com/fmtlib/fmt/issues/1354, - https://github.com/fmtlib/fmt/issues/1362, - https://github.com/fmtlib/fmt/issues/1366, - https://github.com/fmtlib/fmt/pull/1364, - https://github.com/fmtlib/fmt/pull/1370, - https://github.com/fmtlib/fmt/pull/1371, - https://github.com/fmtlib/fmt/issues/1385, - https://github.com/fmtlib/fmt/issues/1388, - https://github.com/fmtlib/fmt/pull/1397, - https://github.com/fmtlib/fmt/pull/1414, - https://github.com/fmtlib/fmt/pull/1416, - https://github.com/fmtlib/fmt/issues/1422 - https://github.com/fmtlib/fmt/pull/1427, - https://github.com/fmtlib/fmt/issues/1431, - https://github.com/fmtlib/fmt/pull/1433). - Thanks @hhb, @gsjaardema, @gabime, @neheb, @vedranmiletic, @dkavolis, - @mwinterb, @orivej, @denizevrenci, @leonklingele, @chronoxor, @kent-tri, - @0x8000-0000 and @marti4d. - -# 6.0.0 - 2019-08-26 - -- Switched to the [MIT license]( - https://github.com/fmtlib/fmt/blob/5a4b24613ba16cc689977c3b5bd8274a3ba1dd1f/LICENSE.rst) - with an optional exception that allows distributing binary code - without attribution. - -- Floating-point formatting is now locale-independent by default: - - ```c++ - #include - #include - - int main() { - std::locale::global(std::locale("ru_RU.UTF-8")); - fmt::print("value = {}", 4.2); - } - ``` - - prints \"value = 4.2\" regardless of the locale. - - For locale-specific formatting use the `n` specifier: - - ```c++ - std::locale::global(std::locale("ru_RU.UTF-8")); - fmt::print("value = {:n}", 4.2); - ``` - - prints \"value = 4,2\". - -- Added an experimental Grisu floating-point formatting algorithm - implementation (disabled by default). To enable it compile with the - `FMT_USE_GRISU` macro defined to 1: - - ```c++ - #define FMT_USE_GRISU 1 - #include - - auto s = fmt::format("{}", 4.2); // formats 4.2 using Grisu - ``` - - With Grisu enabled, {fmt} is 13x faster than `std::ostringstream` - (libc++) and 10x faster than `sprintf` on - [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) ([full - results](https://fmt.dev/unknown_mac64_clang10.0.html)): - - ![](https://user-images.githubusercontent.com/576385/54883977-9fe8c000-4e28-11e9-8bde-272d122e7c52.jpg) - -- Separated formatting and parsing contexts for consistency with - [C++20 std::format](http://eel.is/c++draft/format), removing the - undocumented `basic_format_context::parse_context()` function. - -- Added [oss-fuzz](https://github.com/google/oss-fuzz) support - (https://github.com/fmtlib/fmt/pull/1199). Thanks @pauldreik. - -- `formatter` specializations now always take precedence over - `operator<<` (https://github.com/fmtlib/fmt/issues/952): - - ```c++ - #include - #include - - struct S {}; - - std::ostream& operator<<(std::ostream& os, S) { - return os << 1; - } - - template <> - struct fmt::formatter : fmt::formatter { - auto format(S, format_context& ctx) { - return formatter::format(2, ctx); - } - }; - - int main() { - std::cout << S() << "\n"; // prints 1 using operator<< - fmt::print("{}\n", S()); // prints 2 using formatter - } - ``` - -- Introduced the experimental `fmt::compile` function that does format - string compilation - (https://github.com/fmtlib/fmt/issues/618, - https://github.com/fmtlib/fmt/issues/1169, - https://github.com/fmtlib/fmt/pull/1171): - - ```c++ - #include - - auto f = fmt::compile("{}"); - std::string s = fmt::format(f, 42); // can be called multiple times to - // format different values - // s == "42" - ``` - - It moves the cost of parsing a format string outside of the format - function which can be beneficial when identically formatting many - objects of the same types. Thanks @stryku. - -- Added experimental `%` format specifier that formats floating-point - values as percentages - (https://github.com/fmtlib/fmt/pull/1060, - https://github.com/fmtlib/fmt/pull/1069, - https://github.com/fmtlib/fmt/pull/1071): - - ```c++ - auto s = fmt::format("{:.1%}", 0.42); // s == "42.0%" - ``` - - Thanks @gawain-bolton. - -- Implemented precision for floating-point durations - (https://github.com/fmtlib/fmt/issues/1004, - https://github.com/fmtlib/fmt/pull/1012): - - ```c++ - auto s = fmt::format("{:.1}", std::chrono::duration(1.234)); - // s == 1.2s - ``` - - Thanks @DanielaE. - -- Implemented `chrono` format specifiers `%Q` and `%q` that give the - value and the unit respectively - (https://github.com/fmtlib/fmt/pull/1019): - - ```c++ - auto value = fmt::format("{:%Q}", 42s); // value == "42" - auto unit = fmt::format("{:%q}", 42s); // unit == "s" - ``` - - Thanks @DanielaE. - -- Fixed handling of dynamic width in chrono formatter: - - ```c++ - auto s = fmt::format("{0:{1}%H:%M:%S}", std::chrono::seconds(12345), 12); - // ^ width argument index ^ width - // s == "03:25:45 " - ``` - - Thanks Howard Hinnant. - -- Removed deprecated `fmt/time.h`. Use `fmt/chrono.h` instead. - -- Added `fmt::format` and `fmt::vformat` overloads that take - `text_style` (https://github.com/fmtlib/fmt/issues/993, - https://github.com/fmtlib/fmt/pull/994): - - ```c++ - #include - - std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red), - "The answer is {}.", 42); - ``` - - Thanks @Naios. - -- Removed the deprecated color API (`print_colored`). Use the new API, - namely `print` overloads that take `text_style` instead. - -- Made `std::unique_ptr` and `std::shared_ptr` formattable as pointers - via `fmt::ptr` (https://github.com/fmtlib/fmt/pull/1121): - - ```c++ - std::unique_ptr p = ...; - fmt::print("{}", fmt::ptr(p)); // prints p as a pointer - ``` - - Thanks @sighingnow. - -- Made `print` and `vprint` report I/O errors - (https://github.com/fmtlib/fmt/issues/1098, - https://github.com/fmtlib/fmt/pull/1099). Thanks @BillyDonahue. - -- Marked deprecated APIs with the `[[deprecated]]` attribute and - removed internal uses of deprecated APIs - (https://github.com/fmtlib/fmt/pull/1022). Thanks @eliaskosunen. - -- Modernized the codebase using more C++11 features and removing - workarounds. Most importantly, `buffer_context` is now an alias - template, so use `buffer_context` instead of - `buffer_context::type`. These features require GCC 4.8 or later. - -- `formatter` specializations now always take precedence over implicit - conversions to `int` and the undocumented `convert_to_int` trait is - now deprecated. - -- Moved the undocumented `basic_writer`, `writer`, and `wwriter` types - to the `internal` namespace. - -- Removed deprecated `basic_format_context::begin()`. Use `out()` - instead. - -- Disallowed passing the result of `join` as an lvalue to prevent - misuse. - -- Refactored the undocumented structs that represent parsed format - specifiers to simplify the API and allow multibyte fill. - -- Moved SFINAE to template parameters to reduce symbol sizes. - -- Switched to `fputws` for writing wide strings so that it\'s no - longer required to call `_setmode` on Windows - (https://github.com/fmtlib/fmt/issues/1229, - https://github.com/fmtlib/fmt/pull/1243). Thanks @jackoalan. - -- Improved literal-based API - (https://github.com/fmtlib/fmt/pull/1254). Thanks @sylveon. - -- Added support for exotic platforms without `uintptr_t` such as IBM i - (AS/400) which has 128-bit pointers and only 64-bit integers - (https://github.com/fmtlib/fmt/issues/1059). - -- Added [Sublime Text syntax highlighting config]( - https://github.com/fmtlib/fmt/blob/master/support/C%2B%2B.sublime-syntax) - (https://github.com/fmtlib/fmt/issues/1037). Thanks @Kronuz. - -- Added the `FMT_ENFORCE_COMPILE_STRING` macro to enforce the use of - compile-time format strings - (https://github.com/fmtlib/fmt/pull/1231). Thanks @jackoalan. - -- Stopped setting `CMAKE_BUILD_TYPE` if {fmt} is a subproject - (https://github.com/fmtlib/fmt/issues/1081). - -- Various build improvements - (https://github.com/fmtlib/fmt/pull/1039, - https://github.com/fmtlib/fmt/pull/1078, - https://github.com/fmtlib/fmt/pull/1091, - https://github.com/fmtlib/fmt/pull/1103, - https://github.com/fmtlib/fmt/pull/1177). - Thanks @luncliff, @jasonszang, @olafhering, @Lecetem and @pauldreik. - -- Improved documentation - (https://github.com/fmtlib/fmt/issues/1049, - https://github.com/fmtlib/fmt/pull/1051, - https://github.com/fmtlib/fmt/pull/1083, - https://github.com/fmtlib/fmt/pull/1113, - https://github.com/fmtlib/fmt/pull/1114, - https://github.com/fmtlib/fmt/issues/1146, - https://github.com/fmtlib/fmt/issues/1180, - https://github.com/fmtlib/fmt/pull/1250, - https://github.com/fmtlib/fmt/pull/1252, - https://github.com/fmtlib/fmt/pull/1265). - Thanks @mikelui, @foonathan, @BillyDonahue, @jwakely, @kaisbe and - @sdebionne. - -- Fixed ambiguous formatter specialization in `fmt/ranges.h` - (https://github.com/fmtlib/fmt/issues/1123). - -- Fixed formatting of a non-empty `std::filesystem::path` which is an - infinitely deep range of its components - (https://github.com/fmtlib/fmt/issues/1268). - -- Fixed handling of general output iterators when formatting - characters (https://github.com/fmtlib/fmt/issues/1056, - https://github.com/fmtlib/fmt/pull/1058). Thanks @abolz. - -- Fixed handling of output iterators in `formatter` specialization for - ranges (https://github.com/fmtlib/fmt/issues/1064). - -- Fixed handling of exotic character types - (https://github.com/fmtlib/fmt/issues/1188). - -- Made chrono formatting work with exceptions disabled - (https://github.com/fmtlib/fmt/issues/1062). - -- Fixed DLL visibility issues - (https://github.com/fmtlib/fmt/pull/1134, - https://github.com/fmtlib/fmt/pull/1147). Thanks @denchat. - -- Disabled the use of UDL template extension on GCC 9 - (https://github.com/fmtlib/fmt/issues/1148). - -- Removed misplaced `format` compile-time checks from `printf` - (https://github.com/fmtlib/fmt/issues/1173). - -- Fixed issues in the experimental floating-point formatter - (https://github.com/fmtlib/fmt/issues/1072, - https://github.com/fmtlib/fmt/issues/1129, - https://github.com/fmtlib/fmt/issues/1153, - https://github.com/fmtlib/fmt/pull/1155, - https://github.com/fmtlib/fmt/issues/1210, - https://github.com/fmtlib/fmt/issues/1222). Thanks @alabuzhev. - -- Fixed bugs discovered by fuzzing or during fuzzing integration - (https://github.com/fmtlib/fmt/issues/1124, - https://github.com/fmtlib/fmt/issues/1127, - https://github.com/fmtlib/fmt/issues/1132, - https://github.com/fmtlib/fmt/pull/1135, - https://github.com/fmtlib/fmt/issues/1136, - https://github.com/fmtlib/fmt/issues/1141, - https://github.com/fmtlib/fmt/issues/1142, - https://github.com/fmtlib/fmt/issues/1178, - https://github.com/fmtlib/fmt/issues/1179, - https://github.com/fmtlib/fmt/issues/1194). Thanks @pauldreik. - -- Fixed building tests on FreeBSD and Hurd - (https://github.com/fmtlib/fmt/issues/1043). Thanks @jackyf. - -- Fixed various warnings and compilation issues - (https://github.com/fmtlib/fmt/pull/998, - https://github.com/fmtlib/fmt/pull/1006, - https://github.com/fmtlib/fmt/issues/1008, - https://github.com/fmtlib/fmt/issues/1011, - https://github.com/fmtlib/fmt/issues/1025, - https://github.com/fmtlib/fmt/pull/1027, - https://github.com/fmtlib/fmt/pull/1028, - https://github.com/fmtlib/fmt/pull/1029, - https://github.com/fmtlib/fmt/pull/1030, - https://github.com/fmtlib/fmt/pull/1031, - https://github.com/fmtlib/fmt/pull/1054, - https://github.com/fmtlib/fmt/issues/1063, - https://github.com/fmtlib/fmt/pull/1068, - https://github.com/fmtlib/fmt/pull/1074, - https://github.com/fmtlib/fmt/pull/1075, - https://github.com/fmtlib/fmt/pull/1079, - https://github.com/fmtlib/fmt/pull/1086, - https://github.com/fmtlib/fmt/issues/1088, - https://github.com/fmtlib/fmt/pull/1089, - https://github.com/fmtlib/fmt/pull/1094, - https://github.com/fmtlib/fmt/issues/1101, - https://github.com/fmtlib/fmt/pull/1102, - https://github.com/fmtlib/fmt/issues/1105, - https://github.com/fmtlib/fmt/pull/1107, - https://github.com/fmtlib/fmt/issues/1115, - https://github.com/fmtlib/fmt/issues/1117, - https://github.com/fmtlib/fmt/issues/1118, - https://github.com/fmtlib/fmt/issues/1120, - https://github.com/fmtlib/fmt/issues/1123, - https://github.com/fmtlib/fmt/pull/1139, - https://github.com/fmtlib/fmt/issues/1140, - https://github.com/fmtlib/fmt/issues/1143, - https://github.com/fmtlib/fmt/pull/1144, - https://github.com/fmtlib/fmt/pull/1150, - https://github.com/fmtlib/fmt/pull/1151, - https://github.com/fmtlib/fmt/issues/1152, - https://github.com/fmtlib/fmt/issues/1154, - https://github.com/fmtlib/fmt/issues/1156, - https://github.com/fmtlib/fmt/pull/1159, - https://github.com/fmtlib/fmt/issues/1175, - https://github.com/fmtlib/fmt/issues/1181, - https://github.com/fmtlib/fmt/issues/1186, - https://github.com/fmtlib/fmt/pull/1187, - https://github.com/fmtlib/fmt/pull/1191, - https://github.com/fmtlib/fmt/issues/1197, - https://github.com/fmtlib/fmt/issues/1200, - https://github.com/fmtlib/fmt/issues/1203, - https://github.com/fmtlib/fmt/issues/1205, - https://github.com/fmtlib/fmt/pull/1206, - https://github.com/fmtlib/fmt/issues/1213, - https://github.com/fmtlib/fmt/issues/1214, - https://github.com/fmtlib/fmt/pull/1217, - https://github.com/fmtlib/fmt/issues/1228, - https://github.com/fmtlib/fmt/pull/1230, - https://github.com/fmtlib/fmt/issues/1232, - https://github.com/fmtlib/fmt/pull/1235, - https://github.com/fmtlib/fmt/pull/1236, - https://github.com/fmtlib/fmt/issues/1240). - Thanks @DanielaE, @mwinterb, @eliaskosunen, @morinmorin, @ricco19, - @waywardmonkeys, @chronoxor, @remyabel, @pauldreik, @gsjaardema, @rcane, - @mocabe, @denchat, @cjdb, @HazardyKnusperkeks, @vedranmiletic, @jackoalan, - @DaanDeMeyer and @starkmapper. - -# 5.3.0 - 2018-12-28 - -- Introduced experimental chrono formatting support: - - ```c++ - #include - - int main() { - using namespace std::literals::chrono_literals; - fmt::print("Default format: {} {}\n", 42s, 100ms); - fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s); - } - ``` - - prints: - - Default format: 42s 100ms - strftime-like format: 03:15:30 - -- Added experimental support for emphasis (bold, italic, underline, - strikethrough), colored output to a file stream, and improved - colored formatting API - (https://github.com/fmtlib/fmt/pull/961, - https://github.com/fmtlib/fmt/pull/967, - https://github.com/fmtlib/fmt/pull/973): - - ```c++ - #include - - int main() { - fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold, - "Hello, {}!\n", "world"); - fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | - fmt::emphasis::underline, "Olá, {}!\n", "Mundo"); - fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, - "你好{}!\n", "世界"); - } - ``` - - prints the following on modern terminals with RGB color support: - - ![](https://github.com/fmtlib/fmt/assets/%0A576385/2a93c904-d6fa-4aa6-b453-2618e1c327d7) - - Thanks @Rakete1111. - -- Added support for 4-bit terminal colors - (https://github.com/fmtlib/fmt/issues/968, - https://github.com/fmtlib/fmt/pull/974) - - ```c++ - #include - - int main() { - print(fg(fmt::terminal_color::red), "stop\n"); - } - ``` - - Note that these colors vary by terminal: - - ![](https://user-images.githubusercontent.com/576385/50405925-dbfc7e00-0770-11e9-9b85-333fab0af9ac.png) - - Thanks @Rakete1111. - -- Parameterized formatting functions on the type of the format string - (https://github.com/fmtlib/fmt/issues/880, - https://github.com/fmtlib/fmt/pull/881, - https://github.com/fmtlib/fmt/pull/883, - https://github.com/fmtlib/fmt/pull/885, - https://github.com/fmtlib/fmt/pull/897, - https://github.com/fmtlib/fmt/issues/920). Any object of - type `S` that has an overloaded `to_string_view(const S&)` returning - `fmt::string_view` can be used as a format string: - - ```c++ - namespace my_ns { - inline string_view to_string_view(const my_string& s) { - return {s.data(), s.length()}; - } - } - - std::string message = fmt::format(my_string("The answer is {}."), 42); - ``` - - Thanks @DanielaE. - -- Made `std::string_view` work as a format string - (https://github.com/fmtlib/fmt/pull/898): - - ```c++ - auto message = fmt::format(std::string_view("The answer is {}."), 42); - ``` - - Thanks @DanielaE. - -- Added wide string support to compile-time format string checks - (https://github.com/fmtlib/fmt/pull/924): - - ```c++ - print(fmt(L"{:f}"), 42); // compile-time error: invalid type specifier - ``` - - Thanks @XZiar. - -- Made colored print functions work with wide strings - (https://github.com/fmtlib/fmt/pull/867): - - ```c++ - #include - - int main() { - print(fg(fmt::color::red), L"{}\n", 42); - } - ``` - - Thanks @DanielaE. - -- Introduced experimental Unicode support - (https://github.com/fmtlib/fmt/issues/628, - https://github.com/fmtlib/fmt/pull/891): - - ```c++ - using namespace fmt::literals; - auto s = fmt::format("{:*^5}"_u, "🤡"_u); // s == "**🤡**"_u - ``` - -- Improved locale support: - - ```c++ - #include - - struct numpunct : std::numpunct { - protected: - char do_thousands_sep() const override { return '~'; } - }; - - std::locale loc; - auto s = fmt::format(std::locale(loc, new numpunct()), "{:n}", 1234567); - // s == "1~234~567" - ``` - -- Constrained formatting functions on proper iterator types - (https://github.com/fmtlib/fmt/pull/921). Thanks @DanielaE. - -- Added `make_printf_args` and `make_wprintf_args` functions - (https://github.com/fmtlib/fmt/pull/934). Thanks @tnovotny. - -- Deprecated `fmt::visit`, `parse_context`, and `wparse_context`. Use - `fmt::visit_format_arg`, `format_parse_context`, and - `wformat_parse_context` instead. - -- Removed undocumented `basic_fixed_buffer` which has been superseded - by the iterator-based API - (https://github.com/fmtlib/fmt/issues/873, - https://github.com/fmtlib/fmt/pull/902). Thanks @superfunc. - -- Disallowed repeated leading zeros in an argument ID: - - ```c++ - fmt::print("{000}", 42); // error - ``` - -- Reintroduced support for gcc 4.4. - -- Fixed compilation on platforms with exotic `double` - (https://github.com/fmtlib/fmt/issues/878). - -- Improved documentation - (https://github.com/fmtlib/fmt/issues/164, - https://github.com/fmtlib/fmt/issues/877, - https://github.com/fmtlib/fmt/pull/901, - https://github.com/fmtlib/fmt/pull/906, - https://github.com/fmtlib/fmt/pull/979). - Thanks @kookjr, @DarkDimius and @HecticSerenity. - -- Added pkgconfig support which makes it easier to consume the library - from meson and other build systems - (https://github.com/fmtlib/fmt/pull/916). Thanks @colemickens. - -- Various build improvements - (https://github.com/fmtlib/fmt/pull/909, - https://github.com/fmtlib/fmt/pull/926, - https://github.com/fmtlib/fmt/pull/937, - https://github.com/fmtlib/fmt/pull/953, - https://github.com/fmtlib/fmt/pull/959). - Thanks @tchaikov, @luncliff, @AndreasSchoenle, @hotwatermorning and @Zefz. - -- Improved `string_view` construction performance - (https://github.com/fmtlib/fmt/pull/914). Thanks @gabime. - -- Fixed non-matching char types - (https://github.com/fmtlib/fmt/pull/895). Thanks @DanielaE. - -- Fixed `format_to_n` with `std::back_insert_iterator` - (https://github.com/fmtlib/fmt/pull/913). Thanks @DanielaE. - -- Fixed locale-dependent formatting - (https://github.com/fmtlib/fmt/issues/905). - -- Fixed various compiler warnings and errors - (https://github.com/fmtlib/fmt/pull/882, - https://github.com/fmtlib/fmt/pull/886, - https://github.com/fmtlib/fmt/pull/933, - https://github.com/fmtlib/fmt/pull/941, - https://github.com/fmtlib/fmt/issues/931, - https://github.com/fmtlib/fmt/pull/943, - https://github.com/fmtlib/fmt/pull/954, - https://github.com/fmtlib/fmt/pull/956, - https://github.com/fmtlib/fmt/pull/962, - https://github.com/fmtlib/fmt/issues/965, - https://github.com/fmtlib/fmt/issues/977, - https://github.com/fmtlib/fmt/pull/983, - https://github.com/fmtlib/fmt/pull/989). - Thanks @Luthaf, @stevenhoving, @christinaa, @lgritz, @DanielaE, - @0x8000-0000 and @liuping1997. - -# 5.2.1 - 2018-09-21 - -- Fixed `visit` lookup issues on gcc 7 & 8 - (https://github.com/fmtlib/fmt/pull/870). Thanks @medithe. -- Fixed linkage errors on older gcc. -- Prevented `fmt/range.h` from specializing `fmt::basic_string_view` - (https://github.com/fmtlib/fmt/issues/865, - https://github.com/fmtlib/fmt/pull/868). Thanks @hhggit. -- Improved error message when formatting unknown types - (https://github.com/fmtlib/fmt/pull/872). Thanks @foonathan. -- Disabled templated user-defined literals when compiled under nvcc - (https://github.com/fmtlib/fmt/pull/875). Thanks @CandyGumdrop. -- Fixed `format_to` formatting to `wmemory_buffer` - (https://github.com/fmtlib/fmt/issues/874). - -# 5.2.0 - 2018-09-13 - -- Optimized format string parsing and argument processing which - resulted in up to 5x speed up on long format strings and significant - performance boost on various benchmarks. For example, version 5.2 is - 2.22x faster than 5.1 on decimal integer formatting with `format_to` - (macOS, clang-902.0.39.2): - - | Method | Time, s | Speedup | - | -------------------------- | --------------: | ------: | - | fmt::format 5.1 | 0.58 | | - | fmt::format 5.2 | 0.35 | 1.66x | - | fmt::format_to 5.1 | 0.51 | | - | fmt::format_to 5.2 | 0.23 | 2.22x | - | sprintf | 0.71 | | - | std::to_string | 1.01 | | - | std::stringstream | 1.73 | | - -- Changed the `fmt` macro from opt-out to opt-in to prevent name - collisions. To enable it define the `FMT_STRING_ALIAS` macro to 1 - before including `fmt/format.h`: - - ```c++ - #define FMT_STRING_ALIAS 1 - #include - std::string answer = format(fmt("{}"), 42); - ``` - -- Added compile-time format string checks to `format_to` overload that - takes `fmt::memory_buffer` - (https://github.com/fmtlib/fmt/issues/783): - - ```c++ - fmt::memory_buffer buf; - // Compile-time error: invalid type specifier. - fmt::format_to(buf, fmt("{:d}"), "foo"); - ``` - -- Moved experimental color support to `fmt/color.h` and enabled the - new API by default. The old API can be enabled by defining the - `FMT_DEPRECATED_COLORS` macro. - -- Added formatting support for types explicitly convertible to - `fmt::string_view`: - - ```c++ - struct foo { - explicit operator fmt::string_view() const { return "foo"; } - }; - auto s = format("{}", foo()); - ``` - - In particular, this makes formatting function work with - `folly::StringPiece`. - -- Implemented preliminary support for `char*_t` by replacing the - `format` function overloads with a single function template - parameterized on the string type. - -- Added support for dynamic argument lists - (https://github.com/fmtlib/fmt/issues/814, - https://github.com/fmtlib/fmt/pull/819). Thanks @MikePopoloski. - -- Reduced executable size overhead for embedded targets using newlib - nano by making locale dependency optional - (https://github.com/fmtlib/fmt/pull/839). Thanks @teajay-fr. - -- Keep `noexcept` specifier when exceptions are disabled - (https://github.com/fmtlib/fmt/issues/801, - https://github.com/fmtlib/fmt/pull/810). Thanks @qis. - -- Fixed formatting of user-defined types providing `operator<<` with - `format_to_n` (https://github.com/fmtlib/fmt/pull/806). - Thanks @mkurdej. - -- Fixed dynamic linkage of new symbols - (https://github.com/fmtlib/fmt/issues/808). - -- Fixed global initialization issue - (https://github.com/fmtlib/fmt/issues/807): - - ```c++ - // This works on compilers with constexpr support. - static const std::string answer = fmt::format("{}", 42); - ``` - -- Fixed various compiler warnings and errors - (https://github.com/fmtlib/fmt/pull/804, - https://github.com/fmtlib/fmt/issues/809, - https://github.com/fmtlib/fmt/pull/811, - https://github.com/fmtlib/fmt/issues/822, - https://github.com/fmtlib/fmt/pull/827, - https://github.com/fmtlib/fmt/issues/830, - https://github.com/fmtlib/fmt/pull/838, - https://github.com/fmtlib/fmt/issues/843, - https://github.com/fmtlib/fmt/pull/844, - https://github.com/fmtlib/fmt/issues/851, - https://github.com/fmtlib/fmt/pull/852, - https://github.com/fmtlib/fmt/pull/854). - Thanks @henryiii, @medithe, and @eliasdaler. - -# 5.1.0 - 2018-07-05 - -- Added experimental support for RGB color output enabled with the - `FMT_EXTENDED_COLORS` macro: - - ```c++ - #define FMT_EXTENDED_COLORS - #define FMT_HEADER_ONLY // or compile fmt with FMT_EXTENDED_COLORS defined - #include - - fmt::print(fmt::color::steel_blue, "Some beautiful text"); - ``` - - The old API (the `print_colored` and `vprint_colored` functions and - the `color` enum) is now deprecated. - (https://github.com/fmtlib/fmt/issues/762 - https://github.com/fmtlib/fmt/pull/767). thanks @Remotion. - -- Added quotes to strings in ranges and tuples - (https://github.com/fmtlib/fmt/pull/766). Thanks @Remotion. - -- Made `format_to` work with `basic_memory_buffer` - (https://github.com/fmtlib/fmt/issues/776). - -- Added `vformat_to_n` and `wchar_t` overload of `format_to_n` - (https://github.com/fmtlib/fmt/issues/764, - https://github.com/fmtlib/fmt/issues/769). - -- Made `is_range` and `is_tuple_like` part of public (experimental) - API to allow specialization for user-defined types - (https://github.com/fmtlib/fmt/issues/751, - https://github.com/fmtlib/fmt/pull/759). Thanks @drrlvn. - -- Added more compilers to continuous integration and increased - `FMT_PEDANTIC` warning levels - (https://github.com/fmtlib/fmt/pull/736). Thanks @eliaskosunen. - -- Fixed compilation with MSVC 2013. - -- Fixed handling of user-defined types in `format_to` - (https://github.com/fmtlib/fmt/issues/793). - -- Forced linking of inline `vformat` functions into the library - (https://github.com/fmtlib/fmt/issues/795). - -- Fixed incorrect call to on_align in `'{:}='` - (https://github.com/fmtlib/fmt/issues/750). - -- Fixed floating-point formatting to a non-back_insert_iterator with - sign & numeric alignment specified - (https://github.com/fmtlib/fmt/issues/756). - -- Fixed formatting to an array with `format_to_n` - (https://github.com/fmtlib/fmt/issues/778). - -- Fixed formatting of more than 15 named arguments - (https://github.com/fmtlib/fmt/issues/754). - -- Fixed handling of compile-time strings when including - `fmt/ostream.h`. (https://github.com/fmtlib/fmt/issues/768). - -- Fixed various compiler warnings and errors - (https://github.com/fmtlib/fmt/issues/742, - https://github.com/fmtlib/fmt/issues/748, - https://github.com/fmtlib/fmt/issues/752, - https://github.com/fmtlib/fmt/issues/770, - https://github.com/fmtlib/fmt/pull/775, - https://github.com/fmtlib/fmt/issues/779, - https://github.com/fmtlib/fmt/pull/780, - https://github.com/fmtlib/fmt/pull/790, - https://github.com/fmtlib/fmt/pull/792, - https://github.com/fmtlib/fmt/pull/800). - Thanks @Remotion, @gabime, @foonathan, @Dark-Passenger and @0x8000-0000. - -# 5.0.0 - 2018-05-21 - -- Added a requirement for partial C++11 support, most importantly - variadic templates and type traits, and dropped `FMT_VARIADIC_*` - emulation macros. Variadic templates are available since GCC 4.4, - Clang 2.9 and MSVC 18.0 (2013). For older compilers use {fmt} - [version 4.x](https://github.com/fmtlib/fmt/releases/tag/4.1.0) - which continues to be maintained and works with C++98 compilers. - -- Renamed symbols to follow standard C++ naming conventions and - proposed a subset of the library for standardization in [P0645R2 - Text Formatting](https://wg21.link/P0645). - -- Implemented `constexpr` parsing of format strings and [compile-time - format string - checks](https://fmt.dev/latest/api.html#compile-time-format-string-checks). - For example - - ```c++ - #include - - std::string s = format(fmt("{:d}"), "foo"); - ``` - - gives a compile-time error because `d` is an invalid specifier for - strings ([godbolt](https://godbolt.org/g/rnCy9Q)): - - ... - :4:19: note: in instantiation of function template specialization 'fmt::v5::format' requested here - std::string s = format(fmt("{:d}"), "foo"); - ^ - format.h:1337:13: note: non-constexpr function 'on_error' cannot be used in a constant expression - handler.on_error("invalid type specifier"); - - Compile-time checks require relaxed `constexpr` (C++14 feature) - support. If the latter is not available, checks will be performed at - runtime. - -- Separated format string parsing and formatting in the extension API - to enable compile-time format string processing. For example - - ```c++ - struct Answer {}; - - namespace fmt { - template <> - struct formatter { - constexpr auto parse(parse_context& ctx) { - auto it = ctx.begin(); - spec = *it; - if (spec != 'd' && spec != 's') - throw format_error("invalid specifier"); - return ++it; - } - - template - auto format(Answer, FormatContext& ctx) { - return spec == 's' ? - format_to(ctx.begin(), "{}", "fourty-two") : - format_to(ctx.begin(), "{}", 42); - } - - char spec = 0; - }; - } - - std::string s = format(fmt("{:x}"), Answer()); - ``` - - gives a compile-time error due to invalid format specifier - ([godbolt](https://godbolt.org/g/2jQ1Dv)): - - ... - :12:45: error: expression '' is not a constant expression - throw format_error("invalid specifier"); - -- Added [iterator - support](https://fmt.dev/latest/api.html#output-iterator-support): - - ```c++ - #include - #include - - std::vector out; - fmt::format_to(std::back_inserter(out), "{}", 42); - ``` - -- Added the - [format_to_n](https://fmt.dev/latest/api.html#_CPPv2N3fmt11format_to_nE8OutputItNSt6size_tE11string_viewDpRK4Args) - function that restricts the output to the specified number of - characters (https://github.com/fmtlib/fmt/issues/298): - - ```c++ - char out[4]; - fmt::format_to_n(out, sizeof(out), "{}", 12345); - // out == "1234" (without terminating '\0') - ``` - -- Added the [formatted_size]( - https://fmt.dev/latest/api.html#_CPPv2N3fmt14formatted_sizeE11string_viewDpRK4Args) - function for computing the output size: - - ```c++ - #include - - auto size = fmt::formatted_size("{}", 12345); // size == 5 - ``` - -- Improved compile times by reducing dependencies on standard headers - and providing a lightweight [core - API](https://fmt.dev/latest/api.html#core-api): - - ```c++ - #include - - fmt::print("The answer is {}.", 42); - ``` - - See [Compile time and code - bloat](https://github.com/fmtlib/fmt#compile-time-and-code-bloat). - -- Added the [make_format_args]( - https://fmt.dev/latest/api.html#_CPPv2N3fmt16make_format_argsEDpRK4Args) - function for capturing formatting arguments: - - ```c++ - // Prints formatted error message. - void vreport_error(const char *format, fmt::format_args args) { - fmt::print("Error: "); - fmt::vprint(format, args); - } - template - void report_error(const char *format, const Args & ... args) { - vreport_error(format, fmt::make_format_args(args...)); - } - ``` - -- Added the `make_printf_args` function for capturing `printf` - arguments (https://github.com/fmtlib/fmt/issues/687, - https://github.com/fmtlib/fmt/pull/694). Thanks @Kronuz. - -- Added prefix `v` to non-variadic functions taking `format_args` to - distinguish them from variadic ones: - - ```c++ - std::string vformat(string_view format_str, format_args args); - - template - std::string format(string_view format_str, const Args & ... args); - ``` - -- Added experimental support for formatting ranges, containers and - tuple-like types in `fmt/ranges.h` - (https://github.com/fmtlib/fmt/pull/735): - - ```c++ - #include - - std::vector v = {1, 2, 3}; - fmt::print("{}", v); // prints {1, 2, 3} - ``` - - Thanks @Remotion. - -- Implemented `wchar_t` date and time formatting - (https://github.com/fmtlib/fmt/pull/712): - - ```c++ - #include - - std::time_t t = std::time(nullptr); - auto s = fmt::format(L"The date is {:%Y-%m-%d}.", *std::localtime(&t)); - ``` - - Thanks @DanielaE. - -- Provided more wide string overloads - (https://github.com/fmtlib/fmt/pull/724). Thanks @DanielaE. - -- Switched from a custom null-terminated string view class to - `string_view` in the format API and provided `fmt::string_view` - which implements a subset of `std::string_view` API for pre-C++17 - systems. - -- Added support for `std::experimental::string_view` - (https://github.com/fmtlib/fmt/pull/607): - - ```c++ - #include - #include - - fmt::print("{}", std::experimental::string_view("foo")); - ``` - - Thanks @virgiliofornazin. - -- Allowed mixing named and automatic arguments: - - ```c++ - fmt::format("{} {two}", 1, fmt::arg("two", 2)); - ``` - -- Removed the write API in favor of the [format - API](https://fmt.dev/latest/api.html#format-api) with compile-time - handling of format strings. - -- Disallowed formatting of multibyte strings into a wide character - target (https://github.com/fmtlib/fmt/pull/606). - -- Improved documentation - (https://github.com/fmtlib/fmt/pull/515, - https://github.com/fmtlib/fmt/issues/614, - https://github.com/fmtlib/fmt/pull/617, - https://github.com/fmtlib/fmt/pull/661, - https://github.com/fmtlib/fmt/pull/680). - Thanks @ibell, @mihaitodor and @johnthagen. - -- Implemented more efficient handling of large number of format - arguments. - -- Introduced an inline namespace for symbol versioning. - -- Added debug postfix `d` to the `fmt` library name - (https://github.com/fmtlib/fmt/issues/636). - -- Removed unnecessary `fmt/` prefix in includes - (https://github.com/fmtlib/fmt/pull/397). Thanks @chronoxor. - -- Moved `fmt/*.h` to `include/fmt/*.h` to prevent irrelevant files and - directories appearing on the include search paths when fmt is used - as a subproject and moved source files to the `src` directory. - -- Added qmake project file `support/fmt.pro` - (https://github.com/fmtlib/fmt/pull/641). Thanks @cowo78. - -- Added Gradle build file `support/build.gradle` - (https://github.com/fmtlib/fmt/pull/649). Thanks @luncliff. - -- Removed `FMT_CPPFORMAT` CMake option. - -- Fixed a name conflict with the macro `CHAR_WIDTH` in glibc - (https://github.com/fmtlib/fmt/pull/616). Thanks @aroig. - -- Fixed handling of nested braces in `fmt::join` - (https://github.com/fmtlib/fmt/issues/638). - -- Added `SOURCELINK_SUFFIX` for compatibility with Sphinx 1.5 - (https://github.com/fmtlib/fmt/pull/497). Thanks @ginggs. - -- Added a missing `inline` in the header-only mode - (https://github.com/fmtlib/fmt/pull/626). Thanks @aroig. - -- Fixed various compiler warnings - (https://github.com/fmtlib/fmt/pull/640, - https://github.com/fmtlib/fmt/pull/656, - https://github.com/fmtlib/fmt/pull/679, - https://github.com/fmtlib/fmt/pull/681, - https://github.com/fmtlib/fmt/pull/705, - https://github.com/fmtlib/fmt/issues/715, - https://github.com/fmtlib/fmt/pull/717, - https://github.com/fmtlib/fmt/pull/720, - https://github.com/fmtlib/fmt/pull/723, - https://github.com/fmtlib/fmt/pull/726, - https://github.com/fmtlib/fmt/pull/730, - https://github.com/fmtlib/fmt/pull/739). - Thanks @peterbell10, @LarsGullik, @foonathan, @eliaskosunen, - @christianparpart, @DanielaE and @mwinterb. - -- Worked around an MSVC bug and fixed several warnings - (https://github.com/fmtlib/fmt/pull/653). Thanks @alabuzhev. - -- Worked around GCC bug 67371 - (https://github.com/fmtlib/fmt/issues/682). - -- Fixed compilation with `-fno-exceptions` - (https://github.com/fmtlib/fmt/pull/655). Thanks @chenxiaolong. - -- Made `constexpr remove_prefix` gcc version check tighter - (https://github.com/fmtlib/fmt/issues/648). - -- Renamed internal type enum constants to prevent collision with - poorly written C libraries - (https://github.com/fmtlib/fmt/issues/644). - -- Added detection of `wostream operator<<` - (https://github.com/fmtlib/fmt/issues/650). - -- Fixed compilation on OpenBSD - (https://github.com/fmtlib/fmt/pull/660). Thanks @hubslave. - -- Fixed compilation on FreeBSD 12 - (https://github.com/fmtlib/fmt/pull/732). Thanks @dankm. - -- Fixed compilation when there is a mismatch between `-std` options - between the library and user code - (https://github.com/fmtlib/fmt/issues/664). - -- Fixed compilation with GCC 7 and `-std=c++11` - (https://github.com/fmtlib/fmt/issues/734). - -- Improved generated binary code on GCC 7 and older - (https://github.com/fmtlib/fmt/issues/668). - -- Fixed handling of numeric alignment with no width - (https://github.com/fmtlib/fmt/issues/675). - -- Fixed handling of empty strings in UTF8/16 converters - (https://github.com/fmtlib/fmt/pull/676). Thanks @vgalka-sl. - -- Fixed formatting of an empty `string_view` - (https://github.com/fmtlib/fmt/issues/689). - -- Fixed detection of `string_view` on libc++ - (https://github.com/fmtlib/fmt/issues/686). - -- Fixed DLL issues (https://github.com/fmtlib/fmt/pull/696). - Thanks @sebkoenig. - -- Fixed compile checks for mixing narrow and wide strings - (https://github.com/fmtlib/fmt/issues/690). - -- Disabled unsafe implicit conversion to `std::string` - (https://github.com/fmtlib/fmt/issues/729). - -- Fixed handling of reused format specs (as in `fmt::join`) for - pointers (https://github.com/fmtlib/fmt/pull/725). Thanks @mwinterb. - -- Fixed installation of `fmt/ranges.h` - (https://github.com/fmtlib/fmt/pull/738). Thanks @sv1990. - -# 4.1.0 - 2017-12-20 - -- Added `fmt::to_wstring()` in addition to `fmt::to_string()` - (https://github.com/fmtlib/fmt/pull/559). Thanks @alabuzhev. -- Added support for C++17 `std::string_view` - (https://github.com/fmtlib/fmt/pull/571 and - https://github.com/fmtlib/fmt/pull/578). - Thanks @thelostt and @mwinterb. -- Enabled stream exceptions to catch errors - (https://github.com/fmtlib/fmt/issues/581). Thanks @crusader-mike. -- Allowed formatting of class hierarchies with `fmt::format_arg()` - (https://github.com/fmtlib/fmt/pull/547). Thanks @rollbear. -- Removed limitations on character types - (https://github.com/fmtlib/fmt/pull/563). Thanks @Yelnats321. -- Conditionally enabled use of `std::allocator_traits` - (https://github.com/fmtlib/fmt/pull/583). Thanks @mwinterb. -- Added support for `const` variadic member function emulation with - `FMT_VARIADIC_CONST` - (https://github.com/fmtlib/fmt/pull/591). Thanks @ludekvodicka. -- Various bugfixes: bad overflow check, unsupported implicit type - conversion when determining formatting function, test segfaults - (https://github.com/fmtlib/fmt/issues/551), ill-formed - macros (https://github.com/fmtlib/fmt/pull/542) and - ambiguous overloads - (https://github.com/fmtlib/fmt/issues/580). Thanks @xylosper. -- Prevented warnings on MSVC - (https://github.com/fmtlib/fmt/pull/605, - https://github.com/fmtlib/fmt/pull/602, and - https://github.com/fmtlib/fmt/pull/545), clang - (https://github.com/fmtlib/fmt/pull/582), GCC - (https://github.com/fmtlib/fmt/issues/573), various - conversion warnings (https://github.com/fmtlib/fmt/pull/609, - https://github.com/fmtlib/fmt/pull/567, - https://github.com/fmtlib/fmt/pull/553 and - https://github.com/fmtlib/fmt/pull/553), and added - `override` and `[[noreturn]]` - (https://github.com/fmtlib/fmt/pull/549 and - https://github.com/fmtlib/fmt/issues/555). - Thanks @alabuzhev, @virgiliofornazin, @alexanderbock, @yumetodo, @VaderY, - @jpcima, @thelostt and @Manu343726. -- Improved CMake: Used `GNUInstallDirs` to set installation location - (https://github.com/fmtlib/fmt/pull/610) and fixed warnings - (https://github.com/fmtlib/fmt/pull/536 and - https://github.com/fmtlib/fmt/pull/556). - Thanks @mikecrowe, @evgen231 and @henryiii. - -# 4.0.0 - 2017-06-27 - -- Removed old compatibility headers `cppformat/*.h` and CMake options - (https://github.com/fmtlib/fmt/pull/527). Thanks @maddinat0r. - -- Added `string.h` containing `fmt::to_string()` as alternative to - `std::to_string()` as well as other string writer functionality - (https://github.com/fmtlib/fmt/issues/326 and - https://github.com/fmtlib/fmt/pull/441): - - ```c++ - #include "fmt/string.h" - - std::string answer = fmt::to_string(42); - ``` - - Thanks @glebov-andrey. - -- Moved `fmt::printf()` to new `printf.h` header and allowed `%s` as - generic specifier (https://github.com/fmtlib/fmt/pull/453), - made `%.f` more conformant to regular `printf()` - (https://github.com/fmtlib/fmt/pull/490), added custom - writer support (https://github.com/fmtlib/fmt/issues/476) - and implemented missing custom argument formatting - (https://github.com/fmtlib/fmt/pull/339 and - https://github.com/fmtlib/fmt/pull/340): - - ```c++ - #include "fmt/printf.h" - - // %s format specifier can be used with any argument type. - fmt::printf("%s", 42); - ``` - - Thanks @mojoBrendan, @manylegged and @spacemoose. - See also https://github.com/fmtlib/fmt/issues/360, - https://github.com/fmtlib/fmt/issues/335 and - https://github.com/fmtlib/fmt/issues/331. - -- Added `container.h` containing a `BasicContainerWriter` to write to - containers like `std::vector` - (https://github.com/fmtlib/fmt/pull/450). Thanks @polyvertex. - -- Added `fmt::join()` function that takes a range and formats its - elements separated by a given string - (https://github.com/fmtlib/fmt/pull/466): - - ```c++ - #include "fmt/format.h" - - std::vector v = {1.2, 3.4, 5.6}; - // Prints "(+01.20, +03.40, +05.60)". - fmt::print("({:+06.2f})", fmt::join(v.begin(), v.end(), ", ")); - ``` - - Thanks @olivier80. - -- Added support for custom formatting specifications to simplify - customization of built-in formatting - (https://github.com/fmtlib/fmt/pull/444). Thanks @polyvertex. - See also https://github.com/fmtlib/fmt/issues/439. - -- Added `fmt::format_system_error()` for error code formatting - (https://github.com/fmtlib/fmt/issues/323 and - https://github.com/fmtlib/fmt/pull/526). Thanks @maddinat0r. - -- Added thread-safe `fmt::localtime()` and `fmt::gmtime()` as - replacement for the standard version to `time.h` - (https://github.com/fmtlib/fmt/pull/396). Thanks @codicodi. - -- Internal improvements to `NamedArg` and `ArgLists` - (https://github.com/fmtlib/fmt/pull/389 and - https://github.com/fmtlib/fmt/pull/390). Thanks @chronoxor. - -- Fixed crash due to bug in `FormatBuf` - (https://github.com/fmtlib/fmt/pull/493). Thanks @effzeh. See also - https://github.com/fmtlib/fmt/issues/480 and - https://github.com/fmtlib/fmt/issues/491. - -- Fixed handling of wide strings in `fmt::StringWriter`. - -- Improved compiler error messages - (https://github.com/fmtlib/fmt/issues/357). - -- Fixed various warnings and issues with various compilers - (https://github.com/fmtlib/fmt/pull/494, - https://github.com/fmtlib/fmt/pull/499, - https://github.com/fmtlib/fmt/pull/483, - https://github.com/fmtlib/fmt/pull/485, - https://github.com/fmtlib/fmt/pull/482, - https://github.com/fmtlib/fmt/pull/475, - https://github.com/fmtlib/fmt/pull/473 and - https://github.com/fmtlib/fmt/pull/414). - Thanks @chronoxor, @zhaohuaxishi, @pkestene, @dschmidt and @0x414c. - -- Improved CMake: targets are now namespaced - (https://github.com/fmtlib/fmt/pull/511 and - https://github.com/fmtlib/fmt/pull/513), supported - header-only `printf.h` - (https://github.com/fmtlib/fmt/pull/354), fixed issue with - minimal supported library subset - (https://github.com/fmtlib/fmt/issues/418, - https://github.com/fmtlib/fmt/pull/419 and - https://github.com/fmtlib/fmt/pull/420). - Thanks @bjoernthiel, @niosHD, @LogicalKnight and @alabuzhev. - -- Improved documentation (https://github.com/fmtlib/fmt/pull/393). - Thanks @pwm1234. - -# 3.0.2 - 2017-06-14 - -- Added `FMT_VERSION` macro - (https://github.com/fmtlib/fmt/issues/411). -- Used `FMT_NULL` instead of literal `0` - (https://github.com/fmtlib/fmt/pull/409). Thanks @alabuzhev. -- Added extern templates for `format_float` - (https://github.com/fmtlib/fmt/issues/413). -- Fixed implicit conversion issue - (https://github.com/fmtlib/fmt/issues/507). -- Fixed signbit detection - (https://github.com/fmtlib/fmt/issues/423). -- Fixed naming collision - (https://github.com/fmtlib/fmt/issues/425). -- Fixed missing intrinsic for C++/CLI - (https://github.com/fmtlib/fmt/pull/457). Thanks @calumr. -- Fixed Android detection - (https://github.com/fmtlib/fmt/pull/458). Thanks @Gachapen. -- Use lean `windows.h` if not in header-only mode - (https://github.com/fmtlib/fmt/pull/503). Thanks @Quentin01. -- Fixed issue with CMake exporting C++11 flag - (https://github.com/fmtlib/fmt/pull/455). Thanks @EricWF. -- Fixed issue with nvcc and MSVC compiler bug and MinGW - (https://github.com/fmtlib/fmt/issues/505). -- Fixed DLL issues (https://github.com/fmtlib/fmt/pull/469 and - https://github.com/fmtlib/fmt/pull/502). - Thanks @richardeakin and @AndreasSchoenle. -- Fixed test compilation under FreeBSD - (https://github.com/fmtlib/fmt/issues/433). -- Fixed various warnings - (https://github.com/fmtlib/fmt/pull/403, - https://github.com/fmtlib/fmt/pull/410 and - https://github.com/fmtlib/fmt/pull/510). - Thanks @Lecetem, @chenhayat and @trozen. -- Worked around a broken `__builtin_clz` in clang with MS codegen - (https://github.com/fmtlib/fmt/issues/519). -- Removed redundant include - (https://github.com/fmtlib/fmt/issues/479). -- Fixed documentation issues. - -# 3.0.1 - 2016-11-01 - -- Fixed handling of thousands separator - (https://github.com/fmtlib/fmt/issues/353). -- Fixed handling of `unsigned char` strings - (https://github.com/fmtlib/fmt/issues/373). -- Corrected buffer growth when formatting time - (https://github.com/fmtlib/fmt/issues/367). -- Removed warnings under MSVC and clang - (https://github.com/fmtlib/fmt/issues/318, - https://github.com/fmtlib/fmt/issues/250, also merged - https://github.com/fmtlib/fmt/pull/385 and - https://github.com/fmtlib/fmt/pull/361). - Thanks @jcelerier and @nmoehrle. -- Fixed compilation issues under Android - (https://github.com/fmtlib/fmt/pull/327, - https://github.com/fmtlib/fmt/issues/345 and - https://github.com/fmtlib/fmt/pull/381), FreeBSD - (https://github.com/fmtlib/fmt/pull/358), Cygwin - (https://github.com/fmtlib/fmt/issues/388), MinGW - (https://github.com/fmtlib/fmt/issues/355) as well as other - issues (https://github.com/fmtlib/fmt/issues/350, - https://github.com/fmtlib/fmt/issues/355, - https://github.com/fmtlib/fmt/pull/348, - https://github.com/fmtlib/fmt/pull/402, - https://github.com/fmtlib/fmt/pull/405). - Thanks @dpantele, @hghwng, @arvedarved, @LogicalKnight and @JanHellwig. -- Fixed some documentation issues and extended specification - (https://github.com/fmtlib/fmt/issues/320, - https://github.com/fmtlib/fmt/pull/333, - https://github.com/fmtlib/fmt/issues/347, - https://github.com/fmtlib/fmt/pull/362). Thanks @smellman. - -# 3.0.0 - 2016-05-07 - -- The project has been renamed from C++ Format (cppformat) to fmt for - consistency with the used namespace and macro prefix - (https://github.com/fmtlib/fmt/issues/307). Library headers - are now located in the `fmt` directory: - - ```c++ - #include "fmt/format.h" - ``` - - Including `format.h` from the `cppformat` directory is deprecated - but works via a proxy header which will be removed in the next major - version. - - The documentation is now available at . - -- Added support for - [strftime](http://en.cppreference.com/w/cpp/chrono/c/strftime)-like - [date and time - formatting](https://fmt.dev/3.0.0/api.html#date-and-time-formatting) - (https://github.com/fmtlib/fmt/issues/283): - - ```c++ - #include "fmt/time.h" - - std::time_t t = std::time(nullptr); - // Prints "The date is 2016-04-29." (with the current date) - fmt::print("The date is {:%Y-%m-%d}.", *std::localtime(&t)); - ``` - -- `std::ostream` support including formatting of user-defined types - that provide overloaded `operator<<` has been moved to - `fmt/ostream.h`: - - ```c++ - #include "fmt/ostream.h" - - class Date { - int year_, month_, day_; - public: - Date(int year, int month, int day) : year_(year), month_(month), day_(day) {} - - friend std::ostream &operator<<(std::ostream &os, const Date &d) { - return os << d.year_ << '-' << d.month_ << '-' << d.day_; - } - }; - - std::string s = fmt::format("The date is {}", Date(2012, 12, 9)); - // s == "The date is 2012-12-9" - ``` - -- Added support for [custom argument - formatters](https://fmt.dev/3.0.0/api.html#argument-formatters) - (https://github.com/fmtlib/fmt/issues/235). - -- Added support for locale-specific integer formatting with the `n` - specifier (https://github.com/fmtlib/fmt/issues/305): - - ```c++ - std::setlocale(LC_ALL, "en_US.utf8"); - fmt::print("cppformat: {:n}\n", 1234567); // prints 1,234,567 - ``` - -- Sign is now preserved when formatting an integer with an incorrect - `printf` format specifier - (https://github.com/fmtlib/fmt/issues/265): - - ```c++ - fmt::printf("%lld", -42); // prints -42 - ``` - - Note that it would be an undefined behavior in `std::printf`. - -- Length modifiers such as `ll` are now optional in printf formatting - functions and the correct type is determined automatically - (https://github.com/fmtlib/fmt/issues/255): - - ```c++ - fmt::printf("%d", std::numeric_limits::max()); - ``` - - Note that it would be an undefined behavior in `std::printf`. - -- Added initial support for custom formatters - (https://github.com/fmtlib/fmt/issues/231). - -- Fixed detection of user-defined literal support on Intel C++ - compiler (https://github.com/fmtlib/fmt/issues/311, - https://github.com/fmtlib/fmt/pull/312). - Thanks @dean0x7d and @speth. - -- Reduced compile time - (https://github.com/fmtlib/fmt/pull/243, - https://github.com/fmtlib/fmt/pull/249, - https://github.com/fmtlib/fmt/issues/317): - - ![](https://cloud.githubusercontent.com/assets/4831417/11614060/b9e826d2-9c36-11e5-8666-d4131bf503ef.png) - - ![](https://cloud.githubusercontent.com/assets/4831417/11614080/6ac903cc-9c37-11e5-8165-26df6efae364.png) - - Thanks @dean0x7d. - -- Compile test fixes (https://github.com/fmtlib/fmt/pull/313). - Thanks @dean0x7d. - -- Documentation fixes (https://github.com/fmtlib/fmt/pull/239, - https://github.com/fmtlib/fmt/issues/248, - https://github.com/fmtlib/fmt/issues/252, - https://github.com/fmtlib/fmt/pull/258, - https://github.com/fmtlib/fmt/issues/260, - https://github.com/fmtlib/fmt/issues/301, - https://github.com/fmtlib/fmt/pull/309). - Thanks @ReadmeCritic @Gachapen and @jwilk. - -- Fixed compiler and sanitizer warnings - (https://github.com/fmtlib/fmt/issues/244, - https://github.com/fmtlib/fmt/pull/256, - https://github.com/fmtlib/fmt/pull/259, - https://github.com/fmtlib/fmt/issues/263, - https://github.com/fmtlib/fmt/issues/274, - https://github.com/fmtlib/fmt/pull/277, - https://github.com/fmtlib/fmt/pull/286, - https://github.com/fmtlib/fmt/issues/291, - https://github.com/fmtlib/fmt/issues/296, - https://github.com/fmtlib/fmt/issues/308). - Thanks @mwinterb, @pweiskircher and @Naios. - -- Improved compatibility with Windows Store apps - (https://github.com/fmtlib/fmt/issues/280, - https://github.com/fmtlib/fmt/pull/285) Thanks @mwinterb. - -- Added tests of compatibility with older C++ standards - (https://github.com/fmtlib/fmt/pull/273). Thanks @niosHD. - -- Fixed Android build - (https://github.com/fmtlib/fmt/pull/271). Thanks @newnon. - -- Changed `ArgMap` to be backed by a vector instead of a map. - (https://github.com/fmtlib/fmt/issues/261, - https://github.com/fmtlib/fmt/pull/262). Thanks @mwinterb. - -- Added `fprintf` overload that writes to a `std::ostream` - (https://github.com/fmtlib/fmt/pull/251). - Thanks @nickhutchinson. - -- Export symbols when building a Windows DLL - (https://github.com/fmtlib/fmt/pull/245). - Thanks @macdems. - -- Fixed compilation on Cygwin - (https://github.com/fmtlib/fmt/issues/304). - -- Implemented a workaround for a bug in Apple LLVM version 4.2 of - clang (https://github.com/fmtlib/fmt/issues/276). - -- Implemented a workaround for Google Test bug - https://github.com/google/googletest/issues/705 on gcc 6 - (https://github.com/fmtlib/fmt/issues/268). Thanks @octoploid. - -- Removed Biicode support because the latter has been discontinued. - -# 2.1.1 - 2016-04-11 - -- The install location for generated CMake files is now configurable - via the `FMT_CMAKE_DIR` CMake variable - (https://github.com/fmtlib/fmt/pull/299). Thanks @niosHD. -- Documentation fixes - (https://github.com/fmtlib/fmt/issues/252). - -# 2.1.0 - 2016-03-21 - -- Project layout and build system improvements - (https://github.com/fmtlib/fmt/pull/267): - - - The code have been moved to the `cppformat` directory. Including - `format.h` from the top-level directory is deprecated but works - via a proxy header which will be removed in the next major - version. - - C++ Format CMake targets now have proper interface definitions. - - Installed version of the library now supports the header-only - configuration. - - Targets `doc`, `install`, and `test` are now disabled if C++ - Format is included as a CMake subproject. They can be enabled by - setting `FMT_DOC`, `FMT_INSTALL`, and `FMT_TEST` in the parent - project. - - Thanks @niosHD. - -# 2.0.1 - 2016-03-13 - -- Improved CMake find and package support - (https://github.com/fmtlib/fmt/issues/264). Thanks @niosHD. -- Fix compile error with Android NDK and mingw32 - (https://github.com/fmtlib/fmt/issues/241). Thanks @Gachapen. -- Documentation fixes - (https://github.com/fmtlib/fmt/issues/248, - https://github.com/fmtlib/fmt/issues/260). - -# 2.0.0 - 2015-12-01 - -## General - -- \[Breaking\] Named arguments - (https://github.com/fmtlib/fmt/pull/169, - https://github.com/fmtlib/fmt/pull/173, - https://github.com/fmtlib/fmt/pull/174): - - ```c++ - fmt::print("The answer is {answer}.", fmt::arg("answer", 42)); - ``` - - Thanks @jamboree. - -- \[Experimental\] User-defined literals for format and named - arguments (https://github.com/fmtlib/fmt/pull/204, - https://github.com/fmtlib/fmt/pull/206, - https://github.com/fmtlib/fmt/pull/207): - - ```c++ - using namespace fmt::literals; - fmt::print("The answer is {answer}.", "answer"_a=42); - ``` - - Thanks @dean0x7d. - -- \[Breaking\] Formatting of more than 16 arguments is now supported - when using variadic templates - (https://github.com/fmtlib/fmt/issues/141). Thanks @Shauren. - -- Runtime width specification - (https://github.com/fmtlib/fmt/pull/168): - - ```c++ - fmt::format("{0:{1}}", 42, 5); // gives " 42" - ``` - - Thanks @jamboree. - -- \[Breaking\] Enums are now formatted with an overloaded - `std::ostream` insertion operator (`operator<<`) if available - (https://github.com/fmtlib/fmt/issues/232). - -- \[Breaking\] Changed default `bool` format to textual, \"true\" or - \"false\" (https://github.com/fmtlib/fmt/issues/170): - - ```c++ - fmt::print("{}", true); // prints "true" - ``` - - To print `bool` as a number use numeric format specifier such as - `d`: - - ```c++ - fmt::print("{:d}", true); // prints "1" - ``` - -- `fmt::printf` and `fmt::sprintf` now support formatting of `bool` - with the `%s` specifier giving textual output, \"true\" or \"false\" - (https://github.com/fmtlib/fmt/pull/223): - - ```c++ - fmt::printf("%s", true); // prints "true" - ``` - - Thanks @LarsGullik. - -- \[Breaking\] `signed char` and `unsigned char` are now formatted as - integers by default - (https://github.com/fmtlib/fmt/pull/217). - -- \[Breaking\] Pointers to C strings can now be formatted with the `p` - specifier (https://github.com/fmtlib/fmt/pull/223): - - ```c++ - fmt::print("{:p}", "test"); // prints pointer value - ``` - - Thanks @LarsGullik. - -- \[Breaking\] `fmt::printf` and `fmt::sprintf` now print null - pointers as `(nil)` and null strings as `(null)` for consistency - with glibc (https://github.com/fmtlib/fmt/pull/226). - Thanks @LarsGullik. - -- \[Breaking\] `fmt::(s)printf` now supports formatting of objects of - user-defined types that provide an overloaded `std::ostream` - insertion operator (`operator<<`) - (https://github.com/fmtlib/fmt/issues/201): - - ```c++ - fmt::printf("The date is %s", Date(2012, 12, 9)); - ``` - -- \[Breaking\] The `Buffer` template is now part of the public API and - can be used to implement custom memory buffers - (https://github.com/fmtlib/fmt/issues/140). Thanks @polyvertex. - -- \[Breaking\] Improved compatibility between `BasicStringRef` and - [std::experimental::basic_string_view]( - http://en.cppreference.com/w/cpp/experimental/basic_string_view) - (https://github.com/fmtlib/fmt/issues/100, - https://github.com/fmtlib/fmt/issues/159, - https://github.com/fmtlib/fmt/issues/183): - - - Comparison operators now compare string content, not pointers - - `BasicStringRef::c_str` replaced by `BasicStringRef::data` - - `BasicStringRef` is no longer assumed to be null-terminated - - References to null-terminated strings are now represented by a new - class, `BasicCStringRef`. - -- Dependency on pthreads introduced by Google Test is now optional - (https://github.com/fmtlib/fmt/issues/185). - -- New CMake options `FMT_DOC`, `FMT_INSTALL` and `FMT_TEST` to control - generation of `doc`, `install` and `test` targets respectively, on - by default (https://github.com/fmtlib/fmt/issues/197, - https://github.com/fmtlib/fmt/issues/198, - https://github.com/fmtlib/fmt/issues/200). Thanks @maddinat0r. - -- `noexcept` is now used when compiling with MSVC2015 - (https://github.com/fmtlib/fmt/pull/215). Thanks @dmkrepo. - -- Added an option to disable use of `windows.h` when - `FMT_USE_WINDOWS_H` is defined as 0 before including `format.h` - (https://github.com/fmtlib/fmt/issues/171). Thanks @alfps. - -- \[Breaking\] `windows.h` is now included with `NOMINMAX` unless - `FMT_WIN_MINMAX` is defined. This is done to prevent breaking code - using `std::min` and `std::max` and only affects the header-only - configuration (https://github.com/fmtlib/fmt/issues/152, - https://github.com/fmtlib/fmt/pull/153, - https://github.com/fmtlib/fmt/pull/154). Thanks @DevO2012. - -- Improved support for custom character types - (https://github.com/fmtlib/fmt/issues/171). Thanks @alfps. - -- Added an option to disable use of IOStreams when `FMT_USE_IOSTREAMS` - is defined as 0 before including `format.h` - (https://github.com/fmtlib/fmt/issues/205, - https://github.com/fmtlib/fmt/pull/208). Thanks @JodiTheTigger. - -- Improved detection of `isnan`, `isinf` and `signbit`. - -## Optimization - -- Made formatting of user-defined types more efficient with a custom - stream buffer (https://github.com/fmtlib/fmt/issues/92, - https://github.com/fmtlib/fmt/pull/230). Thanks @NotImplemented. -- Further improved performance of `fmt::Writer` on integer formatting - and fixed a minor regression. Now it is \~7% faster than - `karma::generate` on Karma\'s benchmark - (https://github.com/fmtlib/fmt/issues/186). -- \[Breaking\] Reduced [compiled code - size](https://github.com/fmtlib/fmt#compile-time-and-code-bloat) - (https://github.com/fmtlib/fmt/issues/143, - https://github.com/fmtlib/fmt/pull/149). - -## Distribution - -- \[Breaking\] Headers are now installed in - `${CMAKE_INSTALL_PREFIX}/include/cppformat` - (https://github.com/fmtlib/fmt/issues/178). Thanks @jackyf. - -- \[Breaking\] Changed the library name from `format` to `cppformat` - for consistency with the project name and to avoid potential - conflicts (https://github.com/fmtlib/fmt/issues/178). - Thanks @jackyf. - -- C++ Format is now available in [Debian](https://www.debian.org/) - GNU/Linux - ([stretch](https://packages.debian.org/source/stretch/cppformat), - [sid](https://packages.debian.org/source/sid/cppformat)) and derived - distributions such as - [Ubuntu](https://launchpad.net/ubuntu/+source/cppformat) 15.10 and - later (https://github.com/fmtlib/fmt/issues/155): - - $ sudo apt-get install libcppformat1-dev - - Thanks @jackyf. - -- [Packages for Fedora and - RHEL](https://admin.fedoraproject.org/pkgdb/package/cppformat/) are - now available. Thanks Dave Johansen. - -- C++ Format can now be installed via [Homebrew](http://brew.sh/) on - OS X (https://github.com/fmtlib/fmt/issues/157): - - $ brew install cppformat - - Thanks @ortho and Anatoliy Bulukin. - -## Documentation - -- Migrated from ReadTheDocs to GitHub Pages for better responsiveness - and reliability (https://github.com/fmtlib/fmt/issues/128). - New documentation address is . -- Added [Building thedocumentation]( - https://fmt.dev/2.0.0/usage.html#building-the-documentation) - section to the documentation. -- Documentation build script is now compatible with Python 3 and newer - pip versions. (https://github.com/fmtlib/fmt/pull/189, - https://github.com/fmtlib/fmt/issues/209). - Thanks @JodiTheTigger and @xentec. -- Documentation fixes and improvements - (https://github.com/fmtlib/fmt/issues/36, - https://github.com/fmtlib/fmt/issues/75, - https://github.com/fmtlib/fmt/issues/125, - https://github.com/fmtlib/fmt/pull/160, - https://github.com/fmtlib/fmt/pull/161, - https://github.com/fmtlib/fmt/issues/162, - https://github.com/fmtlib/fmt/issues/165, - https://github.com/fmtlib/fmt/issues/210). - Thanks @syohex. -- Fixed out-of-tree documentation build - (https://github.com/fmtlib/fmt/issues/177). Thanks @jackyf. - -## Fixes - -- Fixed `initializer_list` detection - (https://github.com/fmtlib/fmt/issues/136). Thanks @Gachapen. - -- \[Breaking\] Fixed formatting of enums with numeric format - specifiers in `fmt::(s)printf` - (https://github.com/fmtlib/fmt/issues/131, - https://github.com/fmtlib/fmt/issues/139): - - ```c++ - enum { ANSWER = 42 }; - fmt::printf("%d", ANSWER); - ``` - - Thanks @Naios. - -- Improved compatibility with old versions of MinGW - (https://github.com/fmtlib/fmt/issues/129, - https://github.com/fmtlib/fmt/pull/130, - https://github.com/fmtlib/fmt/issues/132). Thanks @cstamford. - -- Fixed a compile error on MSVC with disabled exceptions - (https://github.com/fmtlib/fmt/issues/144). - -- Added a workaround for broken implementation of variadic templates - in MSVC2012 (https://github.com/fmtlib/fmt/issues/148). - -- Placed the anonymous namespace within `fmt` namespace for the - header-only configuration (https://github.com/fmtlib/fmt/issues/171). - Thanks @alfps. - -- Fixed issues reported by Coverity Scan - (https://github.com/fmtlib/fmt/issues/187, - https://github.com/fmtlib/fmt/issues/192). - -- Implemented a workaround for a name lookup bug in MSVC2010 - (https://github.com/fmtlib/fmt/issues/188). - -- Fixed compiler warnings - (https://github.com/fmtlib/fmt/issues/95, - https://github.com/fmtlib/fmt/issues/96, - https://github.com/fmtlib/fmt/pull/114, - https://github.com/fmtlib/fmt/issues/135, - https://github.com/fmtlib/fmt/issues/142, - https://github.com/fmtlib/fmt/issues/145, - https://github.com/fmtlib/fmt/issues/146, - https://github.com/fmtlib/fmt/issues/158, - https://github.com/fmtlib/fmt/issues/163, - https://github.com/fmtlib/fmt/issues/175, - https://github.com/fmtlib/fmt/issues/190, - https://github.com/fmtlib/fmt/pull/191, - https://github.com/fmtlib/fmt/issues/194, - https://github.com/fmtlib/fmt/pull/196, - https://github.com/fmtlib/fmt/issues/216, - https://github.com/fmtlib/fmt/pull/218, - https://github.com/fmtlib/fmt/pull/220, - https://github.com/fmtlib/fmt/pull/229, - https://github.com/fmtlib/fmt/issues/233, - https://github.com/fmtlib/fmt/issues/234, - https://github.com/fmtlib/fmt/pull/236, - https://github.com/fmtlib/fmt/issues/281, - https://github.com/fmtlib/fmt/issues/289). - Thanks @seanmiddleditch, @dixlorenz, @CarterLi, @Naios, @fmatthew5876, - @LevskiWeng, @rpopescu, @gabime, @cubicool, @jkflying, @LogicalKnight, - @inguin and @Jopie64. - -- Fixed portability issues (mostly causing test failures) on ARM, - ppc64, ppc64le, s390x and SunOS 5.11 i386 - (https://github.com/fmtlib/fmt/issues/138, - https://github.com/fmtlib/fmt/issues/179, - https://github.com/fmtlib/fmt/issues/180, - https://github.com/fmtlib/fmt/issues/202, - https://github.com/fmtlib/fmt/issues/225, [Red Hat Bugzilla - Bug 1260297](https://bugzilla.redhat.com/show_bug.cgi?id=1260297)). - Thanks @Naios, @jackyf and Dave Johansen. - -- Fixed a name conflict with macro `free` defined in `crtdbg.h` when - `_CRTDBG_MAP_ALLOC` is set (https://github.com/fmtlib/fmt/issues/211). - -- Fixed shared library build on OS X - (https://github.com/fmtlib/fmt/pull/212). Thanks @dean0x7d. - -- Fixed an overload conflict on MSVC when `/Zc:wchar_t-` option is - specified (https://github.com/fmtlib/fmt/pull/214). - Thanks @slavanap. - -- Improved compatibility with MSVC 2008 - (https://github.com/fmtlib/fmt/pull/236). Thanks @Jopie64. - -- Improved compatibility with bcc32 - (https://github.com/fmtlib/fmt/issues/227). - -- Fixed `static_assert` detection on Clang - (https://github.com/fmtlib/fmt/pull/228). Thanks @dean0x7d. - -# 1.1.0 - 2015-03-06 - -- Added `BasicArrayWriter`, a class template that provides operations - for formatting and writing data into a fixed-size array - (https://github.com/fmtlib/fmt/issues/105 and - https://github.com/fmtlib/fmt/issues/122): - - ```c++ - char buffer[100]; - fmt::ArrayWriter w(buffer); - w.write("The answer is {}", 42); - ``` - -- Added [0 A.D.](http://play0ad.com/) and [PenUltima Online - (POL)](http://www.polserver.com/) to the list of notable projects - using C++ Format. - -- C++ Format now uses MSVC intrinsics for better formatting performance - (https://github.com/fmtlib/fmt/pull/115, - https://github.com/fmtlib/fmt/pull/116, - https://github.com/fmtlib/fmt/pull/118 and - https://github.com/fmtlib/fmt/pull/121). Previously these - optimizations where only used on GCC and Clang. - Thanks @CarterLi and @objectx. - -- CMake install target - (https://github.com/fmtlib/fmt/pull/119). Thanks @TrentHouliston. - - You can now install C++ Format with `make install` command. - -- Improved [Biicode](http://www.biicode.com/) support - (https://github.com/fmtlib/fmt/pull/98 and - https://github.com/fmtlib/fmt/pull/104). - Thanks @MariadeAnton and @franramirez688. - -- Improved support for building with [Android NDK]( - https://developer.android.com/tools/sdk/ndk/index.html) - (https://github.com/fmtlib/fmt/pull/107). Thanks @newnon. - - The [android-ndk-example](https://github.com/fmtlib/android-ndk-example) - repository provides and example of using C++ Format with Android NDK: - - ![](https://raw.githubusercontent.com/fmtlib/android-ndk-example/master/screenshot.png) - -- Improved documentation of `SystemError` and `WindowsError` - (https://github.com/fmtlib/fmt/issues/54). - -- Various code improvements - (https://github.com/fmtlib/fmt/pull/110, - https://github.com/fmtlib/fmt/pull/111 - https://github.com/fmtlib/fmt/pull/112). Thanks @CarterLi. - -- Improved compile-time errors when formatting wide into narrow - strings (https://github.com/fmtlib/fmt/issues/117). - -- Fixed `BasicWriter::write` without formatting arguments when C++11 - support is disabled - (https://github.com/fmtlib/fmt/issues/109). - -- Fixed header-only build on OS X with GCC 4.9 - (https://github.com/fmtlib/fmt/issues/124). - -- Fixed packaging issues (https://github.com/fmtlib/fmt/issues/94). - -- Added [changelog](https://github.com/fmtlib/fmt/blob/master/ChangeLog.md) - (https://github.com/fmtlib/fmt/issues/103). - -# 1.0.0 - 2015-02-05 - -- Add support for a header-only configuration when `FMT_HEADER_ONLY` - is defined before including `format.h`: - - ```c++ - #define FMT_HEADER_ONLY - #include "format.h" - ``` - -- Compute string length in the constructor of `BasicStringRef` instead - of the `size` method - (https://github.com/fmtlib/fmt/issues/79). This eliminates - size computation for string literals on reasonable optimizing - compilers. - -- Fix formatting of types with overloaded `operator <<` for - `std::wostream` (https://github.com/fmtlib/fmt/issues/86): - - ```c++ - fmt::format(L"The date is {0}", Date(2012, 12, 9)); - ``` - -- Fix linkage of tests on Arch Linux - (https://github.com/fmtlib/fmt/issues/89). - -- Allow precision specifier for non-float arguments - (https://github.com/fmtlib/fmt/issues/90): - - ```c++ - fmt::print("{:.3}\n", "Carpet"); // prints "Car" - ``` - -- Fix build on Android NDK (https://github.com/fmtlib/fmt/issues/93). - -- Improvements to documentation build procedure. - -- Remove `FMT_SHARED` CMake variable in favor of standard [BUILD_SHARED_LIBS]( - http://www.cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html). - -- Fix error handling in `fmt::fprintf`. - -- Fix a number of warnings. - -# 0.12.0 - 2014-10-25 - -- \[Breaking\] Improved separation between formatting and buffer - management. `Writer` is now a base class that cannot be instantiated - directly. The new `MemoryWriter` class implements the default buffer - management with small allocations done on stack. So `fmt::Writer` - should be replaced with `fmt::MemoryWriter` in variable - declarations. - - Old code: - - ```c++ - fmt::Writer w; - ``` - - New code: - - ```c++ - fmt::MemoryWriter w; - ``` - - If you pass `fmt::Writer` by reference, you can continue to do so: - - ```c++ - void f(fmt::Writer &w); - ``` - - This doesn\'t affect the formatting API. - -- Support for custom memory allocators - (https://github.com/fmtlib/fmt/issues/69) - -- Formatting functions now accept [signed char]{.title-ref} and - [unsigned char]{.title-ref} strings as arguments - (https://github.com/fmtlib/fmt/issues/73): - - ```c++ - auto s = format("GLSL version: {}", glGetString(GL_VERSION)); - ``` - -- Reduced code bloat. According to the new [benchmark - results](https://github.com/fmtlib/fmt#compile-time-and-code-bloat), - cppformat is close to `printf` and by the order of magnitude better - than Boost Format in terms of compiled code size. - -- Improved appearance of the documentation on mobile by using the - [Sphinx Bootstrap - theme](http://ryan-roemer.github.io/sphinx-bootstrap-theme/): - - | Old | New | - | --- | --- | - | ![](https://cloud.githubusercontent.com/assets/576385/4792130/cd256436-5de3-11e4-9a62-c077d0c2b003.png) | ![](https://cloud.githubusercontent.com/assets/576385/4792131/cd29896c-5de3-11e4-8f59-cac952942bf0.png) | - -# 0.11.0 - 2014-08-21 - -- Safe printf implementation with a POSIX extension for positional - arguments: - - ```c++ - fmt::printf("Elapsed time: %.2f seconds", 1.23); - fmt::printf("%1$s, %3$d %2$s", weekday, month, day); - ``` - -- Arguments of `char` type can now be formatted as integers (Issue - https://github.com/fmtlib/fmt/issues/55): - - ```c++ - fmt::format("0x{0:02X}", 'a'); - ``` - -- Deprecated parts of the API removed. - -- The library is now built and tested on MinGW with Appveyor in - addition to existing test platforms Linux/GCC, OS X/Clang, - Windows/MSVC. - -# 0.10.0 - 2014-07-01 - -**Improved API** - -- All formatting methods are now implemented as variadic functions - instead of using `operator<<` for feeding arbitrary arguments into a - temporary formatter object. This works both with C++11 where - variadic templates are used and with older standards where variadic - functions are emulated by providing lightweight wrapper functions - defined with the `FMT_VARIADIC` macro. You can use this macro for - defining your own portable variadic functions: - - ```c++ - void report_error(const char *format, const fmt::ArgList &args) { - fmt::print("Error: {}"); - fmt::print(format, args); - } - FMT_VARIADIC(void, report_error, const char *) - - report_error("file not found: {}", path); - ``` - - Apart from a more natural syntax, this also improves performance as - there is no need to construct temporary formatter objects and - control arguments\' lifetimes. Because the wrapper functions are - very lightweight, this doesn\'t cause code bloat even in pre-C++11 - mode. - -- Simplified common case of formatting an `std::string`. Now it - requires a single function call: - - ```c++ - std::string s = format("The answer is {}.", 42); - ``` - - Previously it required 2 function calls: - - ```c++ - std::string s = str(Format("The answer is {}.") << 42); - ``` - - Instead of unsafe `c_str` function, `fmt::Writer` should be used - directly to bypass creation of `std::string`: - - ```c++ - fmt::Writer w; - w.write("The answer is {}.", 42); - w.c_str(); // returns a C string - ``` - - This doesn\'t do dynamic memory allocation for small strings and is - less error prone as the lifetime of the string is the same as for - `std::string::c_str` which is well understood (hopefully). - -- Improved consistency in naming functions that are a part of the - public API. Now all public functions are lowercase following the - standard library conventions. Previously it was a combination of - lowercase and CapitalizedWords. Issue - https://github.com/fmtlib/fmt/issues/50. - -- Old functions are marked as deprecated and will be removed in the - next release. - -**Other Changes** - -- Experimental support for printf format specifications (work in - progress): - - ```c++ - fmt::printf("The answer is %d.", 42); - std::string s = fmt::sprintf("Look, a %s!", "string"); - ``` - -- Support for hexadecimal floating point format specifiers `a` and - `A`: - - ```c++ - print("{:a}", -42.0); // Prints -0x1.5p+5 - print("{:A}", -42.0); // Prints -0X1.5P+5 - ``` - -- CMake option `FMT_SHARED` that specifies whether to build format as - a shared library (off by default). - -# 0.9.0 - 2014-05-13 - -- More efficient implementation of variadic formatting functions. - -- `Writer::Format` now has a variadic overload: - - ```c++ - Writer out; - out.Format("Look, I'm {}!", "variadic"); - ``` - -- For efficiency and consistency with other overloads, variadic - overload of the `Format` function now returns `Writer` instead of - `std::string`. Use the `str` function to convert it to - `std::string`: - - ```c++ - std::string s = str(Format("Look, I'm {}!", "variadic")); - ``` - -- Replaced formatter actions with output sinks: `NoAction` -\> - `NullSink`, `Write` -\> `FileSink`, `ColorWriter` -\> - `ANSITerminalSink`. This improves naming consistency and shouldn\'t - affect client code unless these classes are used directly which - should be rarely needed. - -- Added `ThrowSystemError` function that formats a message and throws - `SystemError` containing the formatted message and system-specific - error description. For example, the following code - - ```c++ - FILE *f = fopen(filename, "r"); - if (!f) - ThrowSystemError(errno, "Failed to open file '{}'") << filename; - ``` - - will throw `SystemError` exception with description \"Failed to open - file \'\\': No such file or directory\" if file doesn\'t - exist. - -- Support for AppVeyor continuous integration platform. - -- `Format` now throws `SystemError` in case of I/O errors. - -- Improve test infrastructure. Print functions are now tested by - redirecting the output to a pipe. - -# 0.8.0 - 2014-04-14 - -- Initial release diff --git a/third_party/fmt/doc/api.md b/third_party/fmt/doc/api.md deleted file mode 100644 index bf0df731..00000000 --- a/third_party/fmt/doc/api.md +++ /dev/null @@ -1,650 +0,0 @@ -# API Reference - -The {fmt} library API consists of the following components: - -- [`fmt/base.h`](#base-api): the base API providing main formatting functions - for `char`/UTF-8 with C++20 compile-time checks and minimal dependencies -- [`fmt/format.h`](#format-api): `fmt::format` and other formatting functions - as well as locale support -- [`fmt/ranges.h`](#ranges-api): formatting of ranges and tuples -- [`fmt/chrono.h`](#chrono-api): date and time formatting -- [`fmt/std.h`](#std-api): formatters for standard library types -- [`fmt/compile.h`](#compile-api): format string compilation -- [`fmt/color.h`](#color-api): terminal colors and text styles -- [`fmt/os.h`](#os-api): system APIs -- [`fmt/ostream.h`](#ostream-api): `std::ostream` support -- [`fmt/args.h`](#args-api): dynamic argument lists -- [`fmt/printf.h`](#printf-api): safe `printf` -- [`fmt/xchar.h`](#xchar-api): optional `wchar_t` support - -All functions and types provided by the library reside in namespace `fmt` -and macros have prefix `FMT_`. - -## Base API - -`fmt/base.h` defines the base API which provides main formatting functions -for `char`/UTF-8 with C++20 compile-time checks. It has minimal include -dependencies for better compile times. This header is only beneficial when -using {fmt} as a library (the default) and not in the header-only mode. -It also provides `formatter` specializations for the following types: - -- `int`, `long long`, -- `unsigned`, `unsigned long long` -- `float`, `double`, `long double` -- `bool` -- `char` -- `const char*`, [`fmt::string_view`](#basic_string_view) -- `const void*` - -The following functions use [format string syntax](syntax.md) similar to that -of [str.format](https://docs.python.org/3/library/stdtypes.html#str.format) -in Python. They take *fmt* and *args* as arguments. - -*fmt* is a format string that contains literal text and replacement fields -surrounded by braces `{}`. The fields are replaced with formatted arguments -in the resulting string. [`fmt::format_string`](#format_string) is a format -string which can be implicitly constructed from a string literal or a -`constexpr` string and is checked at compile time in C++20. To pass a runtime -format string wrap it in [`fmt::runtime`](#runtime). - -*args* is an argument list representing objects to be formatted. - -I/O errors are reported as [`std::system_error`]( -https://en.cppreference.com/w/cpp/error/system_error) exceptions unless -specified otherwise. - -::: print(format_string, T&&...) - -::: print(FILE*, format_string, T&&...) - -::: println(format_string, T&&...) - -::: println(FILE*, format_string, T&&...) - -::: format_to(OutputIt&&, format_string, T&&...) - -::: format_to_n(OutputIt, size_t, format_string, T&&...) - -::: format_to_n_result - -::: formatted_size(format_string, T&&...) - - -### Formatting User-Defined Types - -The {fmt} library provides formatters for many standard C++ types. -See [`fmt/ranges.h`](#ranges-api) for ranges and tuples including standard -containers such as `std::vector`, [`fmt/chrono.h`](#chrono-api) for date and -time formatting and [`fmt/std.h`](#std-api) for other standard library types. - -There are two ways to make a user-defined type formattable: providing a -`format_as` function or specializing the `formatter` struct template. - -Use `format_as` if you want to make your type formattable as some other -type with the same format specifiers. The `format_as` function should -take an object of your type and return an object of a formattable type. -It should be defined in the same namespace as your type. - -Example ([run](https://godbolt.org/z/nvME4arz8)): - - #include - - namespace kevin_namespacy { - - enum class film { - house_of_cards, american_beauty, se7en = 7 - }; - - auto format_as(film f) { return fmt::underlying(f); } - - } - - int main() { - fmt::print("{}\n", kevin_namespacy::film::se7en); // Output: 7 - } - -Using specialization is more complex but gives you full control over -parsing and formatting. To use this method specialize the `formatter` -struct template for your type and implement `parse` and `format` -methods. - -The recommended way of defining a formatter is by reusing an existing -one via inheritance or composition. This way you can support standard -format specifiers without implementing them yourself. For example: - -```c++ -// color.h: -#include - -enum class color {red, green, blue}; - -template <> struct fmt::formatter: formatter { - // parse is inherited from formatter. - - auto format(color c, format_context& ctx) const - -> format_context::iterator; -}; -``` - -```c++ -// color.cc: -#include "color.h" -#include - -auto fmt::formatter::format(color c, format_context& ctx) const - -> format_context::iterator { - string_view name = "unknown"; - switch (c) { - case color::red: name = "red"; break; - case color::green: name = "green"; break; - case color::blue: name = "blue"; break; - } - return formatter::format(name, ctx); -} -``` - -Note that `formatter::format` is defined in `fmt/format.h` -so it has to be included in the source file. Since `parse` is inherited -from `formatter` it will recognize all string format -specifications, for example - -```c++ -fmt::format("{:>10}", color::blue) -``` - -will return `" blue"`. - - - -In general the formatter has the following form: - - template <> struct fmt::formatter { - // Parses format specifiers and stores them in the formatter. - // - // [ctx.begin(), ctx.end()) is a, possibly empty, character range that - // contains a part of the format string starting from the format - // specifications to be parsed, e.g. in - // - // fmt::format("{:f} continued", ...); - // - // the range will contain "f} continued". The formatter should parse - // specifiers until '}' or the end of the range. In this example the - // formatter should parse the 'f' specifier and return an iterator - // pointing to '}'. - constexpr auto parse(format_parse_context& ctx) - -> format_parse_context::iterator; - - // Formats value using the parsed format specification stored in this - // formatter and writes the output to ctx.out(). - auto format(const T& value, format_context& ctx) const - -> format_context::iterator; - }; - -It is recommended to at least support fill, align and width that apply -to the whole object and have the same semantics as in standard -formatters. - -You can also write a formatter for a hierarchy of classes: - -```c++ -// demo.h: -#include -#include - -struct A { - virtual ~A() {} - virtual std::string name() const { return "A"; } -}; - -struct B : A { - virtual std::string name() const { return "B"; } -}; - -template -struct fmt::formatter, char>> : - fmt::formatter { - auto format(const A& a, format_context& ctx) const { - return formatter::format(a.name(), ctx); - } -}; -``` - -```c++ -// demo.cc: -#include "demo.h" -#include - -int main() { - B b; - A& a = b; - fmt::print("{}", a); // Output: B -} -``` - -Providing both a `formatter` specialization and a `format_as` overload is -disallowed. - -::: basic_format_parse_context - -::: context - -::: format_context - -### Compile-Time Checks - -Compile-time format string checks are enabled by default on compilers -that support C++20 `consteval`. On older compilers you can use the -[FMT_STRING](#legacy-checks) macro defined in `fmt/format.h` instead. - -Unused arguments are allowed as in Python's `str.format` and ordinary functions. - -::: basic_format_string - -::: format_string - -::: runtime(string_view) - -### Named Arguments - -::: arg(const Char*, const T&) - -Named arguments are not supported in compile-time checks at the moment. - -### Type Erasure - -You can create your own formatting function with compile-time checks and -small binary footprint, for example ([run](https://godbolt.org/z/b9Pbasvzc)): - -```c++ -#include - -void vlog(const char* file, int line, - fmt::string_view fmt, fmt::format_args args) { - fmt::print("{}: {}: {}", file, line, fmt::vformat(fmt, args)); -} - -template -void log(const char* file, int line, - fmt::format_string fmt, T&&... args) { - vlog(file, line, fmt, fmt::make_format_args(args...)); -} - -#define MY_LOG(fmt, ...) log(__FILE__, __LINE__, fmt, __VA_ARGS__) - -MY_LOG("invalid squishiness: {}", 42); -``` - -Note that `vlog` is not parameterized on argument types which improves -compile times and reduces binary code size compared to a fully -parameterized version. - -::: make_format_args(T&...) - -::: basic_format_args - -::: format_args - -::: basic_format_arg - -### Compatibility - -::: basic_string_view - -::: string_view - -## Format API - -`fmt/format.h` defines the full format API providing additional -formatting functions and locale support. - - -::: format(format_string, T&&...) - -::: vformat(string_view, format_args) - -::: operator""_a() - -### Utilities - -::: ptr(T) - -::: underlying(Enum) - -::: to_string(const T&) - -::: group_digits(T) - -::: detail::buffer - -::: basic_memory_buffer - -### System Errors - -{fmt} does not use `errno` to communicate errors to the user, but it may -call system functions which set `errno`. Users should not make any -assumptions about the value of `errno` being preserved by library -functions. - -::: system_error - -::: format_system_error - -### Custom Allocators - -The {fmt} library supports custom dynamic memory allocators. A custom -allocator class can be specified as a template argument to -[`fmt::basic_memory_buffer`](#basic_memory_buffer): - - using custom_memory_buffer = - fmt::basic_memory_buffer; - -It is also possible to write a formatting function that uses a custom -allocator: - - using custom_string = - std::basic_string, custom_allocator>; - - custom_string vformat(custom_allocator alloc, fmt::string_view format_str, - fmt::format_args args) { - auto buf = custom_memory_buffer(alloc); - fmt::vformat_to(std::back_inserter(buf), format_str, args); - return custom_string(buf.data(), buf.size(), alloc); - } - - template - inline custom_string format(custom_allocator alloc, - fmt::string_view format_str, - const Args& ... args) { - return vformat(alloc, format_str, fmt::make_format_args(args...)); - } - -The allocator will be used for the output container only. Formatting -functions normally don't do any allocations for built-in and string -types except for non-default floating-point formatting that occasionally -falls back on `sprintf`. - -### Locale - -All formatting is locale-independent by default. Use the `'L'` format -specifier to insert the appropriate number separator characters from the -locale: - - #include - #include - - std::locale::global(std::locale("en_US.UTF-8")); - auto s = fmt::format("{:L}", 1000000); // s == "1,000,000" - -`fmt/format.h` provides the following overloads of formatting functions -that take `std::locale` as a parameter. The locale type is a template -parameter to avoid the expensive `` include. - -::: format(const Locale&, format_string, T&&...) - -::: format_to(OutputIt, const Locale&, format_string, T&&...) - -::: formatted_size(const Locale&, format_string, T&&...) - - -### Legacy Compile-Time Checks - -`FMT_STRING` enables compile-time checks on older compilers. It requires -C++14 or later and is a no-op in C++11. - -::: FMT_STRING - -To force the use of legacy compile-time checks, define the preprocessor -variable `FMT_ENFORCE_COMPILE_STRING`. When set, functions accepting -`FMT_STRING` will fail to compile with regular strings. - - -## Range and Tuple Formatting - -`fmt/ranges.h` provides formatting support for ranges and tuples: - - #include - - fmt::print("{}", std::tuple{'a', 42}); - // Output: ('a', 42) - -Using `fmt::join`, you can separate tuple elements with a custom separator: - - #include - - auto t = std::tuple{1, 'a'}; - fmt::print("{}", fmt::join(t, ", ")); - // Output: 1, a - -::: join(Range&&, string_view) - -::: join(It, Sentinel, string_view) - -::: join(std::initializer_list, string_view) - - -## Date and Time Formatting - -`fmt/chrono.h` provides formatters for - -- [`std::chrono::duration`](https://en.cppreference.com/w/cpp/chrono/duration) -- [`std::chrono::time_point`]( - https://en.cppreference.com/w/cpp/chrono/time_point) -- [`std::tm`](https://en.cppreference.com/w/cpp/chrono/c/tm) - -The format syntax is described in [Chrono Format Specifications](syntax.md# -chrono-format-specifications). - -**Example**: - - #include - - int main() { - std::time_t t = std::time(nullptr); - - fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t)); - // Output: The date is 2020-11-07. - // (with 2020-11-07 replaced by the current date) - - using namespace std::literals::chrono_literals; - - fmt::print("Default format: {} {}\n", 42s, 100ms); - // Output: Default format: 42s 100ms - - fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s); - // Output: strftime-like format: 03:15:30 - } - -::: localtime(std::time_t) - -::: gmtime(std::time_t) - - -## Standard Library Types Formatting - -`fmt/std.h` provides formatters for: - -- [`std::atomic`](https://en.cppreference.com/w/cpp/atomic/atomic) -- [`std::atomic_flag`](https://en.cppreference.com/w/cpp/atomic/atomic_flag) -- [`std::bitset`](https://en.cppreference.com/w/cpp/utility/bitset) -- [`std::error_code`](https://en.cppreference.com/w/cpp/error/error_code) -- [`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path) -- [`std::monostate`](https://en.cppreference.com/w/cpp/utility/variant/monostate) -- [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional) -- [`std::source_location`](https://en.cppreference.com/w/cpp/utility/source_location) -- [`std::thread::id`](https://en.cppreference.com/w/cpp/thread/thread/id) -- [`std::variant`](https://en.cppreference.com/w/cpp/utility/variant/variant) - -::: ptr(const std::unique_ptr&) - -::: ptr(const std::shared_ptr&) - -### Formatting Variants - -A `std::variant` is only formattable if every variant alternative is -formattable, and requires the `__cpp_lib_variant` [library -feature](https://en.cppreference.com/w/cpp/feature_test). - -**Example**: - - #include - - fmt::print("{}", std::variant('x')); - // Output: variant('x') - - fmt::print("{}", std::variant()); - // Output: variant(monostate) - - -## Format String Compilation - -`fmt/compile.h` provides format string compilation enabled via the -`FMT_COMPILE` macro or the `_cf` user-defined literal defined in -namespace `fmt::literals`. Format strings marked with `FMT_COMPILE` -or `_cf` are parsed, checked and converted into efficient formatting -code at compile-time. This supports arguments of built-in and string -types as well as user-defined types with `format` functions taking -the format context type as a template parameter in their `formatter` -specializations. For example: - - template <> struct fmt::formatter { - constexpr auto parse(format_parse_context& ctx); - - template - auto format(const point& p, FormatContext& ctx) const; - }; - -Format string compilation can generate more binary code compared to the -default API and is only recommended in places where formatting is a -performance bottleneck. - -::: FMT_COMPILE - -::: operator""_cf - - -## Terminal Colors and Text Styles - -`fmt/color.h` provides support for terminal color and text style output. - -::: print(const text_style&, format_string, T&&...) - -::: fg(detail::color_type) - -::: bg(detail::color_type) - -::: styled(const T&, text_style) - - -## System APIs - -::: ostream - -::: windows_error - - -## `std::ostream` Support - -`fmt/ostream.h` provides `std::ostream` support including formatting of -user-defined types that have an overloaded insertion operator -(`operator<<`). In order to make a type formattable via `std::ostream` -you should provide a `formatter` specialization inherited from -`ostream_formatter`: - - #include - - struct date { - int year, month, day; - - friend std::ostream& operator<<(std::ostream& os, const date& d) { - return os << d.year << '-' << d.month << '-' << d.day; - } - }; - - template <> struct fmt::formatter : ostream_formatter {}; - - std::string s = fmt::format("The date is {}", date{2012, 12, 9}); - // s == "The date is 2012-12-9" - -::: streamed(const T&) - -::: print(std::ostream&, format_string, T&&...) - - -## Dynamic Argument Lists - -The header `fmt/args.h` provides `dynamic_format_arg_store`, a builder-like API -that can be used to construct format argument lists dynamically. - -::: dynamic_format_arg_store - - -## Safe `printf` - -The header `fmt/printf.h` provides `printf`-like formatting -functionality. The following functions use [printf format string -syntax](https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html) -with the POSIX extension for positional arguments. Unlike their standard -counterparts, the `fmt` functions are type-safe and throw an exception -if an argument type doesn't match its format specification. - -::: printf(string_view, const T&...) - -::: fprintf(std::FILE*, const S&, const T&...) - -::: sprintf(const S&, const T&...) - - -## Wide Strings - -The optional header `fmt/xchar.h` provides support for `wchar_t` and -exotic character types. - -::: is_char - -::: wstring_view - -::: wformat_context - -::: to_wstring(const T&) - -## Compatibility with C++20 `std::format` - -{fmt} implements nearly all of the [C++20 formatting -library](https://en.cppreference.com/w/cpp/utility/format) with the -following differences: - -- Names are defined in the `fmt` namespace instead of `std` to avoid - collisions with standard library implementations. -- Width calculation doesn't use grapheme clusterization. The latter has - been implemented in a separate branch but hasn't been integrated yet. diff --git a/third_party/fmt/doc/fmt.css b/third_party/fmt/doc/fmt.css deleted file mode 100644 index 994d6e2e..00000000 --- a/third_party/fmt/doc/fmt.css +++ /dev/null @@ -1,61 +0,0 @@ -:root { - --md-primary-fg-color: #0050D0; -} - -.md-grid { - max-width: 960px; -} - -@media (min-width: 400px) { - .md-tabs { - display: block; - } -} - -.docblock { - border-left: .05rem solid var(--md-primary-fg-color); -} - -.docblock-desc { - margin-left: 1em; -} - -pre > code.decl { - white-space: pre-wrap; -} - - -code.decl > div { - text-indent: -2ch; /* Negative indent to counteract the indent on the first line */ - padding-left: 2ch; /* Add padding to the left to create an indent */ -} - -.features-container { - display: flex; - flex-wrap: wrap; - gap: 20px; - justify-content: center; /* Center the items horizontally */ -} - -.feature { - flex: 1 1 calc(50% - 20px); /* Two columns with space between */ - max-width: 600px; /* Set the maximum width for the feature boxes */ - box-sizing: border-box; - padding: 10px; - overflow: hidden; /* Hide overflow content */ - text-overflow: ellipsis; /* Handle text overflow */ - white-space: normal; /* Allow text wrapping */ -} - -.feature h2 { - margin-top: 0px; - font-weight: bold; -} - -@media (max-width: 768px) { - .feature { - flex: 1 1 100%; /* Stack columns on smaller screens */ - max-width: 100%; /* Allow full width on smaller screens */ - white-space: normal; /* Allow text wrapping on smaller screens */ - } -} diff --git a/third_party/fmt/doc/fmt.js b/third_party/fmt/doc/fmt.js deleted file mode 100644 index da7e95b7..00000000 --- a/third_party/fmt/doc/fmt.js +++ /dev/null @@ -1,4 +0,0 @@ -document$.subscribe(() => { - hljs.highlightAll(), - { language: 'c++' } -}) diff --git a/third_party/fmt/doc/get-started.md b/third_party/fmt/doc/get-started.md deleted file mode 100644 index e61da882..00000000 --- a/third_party/fmt/doc/get-started.md +++ /dev/null @@ -1,222 +0,0 @@ -# Get Started - -Compile and run {fmt} examples online with [Compiler Explorer]( -https://godbolt.org/z/P7h6cd6o3). - -{fmt} is compatible with any build system. The next section describes its usage -with CMake, while the [Build Systems](#build-systems) section covers the rest. - -## CMake - -{fmt} provides two CMake targets: `fmt::fmt` for the compiled library and -`fmt::fmt-header-only` for the header-only library. It is recommended to use -the compiled library for improved build times. - -There are three primary ways to use {fmt} with CMake: - -* **FetchContent**: Starting from CMake 3.11, you can use [`FetchContent`]( - https://cmake.org/cmake/help/v3.30/module/FetchContent.html) to automatically - download {fmt} as a dependency at configure time: - - include(FetchContent) - - FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG e69e5f977d458f2650bb346dadf2ad30c5320281) # 10.2.1 - FetchContent_MakeAvailable(fmt) - - target_link_libraries( fmt::fmt) - -* **Installed**: You can find and use an [installed](#installation) version of - {fmt} in your `CMakeLists.txt` file as follows: - - find_package(fmt) - target_link_libraries( fmt::fmt) - -* **Embedded**: You can add the {fmt} source tree to your project and include it - in your `CMakeLists.txt` file: - - add_subdirectory(fmt) - target_link_libraries( fmt::fmt) - -## Installation - -### Debian/Ubuntu - -To install {fmt} on Debian, Ubuntu, or any other Debian-based Linux -distribution, use the following command: - - apt install libfmt-dev - -### Homebrew - -Install {fmt} on macOS using [Homebrew](https://brew.sh/): - - brew install fmt - -### Conda - -Install {fmt} on Linux, macOS, and Windows with [Conda]( -https://docs.conda.io/en/latest/), using its [conda-forge package]( -https://github.com/conda-forge/fmt-feedstock): - - conda install -c conda-forge fmt - -### vcpkg - -Download and install {fmt} using the vcpkg package manager: - - git clone https://github.com/Microsoft/vcpkg.git - cd vcpkg - ./bootstrap-vcpkg.sh - ./vcpkg integrate install - ./vcpkg install fmt - - - -## Building from Source - -CMake works by generating native makefiles or project files that can be -used in the compiler environment of your choice. The typical workflow -starts with: - - mkdir build # Create a directory to hold the build output. - cd build - cmake .. # Generate native build scripts. - -run in the `fmt` repository. - -If you are on a Unix-like system, you should now see a Makefile in the -current directory. Now you can build the library by running `make`. - -Once the library has been built you can invoke `make test` to run the tests. - -You can control generation of the make `test` target with the `FMT_TEST` -CMake option. This can be useful if you include fmt as a subdirectory in -your project but don't want to add fmt's tests to your `test` target. - -To build a shared library set the `BUILD_SHARED_LIBS` CMake variable to `TRUE`: - - cmake -DBUILD_SHARED_LIBS=TRUE .. - -To build a static library with position-independent code (e.g. for -linking it into another shared library such as a Python extension), set the -`CMAKE_POSITION_INDEPENDENT_CODE` CMake variable to `TRUE`: - - cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE .. - -After building the library you can install it on a Unix-like system by -running `sudo make install`. - -### Building the Docs - -To build the documentation you need the following software installed on -your system: - -- [Python](https://www.python.org/) -- [Doxygen](http://www.stack.nl/~dimitri/doxygen/) -- [MkDocs](https://www.mkdocs.org/) with `mkdocs-material`, `mkdocstrings`, - `pymdown-extensions` and `mike` - -First generate makefiles or project files using CMake as described in -the previous section. Then compile the `doc` target/project, for example: - - make doc - -This will generate the HTML documentation in `doc/html`. - -## Build Systems - -### build2 - -You can use [build2](https://build2.org), a dependency manager and a build -system, to use {fmt}. - -Currently this package is available in these package repositories: - -- for released and published versions. -- for unreleased or custom versions. - -**Usage:** - -- `build2` package name: `fmt` -- Library target name: `lib{fmt}` - -To make your `build2` project depend on `fmt`: - -- Add one of the repositories to your configurations, or in your - `repositories.manifest`, if not already there: - - : - role: prerequisite - location: https://pkg.cppget.org/1/stable - -- Add this package as a dependency to your `manifest` file (example - for version 10): - - depends: fmt ~10.0.0 - -- Import the target and use it as a prerequisite to your own target - using `fmt` in the appropriate `buildfile`: - - import fmt = fmt%lib{fmt} - lib{mylib} : cxx{**} ... $fmt - -Then build your project as usual with `b` or `bdep update`. - -### Meson - -[Meson WrapDB](https://mesonbuild.com/Wrapdb-projects.html) includes an `fmt` -package. - -**Usage:** - -- Install the `fmt` subproject from the WrapDB by running: - - meson wrap install fmt - - from the root of your project. - -- In your project's `meson.build` file, add an entry for the new subproject: - - fmt = subproject('fmt') - fmt_dep = fmt.get_variable('fmt_dep') - -- Include the new dependency object to link with fmt: - - my_build_target = executable( - 'name', 'src/main.cc', dependencies: [fmt_dep]) - -**Options:** - -If desired, {fmt} can be built as a static library, or as a header-only library. - -For a static build, use the following subproject definition: - - fmt = subproject('fmt', default_options: 'default_library=static') - fmt_dep = fmt.get_variable('fmt_dep') - -For the header-only version, use: - - fmt = subproject('fmt') - fmt_dep = fmt.get_variable('fmt_header_only_dep') - -### Android NDK - -{fmt} provides [Android.mk file]( -https://github.com/fmtlib/fmt/blob/master/support/Android.mk) that can be used -to build the library with [Android NDK]( -https://developer.android.com/tools/sdk/ndk/index.html). - -### Other - -To use the {fmt} library with any other build system, add -`include/fmt/base.h`, `include/fmt/format.h`, `include/fmt/format-inl.h`, -`src/format.cc` and optionally other headers from a [release archive]( -https://github.com/fmtlib/fmt/releases) or the [git repository]( -https://github.com/fmtlib/fmt) to your project, add `include` to include -directories and make sure `src/format.cc` is compiled and linked with your code. diff --git a/third_party/fmt/doc/index.md b/third_party/fmt/doc/index.md deleted file mode 100644 index 457857c4..00000000 --- a/third_party/fmt/doc/index.md +++ /dev/null @@ -1,151 +0,0 @@ ---- -hide: - - navigation - - toc ---- - -# A modern formatting library - -
- -
-

Safety

-

- Inspired by Python's formatting facility, {fmt} provides a safe replacement - for the printf family of functions. Errors in format strings, - which are a common source of vulnerabilities in C, are reported at - compile time. For example: - -

fmt::format("{:d}", "I am not a number");
- - will give a compile-time error because d is not a valid - format specifier for strings. APIs like - fmt::format prevent buffer overflow errors via - automatic memory management. -

-→ Learn more -
- -
-

Extensibility

-

- Formatting of most standard types, including all containers, dates, - and times is supported out-of-the-box. For example: - -

fmt::print("{}", std::vector{1, 2, 3});
- - prints the vector in a JSON-like format: - -
[1, 2, 3]
- - You can make your own types formattable and even make compile-time - checks work for them. -

-→ Learn more -
- -
-

Performance

-

- {fmt} can be anywhere from tens of percent to 20-30 times faster than - iostreams and sprintf, especially for numeric formatting. - - - - - - The library minimizes dynamic memory allocations and can optionally - compile format strings to optimal code. -

-
- -
-

Unicode support

-

- {fmt} provides portable Unicode support on major operating systems - with UTF-8 and char strings. For example: - -

fmt::print("Слава Україні!");
- - will be printed correctly on Linux, macOS, and even Windows console, - irrespective of the codepages. -

-

- The default is locale-independent, but you can opt into localized - formatting and {fmt} makes it work with Unicode, addressing issues in the - standard libary. -

-
- -
-

Fast compilation

-

- The library makes extensive use of type erasure to achieve fast - compilation. fmt/base.h provides a subset of the API with - minimal include dependencies and enough functionality to replace - all uses of *printf. -

-

- Code using {fmt} is usually several times faster to compile than the - equivalent iostreams code, and while printf compiles faster - still, the gap is narrowing. -

- -→ Learn more -
- -
-

Small binary footprint

-

- Type erasure is also used to prevent template bloat, resulting in compact - per-call binary code. For example, a call to fmt::print with - a single argument is just a few - instructions, comparable to printf despite adding - runtime safety, and much smaller than the equivalent iostreams code. -

-

- The library itself has small binary footprint and some components such as - floating-point formatting can be disabled to make it even smaller for - resource-constrained devices. -

-
- -
-

Portability

-

- {fmt} has a small self-contained codebase with the core consisting of - just three headers and no external dependencies. -

-

- The library is highly portable and requires only a minimal subset of - C++11 features which are available in GCC 4.8, Clang 3.4, MSVC 19.0 - (2015) and later. Newer compiler and standard library features are used - if available, and enable additional functionality. -

-

- Where possible, the output of formatting functions is consistent across - platforms. -

-

-
- -
-

Open source

-

- {fmt} is in the top hundred open-source C++ libraries on GitHub and has - hundreds of - all-time contributors. -

-

- The library is distributed under a permissive MIT - license and is - relied upon by many open-source projects, including Blender, PyTorch, - Apple's FoundationDB, Windows Terminal, MongoDB, and others. -

-
- -
diff --git a/third_party/fmt/doc/perf.svg b/third_party/fmt/doc/perf.svg deleted file mode 100644 index 7867a154..00000000 --- a/third_party/fmt/doc/perf.svg +++ /dev/null @@ -1 +0,0 @@ -double to string02505007501,0001,2501,500ostringstreamostrstreamsprintfdoubleconvfmtTime (ns), smaller is better \ No newline at end of file diff --git a/third_party/fmt/doc/python-license.txt b/third_party/fmt/doc/python-license.txt deleted file mode 100644 index 88eed1f9..00000000 --- a/third_party/fmt/doc/python-license.txt +++ /dev/null @@ -1,290 +0,0 @@ -A. HISTORY OF THE SOFTWARE -========================== - -Python was created in the early 1990s by Guido van Rossum at Stichting -Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands -as a successor of a language called ABC. Guido remains Python's -principal author, although it includes many contributions from others. - -In 1995, Guido continued his work on Python at the Corporation for -National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) -in Reston, Virginia where he released several versions of the -software. - -In May 2000, Guido and the Python core development team moved to -BeOpen.com to form the BeOpen PythonLabs team. In October of the same -year, the PythonLabs team moved to Digital Creations (now Zope -Corporation, see http://www.zope.com). In 2001, the Python Software -Foundation (PSF, see http://www.python.org/psf/) was formed, a -non-profit organization created specifically to own Python-related -Intellectual Property. Zope Corporation is a sponsoring member of -the PSF. - -All Python releases are Open Source (see http://www.opensource.org for -the Open Source Definition). Historically, most, but not all, Python -releases have also been GPL-compatible; the table below summarizes -the various releases. - - Release Derived Year Owner GPL- - from compatible? (1) - - 0.9.0 thru 1.2 1991-1995 CWI yes - 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes - 1.6 1.5.2 2000 CNRI no - 2.0 1.6 2000 BeOpen.com no - 1.6.1 1.6 2001 CNRI yes (2) - 2.1 2.0+1.6.1 2001 PSF no - 2.0.1 2.0+1.6.1 2001 PSF yes - 2.1.1 2.1+2.0.1 2001 PSF yes - 2.2 2.1.1 2001 PSF yes - 2.1.2 2.1.1 2002 PSF yes - 2.1.3 2.1.2 2002 PSF yes - 2.2.1 2.2 2002 PSF yes - 2.2.2 2.2.1 2002 PSF yes - 2.2.3 2.2.2 2003 PSF yes - 2.3 2.2.2 2002-2003 PSF yes - 2.3.1 2.3 2002-2003 PSF yes - 2.3.2 2.3.1 2002-2003 PSF yes - 2.3.3 2.3.2 2002-2003 PSF yes - 2.3.4 2.3.3 2004 PSF yes - 2.3.5 2.3.4 2005 PSF yes - 2.4 2.3 2004 PSF yes - 2.4.1 2.4 2005 PSF yes - 2.4.2 2.4.1 2005 PSF yes - 2.4.3 2.4.2 2006 PSF yes - 2.4.4 2.4.3 2006 PSF yes - 2.5 2.4 2006 PSF yes - 2.5.1 2.5 2007 PSF yes - 2.5.2 2.5.1 2008 PSF yes - 2.5.3 2.5.2 2008 PSF yes - 2.6 2.5 2008 PSF yes - 2.6.1 2.6 2008 PSF yes - 2.6.2 2.6.1 2009 PSF yes - 2.6.3 2.6.2 2009 PSF yes - 2.6.4 2.6.3 2009 PSF yes - 2.6.5 2.6.4 2010 PSF yes - 3.0 2.6 2008 PSF yes - 3.0.1 3.0 2009 PSF yes - 3.1 3.0.1 2009 PSF yes - 3.1.1 3.1 2009 PSF yes - 3.1.2 3.1.1 2010 PSF yes - 3.1.3 3.1.2 2010 PSF yes - 3.1.4 3.1.3 2011 PSF yes - 3.2 3.1 2011 PSF yes - 3.2.1 3.2 2011 PSF yes - 3.2.2 3.2.1 2011 PSF yes - 3.2.3 3.2.2 2012 PSF yes - 3.3.0 3.2 2012 PSF yes - -Footnotes: - -(1) GPL-compatible doesn't mean that we're distributing Python under - the GPL. All Python licenses, unlike the GPL, let you distribute - a modified version without making your changes open source. The - GPL-compatible licenses make it possible to combine Python with - other software that is released under the GPL; the others don't. - -(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, - because its license has a choice of law clause. According to - CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 - is "not incompatible" with the GPL. - -Thanks to the many outside volunteers who have worked under Guido's -direction to make these releases possible. - - -B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON -=============================================================== - -PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 --------------------------------------------- - -1. This LICENSE AGREEMENT is between the Python Software Foundation -("PSF"), and the Individual or Organization ("Licensee") accessing and -otherwise using this software ("Python") in source or binary form and -its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF hereby -grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, -analyze, test, perform and/or display publicly, prepare derivative works, -distribute, and otherwise use Python alone or in any derivative version, -provided, however, that PSF's License Agreement and PSF's notice of copyright, -i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -2011, 2012 Python Software Foundation; All Rights Reserved" are retained in Python -alone or in any derivative version prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python. - -4. PSF is making Python available to Licensee on an "AS IS" -basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between PSF and -Licensee. This License Agreement does not grant permission to use PSF -trademarks or trade name in a trademark sense to endorse or promote -products or services of Licensee, or any third party. - -8. By copying, installing or otherwise using Python, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - - -BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 -------------------------------------------- - -BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 - -1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an -office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the -Individual or Organization ("Licensee") accessing and otherwise using -this software in source or binary form and its associated -documentation ("the Software"). - -2. Subject to the terms and conditions of this BeOpen Python License -Agreement, BeOpen hereby grants Licensee a non-exclusive, -royalty-free, world-wide license to reproduce, analyze, test, perform -and/or display publicly, prepare derivative works, distribute, and -otherwise use the Software alone or in any derivative version, -provided, however, that the BeOpen Python License is retained in the -Software, alone or in any derivative version prepared by Licensee. - -3. BeOpen is making the Software available to Licensee on an "AS IS" -basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE -SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS -AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY -DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -5. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -6. This License Agreement shall be governed by and interpreted in all -respects by the law of the State of California, excluding conflict of -law provisions. Nothing in this License Agreement shall be deemed to -create any relationship of agency, partnership, or joint venture -between BeOpen and Licensee. This License Agreement does not grant -permission to use BeOpen trademarks or trade names in a trademark -sense to endorse or promote products or services of Licensee, or any -third party. As an exception, the "BeOpen Python" logos available at -http://www.pythonlabs.com/logos.html may be used according to the -permissions granted on that web page. - -7. By copying, installing or otherwise using the software, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - - -CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 ---------------------------------------- - -1. This LICENSE AGREEMENT is between the Corporation for National -Research Initiatives, having an office at 1895 Preston White Drive, -Reston, VA 20191 ("CNRI"), and the Individual or Organization -("Licensee") accessing and otherwise using Python 1.6.1 software in -source or binary form and its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, CNRI -hereby grants Licensee a nonexclusive, royalty-free, world-wide -license to reproduce, analyze, test, perform and/or display publicly, -prepare derivative works, distribute, and otherwise use Python 1.6.1 -alone or in any derivative version, provided, however, that CNRI's -License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) -1995-2001 Corporation for National Research Initiatives; All Rights -Reserved" are retained in Python 1.6.1 alone or in any derivative -version prepared by Licensee. Alternately, in lieu of CNRI's License -Agreement, Licensee may substitute the following text (omitting the -quotes): "Python 1.6.1 is made available subject to the terms and -conditions in CNRI's License Agreement. This Agreement together with -Python 1.6.1 may be located on the Internet using the following -unique, persistent identifier (known as a handle): 1895.22/1013. This -Agreement may also be obtained from a proxy server on the Internet -using the following URL: http://hdl.handle.net/1895.22/1013". - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python 1.6.1 or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python 1.6.1. - -4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" -basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. This License Agreement shall be governed by the federal -intellectual property law of the United States, including without -limitation the federal copyright law, and, to the extent such -U.S. federal law does not apply, by the law of the Commonwealth of -Virginia, excluding Virginia's conflict of law provisions. -Notwithstanding the foregoing, with regard to derivative works based -on Python 1.6.1 that incorporate non-separable material that was -previously distributed under the GNU General Public License (GPL), the -law of the Commonwealth of Virginia shall govern this License -Agreement only as to issues arising under or with respect to -Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this -License Agreement shall be deemed to create any relationship of -agency, partnership, or joint venture between CNRI and Licensee. This -License Agreement does not grant permission to use CNRI trademarks or -trade name in a trademark sense to endorse or promote products or -services of Licensee, or any third party. - -8. By clicking on the "ACCEPT" button where indicated, or by copying, -installing or otherwise using Python 1.6.1, Licensee agrees to be -bound by the terms and conditions of this License Agreement. - - ACCEPT - - -CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 --------------------------------------------------- - -Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, -The Netherlands. All rights reserved. - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/third_party/fmt/doc/syntax.md b/third_party/fmt/doc/syntax.md deleted file mode 100644 index 87fa53f8..00000000 --- a/third_party/fmt/doc/syntax.md +++ /dev/null @@ -1,887 +0,0 @@ -# Format String Syntax - -Formatting functions such as [`fmt::format`](api.md#format) and [`fmt::print`]( -api.md#print) use the same format string syntax described in this section. - -Format strings contain "replacement fields" surrounded by curly braces `{}`. -Anything that is not contained in braces is considered literal text, which is -copied unchanged to the output. If you need to include a brace character in -the literal text, it can be escaped by doubling: `{{` and `}}`. - -The grammar for a replacement field is as follows: - - -
replacement_field ::= "{" [arg_id] [":" (format_spec | chrono_format_spec)] "}"
-arg_id            ::= integer | identifier
-integer           ::= digit+
-digit             ::= "0"..."9"
-identifier        ::= id_start id_continue*
-id_start          ::= "a"..."z" | "A"..."Z" | "_"
-id_continue       ::= id_start | digit
-
- -In less formal terms, the replacement field can start with an *arg_id* that -specifies the argument whose value is to be formatted and inserted into the -output instead of the replacement field. The *arg_id* is optionally followed -by a *format_spec*, which is preceded by a colon `':'`. These specify a -non-default format for the replacement value. - -See also the [Format Specification -Mini-Language](#format-specification-mini-language) section. - -If the numerical arg_ids in a format string are 0, 1, 2, ... in sequence, -they can all be omitted (not just some) and the numbers 0, 1, 2, ... will be -automatically inserted in that order. - -Named arguments can be referred to by their names or indices. - -Some simple format string examples: - -```c++ -"First, thou shalt count to {0}" // References the first argument -"Bring me a {}" // Implicitly references the first argument -"From {} to {}" // Same as "From {0} to {1}" -``` - -The *format_spec* field contains a specification of how the value should -be presented, including such details as field width, alignment, padding, -decimal precision and so on. Each value type can define its own -"formatting mini-language" or interpretation of the *format_spec*. - -Most built-in types support a common formatting mini-language, which is -described in the next section. - -A *format_spec* field can also include nested replacement fields in -certain positions within it. These nested replacement fields can contain -only an argument id; format specifications are not allowed. This allows -the formatting of a value to be dynamically specified. - -See the [Format Examples](#format-examples) section for some examples. - -## Format Specification Mini-Language - -"Format specifications" are used within replacement fields contained within a -format string to define how individual values are presented. Each formattable -type may define how the format specification is to be interpreted. - -Most built-in types implement the following options for format -specifications, although some of the formatting options are only -supported by the numeric types. - -The general form of a *standard format specifier* is: - - -
format_spec ::= [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type]
-fill        ::= <a character other than '{' or '}'>
-align       ::= "<" | ">" | "^"
-sign        ::= "+" | "-" | " "
-width       ::= integer | "{" [arg_id] "}"
-precision   ::= integer | "{" [arg_id] "}"
-type        ::= "a" | "A" | "b" | "B" | "c" | "d" | "e" | "E" | "f" | "F" |
-                "g" | "G" | "o" | "p" | "s" | "x" | "X" | "?"
-
- -The *fill* character can be any Unicode code point other than `'{'` or `'}'`. -The presence of a fill character is signaled by the character following it, -which must be one of the alignment options. If the second character of -*format_spec* is not a valid alignment option, then it is assumed that both -the fill character and the alignment option are absent. - -The meaning of the various alignment options is as follows: - - - - - - - - - - - - - - - - - - -
OptionMeaning
'<' - Forces the field to be left-aligned within the available space (this is the - default for most objects). -
'>' - Forces the field to be right-aligned within the available space (this is - the default for numbers). -
'^'Forces the field to be centered within the available space.
- -Note that unless a minimum field width is defined, the field width will -always be the same size as the data to fill it, so that the alignment -option has no meaning in this case. - -The *sign* option is only valid for floating point and signed integer types, -and can be one of the following: - - - - - - - - - - - - - - - - - - -
OptionMeaning
'+' - Indicates that a sign should be used for both nonnegative as well as - negative numbers. -
'-' - Indicates that a sign should be used only for negative numbers (this is the - default behavior). -
space - Indicates that a leading space should be used on nonnegative numbers, and a - minus sign on negative numbers. -
- -The `'#'` option causes the "alternate form" to be used for the -conversion. The alternate form is defined differently for different -types. This option is only valid for integer and floating-point types. -For integers, when binary, octal, or hexadecimal output is used, this -option adds the prefix respective `"0b"` (`"0B"`), `"0"`, or `"0x"` -(`"0X"`) to the output value. Whether the prefix is lower-case or -upper-case is determined by the case of the type specifier, for example, -the prefix `"0x"` is used for the type `'x'` and `"0X"` is used for -`'X'`. For floating-point numbers the alternate form causes the result -of the conversion to always contain a decimal-point character, even if -no digits follow it. Normally, a decimal-point character appears in the -result of these conversions only if a digit follows it. In addition, for -`'g'` and `'G'` conversions, trailing zeros are not removed from the -result. - -*width* is a decimal integer defining the minimum field width. If not -specified, then the field width will be determined by the content. - -Preceding the *width* field by a zero (`'0'`) character enables -sign-aware zero-padding for numeric types. It forces the padding to be -placed after the sign or base (if any) but before the digits. This is -used for printing fields in the form "+000000120". This option is only -valid for numeric types and it has no effect on formatting of infinity -and NaN. This option is ignored when any alignment specifier is present. - -The *precision* is a decimal number indicating how many digits should be -displayed after the decimal point for a floating-point value formatted -with `'f'` and `'F'`, or before and after the decimal point for a -floating-point value formatted with `'g'` or `'G'`. For non-number types -the field indicates the maximum field size - in other words, how many -characters will be used from the field content. The *precision* is not -allowed for integer, character, Boolean, and pointer values. Note that a -C string must be null-terminated even if precision is specified. - -The `'L'` option uses the current locale setting to insert the appropriate -number separator characters. This option is only valid for numeric types. - -Finally, the *type* determines how the data should be presented. - -The available string presentation types are: - - - - - - - - - - - - - - - - - - -
TypeMeaning
's' - String format. This is the default type for strings and may be omitted. -
'?'Debug format. The string is quoted and special characters escaped.
noneThe same as 's'.
- -The available character presentation types are: - - - - - - - - - - - - - - - - - - -
TypeMeaning
'c' - Character format. This is the default type for characters and may be - omitted. -
'?'Debug format. The character is quoted and special characters escaped.
noneThe same as 'c'.
- -The available integer presentation types are: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeMeaning
'b' - Binary format. Outputs the number in base 2. Using the '#' - option with this type adds the prefix "0b" to the output value. -
'B' - Binary format. Outputs the number in base 2. Using the '#' - option with this type adds the prefix "0B" to the output value. -
'c'Character format. Outputs the number as a character.
'd'Decimal integer. Outputs the number in base 10.
'o'Octal format. Outputs the number in base 8.
'x' - Hex format. Outputs the number in base 16, using lower-case letters for the - digits above 9. Using the '#' option with this type adds the - prefix "0x" to the output value. -
'X' - Hex format. Outputs the number in base 16, using upper-case letters for the - digits above 9. Using the '#' option with this type adds the - prefix "0X" to the output value. -
noneThe same as 'd'.
- -Integer presentation types can also be used with character and Boolean values -with the only exception that `'c'` cannot be used with `bool`. Boolean values -are formatted using textual representation, either `true` or `false`, if the -presentation type is not specified. - -The available presentation types for floating-point values are: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeMeaning
'a' - Hexadecimal floating point format. Prints the number in base 16 with - prefix "0x" and lower-case letters for digits above 9. - Uses 'p' to indicate the exponent. -
'A' - Same as 'a' except it uses upper-case letters for the - prefix, digits above 9 and to indicate the exponent. -
'e' - Exponent notation. Prints the number in scientific notation using - the letter 'e' to indicate the exponent. -
'E' - Exponent notation. Same as 'e' except it uses an - upper-case 'E' as the separator character. -
'f'Fixed point. Displays the number as a fixed-point number.
'F' - Fixed point. Same as 'f', but converts nan - to NAN and inf to INF. -
'g' -

General format. For a given precision p >= 1, - this rounds the number to p significant digits and then - formats the result in either fixed-point format or in scientific - notation, depending on its magnitude.

-

A precision of 0 is treated as equivalent to a precision - of 1.

-
'G' - General format. Same as 'g' except switches to - 'E' if the number gets too large. The representations of - infinity and NaN are uppercased, too. -
none - Similar to 'g', except that the default precision is as - high as needed to represent the particular value. -
- -The available presentation types for pointers are: - - - - - - - - - - - - - - -
TypeMeaning
'p' - Pointer format. This is the default type for pointers and may be omitted. -
noneThe same as 'p'.
- -## Chrono Format Specifications - -Format specifications for chrono duration and time point types as well as -`std::tm` have the following syntax: - - -
chrono_format_spec ::= [[fill]align][width]["." precision][chrono_specs]
-chrono_specs       ::= conversion_spec |
-                       chrono_specs (conversion_spec | literal_char)
-conversion_spec    ::= "%" [padding_modifier] [locale_modifier] chrono_type
-literal_char       ::= <a character other than '{', '}' or '%'>
-padding_modifier   ::= "-" | "_"  | "0"
-locale_modifier    ::= "E" | "O"
-chrono_type        ::= "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" |
-                       "F" | "g" | "G" | "h" | "H" | "I" | "j" | "m" | "M" |
-                       "n" | "p" | "q" | "Q" | "r" | "R" | "S" | "t" | "T" |
-                       "u" | "U" | "V" | "w" | "W" | "x" | "X" | "y" | "Y" |
-                       "z" | "Z" | "%"
-
- -Literal chars are copied unchanged to the output. Precision is valid only -for `std::chrono::duration` types with a floating-point representation type. - -The available presentation types (*chrono_type*) are: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TypeMeaning
'a' - The abbreviated weekday name, e.g. "Sat". If the value does not contain a - valid weekday, an exception of type format_error is thrown. -
'A' - The full weekday name, e.g. "Saturday". If the value does not contain a - valid weekday, an exception of type format_error is thrown. -
'b' - The abbreviated month name, e.g. "Nov". If the value does not contain a - valid month, an exception of type format_error is thrown. -
'B' - The full month name, e.g. "November". If the value does not contain a valid - month, an exception of type format_error is thrown. -
'c' - The date and time representation, e.g. "Sat Nov 12 22:04:00 1955". The - modified command %Ec produces the locale's alternate date and - time representation. -
'C' - The year divided by 100 using floored division, e.g. "19". If the result - is a single decimal digit, it is prefixed with 0. The modified command - %EC produces the locale's alternative representation of the - century. -
'd' - The day of month as a decimal number. If the result is a single decimal - digit, it is prefixed with 0. The modified command %Od - produces the locale's alternative representation. -
'D'Equivalent to %m/%d/%y, e.g. "11/12/55".
'e' - The day of month as a decimal number. If the result is a single decimal - digit, it is prefixed with a space. The modified command %Oe - produces the locale's alternative representation. -
'F'Equivalent to %Y-%m-%d, e.g. "1955-11-12".
'g' - The last two decimal digits of the ISO week-based year. If the result is a - single digit it is prefixed by 0. -
'G' - The ISO week-based year as a decimal number. If the result is less than - four digits it is left-padded with 0 to four digits. -
'h'Equivalent to %b, e.g. "Nov".
'H' - The hour (24-hour clock) as a decimal number. If the result is a single - digit, it is prefixed with 0. The modified command %OH - produces the locale's alternative representation. -
'I' - The hour (12-hour clock) as a decimal number. If the result is a single - digit, it is prefixed with 0. The modified command %OI - produces the locale's alternative representation. -
'j' - If the type being formatted is a specialization of duration, the decimal - number of days without padding. Otherwise, the day of the year as a decimal - number. Jan 1 is 001. If the result is less than three digits, it is - left-padded with 0 to three digits. -
'm' - The month as a decimal number. Jan is 01. If the result is a single digit, - it is prefixed with 0. The modified command %Om produces the - locale's alternative representation. -
'M' - The minute as a decimal number. If the result is a single digit, it - is prefixed with 0. The modified command %OM produces the - locale's alternative representation. -
'n'A new-line character.
'p'The AM/PM designations associated with a 12-hour clock.
'q'The duration's unit suffix.
'Q' - The duration's numeric value (as if extracted via .count()). -
'r'The 12-hour clock time, e.g. "10:04:00 PM".
'R'Equivalent to %H:%M, e.g. "22:04".
'S' - Seconds as a decimal number. If the number of seconds is less than 10, the - result is prefixed with 0. If the precision of the input cannot be exactly - represented with seconds, then the format is a decimal floating-point number - with a fixed format and a precision matching that of the precision of the - input (or to a microseconds precision if the conversion to floating-point - decimal seconds cannot be made within 18 fractional digits). The character - for the decimal point is localized according to the locale. The modified - command %OS produces the locale's alternative representation. -
't'A horizontal-tab character.
'T'Equivalent to %H:%M:%S.
'u' - The ISO weekday as a decimal number (1-7), where Monday is 1. The modified - command %Ou produces the locale's alternative representation. -
'U' - The week number of the year as a decimal number. The first Sunday of the - year is the first day of week 01. Days of the same year prior to that are - in week 00. If the result is a single digit, it is prefixed with 0. - The modified command %OU produces the locale's alternative - representation. -
'V' - The ISO week-based week number as a decimal number. If the result is a - single digit, it is prefixed with 0. The modified command %OV - produces the locale's alternative representation. -
'w' - The weekday as a decimal number (0-6), where Sunday is 0. The modified - command %Ow produces the locale's alternative representation. -
'W' - The week number of the year as a decimal number. The first Monday of the - year is the first day of week 01. Days of the same year prior to that are - in week 00. If the result is a single digit, it is prefixed with 0. - The modified command %OW produces the locale's alternative - representation. -
'x' - The date representation, e.g. "11/12/55". The modified command - %Ex produces the locale's alternate date representation. -
'X' - The time representation, e.g. "10:04:00". The modified command - %EX produces the locale's alternate time representation. -
'y' - The last two decimal digits of the year. If the result is a single digit - it is prefixed by 0. The modified command %Oy produces the - locale's alternative representation. The modified command %Ey - produces the locale's alternative representation of offset from - %EC (year only). -
'Y' - The year as a decimal number. If the result is less than four digits it is - left-padded with 0 to four digits. The modified command %EY - produces the locale's alternative full year representation. -
'z' - The offset from UTC in the ISO 8601:2004 format. For example -0430 refers - to 4 hours 30 minutes behind UTC. If the offset is zero, +0000 is used. - The modified commands %Ez and %Oz insert a - : between the hours and minutes: -04:30. If the offset - information is not available, an exception of type - format_error is thrown. -
'Z' - The time zone abbreviation. If the time zone abbreviation is not available, - an exception of type format_error is thrown. -
'%'A % character.
- -Specifiers that have a calendaric component such as `'d'` (the day of month) -are valid only for `std::tm` and time points but not durations. - -The available padding modifiers (*padding_modifier*) are: - -| Type | Meaning | -|-------|-----------------------------------------| -| `'-'` | Pad a numeric result with spaces. | -| `'_'` | Do not pad a numeric result string. | -| `'0'` | Pad a numeric result string with zeros. | - -These modifiers are only supported for the `'H'`, `'I'`, `'M'`, `'S'`, `'U'`, -`'V'` and `'W'` presentation types. - -## Range Format Specifications - -Format specifications for range types have the following syntax: - -
range_format_spec ::= ["n"][range_type][range_underlying_spec]
-
- -The `'n'` option formats the range without the opening and closing brackets. - -The available presentation types for `range_type` are: - -| Type | Meaning | -|--------|------------------------------------------------------------| -| none | Default format. | -| `'s'` | String format. The range is formatted as a string. | -| `'?⁠s'` | Debug format. The range is formatted as an escaped string. | - -If `range_type` is `'s'` or `'?s'`, the range element type must be a character -type. The `'n'` option and `range_underlying_spec` are mutually exclusive with -`'s'` and `'?s'`. - -The `range_underlying_spec` is parsed based on the formatter of the range's -element type. - -By default, a range of characters or strings is printed escaped and quoted. -But if any `range_underlying_spec` is provided (even if it is empty), then the -characters or strings are printed according to the provided specification. - -Examples: - -```c++ -fmt::print("{}", std::vector{10, 20, 30}); -// Output: [10, 20, 30] -fmt::print("{::#x}", std::vector{10, 20, 30}); -// Output: [0xa, 0x14, 0x1e] -fmt::print("{}", std::vector{'h', 'e', 'l', 'l', 'o'}); -// Output: ['h', 'e', 'l', 'l', 'o'] -fmt::print("{:n}", std::vector{'h', 'e', 'l', 'l', 'o'}); -// Output: 'h', 'e', 'l', 'l', 'o' -fmt::print("{:s}", std::vector{'h', 'e', 'l', 'l', 'o'}); -// Output: "hello" -fmt::print("{:?s}", std::vector{'h', 'e', 'l', 'l', 'o', '\n'}); -// Output: "hello\n" -fmt::print("{::}", std::vector{'h', 'e', 'l', 'l', 'o'}); -// Output: [h, e, l, l, o] -fmt::print("{::d}", std::vector{'h', 'e', 'l', 'l', 'o'}); -// Output: [104, 101, 108, 108, 111] -``` - -## Format Examples - -This section contains examples of the format syntax and comparison with -the printf formatting. - -In most of the cases the syntax is similar to the printf formatting, -with the addition of the `{}` and with `:` used instead of `%`. For -example, `"%03.2f"` can be translated to `"{:03.2f}"`. - -The new format syntax also supports new and different options, shown in -the following examples. - -Accessing arguments by position: - -```c++ -fmt::format("{0}, {1}, {2}", 'a', 'b', 'c'); -// Result: "a, b, c" -fmt::format("{}, {}, {}", 'a', 'b', 'c'); -// Result: "a, b, c" -fmt::format("{2}, {1}, {0}", 'a', 'b', 'c'); -// Result: "c, b, a" -fmt::format("{0}{1}{0}", "abra", "cad"); // arguments' indices can be repeated -// Result: "abracadabra" -``` - -Aligning the text and specifying a width: - -```c++ -fmt::format("{:<30}", "left aligned"); -// Result: "left aligned " -fmt::format("{:>30}", "right aligned"); -// Result: " right aligned" -fmt::format("{:^30}", "centered"); -// Result: " centered " -fmt::format("{:*^30}", "centered"); // use '*' as a fill char -// Result: "***********centered***********" -``` - -Dynamic width: - -```c++ -fmt::format("{:<{}}", "left aligned", 30); -// Result: "left aligned " -``` - -Dynamic precision: - -```c++ -fmt::format("{:.{}f}", 3.14, 1); -// Result: "3.1" -``` - -Replacing `%+f`, `%-f`, and `% f` and specifying a sign: - -```c++ -fmt::format("{:+f}; {:+f}", 3.14, -3.14); // show it always -// Result: "+3.140000; -3.140000" -fmt::format("{: f}; {: f}", 3.14, -3.14); // show a space for positive numbers -// Result: " 3.140000; -3.140000" -fmt::format("{:-f}; {:-f}", 3.14, -3.14); // show only the minus -- same as '{:f}; {:f}' -// Result: "3.140000; -3.140000" -``` - -Replacing `%x` and `%o` and converting the value to different bases: - -```c++ -fmt::format("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); -// Result: "int: 42; hex: 2a; oct: 52; bin: 101010" -// with 0x or 0 or 0b as prefix: -fmt::format("int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}", 42); -// Result: "int: 42; hex: 0x2a; oct: 052; bin: 0b101010" -``` - -Padded hex byte with prefix and always prints both hex characters: - -```c++ -fmt::format("{:#04x}", 0); -// Result: "0x00" -``` - -Box drawing using Unicode fill: - -```c++ -fmt::print( - "┌{0:─^{2}}┐\n" - "│{1: ^{2}}│\n" - "└{0:─^{2}}┘\n", "", "Hello, world!", 20); -``` - -prints: - -``` -┌────────────────────┐ -│ Hello, world! │ -└────────────────────┘ -``` - -Using type-specific formatting: - -```c++ -#include - -auto t = tm(); -t.tm_year = 2010 - 1900; -t.tm_mon = 7; -t.tm_mday = 4; -t.tm_hour = 12; -t.tm_min = 15; -t.tm_sec = 58; -fmt::print("{:%Y-%m-%d %H:%M:%S}", t); -// Prints: 2010-08-04 12:15:58 -``` - -Using the comma as a thousands separator: - -```c++ -#include - -auto s = fmt::format(std::locale("en_US.UTF-8"), "{:L}", 1234567890); -// s == "1,234,567,890" -``` diff --git a/third_party/fmt/support/Android.mk b/third_party/fmt/support/Android.mk deleted file mode 100644 index 84a3e32f..00000000 --- a/third_party/fmt/support/Android.mk +++ /dev/null @@ -1,15 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := fmt_static -LOCAL_MODULE_FILENAME := libfmt - -LOCAL_SRC_FILES := ../src/format.cc - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) - -LOCAL_CFLAGS += -std=c++11 -fexceptions - -include $(BUILD_STATIC_LIBRARY) - diff --git a/third_party/fmt/support/AndroidManifest.xml b/third_party/fmt/support/AndroidManifest.xml deleted file mode 100644 index c282ef5a..00000000 --- a/third_party/fmt/support/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/third_party/fmt/support/C++.sublime-syntax b/third_party/fmt/support/C++.sublime-syntax deleted file mode 100644 index 9dfb5cbe..00000000 --- a/third_party/fmt/support/C++.sublime-syntax +++ /dev/null @@ -1,2061 +0,0 @@ -%YAML 1.2 ---- -# http://www.sublimetext.com/docs/3/syntax.html -name: C++ (fmt) -comment: I don't think anyone uses .hp. .cp tends to be paired with .h. (I could be wrong. :) -- chris -file_extensions: - - cpp - - cc - - cp - - cxx - - c++ - - C - - h - - hh - - hpp - - hxx - - h++ - - inl - - ipp -first_line_match: '-\*- C\+\+ -\*-' -scope: source.c++ -variables: - identifier: \b[[:alpha:]_][[:alnum:]_]*\b # upper and lowercase - macro_identifier: \b[[:upper:]_][[:upper:][:digit:]_]{2,}\b # only uppercase, at least 3 chars - path_lookahead: '(?:::\s*)?(?:{{identifier}}\s*::\s*)*(?:template\s+)?{{identifier}}' - operator_method_name: '\boperator\s*(?:[-+*/%^&|~!=<>]|[-+*/%^&|=!<>]=|<<=?|>>=?|&&|\|\||\+\+|--|,|->\*?|\(\)|\[\]|""\s*{{identifier}})' - casts: 'const_cast|dynamic_cast|reinterpret_cast|static_cast' - operator_keywords: 'and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq|noexcept' - control_keywords: 'break|case|catch|continue|default|do|else|for|goto|if|_Pragma|return|switch|throw|try|while' - memory_operators: 'new|delete' - basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void' - before_tag: 'struct|union|enum\s+class|enum\s+struct|enum|class' - declspec: '__declspec\(\s*\w+(?:\([^)]+\))?\s*\)' - storage_classes: 'static|export|extern|friend|explicit|virtual|register|thread_local' - type_qualifier: 'const|constexpr|mutable|typename|volatile' - compiler_directive: 'inline|restrict|__restrict__|__restrict' - visibility_modifiers: 'private|protected|public' - other_keywords: 'typedef|nullptr|{{visibility_modifiers}}|static_assert|sizeof|using|typeid|alignof|alignas|namespace|template' - modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}' - non_angle_brackets: '(?=<<|<=)' - - regular: '[^(){}&;*^%=<>-]*' - paren_open: (?:\( - paren_close: '\))?' - generic_open: (?:< - generic_close: '>)?' - balance_parentheses: '{{regular}}{{paren_open}}{{regular}}{{paren_close}}{{regular}}' - generic_lookahead: <{{regular}}{{generic_open}}{{regular}}{{generic_open}}{{regular}}{{generic_close}}\s*{{generic_close}}{{balance_parentheses}}> - - data_structures_forward_decl_lookahead: '(\s+{{macro_identifier}})*\s*(:\s*({{path_lookahead}}|{{visibility_modifiers}}|,|\s|<[^;]*>)+)?;' - non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__|typeid|alignof|alignas|static_assert' - - format_spec: |- - (?x: - (?:.? [<>=^])? # fill align - [ +-]? # sign - \#? # alternate form - # technically, octal and hexadecimal integers are also supported as 'width', but rarely used - \d* # width - ,? # thousands separator - (?:\.\d+)? # precision - [bcdeEfFgGnosxX%]? # type - ) - -contexts: - main: - - include: preprocessor-global - - include: global - - ############################################################################# - # Reusable contexts - # - # The follow contexts are currently constructed to be reused in the - # Objetive-C++ syntax. They are specifically constructed to not push into - # sub-contexts, which ensures that Objective-C++ code isn't accidentally - # lexed as plain C++. - # - # The "unique-*" contexts are additions that C++ makes over C, and thus can - # be directly reused in Objective-C++ along with contexts from Objective-C - # and C. - ############################################################################# - - unique-late-expressions: - # This is highlighted after all of the other control keywords - # to allow operator overloading to be lexed properly - - match: \boperator\b - scope: keyword.control.c++ - - unique-modifiers: - - match: \b({{modifiers}})\b - scope: storage.modifier.c++ - - unique-variables: - - match: \bthis\b - scope: variable.language.c++ - # common C++ instance var naming idiom -- fMemberName - - match: '\b(f|m)[[:upper:]]\w*\b' - scope: variable.other.readwrite.member.c++ - # common C++ instance var naming idiom -- m_member_name - - match: '\bm_[[:alnum:]_]+\b' - scope: variable.other.readwrite.member.c++ - - unique-constants: - - match: \bnullptr\b - scope: constant.language.c++ - - unique-keywords: - - match: \busing\b - scope: keyword.control.c++ - - match: \bbreak\b - scope: keyword.control.flow.break.c++ - - match: \bcontinue\b - scope: keyword.control.flow.continue.c++ - - match: \bgoto\b - scope: keyword.control.flow.goto.c++ - - match: \breturn\b - scope: keyword.control.flow.return.c++ - - match: \bthrow\b - scope: keyword.control.flow.throw.c++ - - match: \b({{control_keywords}})\b - scope: keyword.control.c++ - - match: '\bdelete\b(\s*\[\])?|\bnew\b(?!])' - scope: keyword.control.c++ - - match: \b({{operator_keywords}})\b - scope: keyword.operator.word.c++ - - unique-types: - - match: \b(char16_t|char32_t|wchar_t|nullptr_t)\b - scope: storage.type.c++ - - match: \bclass\b - scope: storage.type.c++ - - unique-strings: - - match: '((?:L|u8|u|U)?R)("([^\(\)\\ ]{0,16})\()' - captures: - 1: storage.type.string.c++ - 2: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.double.c++ - - match: '\)\3"' - scope: punctuation.definition.string.end.c++ - pop: true - - match: '\{\{|\}\}' - scope: constant.character.escape.c++ - - include: formatting-syntax - - unique-numbers: - - match: |- - (?x) - (?: - # floats - (?: - (?:\b\d(?:[\d']*\d)?\.\d(?:[\d']*\d)?|\B\.\d(?:[\d']*\d)?)(?:[Ee][+-]?\d(?:[\d']*\d)?)?(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))?\b - | - (?:\b\d(?:[\d']*\d)?\.)(?:\B|(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))\b|(?:[Ee][+-]?\d(?:[\d']*\d)?)(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))?\b) - | - \b\d(?:[\d']*\d)?(?:[Ee][+-]?\d(?:[\d']*\d)?)(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\w*))?\b - ) - | - # ints - \b(?: - (?: - # dec - [1-9](?:[\d']*\d)? - | - # oct - 0(?:[0-7']*[0-7])? - | - # hex - 0[Xx][\da-fA-F](?:[\da-fA-F']*[\da-fA-F])? - | - # bin - 0[Bb][01](?:[01']*[01])? - ) - # int suffixes - (?:(?:l{1,2}|L{1,2})[uU]?|[uU](?:l{0,2}|L{0,2})|(?:i[fl]?|h|min|[mun]?s|_\w*))?)\b - ) - (?!\.) # Number must not be followed by a decimal point - scope: constant.numeric.c++ - - identifiers: - - match: '{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.c++ - - match: '(?:(::)\s*)?{{identifier}}' - captures: - 1: punctuation.accessor.c++ - - function-specifiers: - - match: \b(const|final|noexcept|override)\b - scope: storage.modifier.c++ - - ############################################################################# - # The following are C++-specific contexts that should not be reused. This is - # because they push into subcontexts and use variables that are C++-specific. - ############################################################################# - - ## Common context layout - - global: - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: global-modifier - - include: namespace - - include: keywords-angle-brackets - - match: '(?={{path_lookahead}}\s*<)' - push: global-modifier - # Take care of comments just before a function definition. - - match: /\* - scope: punctuation.definition.comment.c - push: - - - match: \s*(?=\w) - set: global-modifier - - match: "" - pop: true - - - meta_scope: comment.block.c - - match: \*/ - scope: punctuation.definition.comment.c - pop: true - - include: early-expressions - - match: ^\s*\b(extern)(?=\s+"C(\+\+)?") - scope: storage.modifier.c++ - push: - - include: comments - - include: strings - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_scope: meta.extern-c.c++ - - match: '^\s*(#\s*ifdef)\s*__cplusplus\s*' - scope: meta.preprocessor.c++ - captures: - 1: keyword.control.import.c++ - set: - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: preprocessor-global - - include: global - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: preprocessor-global - - include: global - - match: (?=\S) - set: global-modifier - - match: ^\s*(?=\w) - push: global-modifier - - include: late-expressions - - statements: - - include: preprocessor-statements - - include: scope:source.c#label - - include: expressions - - expressions: - - include: early-expressions - - include: late-expressions - - early-expressions: - - include: early-expressions-before-generic-type - - include: generic-type - - include: early-expressions-after-generic-type - - early-expressions-before-generic-type: - - include: preprocessor-expressions - - include: comments - - include: case-default - - include: typedef - - include: keywords-angle-brackets - - include: keywords-parens - - include: keywords - - include: numbers - # Prevent a '<' from getting scoped as the start of another template - # parameter list, if in reality a less-than-or-equals sign is meant. - - match: <= - scope: keyword.operator.comparison.c - - early-expressions-after-generic-type: - - include: members-arrow - - include: operators - - include: members-dot - - include: strings - - include: parens - - include: brackets - - include: block - - include: variables - - include: constants - - match: ',' - scope: punctuation.separator.c++ - - match: '\)|\}' - scope: invalid.illegal.stray-bracket-end.c++ - - expressions-minus-generic-type: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions - - expressions-minus-generic-type-function-call: - - include: early-expressions-before-generic-type - - include: angle-brackets - - include: early-expressions-after-generic-type - - include: late-expressions-before-function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - late-expressions: - - include: late-expressions-before-function-call - - include: function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - late-expressions-before-function-call: - - include: unique-late-expressions - - include: modifiers-parens - - include: modifiers - - include: types - - expressions-minus-function-call: - - include: early-expressions - - include: late-expressions-before-function-call - - include: identifiers - - match: ';' - scope: punctuation.terminator.c++ - - comments: - - include: scope:source.c#comments - - operators: - - include: scope:source.c#operators - - modifiers: - - include: unique-modifiers - - include: scope:source.c#modifiers - - variables: - - include: unique-variables - - include: scope:source.c#variables - - constants: - - include: unique-constants - - include: scope:source.c#constants - - keywords: - - include: unique-keywords - - include: scope:source.c#keywords - - types: - - include: unique-types - - include: types-parens - - include: scope:source.c#types - - strings: - - include: unique-strings - - match: '(L|u8|u|U)?(")' - captures: - 1: storage.type.string.c++ - 2: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.double.c++ - - match: '"' - scope: punctuation.definition.string.end.c++ - pop: true - - include: scope:source.c#string_escaped_char - - match: |- - (?x)% - (\d+\$)? # field (argument #) - [#0\- +']* # flags - [,;:_]? # separator character (AltiVec) - ((-?\d+)|\*(-?\d+\$)?)? # minimum field width - (\.((-?\d+)|\*(-?\d+\$)?)?)? # precision - (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)? # length modifier - (\[[^\]]+\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type - scope: constant.other.placeholder.c++ - - match: '\{\{|\}\}' - scope: constant.character.escape.c++ - - include: formatting-syntax - - include: scope:source.c#strings - - formatting-syntax: - # https://docs.python.org/3.6/library/string.html#formatstrings - - match: |- # simple form - (?x) - (\{) - (?: [\w.\[\]]+)? # field_name - ( ! [ars])? # conversion - ( : (?:{{format_spec}}| # format_spec OR - [^}%]*%.[^}]*) # any format-like string - )? - (\}) - scope: constant.other.placeholder.c++ - captures: - 1: punctuation.definition.placeholder.begin.c++ - 2: storage.modifier.c++onversion.c++ - 3: constant.other.format-spec.c++ - 4: punctuation.definition.placeholder.end.c++ - - match: \{(?=[^\}"']+\{[^"']*\}) # complex (nested) form - scope: punctuation.definition.placeholder.begin.c++ - push: - - meta_scope: constant.other.placeholder.c++ - - match: \} - scope: punctuation.definition.placeholder.end.c++ - pop: true - - match: '[\w.\[\]]+' - - match: '![ars]' - scope: storage.modifier.conversion.c++ - - match: ':' - push: - - meta_scope: meta.format-spec.c++ constant.other.format-spec.c++ - - match: (?=\}) - pop: true - - include: formatting-syntax - - numbers: - - include: unique-numbers - - include: scope:source.c#numbers - - ## C++-specific contexts - - case-default: - - match: '\b(default|case)\b' - scope: keyword.control.c++ - push: - - match: (?=[);,]) - pop: true - - match: ':' - scope: punctuation.separator.c++ - pop: true - - include: expressions - - modifiers-parens: - - match: '\b(alignas)\b\s*(\()' - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: \b(__attribute__)\s*(\(\() - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push : - - meta_scope: meta.attribute.c++ - - meta_content_scope: meta.group.c++ - - include: parens - - include: strings - - match: \)\) - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - match: \b(__declspec)(\() - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - match: '\b(align|allocate|code_seg|deprecated|property|uuid)\b\s*(\()' - captures: - 1: storage.modifier.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: numbers - - include: strings - - match: \b(get|put)\b - scope: variable.parameter.c++ - - match: ',' - scope: punctuation.separator.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\b' - scope: constant.other.c++ - - types-parens: - - match: '\b(decltype)\b\s*(\()' - captures: - 1: storage.type.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - keywords-angle-brackets: - - match: \b({{casts}})\b\s* - scope: keyword.operator.word.cast.c++ - push: - - match: '>' - scope: punctuation.section.generic.end.c++ - pop: true - - match: '<' - scope: punctuation.section.generic.begin.c++ - push: - - match: '(?=>)' - pop: true - - include: expressions-minus-generic-type-function-call - - keywords-parens: - - match: '\b(alignof|typeid|static_assert|sizeof)\b\s*(\()' - captures: - 1: keyword.operator.word.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - namespace: - - match: '\b(using)\s+(namespace)\s+(?={{path_lookahead}})' - captures: - 1: keyword.control.c++ - 2: keyword.control.c++ - push: - - include: identifiers - - match: '' - pop: true - - match: '\b(namespace)\s+(?=({{path_lookahead}})?(?!\s*[;,]))' - scope: meta.namespace.c++ - captures: - 1: keyword.control.c++ - push: - - meta_content_scope: meta.namespace.c++ entity.name.namespace.c++ - - include: identifiers - - match: '' - set: - - meta_scope: meta.namespace.c++ - - include: comments - - match: '=' - scope: keyword.operator.alias.c++ - - match: '(?=;)' - pop: true - - match: '\}' - scope: meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: '(?=\})' - pop: true - - include: preprocessor-global - - include: global - - include: expressions - - template-common: - # Exit the template scope if we hit some basic invalid characters. This - # helps when a user is in the middle of typing their template types and - # prevents re-highlighting the whole file until the next > is found. - - match: (?=[{};]) - pop: true - - include: expressions - - template: - - match: \btemplate\b - scope: storage.type.template.c++ - push: - - meta_scope: meta.template.c++ - # Explicitly include comments here at the top, in order to NOT match the - # \S lookahead in the case of comments. - - include: comments - - match: < - scope: punctuation.section.generic.begin.c++ - set: - - meta_content_scope: meta.template.c++ - - match: '>' - scope: meta.template.c++ punctuation.section.generic.end.c++ - pop: true - - match: \.{3} - scope: keyword.operator.variadic.c++ - - match: \b(typename|{{before_tag}})\b - scope: storage.type.c++ - - include: template # include template here for nested templates - - include: template-common - - match: (?=\S) - set: - - meta_content_scope: meta.template.c++ - - match: \b({{before_tag}})\b - scope: storage.type.c++ - - include: template-common - - generic-type: - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}}\s*\()' - push: - - meta_scope: meta.function-call.c++ - - match: \btemplate\b - scope: storage.type.template.c++ - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - captures: - 1: punctuation.accessor.double-colon.c++ - 2: punctuation.accessor.double-colon.c++ - - match: (?:(::)\s*)?({{identifier}})\s*(<) - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.section.generic.begin.c++ - push: - - match: '>' - scope: punctuation.section.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - match: (?:(::)\s*)?({{identifier}})\s*(\() - captures: - 1: punctuation.accessor.double-colon.c++ - 2: variable.function.c++ - 3: punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - include: angle-brackets - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '(?=(?!template){{path_lookahead}}\s*{{generic_lookahead}})' - push: - - include: identifiers - - match: '<' - scope: punctuation.section.generic.begin.c++ - set: - - match: '>' - scope: punctuation.section.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - angle-brackets: - - match: '<(?!<)' - scope: punctuation.section.generic.begin.c++ - push: - - match: '>' - scope: punctuation.section.generic.end.c++ - pop: true - - include: expressions-minus-generic-type-function-call - - block: - - match: '\{' - scope: punctuation.section.block.begin.c++ - push: - - meta_scope: meta.block.c++ - - match: (?=^\s*#\s*(elif|else|endif)\b) - pop: true - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - function-call: - - match: (?={{path_lookahead}}\s*\() - push: - - meta_scope: meta.function-call.c++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - 2: punctuation.accessor.c++ - - match: '(?:(::)\s*)?{{identifier}}' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\)' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - members-inside-function-call: - - meta_content_scope: meta.method-call.c++ meta.group.c++ - - match: \) - scope: meta.method-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - members-after-accessor-junction: - # After we've seen an accessor (dot or arrow), this context decides what - # kind of entity we're accessing. - - include: comments - - match: \btemplate\b - scope: meta.method-call.c++ storage.type.template.c++ - # Guaranteed to be a template member function call after we match this - set: - - meta_content_scope: meta.method-call.c++ - - include: comments - - match: '{{identifier}}' - scope: variable.function.member.c++ - set: - - meta_content_scope: meta.method-call.c++ - - match: \( - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - - include: comments - - include: angle-brackets - - match: (?=\S) # safety pop - pop: true - - match: (?=\S) # safety pop - pop: true - # Operator overloading - - match: '({{operator_method_name}})\s*(\()' - captures: - 0: meta.method-call.c++ - 1: variable.function.member.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - # Non-templated member function call - - match: (~?{{identifier}})\s*(\() - captures: - 0: meta.method-call.c++ - 1: variable.function.member.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - set: members-inside-function-call - # Templated member function call - - match: (~?{{identifier}})\s*(?={{generic_lookahead}}) - captures: - 1: variable.function.member.c++ - set: - - meta_scope: meta.method-call.c++ - - match: < - scope: punctuation.section.generic.begin.c++ - set: - - meta_content_scope: meta.method-call.c++ - - match: '>' - scope: punctuation.section.generic.end.c++ - set: - - meta_content_scope: meta.method-call.c++ - - include: comments - - match: \( - scope: punctuation.section.group.begin.c++ - set: members-inside-function-call - - match: (?=\S) # safety pop - pop: true - - include: expressions - # Explicit base-class access - - match: ({{identifier}})\s*(::) - captures: - 1: variable.other.base-class.c++ - 2: punctuation.accessor.double-colon.c++ - set: members-after-accessor-junction # reset - # Just a regular member variable - - match: '{{identifier}}' - scope: variable.other.readwrite.member.c++ - pop: true - - members-dot: - - include: scope:source.c#access-illegal - # No lookahead required because members-dot goes after operators in the - # early-expressions-after-generic-type context. This means triple dots - # (i.e. "..." or "variadic") is attempted first. - - match: \. - scope: punctuation.accessor.dot.c++ - push: members-after-accessor-junction - - members-arrow: - # This needs to be before operators in the - # early-expressions-after-generic-type context because otherwise the "->" - # from the C language will match. - - match: -> - scope: punctuation.accessor.arrow.c++ - push: members-after-accessor-junction - - typedef: - - match: \btypedef\b - scope: storage.type.c++ - push: - - match: ({{identifier}})?\s*(?=;) - captures: - 1: entity.name.type.typedef.c++ - pop: true - - match: \b(struct)\s+({{identifier}})\b - captures: - 1: storage.type.c++ - - include: expressions-minus-generic-type - - parens: - - match: \( - scope: punctuation.section.group.begin.c++ - push: - - meta_scope: meta.group.c++ - - match: \) - scope: punctuation.section.group.end.c++ - pop: true - - include: expressions - - brackets: - - match: \[ - scope: punctuation.section.brackets.begin.c++ - push: - - meta_scope: meta.brackets.c++ - - match: \] - scope: punctuation.section.brackets.end.c++ - pop: true - - include: expressions - - function-trailing-return-type: - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - - include: identifiers - - match: \*|& - scope: keyword.operator.c++ - - include: function-trailing-return-type-parens - - match: '(?=\S)' - pop: true - - function-trailing-return-type-parens: - - match: \( - scope: punctuation.section.group.begin.c++ - push: - - meta_scope: meta.group.c++ - - match: \) - scope: punctuation.section.group.end.c++ - pop: true - - include: function-trailing-return-type - - ## Detection of function and data structure definitions at the global level - - global-modifier: - - include: comments - - include: modifiers-parens - - include: modifiers - # Constructors and destructors don't have a type - - match: '(?={{path_lookahead}}\s*::\s*{{identifier}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ entity.name.function.constructor.c++ - - include: identifiers - - match: '(?=[^\w\s])' - set: function-definition-params - - match: '(?={{path_lookahead}}\s*::\s*~{{identifier}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ entity.name.function.destructor.c++ - - include: identifiers - - match: '~{{identifier}}' - - match: '(?=[^\w\s])' - set: function-definition-params - # If we see a path ending in :: before a newline, we don't know if it is - # a constructor or destructor, or a long return type, so we are just going - # to treat it like a regular function. Most likely it is a constructor, - # since it doesn't seem most developers would create such a long typename. - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: - - meta_content_scope: meta.function.c++ entity.name.function.c++ - - include: identifiers - - match: '~{{identifier}}' - - match: '(?=[^\w\s])' - set: function-definition-params - - include: unique-strings - - match: '(?=\S)' - set: global-type - - global-type: - - include: comments - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: global-maybe-function - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: storage.type.c++ - set: - - include: identifiers - - match: '' - set: global-maybe-function - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - # Allow a macro call - - match: '({{identifier}})\s*(\()(?=[^\)]+\))' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: '(?={{path_lookahead}}\s*\()' - set: - - include: function-call - - match: '' - pop: true - - include: variables - - include: constants - - include: identifiers - - match: (?=\W) - pop: true - - global-maybe-function: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.c++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # All uppercase identifier just before a newline is most likely a macro - - match: '[[:upper:][:digit:]_]+\s*$' - # Operator overloading - - match: '(?=({{path_lookahead}}\s*(?:{{generic_lookahead}})?::\s*)?{{operator_method_name}}\s*(\(|$))' - set: - - meta_content_scope: meta.function.c++ entity.name.function.c++ - - include: identifiers - - match: '(?=\s*(\(|$))' - set: function-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\(|$)))' - push: - - include: identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*(\(|$))' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\(|$))' - set: [function-definition-params, global-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [function-definition-params, global-function-identifier] - - match: '(?=\S)' - pop: true - - global-function-identifier-generic: - - include: angle-brackets - - match: '::' - scope: punctuation.accessor.c++ - - match: '(?={{identifier}}<.*>\s*\()' - push: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=<)' - pop: true - - match: '(?={{identifier}}\s*\()' - push: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '' - pop: true - - match: '(?=\()' - pop: true - - global-function-identifier: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - function-definition-params: - - meta_content_scope: meta.function.c++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.function.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function.parameters.c++ meta.group.c++ - - match : \) - scope: punctuation.section.group.end.c++ - set: function-definition-continue - - match: '\bvoid\b' - scope: storage.type.c++ - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - include: expressions-minus-generic-type - - include: scope:source.c#preprocessor-line-continuation - - match: (?=\S) - pop: true - - function-definition-continue: - - meta_content_scope: meta.function.c++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.c++ - set: function-definition-trailing-return - - include: function-specifiers - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '&' - scope: keyword.operator.c++ - - match: \b0\b - scope: constant.numeric.c++ - - match: \b(default|delete)\b - scope: storage.modifier.c++ - - match: '(?=\{)' - set: function-definition-body - - match: '(?=\S)' - pop: true - - function-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: function-definition-body - - include: function-specifiers - - include: function-trailing-return-type - - function-definition-body: - - meta_content_scope: meta.function.c++ meta.block.c++ - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.function.c++ meta.block.c++ - - match: '\}' - scope: meta.function.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: (?=^\s*#\s*(elif|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Data structures including classes, structs, unions and enums - - data-structures: - - match: '\bclass\b' - scope: storage.type.c++ - set: data-structures-class-definition - # Detect variable type definitions using struct/enum/union followed by a tag - - match: '\b({{before_tag}})(?=\s+{{path_lookahead}}\s+{{path_lookahead}}\s*[=;\[])' - scope: storage.type.c++ - - match: '\bstruct\b' - scope: storage.type.c++ - set: data-structures-struct-definition - - match: '\benum(\s+(class|struct))?\b' - scope: storage.type.c++ - set: data-structures-enum-definition - - match: '\bunion\b' - scope: storage.type.c++ - set: data-structures-union-definition - - match: '(?=\S)' - pop: true - - preprocessor-workaround-eat-macro-before-identifier: - # Handle macros so they aren't matched as the class name - - match: ({{macro_identifier}})(?=\s+~?{{identifier}}) - captures: - 1: meta.assumed-macro.c - - data-structures-class-definition: - - meta_scope: meta.class.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.class.forward-decl.c++ - set: data-structures-class-definition-after-identifier - - match: '{{identifier}}' - scope: entity.name.class.c++ - set: data-structures-class-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-class-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-class-definition-after-identifier: - - meta_content_scope: meta.class.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.class.c++ meta.block.c++ - - match: '\}' - scope: meta.class.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - data-structures-struct-definition: - - meta_scope: meta.struct.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.struct.forward-decl.c++ - set: data-structures-struct-definition-after-identifier - - match: '{{identifier}}' - scope: entity.name.struct.c++ - set: data-structures-struct-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-struct-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-struct-definition-after-identifier: - - meta_content_scope: meta.struct.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.struct.c++ meta.block.c++ - - match: '\}' - scope: meta.struct.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - data-structures-enum-definition: - - meta_scope: meta.enum.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.enum.forward-decl.c++ - set: data-structures-enum-definition-after-identifier - - match: '{{identifier}}' - scope: entity.name.enum.c++ - set: data-structures-enum-definition-after-identifier - - match: '(?=[:{])' - set: data-structures-enum-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-enum-definition-after-identifier: - - meta_content_scope: meta.enum.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - - include: data-structures-definition-common-end - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.enum.c++ meta.block.c++ - # Enums don't support methods so we have a simplified body - - match: '\}' - scope: meta.enum.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: statements - - data-structures-union-definition: - - meta_scope: meta.union.c++ - - include: data-structures-definition-common-begin - - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})' - scope: entity.name.union.forward-decl.c++ - set: data-structures-union-definition-after-identifier - - match: '{{identifier}}' - scope: entity.name.union.c++ - set: data-structures-union-definition-after-identifier - - match: '(?=[{])' - set: data-structures-union-definition-after-identifier - - match: '(?=;)' - pop: true - - data-structures-union-definition-after-identifier: - - meta_content_scope: meta.union.c++ - - include: data-structures-definition-common-begin - # No matching of identifiers since they should all be macros at this point - # Unions don't support base classes - - include: angle-brackets - - match: '\{' - scope: meta.block.c++ punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.union.c++ meta.block.c++ - - match: '\}' - scope: meta.union.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - include: data-structures-body - - match: '(?=;)' - pop: true - - data-structures-definition-common-begin: - - include: comments - - match: '(?=\b(?:{{before_tag}}|{{control_keywords}})\b)' - pop: true - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - include: preprocessor-workaround-eat-macro-before-identifier - - data-structures-definition-common-end: - - include: angle-brackets - - match: \bfinal\b - scope: storage.modifier.c++ - - match: ':' - scope: punctuation.separator.c++ - push: - - include: comments - - include: preprocessor-other - - include: modifiers-parens - - include: modifiers - - match: '\b(virtual|{{visibility_modifiers}})\b' - scope: storage.modifier.c++ - - match: (?={{path_lookahead}}) - push: - - meta_scope: entity.other.inherited-class.c++ - - include: identifiers - - match: '' - pop: true - - include: angle-brackets - - match: ',' - scope: punctuation.separator.c++ - - match: (?=\{|;) - pop: true - - match: '(?=;)' - pop: true - - data-structures-body: - - include: preprocessor-data-structures - - match: '(?=\btemplate\b)' - push: - - include: template - - match: (?=\S) - set: data-structures-modifier - - include: typedef - - match: \b({{visibility_modifiers}})\s*(:)(?!:) - captures: - 1: storage.modifier.c++ - 2: punctuation.section.class.c++ - - match: '^\s*(?=(?:~?\w+|::))' - push: data-structures-modifier - - include: expressions-minus-generic-type - - data-structures-modifier: - - match: '\bfriend\b' - scope: storage.modifier.c++ - push: - - match: (?=;) - pop: true - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_scope: meta.block.c++ - - match: '\}' - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - match: '\b({{before_tag}})\b' - scope: storage.type.c++ - - include: expressions-minus-function-call - - include: comments - - include: modifiers-parens - - include: modifiers - - match: '\bstatic_assert(?=\s*\()' - scope: meta.static-assert.c++ keyword.operator.word.c++ - push: - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: '\)' - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - # Destructor - - match: '(?:{{identifier}}\s*(::)\s*)?~{{identifier}}(?=\s*(\(|$))' - scope: meta.method.destructor.c++ entity.name.function.destructor.c++ - captures: - 1: punctuation.accessor.c++ - set: method-definition-params - # It's a macro, not a constructor if there is no type in the first param - - match: '({{identifier}})\s*(\()(?=\s*(?!void){{identifier}}\s*[),])' - captures: - 1: variable.function.c++ - 2: meta.group.c++ punctuation.section.group.begin.c++ - push: - - meta_scope: meta.function-call.c++ - - meta_content_scope: meta.group.c++ - - match: '\)' - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - # Constructor - - include: preprocessor-workaround-eat-macro-before-identifier - - match: '((?!{{before_tag}}|template){{identifier}})(?=\s*\()' - scope: meta.method.constructor.c++ entity.name.function.constructor.c++ - set: method-definition-params - # Long form constructor - - match: '({{identifier}}\s*(::)\s*{{identifier}})(?=\s*\()' - captures: - 1: meta.method.constructor.c++ entity.name.function.constructor.c++ - 2: punctuation.accessor.c++ - push: method-definition-params - - match: '(?=\S)' - set: data-structures-type - - data-structures-type: - - include: comments - - match: \*|& - scope: keyword.operator.c++ - # Cast methods - - match: '(operator)\s+({{identifier}})(?=\s*(\(|$))' - captures: - 1: keyword.control.c++ - 2: meta.method.c++ entity.name.function.c++ - set: method-definition-params - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\b)' - pop: true - - match: '(?=\s)' - set: data-structures-maybe-method - # If a class/struct/enum followed by a name that is not a macro or declspec - # then this is likely a return type of a function. This is uncommon. - - match: |- - (?x: - ({{before_tag}}) - \s+ - (?= - (?![[:upper:][:digit:]_]+\b|__declspec|{{before_tag}}) - {{path_lookahead}} - (\s+{{identifier}}\s*\(|\s*[*&]) - ) - ) - captures: - 1: storage.type.c++ - set: - - include: identifiers - - match: '' - set: data-structures-maybe-method - # The previous match handles return types of struct/enum/etc from a func, - # there this one exits the context to allow matching an actual struct/class - - match: '(?=\b({{before_tag}})\b)' - set: data-structures - - match: '(?=\b({{casts}})\b\s*<)' - pop: true - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: variables - - include: constants - - include: identifiers - - match: (?=[&*]) - set: data-structures-maybe-method - - match: (?=\W) - pop: true - - data-structures-maybe-method: - - include: comments - # Consume pointer info, macros and any type info that was offset by macros - - match: \*|& - scope: keyword.operator.c++ - - match: '(?=\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\b)' - pop: true - - match: '\b({{type_qualifier}})\b' - scope: storage.modifier.c++ - - match: '{{non_angle_brackets}}' - pop: true - - include: angle-brackets - - include: types - - include: modifiers-parens - - include: modifiers - # Operator overloading - - match: '{{operator_method_name}}(?=\s*(\(|$))' - scope: meta.method.c++ entity.name.function.c++ - set: method-definition-params - # Identifier that is not the function name - likely a macro or type - - match: '(?={{path_lookahead}}([ \t]+|[*&])(?!\s*(<|::|\()))' - push: - - include: identifiers - - match: '' - pop: true - # Real function definition - - match: '(?={{path_lookahead}}({{generic_lookahead}})\s*(\())' - set: [method-definition-params, data-structures-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*(\())' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?={{path_lookahead}}\s*::\s*$)' - set: [method-definition-params, data-structures-function-identifier] - - match: '(?=\S)' - pop: true - - data-structures-function-identifier-generic: - - include: angle-brackets - - match: '(?={{identifier}})' - push: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=<)' - pop: true - - match: '(?=\()' - pop: true - - data-structures-function-identifier: - - meta_content_scope: entity.name.function.c++ - - include: identifiers - - match: '(?=\S)' - pop: true - - method-definition-params: - - meta_content_scope: meta.method.c++ - - include: comments - - match: '(?=\()' - set: - - match: \( - scope: meta.method.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.method.parameters.c++ meta.group.c++ - - match : \) - scope: punctuation.section.group.end.c++ - set: method-definition-continue - - match: '\bvoid\b' - scope: storage.type.c++ - - match: '{{identifier}}(?=\s*(\[|,|\)|=))' - scope: variable.parameter.c++ - - match: '=' - scope: keyword.operator.assignment.c++ - push: - - match: '(?=,|\))' - pop: true - - include: expressions-minus-generic-type - - include: expressions-minus-generic-type - - match: '(?=\S)' - pop: true - - method-definition-continue: - - meta_content_scope: meta.method.c++ - - include: comments - - match: '(?=;)' - pop: true - - match: '->' - scope: punctuation.separator.c++ - set: method-definition-trailing-return - - include: function-specifiers - - match: '=' - scope: keyword.operator.assignment.c++ - - match: '&' - scope: keyword.operator.c++ - - match: \b0\b - scope: constant.numeric.c++ - - match: \b(default|delete)\b - scope: storage.modifier.c++ - - match: '(?=:)' - set: - - match: ':' - scope: punctuation.separator.initializer-list.c++ - set: - - meta_scope: meta.method.constructor.initializer-list.c++ - - match: '{{identifier}}' - scope: variable.other.readwrite.member.c++ - push: - - match: \( - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.group.c++ - - match: \) - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - match: \{ - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: - - meta_content_scope: meta.group.c++ - - match: \} - scope: meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - include: comments - - match: (?=\{|;) - set: method-definition-continue - - include: expressions - - match: '(?=\{)' - set: method-definition-body - - match: '(?=\S)' - pop: true - - method-definition-trailing-return: - - include: comments - - match: '(?=;)' - pop: true - - match: '(?=\{)' - set: method-definition-body - - include: function-specifiers - - include: function-trailing-return-type - - method-definition-body: - - meta_content_scope: meta.method.c++ meta.block.c++ - - match: '\{' - scope: punctuation.section.block.begin.c++ - set: - - meta_content_scope: meta.method.c++ meta.block.c++ - - match: '\}' - scope: meta.method.c++ meta.block.c++ punctuation.section.block.end.c++ - pop: true - - match: (?=^\s*#\s*(elif|else|endif)\b) - pop: true - - match: '(?=({{before_tag}})([^(;]+$|.*\{))' - push: data-structures - - include: statements - - ## Preprocessor for data-structures - - preprocessor-data-structures: - - include: preprocessor-rule-enabled-data-structures - - include: preprocessor-rule-disabled-data-structures - - include: preprocessor-practical-workarounds - - preprocessor-rule-disabled-data-structures: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: constant.numeric.preprocessor.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: data-structures-body - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-data-structures: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: constant.numeric.preprocessor.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: data-structures-body - - ## Preprocessor for global - - preprocessor-global: - - include: preprocessor-rule-enabled-global - - include: preprocessor-rule-disabled-global - - include: preprocessor-rule-other-global - - preprocessor-statements: - - include: preprocessor-rule-enabled-statements - - include: preprocessor-rule-disabled-statements - - include: preprocessor-rule-other-statements - - preprocessor-expressions: - - include: scope:source.c#incomplete-inc - - include: preprocessor-macro-define - - include: scope:source.c#pragma-mark - - include: preprocessor-other - - preprocessor-rule-disabled-global: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: constant.numeric.preprocessor.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-global: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: constant.numeric.preprocessor.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-rule-other-global: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - # Enter a new scope where all elif/else branches have their - # contexts popped by a subsequent elif/else/endif. This ensures that - # preprocessor branches don't push multiple meta.block scopes on - # the stack, thus messing up the "global" context's detection of - # functions. - - match: $\n - set: preprocessor-if-branch-global - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: (?=^\s*#\s*(elif|else)\b) - push: preprocessor-elif-else-branch-global - - match: \{ - scope: punctuation.section.block.begin.c++ - set: preprocessor-block-if-branch-global - - include: preprocessor-global - - include: negated-block - - include: global - - preprocessor-block-if-branch-global: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-global - - match: (?=^\s*#\s*(elif|else)\b) - push: preprocessor-elif-else-branch-global - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-block-finish-global: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-if-branch-global - - match: \} - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-global: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.c++ - pop: true - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-global - - include: statements - - preprocessor-elif-else-branch-global: - - match: (?=^\s*#\s*(endif)\b) - pop: true - - include: preprocessor-global - - include: negated-block - - include: global - - ## Preprocessor for statements - - preprocessor-rule-disabled-statements: - - match: ^\s*((#if)\s+(0))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: constant.numeric.preprocessor.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - match: "" - push: - - meta_scope: comment.block.preprocessor.if-branch.c++ - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - preprocessor-rule-enabled-statements: - - match: ^\s*((#if)\s+(0*1))\b - captures: - 1: meta.preprocessor.c++ - 2: keyword.control.import.c++ - 3: constant.numeric.preprocessor.c++ - push: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: ^\s*(#\s*else)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.else.c++ - push: - - meta_content_scope: comment.block.preprocessor.else-branch.c++ - - match: (?=^\s*#\s*endif\b) - pop: true - - include: scope:source.c#preprocessor-disabled - - match: "" - push: - - match: (?=^\s*#\s*(else|endif)\b) - pop: true - - include: negated-block - - include: statements - - preprocessor-rule-other-statements: - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - # Enter a new scope where all elif/else branches have their - # contexts popped by a subsequent elif/else/endif. This ensures that - # preprocessor branches don't push multiple meta.block scopes on - # the stack, thus messing up the "global" context's detection of - # functions. - - match: $\n - set: preprocessor-if-branch-statements - - # These gymnastics here ensure that we are properly handling scope even - # when the preprocessor is used to create different scope beginnings, such - # as a different if/while condition - preprocessor-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - pop: true - - match: (?=^\s*#\s*(elif|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \{ - scope: punctuation.section.block.begin.c++ - set: preprocessor-block-if-branch-statements - - match: (?=(?!{{non_func_keywords}}){{path_lookahead}}\s*\() - set: preprocessor-if-branch-function-call - - include: negated-block - - include: statements - - preprocessor-if-branch-function-call: - - meta_content_scope: meta.function-call.c++ - - include: scope:source.c#c99 - - match: '(?:(::)\s*)?{{identifier}}\s*(::)\s*' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - 2: punctuation.accessor.c++ - - match: '(?:(::)\s*)?{{identifier}}' - scope: variable.function.c++ - captures: - 1: punctuation.accessor.c++ - - match: '\(' - scope: meta.group.c++ punctuation.section.group.begin.c++ - set: preprocessor-if-branch-function-call-arguments - - preprocessor-if-branch-function-call-arguments: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match : \) - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*(?:elif|else))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-if-branch-statements - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-if-branch-function-call-arguments-finish - - include: expressions - - preprocessor-if-branch-function-call-arguments-finish: - - meta_content_scope: meta.function-call.c++ meta.group.c++ - - match: \) - scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++ - pop: true - - include: expressions - - preprocessor-block-if-branch-statements: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-statements - - match: (?=^\s*#\s*(elif|else)\b) - push: preprocessor-elif-else-branch-statements - - match: \} - scope: punctuation.section.block.end.c++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-block-finish-statements: - - meta_scope: meta.block.c++ - - match: ^\s*(#\s*(?:if|ifdef|ifndef))\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - set: preprocessor-block-finish-if-branch-statements - - match: \} - scope: punctuation.section.block.end.c++ - pop: true - - include: statements - - preprocessor-block-finish-if-branch-statements: - - match: ^\s*(#\s*endif)\b - captures: - 1: keyword.control.import.c++ - pop: true - - match: \} - scope: meta.block.c++ punctuation.section.block.end.c++ - set: preprocessor-if-branch-statements - - include: statements - - preprocessor-elif-else-branch-statements: - - match: (?=^\s*#\s*endif\b) - pop: true - - include: negated-block - - include: statements - - ## Preprocessor other - - negated-block: - - match: '\}' - scope: punctuation.section.block.end.c++ - push: - - match: '\{' - scope: punctuation.section.block.begin.c++ - pop: true - - match: (?=^\s*#\s*(elif|else|endif)\b) - pop: true - - include: statements - - preprocessor-macro-define: - - match: ^\s*(\#\s*define)\b - captures: - 1: meta.preprocessor.macro.c++ keyword.control.import.define.c++ - push: - - meta_content_scope: meta.preprocessor.macro.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '({{identifier}})(?=\()' - scope: entity.name.function.preprocessor.c++ - set: - - match: '\(' - scope: punctuation.section.group.begin.c++ - set: preprocessor-macro-params - - match: '{{identifier}}' - scope: entity.name.constant.preprocessor.c++ - set: preprocessor-macro-definition - - preprocessor-macro-params: - - meta_scope: meta.preprocessor.macro.parameters.c++ meta.group.c++ - - match: '{{identifier}}' - scope: variable.parameter.c++ - - match: \) - scope: punctuation.section.group.end.c++ - set: preprocessor-macro-definition - - match: ',' - scope: punctuation.separator.c++ - push: - - match: '{{identifier}}' - scope: variable.parameter.c++ - pop: true - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c++ - - match: '(?=\))' - pop: true - - match: (/\*).*(\*/) - scope: comment.block.c++ - captures: - 1: punctuation.definition.comment.c++ - 2: punctuation.definition.comment.c++ - - match: '\S+' - scope: invalid.illegal.unexpected-character.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-comments - - match: '\.\.\.' - scope: keyword.operator.variadic.c++ - - match: (/\*).*(\*/) - scope: comment.block.c++ - captures: - 1: punctuation.definition.comment.c++ - 2: punctuation.definition.comment.c++ - - match: $\n - scope: invalid.illegal.unexpected-end-of-line.c++ - - preprocessor-macro-definition: - - meta_content_scope: meta.preprocessor.macro.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - # Don't define blocks in define statements - - match: '\{' - scope: punctuation.section.block.begin.c++ - - match: '\}' - scope: punctuation.section.block.end.c++ - - include: expressions - - preprocessor-practical-workarounds: - - include: preprocessor-convention-ignore-uppercase-ident-lines - - include: scope:source.c#preprocessor-convention-ignore-uppercase-calls-without-semicolon - - preprocessor-convention-ignore-uppercase-ident-lines: - - match: ^(\s*{{macro_identifier}})+\s*$ - scope: meta.assumed-macro.c++ - push: - # It's possible that we are dealing with a function return type on its own line, and the - # name of the function is on the subsequent line. - - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\s*\()' - set: [function-definition-params, global-function-identifier-generic] - - match: '(?={{path_lookahead}}\s*\()' - set: [function-definition-params, global-function-identifier] - - match: ^ - pop: true - - preprocessor-other: - - match: ^\s*(#\s*(?:if|ifdef|ifndef|elif|else|line|pragma|undef))\b - captures: - 1: keyword.control.import.c++ - push: - - meta_scope: meta.preprocessor.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: \bdefined\b - scope: keyword.control.c++ - - match: ^\s*(#\s*endif)\b - captures: - 1: meta.preprocessor.c++ keyword.control.import.c++ - - match: ^\s*(#\s*(?:error|warning))\b - captures: - 1: keyword.control.import.error.c++ - push: - - meta_scope: meta.preprocessor.diagnostic.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - include: strings - - match: '\S+' - scope: string.unquoted.c++ - - match: ^\s*(#\s*(?:include|include_next|import))\b - captures: - 1: keyword.control.import.include.c++ - push: - - meta_scope: meta.preprocessor.include.c++ - - include: scope:source.c#preprocessor-line-continuation - - include: scope:source.c#preprocessor-line-ending - - include: scope:source.c#preprocessor-comments - - match: '"' - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.double.include.c++ - - match: '"' - scope: punctuation.definition.string.end.c++ - pop: true - - match: < - scope: punctuation.definition.string.begin.c++ - push: - - meta_scope: string.quoted.other.lt-gt.include.c++ - - match: '>' - scope: punctuation.definition.string.end.c++ - pop: true - - include: preprocessor-practical-workarounds diff --git a/third_party/fmt/support/README b/third_party/fmt/support/README deleted file mode 100644 index 468f5485..00000000 --- a/third_party/fmt/support/README +++ /dev/null @@ -1,4 +0,0 @@ -This directory contains build support files such as - -* CMake modules -* Build scripts diff --git a/third_party/fmt/support/Vagrantfile b/third_party/fmt/support/Vagrantfile deleted file mode 100644 index 9d0ff6a5..00000000 --- a/third_party/fmt/support/Vagrantfile +++ /dev/null @@ -1,19 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# A vagrant config for testing against gcc-4.8. -Vagrant.configure("2") do |config| - config.vm.box = "bento/ubuntu-22.04-arm64" - - config.vm.provider "vmware_desktop" do |vb| - vb.memory = "4096" - end - - config.vm.provision "shell", inline: <<-SHELL - apt-get update - apt-get install -y g++ make wget git - wget -q https://github.com/Kitware/CMake/releases/download/v3.26.0/cmake-3.26.0-Linux-x86_64.tar.gz - tar xzf cmake-3.26.0-Linux-x86_64.tar.gz - ln -s `pwd`/cmake-3.26.0-Linux-x86_64/bin/cmake /usr/local/bin - SHELL -end diff --git a/third_party/fmt/support/bazel/.bazelversion b/third_party/fmt/support/bazel/.bazelversion deleted file mode 100644 index a8a18875..00000000 --- a/third_party/fmt/support/bazel/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.1.2 diff --git a/third_party/fmt/support/bazel/BUILD.bazel b/third_party/fmt/support/bazel/BUILD.bazel deleted file mode 100644 index 1a06ed52..00000000 --- a/third_party/fmt/support/bazel/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -cc_library( - name = "fmt", - srcs = [ - #"src/fmt.cc", # No C++ module support, yet in Bazel (https://github.com/bazelbuild/bazel/pull/19940) - "src/format.cc", - "src/os.cc", - ], - hdrs = glob([ - "include/fmt/*.h", - ]), - copts = select({ - "@platforms//os:windows": ["-utf-8"], - "//conditions:default": [], - }), - includes = [ - "include", - ], - strip_include_prefix = "include", - visibility = ["//visibility:public"], -) diff --git a/third_party/fmt/support/bazel/MODULE.bazel b/third_party/fmt/support/bazel/MODULE.bazel deleted file mode 100644 index 6023f362..00000000 --- a/third_party/fmt/support/bazel/MODULE.bazel +++ /dev/null @@ -1,6 +0,0 @@ -module( - name = "fmt", - compatibility_level = 10, -) - -bazel_dep(name = "platforms", version = "0.0.10") diff --git a/third_party/fmt/support/bazel/README.md b/third_party/fmt/support/bazel/README.md deleted file mode 100644 index 44508f1c..00000000 --- a/third_party/fmt/support/bazel/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# Bazel support - -To get [Bazel](https://bazel.build/) working with {fmt} you can copy the files `BUILD.bazel`, -`MODULE.bazel`, `WORKSPACE.bazel`, and `.bazelversion` from this folder (`support/bazel`) to the root folder of this project. -This way {fmt} gets bazelized and can be used with Bazel (e.g. doing a `bazel build //...` on {fmt}). - -## Using {fmt} as a dependency - -### Using Bzlmod - -The [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/fmt) provides support for {fmt}. - -For instance, to use {fmt} add to your `MODULE.bazel` file: - -``` -bazel_dep(name = "fmt", version = "10.2.1") -``` - -### Live at head - -For a live-at-head approach, you can copy the contents of this repository and move the Bazel-related build files to the root folder of this project as described above and make use of `local_path_override`, e.g.: - -``` -local_path_override( - module_name = "fmt", - path = "../third_party/fmt", -) -``` diff --git a/third_party/fmt/support/bazel/WORKSPACE.bazel b/third_party/fmt/support/bazel/WORKSPACE.bazel deleted file mode 100644 index b1be18f3..00000000 --- a/third_party/fmt/support/bazel/WORKSPACE.bazel +++ /dev/null @@ -1,2 +0,0 @@ -# WORKSPACE marker file needed by Bazel - diff --git a/third_party/fmt/support/build.gradle b/third_party/fmt/support/build.gradle deleted file mode 100644 index c5126d05..00000000 --- a/third_party/fmt/support/build.gradle +++ /dev/null @@ -1,132 +0,0 @@ -import java.nio.file.Paths - -// General gradle arguments for root project -buildscript { - repositories { - google() - jcenter() - } - dependencies { - // - // https://developer.android.com/studio/releases/gradle-plugin#updating-gradle - // - // Notice that 4.0.0 here is the version of [Android Gradle Plugin] - // According to URL above you will need Gradle 6.1 or higher - // - classpath "com.android.tools.build:gradle:4.1.1" - } -} -repositories { - google() - jcenter() -} - -// Project's root where CMakeLists.txt exists: rootDir/support/.cxx -> rootDir -def rootDir = Paths.get(project.buildDir.getParent()).getParent() -println("rootDir: ${rootDir}") - -// Output: Shared library (.so) for Android -apply plugin: "com.android.library" -android { - compileSdkVersion 25 // Android 7.0 - - // Target ABI - // - This option controls target platform of module - // - The platform might be limited by compiler's support - // some can work with Clang(default), but some can work only with GCC... - // if bad, both toolchains might not support it - splits { - abi { - enable true - // Specify platforms for Application - reset() - include "arm64-v8a", "armeabi-v7a", "x86_64" - } - } - ndkVersion "21.3.6528147" // ANDROID_NDK_HOME is deprecated. Be explicit - - defaultConfig { - minSdkVersion 21 // Android 5.0+ - targetSdkVersion 25 // Follow Compile SDK - versionCode 34 // Follow release count - versionName "7.1.2" // Follow Official version - - externalNativeBuild { - cmake { - arguments "-DANDROID_STL=c++_shared" // Specify Android STL - arguments "-DBUILD_SHARED_LIBS=true" // Build shared object - arguments "-DFMT_TEST=false" // Skip test - arguments "-DFMT_DOC=false" // Skip document - cppFlags "-std=c++17" - targets "fmt" - } - } - println(externalNativeBuild.cmake.cppFlags) - println(externalNativeBuild.cmake.arguments) - } - - // External Native build - // - Use existing CMakeList.txt - // - Give path to CMake. This gradle file should be - // neighbor of the top level cmake - externalNativeBuild { - cmake { - version "3.10.0+" - path "${rootDir}/CMakeLists.txt" - // buildStagingDirectory "./build" // Custom path for cmake output - } - } - - sourceSets{ - // Android Manifest for Gradle - main { - manifest.srcFile "AndroidManifest.xml" - } - } - - // https://developer.android.com/studio/build/native-dependencies#build_system_configuration - buildFeatures { - prefab true - prefabPublishing true - } - prefab { - fmt { - headers "${rootDir}/include" - } - } -} - -assemble.doLast -{ - // Instead of `ninja install`, Gradle will deploy the files. - // We are doing this since FMT is dependent to the ANDROID_STL after build - copy { - from "build/intermediates/cmake" - into "${rootDir}/libs" - } - // Copy debug binaries - copy { - from "${rootDir}/libs/debug/obj" - into "${rootDir}/libs/debug" - } - // Copy Release binaries - copy { - from "${rootDir}/libs/release/obj" - into "${rootDir}/libs/release" - } - // Remove empty directory - delete "${rootDir}/libs/debug/obj" - delete "${rootDir}/libs/release/obj" - - // Copy AAR files. Notice that the aar is named after the folder of this script. - copy { - from "build/outputs/aar/support-release.aar" - into "${rootDir}/libs" - rename "support-release.aar", "fmt-release.aar" - } - copy { - from "build/outputs/aar/support-debug.aar" - into "${rootDir}/libs" - rename "support-debug.aar", "fmt-debug.aar" - } -} diff --git a/third_party/fmt/support/check-commits b/third_party/fmt/support/check-commits deleted file mode 100755 index 11472d41..00000000 --- a/third_party/fmt/support/check-commits +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -"""Compile source on a range of commits - -Usage: - check-commits -""" - -import docopt, os, sys, tempfile -from subprocess import check_call, check_output, run - -args = docopt.docopt(__doc__) -start = args.get('') -source = args.get('') - -cwd = os.getcwd() - -with tempfile.TemporaryDirectory() as work_dir: - check_call(['git', 'clone', 'https://github.com/fmtlib/fmt.git'], - cwd=work_dir) - repo_dir = os.path.join(work_dir, 'fmt') - commits = check_output( - ['git', 'rev-list', f'{start}..HEAD', '--abbrev-commit', - '--', 'include', 'src'], - text=True, cwd=repo_dir).rstrip().split('\n') - commits.reverse() - print('Time\tCommit') - for commit in commits: - check_call(['git', '-c', 'advice.detachedHead=false', 'checkout', commit], - cwd=repo_dir) - returncode = run( - ['c++', '-std=c++11', '-O3', '-DNDEBUG', '-I', 'include', - 'src/format.cc', os.path.join(cwd, source)], cwd=repo_dir).returncode - if returncode != 0: - continue - times = [] - for i in range(5): - output = check_output([os.path.join(repo_dir, 'a.out')], text=True) - times.append(float(output)) - message = check_output(['git', 'log', '-1', '--pretty=format:%s', commit], - cwd=repo_dir, text=True) - print(f'{min(times)}\t{commit} {message[:40]}') - sys.stdout.flush() diff --git a/third_party/fmt/support/docopt.py b/third_party/fmt/support/docopt.py deleted file mode 100644 index 2e43f7ce..00000000 --- a/third_party/fmt/support/docopt.py +++ /dev/null @@ -1,581 +0,0 @@ -"""Pythonic command-line interface parser that will make you smile. - - * http://docopt.org - * Repository and issue-tracker: https://github.com/docopt/docopt - * Licensed under terms of MIT license (see LICENSE-MIT) - * Copyright (c) 2013 Vladimir Keleshev, vladimir@keleshev.com - -""" -import sys -import re - - -__all__ = ['docopt'] -__version__ = '0.6.1' - - -class DocoptLanguageError(Exception): - - """Error in construction of usage-message by developer.""" - - -class DocoptExit(SystemExit): - - """Exit in case user invoked program with incorrect arguments.""" - - usage = '' - - def __init__(self, message=''): - SystemExit.__init__(self, (message + '\n' + self.usage).strip()) - - -class Pattern(object): - - def __eq__(self, other): - return repr(self) == repr(other) - - def __hash__(self): - return hash(repr(self)) - - def fix(self): - self.fix_identities() - self.fix_repeating_arguments() - return self - - def fix_identities(self, uniq=None): - """Make pattern-tree tips point to same object if they are equal.""" - if not hasattr(self, 'children'): - return self - uniq = list(set(self.flat())) if uniq is None else uniq - for i, child in enumerate(self.children): - if not hasattr(child, 'children'): - assert child in uniq - self.children[i] = uniq[uniq.index(child)] - else: - child.fix_identities(uniq) - - def fix_repeating_arguments(self): - """Fix elements that should accumulate/increment values.""" - either = [list(child.children) for child in transform(self).children] - for case in either: - for e in [child for child in case if case.count(child) > 1]: - if type(e) is Argument or type(e) is Option and e.argcount: - if e.value is None: - e.value = [] - elif type(e.value) is not list: - e.value = e.value.split() - if type(e) is Command or type(e) is Option and e.argcount == 0: - e.value = 0 - return self - - -def transform(pattern): - """Expand pattern into an (almost) equivalent one, but with single Either. - - Example: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d) - Quirks: [-a] => (-a), (-a...) => (-a -a) - - """ - result = [] - groups = [[pattern]] - while groups: - children = groups.pop(0) - parents = [Required, Optional, OptionsShortcut, Either, OneOrMore] - if any(t in map(type, children) for t in parents): - child = [c for c in children if type(c) in parents][0] - children.remove(child) - if type(child) is Either: - for c in child.children: - groups.append([c] + children) - elif type(child) is OneOrMore: - groups.append(child.children * 2 + children) - else: - groups.append(child.children + children) - else: - result.append(children) - return Either(*[Required(*e) for e in result]) - - -class LeafPattern(Pattern): - - """Leaf/terminal node of a pattern tree.""" - - def __init__(self, name, value=None): - self.name, self.value = name, value - - def __repr__(self): - return '%s(%r, %r)' % (self.__class__.__name__, self.name, self.value) - - def flat(self, *types): - return [self] if not types or type(self) in types else [] - - def match(self, left, collected=None): - collected = [] if collected is None else collected - pos, match = self.single_match(left) - if match is None: - return False, left, collected - left_ = left[:pos] + left[pos + 1:] - same_name = [a for a in collected if a.name == self.name] - if type(self.value) in (int, list): - if type(self.value) is int: - increment = 1 - else: - increment = ([match.value] if type(match.value) is str - else match.value) - if not same_name: - match.value = increment - return True, left_, collected + [match] - same_name[0].value += increment - return True, left_, collected - return True, left_, collected + [match] - - -class BranchPattern(Pattern): - - """Branch/inner node of a pattern tree.""" - - def __init__(self, *children): - self.children = list(children) - - def __repr__(self): - return '%s(%s)' % (self.__class__.__name__, - ', '.join(repr(a) for a in self.children)) - - def flat(self, *types): - if type(self) in types: - return [self] - return sum([child.flat(*types) for child in self.children], []) - - -class Argument(LeafPattern): - - def single_match(self, left): - for n, pattern in enumerate(left): - if type(pattern) is Argument: - return n, Argument(self.name, pattern.value) - return None, None - - @classmethod - def parse(class_, source): - name = re.findall('(<\S*?>)', source)[0] - value = re.findall('\[default: (.*)\]', source, flags=re.I) - return class_(name, value[0] if value else None) - - -class Command(Argument): - - def __init__(self, name, value=False): - self.name, self.value = name, value - - def single_match(self, left): - for n, pattern in enumerate(left): - if type(pattern) is Argument: - if pattern.value == self.name: - return n, Command(self.name, True) - else: - break - return None, None - - -class Option(LeafPattern): - - def __init__(self, short=None, long=None, argcount=0, value=False): - assert argcount in (0, 1) - self.short, self.long, self.argcount = short, long, argcount - self.value = None if value is False and argcount else value - - @classmethod - def parse(class_, option_description): - short, long, argcount, value = None, None, 0, False - options, _, description = option_description.strip().partition(' ') - options = options.replace(',', ' ').replace('=', ' ') - for s in options.split(): - if s.startswith('--'): - long = s - elif s.startswith('-'): - short = s - else: - argcount = 1 - if argcount: - matched = re.findall('\[default: (.*)\]', description, flags=re.I) - value = matched[0] if matched else None - return class_(short, long, argcount, value) - - def single_match(self, left): - for n, pattern in enumerate(left): - if self.name == pattern.name: - return n, pattern - return None, None - - @property - def name(self): - return self.long or self.short - - def __repr__(self): - return 'Option(%r, %r, %r, %r)' % (self.short, self.long, - self.argcount, self.value) - - -class Required(BranchPattern): - - def match(self, left, collected=None): - collected = [] if collected is None else collected - l = left - c = collected - for pattern in self.children: - matched, l, c = pattern.match(l, c) - if not matched: - return False, left, collected - return True, l, c - - -class Optional(BranchPattern): - - def match(self, left, collected=None): - collected = [] if collected is None else collected - for pattern in self.children: - m, left, collected = pattern.match(left, collected) - return True, left, collected - - -class OptionsShortcut(Optional): - - """Marker/placeholder for [options] shortcut.""" - - -class OneOrMore(BranchPattern): - - def match(self, left, collected=None): - assert len(self.children) == 1 - collected = [] if collected is None else collected - l = left - c = collected - l_ = None - matched = True - times = 0 - while matched: - # could it be that something didn't match but changed l or c? - matched, l, c = self.children[0].match(l, c) - times += 1 if matched else 0 - if l_ == l: - break - l_ = l - if times >= 1: - return True, l, c - return False, left, collected - - -class Either(BranchPattern): - - def match(self, left, collected=None): - collected = [] if collected is None else collected - outcomes = [] - for pattern in self.children: - matched, _, _ = outcome = pattern.match(left, collected) - if matched: - outcomes.append(outcome) - if outcomes: - return min(outcomes, key=lambda outcome: len(outcome[1])) - return False, left, collected - - -class Tokens(list): - - def __init__(self, source, error=DocoptExit): - self += source.split() if hasattr(source, 'split') else source - self.error = error - - @staticmethod - def from_pattern(source): - source = re.sub(r'([\[\]\(\)\|]|\.\.\.)', r' \1 ', source) - source = [s for s in re.split('\s+|(\S*<.*?>)', source) if s] - return Tokens(source, error=DocoptLanguageError) - - def move(self): - return self.pop(0) if len(self) else None - - def current(self): - return self[0] if len(self) else None - - -def parse_long(tokens, options): - """long ::= '--' chars [ ( ' ' | '=' ) chars ] ;""" - long, eq, value = tokens.move().partition('=') - assert long.startswith('--') - value = None if eq == value == '' else value - similar = [o for o in options if o.long == long] - if tokens.error is DocoptExit and similar == []: # if no exact match - similar = [o for o in options if o.long and o.long.startswith(long)] - if len(similar) > 1: # might be simply specified ambiguously 2+ times? - raise tokens.error('%s is not a unique prefix: %s?' % - (long, ', '.join(o.long for o in similar))) - elif len(similar) < 1: - argcount = 1 if eq == '=' else 0 - o = Option(None, long, argcount) - options.append(o) - if tokens.error is DocoptExit: - o = Option(None, long, argcount, value if argcount else True) - else: - o = Option(similar[0].short, similar[0].long, - similar[0].argcount, similar[0].value) - if o.argcount == 0: - if value is not None: - raise tokens.error('%s must not have an argument' % o.long) - else: - if value is None: - if tokens.current() in [None, '--']: - raise tokens.error('%s requires argument' % o.long) - value = tokens.move() - if tokens.error is DocoptExit: - o.value = value if value is not None else True - return [o] - - -def parse_shorts(tokens, options): - """shorts ::= '-' ( chars )* [ [ ' ' ] chars ] ;""" - token = tokens.move() - assert token.startswith('-') and not token.startswith('--') - left = token.lstrip('-') - parsed = [] - while left != '': - short, left = '-' + left[0], left[1:] - similar = [o for o in options if o.short == short] - if len(similar) > 1: - raise tokens.error('%s is specified ambiguously %d times' % - (short, len(similar))) - elif len(similar) < 1: - o = Option(short, None, 0) - options.append(o) - if tokens.error is DocoptExit: - o = Option(short, None, 0, True) - else: # why copying is necessary here? - o = Option(short, similar[0].long, - similar[0].argcount, similar[0].value) - value = None - if o.argcount != 0: - if left == '': - if tokens.current() in [None, '--']: - raise tokens.error('%s requires argument' % short) - value = tokens.move() - else: - value = left - left = '' - if tokens.error is DocoptExit: - o.value = value if value is not None else True - parsed.append(o) - return parsed - - -def parse_pattern(source, options): - tokens = Tokens.from_pattern(source) - result = parse_expr(tokens, options) - if tokens.current() is not None: - raise tokens.error('unexpected ending: %r' % ' '.join(tokens)) - return Required(*result) - - -def parse_expr(tokens, options): - """expr ::= seq ( '|' seq )* ;""" - seq = parse_seq(tokens, options) - if tokens.current() != '|': - return seq - result = [Required(*seq)] if len(seq) > 1 else seq - while tokens.current() == '|': - tokens.move() - seq = parse_seq(tokens, options) - result += [Required(*seq)] if len(seq) > 1 else seq - return [Either(*result)] if len(result) > 1 else result - - -def parse_seq(tokens, options): - """seq ::= ( atom [ '...' ] )* ;""" - result = [] - while tokens.current() not in [None, ']', ')', '|']: - atom = parse_atom(tokens, options) - if tokens.current() == '...': - atom = [OneOrMore(*atom)] - tokens.move() - result += atom - return result - - -def parse_atom(tokens, options): - """atom ::= '(' expr ')' | '[' expr ']' | 'options' - | long | shorts | argument | command ; - """ - token = tokens.current() - result = [] - if token in '([': - tokens.move() - matching, pattern = {'(': [')', Required], '[': [']', Optional]}[token] - result = pattern(*parse_expr(tokens, options)) - if tokens.move() != matching: - raise tokens.error("unmatched '%s'" % token) - return [result] - elif token == 'options': - tokens.move() - return [OptionsShortcut()] - elif token.startswith('--') and token != '--': - return parse_long(tokens, options) - elif token.startswith('-') and token not in ('-', '--'): - return parse_shorts(tokens, options) - elif token.startswith('<') and token.endswith('>') or token.isupper(): - return [Argument(tokens.move())] - else: - return [Command(tokens.move())] - - -def parse_argv(tokens, options, options_first=False): - """Parse command-line argument vector. - - If options_first: - argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ; - else: - argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ; - - """ - parsed = [] - while tokens.current() is not None: - if tokens.current() == '--': - return parsed + [Argument(None, v) for v in tokens] - elif tokens.current().startswith('--'): - parsed += parse_long(tokens, options) - elif tokens.current().startswith('-') and tokens.current() != '-': - parsed += parse_shorts(tokens, options) - elif options_first: - return parsed + [Argument(None, v) for v in tokens] - else: - parsed.append(Argument(None, tokens.move())) - return parsed - - -def parse_defaults(doc): - defaults = [] - for s in parse_section('options:', doc): - # FIXME corner case "bla: options: --foo" - _, _, s = s.partition(':') # get rid of "options:" - split = re.split('\n[ \t]*(-\S+?)', '\n' + s)[1:] - split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])] - options = [Option.parse(s) for s in split if s.startswith('-')] - defaults += options - return defaults - - -def parse_section(name, source): - pattern = re.compile('^([^\n]*' + name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', - re.IGNORECASE | re.MULTILINE) - return [s.strip() for s in pattern.findall(source)] - - -def formal_usage(section): - _, _, section = section.partition(':') # drop "usage:" - pu = section.split() - return '( ' + ' '.join(') | (' if s == pu[0] else s for s in pu[1:]) + ' )' - - -def extras(help, version, options, doc): - if help and any((o.name in ('-h', '--help')) and o.value for o in options): - print(doc.strip("\n")) - sys.exit() - if version and any(o.name == '--version' and o.value for o in options): - print(version) - sys.exit() - - -class Dict(dict): - def __repr__(self): - return '{%s}' % ',\n '.join('%r: %r' % i for i in sorted(self.items())) - - -def docopt(doc, argv=None, help=True, version=None, options_first=False): - """Parse `argv` based on command-line interface described in `doc`. - - `docopt` creates your command-line interface based on its - description that you pass as `doc`. Such description can contain - --options, , commands, which could be - [optional], (required), (mutually | exclusive) or repeated... - - Parameters - ---------- - doc : str - Description of your command-line interface. - argv : list of str, optional - Argument vector to be parsed. sys.argv[1:] is used if not - provided. - help : bool (default: True) - Set to False to disable automatic help on -h or --help - options. - version : any object - If passed, the object will be printed if --version is in - `argv`. - options_first : bool (default: False) - Set to True to require options precede positional arguments, - i.e. to forbid options and positional arguments intermix. - - Returns - ------- - args : dict - A dictionary, where keys are names of command-line elements - such as e.g. "--verbose" and "", and values are the - parsed values of those elements. - - Example - ------- - >>> from docopt import docopt - >>> doc = ''' - ... Usage: - ... my_program tcp [--timeout=] - ... my_program serial [--baud=] [--timeout=] - ... my_program (-h | --help | --version) - ... - ... Options: - ... -h, --help Show this screen and exit. - ... --baud= Baudrate [default: 9600] - ... ''' - >>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30'] - >>> docopt(doc, argv) - {'--baud': '9600', - '--help': False, - '--timeout': '30', - '--version': False, - '': '127.0.0.1', - '': '80', - 'serial': False, - 'tcp': True} - - See also - -------- - * For video introduction see http://docopt.org - * Full documentation is available in README.rst as well as online - at https://github.com/docopt/docopt#readme - - """ - argv = sys.argv[1:] if argv is None else argv - - usage_sections = parse_section('usage:', doc) - if len(usage_sections) == 0: - raise DocoptLanguageError('"usage:" (case-insensitive) not found.') - if len(usage_sections) > 1: - raise DocoptLanguageError('More than one "usage:" (case-insensitive).') - DocoptExit.usage = usage_sections[0] - - options = parse_defaults(doc) - pattern = parse_pattern(formal_usage(DocoptExit.usage), options) - # [default] syntax for argument is disabled - #for a in pattern.flat(Argument): - # same_name = [d for d in arguments if d.name == a.name] - # if same_name: - # a.value = same_name[0].value - argv = parse_argv(Tokens(argv), list(options), options_first) - pattern_options = set(pattern.flat(Option)) - for options_shortcut in pattern.flat(OptionsShortcut): - doc_options = parse_defaults(doc) - options_shortcut.children = list(set(doc_options) - pattern_options) - #if any_options: - # options_shortcut.children += [Option(o.short, o.long, o.argcount) - # for o in argv if type(o) is Option] - extras(help, version, argv, doc) - matched, left, collected = pattern.fix().match(argv) - if matched and left == []: # better error message if left? - return Dict((a.name, a.value) for a in (pattern.flat() + collected)) - raise DocoptExit() diff --git a/third_party/fmt/support/manage.py b/third_party/fmt/support/manage.py deleted file mode 100755 index 3467afb0..00000000 --- a/third_party/fmt/support/manage.py +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env python3 - -"""Manage site and releases. - -Usage: - manage.py release [] - manage.py site - -For the release command $FMT_TOKEN should contain a GitHub personal access token -obtained from https://github.com/settings/tokens. -""" - -from __future__ import print_function -import datetime, docopt, errno, fileinput, json, os -import re, requests, shutil, sys -from contextlib import contextmanager -from subprocess import check_call - - -class Git: - def __init__(self, dir): - self.dir = dir - - def call(self, method, args, **kwargs): - return check_call(['git', method] + list(args), **kwargs) - - def add(self, *args): - return self.call('add', args, cwd=self.dir) - - def checkout(self, *args): - return self.call('checkout', args, cwd=self.dir) - - def clean(self, *args): - return self.call('clean', args, cwd=self.dir) - - def clone(self, *args): - return self.call('clone', list(args) + [self.dir]) - - def commit(self, *args): - return self.call('commit', args, cwd=self.dir) - - def pull(self, *args): - return self.call('pull', args, cwd=self.dir) - - def push(self, *args): - return self.call('push', args, cwd=self.dir) - - def reset(self, *args): - return self.call('reset', args, cwd=self.dir) - - def update(self, *args): - clone = not os.path.exists(self.dir) - if clone: - self.clone(*args) - return clone - - -def clean_checkout(repo, branch): - repo.clean('-f', '-d') - repo.reset('--hard') - repo.checkout(branch) - - -class Runner: - def __init__(self, cwd): - self.cwd = cwd - - def __call__(self, *args, **kwargs): - kwargs['cwd'] = kwargs.get('cwd', self.cwd) - check_call(args, **kwargs) - - -def create_build_env(): - """Create a build environment.""" - class Env: - pass - env = Env() - env.fmt_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - env.build_dir = 'build' - env.fmt_repo = Git(os.path.join(env.build_dir, 'fmt')) - return env - - -fmt_repo_url = 'git@github.com:fmtlib/fmt' - - -def update_site(env): - env.fmt_repo.update(fmt_repo_url) - - doc_repo = Git(os.path.join(env.build_dir, 'fmt.dev')) - doc_repo.update('git@github.com:fmtlib/fmt.dev') - - version = '11.0.0' - clean_checkout(env.fmt_repo, version) - target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc') - - # Build the docs. - html_dir = os.path.join(env.build_dir, 'html') - if os.path.exists(html_dir): - shutil.rmtree(html_dir) - include_dir = env.fmt_repo.dir - import build - build.build_docs(version, doc_dir=target_doc_dir, - include_dir=include_dir, work_dir=env.build_dir) - shutil.rmtree(os.path.join(html_dir, '.doctrees')) - # Copy docs to the website. - version_doc_dir = os.path.join(doc_repo.dir, version) - try: - shutil.rmtree(version_doc_dir) - except OSError as e: - if e.errno != errno.ENOENT: - raise - shutil.move(html_dir, version_doc_dir) - - -def release(args): - env = create_build_env() - fmt_repo = env.fmt_repo - - branch = args.get('') - if branch is None: - branch = 'master' - if not fmt_repo.update('-b', branch, fmt_repo_url): - clean_checkout(fmt_repo, branch) - - # Update the date in the changelog and extract the version and the first - # section content. - changelog = 'ChangeLog.md' - changelog_path = os.path.join(fmt_repo.dir, changelog) - is_first_section = True - first_section = [] - for i, line in enumerate(fileinput.input(changelog_path, inplace=True)): - if i == 0: - version = re.match(r'# (.*) - TBD', line).group(1) - line = '# {} - {}\n'.format( - version, datetime.date.today().isoformat()) - elif not is_first_section: - pass - elif line.startswith('#'): - is_first_section = False - else: - first_section.append(line) - sys.stdout.write(line) - if first_section[0] == '\n': - first_section.pop(0) - - ns_version = None - base_h_path = os.path.join(fmt_repo.dir, 'include', 'fmt', 'base.h') - for line in fileinput.input(base_h_path): - m = re.match(r'\s*inline namespace v(.*) .*', line) - if m: - ns_version = m.group(1) - break - major_version = version.split('.')[0] - if not ns_version or ns_version != major_version: - raise Exception(f'Version mismatch {ns_version} != {major_version}') - - # Workaround GitHub-flavored Markdown treating newlines as
. - changes = '' - code_block = False - stripped = False - for line in first_section: - if re.match(r'^\s*```', line): - code_block = not code_block - changes += line - stripped = False - continue - if code_block: - changes += line - continue - if line == '\n' or re.match(r'^\s*\|.*', line): - if stripped: - changes += '\n' - stripped = False - changes += line - continue - if stripped: - line = ' ' + line.lstrip() - changes += line.rstrip() - stripped = True - - fmt_repo.checkout('-B', 'release') - fmt_repo.add(changelog) - fmt_repo.commit('-m', 'Update version') - - # Build the docs and package. - run = Runner(fmt_repo.dir) - run('cmake', '.') - run('make', 'doc', 'package_source') - - # Create a release on GitHub. - fmt_repo.push('origin', 'release') - auth_headers = {'Authorization': 'token ' + os.getenv('FMT_TOKEN')} - r = requests.post('https://api.github.com/repos/fmtlib/fmt/releases', - headers=auth_headers, - data=json.dumps({'tag_name': version, - 'target_commitish': 'release', - 'body': changes, 'draft': True})) - if r.status_code != 201: - raise Exception('Failed to create a release ' + str(r)) - id = r.json()['id'] - uploads_url = 'https://uploads.github.com/repos/fmtlib/fmt/releases' - package = 'fmt-{}.zip'.format(version) - r = requests.post( - '{}/{}/assets?name={}'.format(uploads_url, id, package), - headers={'Content-Type': 'application/zip'} | auth_headers, - data=open('build/fmt/' + package, 'rb')) - if r.status_code != 201: - raise Exception('Failed to upload an asset ' + str(r)) - - update_site(env) - -if __name__ == '__main__': - args = docopt.docopt(__doc__) - if args.get('release'): - release(args) - elif args.get('site'): - update_site(create_build_env()) diff --git a/third_party/fmt/support/mkdocs b/third_party/fmt/support/mkdocs deleted file mode 100755 index 6901918e..00000000 --- a/third_party/fmt/support/mkdocs +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -# A script to invoke mkdocs with the correct environment. -# Additionally supports deploying via mike: -# ./mkdocs deploy [mike-deploy-options] - -import errno, os, shutil, sys -from subprocess import call - -support_dir = os.path.dirname(os.path.normpath(__file__)) -build_dir = os.path.join(os.path.dirname(support_dir), 'build') - -# Set PYTHONPATH for the mkdocstrings handler. -env = os.environ.copy() -path = env.get('PYTHONPATH') -env['PYTHONPATH'] = \ - (path + ':' if path else '') + os.path.join(support_dir, 'python') - -config_path = os.path.join(support_dir, 'mkdocs.yml') -args = sys.argv[1:] -if len(args) > 0: - command = args[0] - if command == 'deploy': - git_url = 'https://github.com/' if 'CI' in os.environ else 'git@github.com:' - site_repo = git_url + 'fmtlib/fmt.dev.git' - - site_dir = os. path.join(build_dir, 'fmt.dev') - try: - shutil.rmtree(site_dir) - except OSError as e: - if e.errno == errno.ENOENT: - pass - ret = call(['git', 'clone', '--depth=1', site_repo, site_dir]) - if ret != 0: - sys.exit(ret) - - # Copy the config to the build dir because the site is built relative to it. - config_build_path = os.path.join(build_dir, 'mkdocs.yml') - shutil.copyfile(config_path, config_build_path) - - sys.exit(call(['mike'] + args + ['--config-file', config_build_path, - '--branch', 'master'], cwd=site_dir, env=env)) - elif not command.startswith('-'): - args += ['-f', config_path] -sys.exit(call(['mkdocs'] + args, env=env)) diff --git a/third_party/fmt/support/mkdocs.yml b/third_party/fmt/support/mkdocs.yml deleted file mode 100644 index 17034cd1..00000000 --- a/third_party/fmt/support/mkdocs.yml +++ /dev/null @@ -1,48 +0,0 @@ -site_name: '{fmt}' - -docs_dir: ../doc - -repo_url: https://github.com/fmtlib/fmt - -theme: - name: material - features: - - navigation.tabs - - navigation.top - - toc.integrate - -extra_javascript: - - https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js - - fmt.js - -extra_css: - - https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css - - fmt.css - -markdown_extensions: - - pymdownx.highlight: - # Use JavaScript syntax highlighter instead of Pygments because it - # automatically applies to code blocks extracted through Doxygen. - use_pygments: false - anchor_linenums: true - line_spans: __span - pygments_lang_class: true - - pymdownx.inlinehilite - - pymdownx.snippets - -plugins: - - search - - mkdocstrings: - default_handler: cxx -nav: - - Home: index.md - - Get Started: get-started.md - - API: api.md - - Syntax: syntax.md - -exclude_docs: ChangeLog-old.md - -extra: - version: - provider: mike - generator: false diff --git a/third_party/fmt/support/printable.py b/third_party/fmt/support/printable.py deleted file mode 100755 index 8fa86b30..00000000 --- a/third_party/fmt/support/printable.py +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/env python3 - -# This script is based on -# https://github.com/rust-lang/rust/blob/master/library/core/src/unicode/printable.py -# distributed under https://github.com/rust-lang/rust/blob/master/LICENSE-MIT. - -# This script uses the following Unicode tables: -# - UnicodeData.txt - - -from collections import namedtuple -import csv -import os -import subprocess - -NUM_CODEPOINTS=0x110000 - -def to_ranges(iter): - current = None - for i in iter: - if current is None or i != current[1] or i in (0x10000, 0x20000): - if current is not None: - yield tuple(current) - current = [i, i + 1] - else: - current[1] += 1 - if current is not None: - yield tuple(current) - -def get_escaped(codepoints): - for c in codepoints: - if (c.class_ or "Cn") in "Cc Cf Cs Co Cn Zl Zp Zs".split() and c.value != ord(' '): - yield c.value - -def get_file(f): - try: - return open(os.path.basename(f)) - except FileNotFoundError: - subprocess.run(["curl", "-O", f], check=True) - return open(os.path.basename(f)) - -Codepoint = namedtuple('Codepoint', 'value class_') - -def get_codepoints(f): - r = csv.reader(f, delimiter=";") - prev_codepoint = 0 - class_first = None - for row in r: - codepoint = int(row[0], 16) - name = row[1] - class_ = row[2] - - if class_first is not None: - if not name.endswith("Last>"): - raise ValueError("Missing Last after First") - - for c in range(prev_codepoint + 1, codepoint): - yield Codepoint(c, class_first) - - class_first = None - if name.endswith("First>"): - class_first = class_ - - yield Codepoint(codepoint, class_) - prev_codepoint = codepoint - - if class_first is not None: - raise ValueError("Missing Last after First") - - for c in range(prev_codepoint + 1, NUM_CODEPOINTS): - yield Codepoint(c, None) - -def compress_singletons(singletons): - uppers = [] # (upper, # items in lowers) - lowers = [] - - for i in singletons: - upper = i >> 8 - lower = i & 0xff - if len(uppers) == 0 or uppers[-1][0] != upper: - uppers.append((upper, 1)) - else: - upper, count = uppers[-1] - uppers[-1] = upper, count + 1 - lowers.append(lower) - - return uppers, lowers - -def compress_normal(normal): - # lengths 0x00..0x7f are encoded as 00, 01, ..., 7e, 7f - # lengths 0x80..0x7fff are encoded as 80 80, 80 81, ..., ff fe, ff ff - compressed = [] # [truelen, (truelenaux), falselen, (falselenaux)] - - prev_start = 0 - for start, count in normal: - truelen = start - prev_start - falselen = count - prev_start = start + count - - assert truelen < 0x8000 and falselen < 0x8000 - entry = [] - if truelen > 0x7f: - entry.append(0x80 | (truelen >> 8)) - entry.append(truelen & 0xff) - else: - entry.append(truelen & 0x7f) - if falselen > 0x7f: - entry.append(0x80 | (falselen >> 8)) - entry.append(falselen & 0xff) - else: - entry.append(falselen & 0x7f) - - compressed.append(entry) - - return compressed - -def print_singletons(uppers, lowers, uppersname, lowersname): - print(" static constexpr singleton {}[] = {{".format(uppersname)) - for u, c in uppers: - print(" {{{:#04x}, {}}},".format(u, c)) - print(" };") - print(" static constexpr unsigned char {}[] = {{".format(lowersname)) - for i in range(0, len(lowers), 8): - print(" {}".format(" ".join("{:#04x},".format(l) for l in lowers[i:i+8]))) - print(" };") - -def print_normal(normal, normalname): - print(" static constexpr unsigned char {}[] = {{".format(normalname)) - for v in normal: - print(" {}".format(" ".join("{:#04x},".format(i) for i in v))) - print(" };") - -def main(): - file = get_file("https://www.unicode.org/Public/UNIDATA/UnicodeData.txt") - - codepoints = get_codepoints(file) - - CUTOFF=0x10000 - singletons0 = [] - singletons1 = [] - normal0 = [] - normal1 = [] - extra = [] - - for a, b in to_ranges(get_escaped(codepoints)): - if a > 2 * CUTOFF: - extra.append((a, b - a)) - elif a == b - 1: - if a & CUTOFF: - singletons1.append(a & ~CUTOFF) - else: - singletons0.append(a) - elif a == b - 2: - if a & CUTOFF: - singletons1.append(a & ~CUTOFF) - singletons1.append((a + 1) & ~CUTOFF) - else: - singletons0.append(a) - singletons0.append(a + 1) - else: - if a >= 2 * CUTOFF: - extra.append((a, b - a)) - elif a & CUTOFF: - normal1.append((a & ~CUTOFF, b - a)) - else: - normal0.append((a, b - a)) - - singletons0u, singletons0l = compress_singletons(singletons0) - singletons1u, singletons1l = compress_singletons(singletons1) - normal0 = compress_normal(normal0) - normal1 = compress_normal(normal1) - - print("""\ -FMT_FUNC auto is_printable(uint32_t cp) -> bool {\ -""") - print_singletons(singletons0u, singletons0l, 'singletons0', 'singletons0_lower') - print_singletons(singletons1u, singletons1l, 'singletons1', 'singletons1_lower') - print_normal(normal0, 'normal0') - print_normal(normal1, 'normal1') - print("""\ - auto lower = static_cast(cp); - if (cp < 0x10000) { - return is_printable(lower, singletons0, - sizeof(singletons0) / sizeof(*singletons0), - singletons0_lower, normal0, sizeof(normal0)); - } - if (cp < 0x20000) { - return is_printable(lower, singletons1, - sizeof(singletons1) / sizeof(*singletons1), - singletons1_lower, normal1, sizeof(normal1)); - }\ -""") - for a, b in extra: - print(" if (0x{:x} <= cp && cp < 0x{:x}) return false;".format(a, a + b)) - print("""\ - return cp < 0x{:x}; -}}\ -""".format(NUM_CODEPOINTS)) - -if __name__ == '__main__': - main() diff --git a/third_party/fmt/support/python/mkdocstrings_handlers/cxx/__init__.py b/third_party/fmt/support/python/mkdocstrings_handlers/cxx/__init__.py deleted file mode 100644 index 4ade52ab..00000000 --- a/third_party/fmt/support/python/mkdocstrings_handlers/cxx/__init__.py +++ /dev/null @@ -1,317 +0,0 @@ -# A basic mkdocstrings handler for {fmt}. -# Copyright (c) 2012 - present, Victor Zverovich - -import os -from pathlib import Path -from typing import Any, List, Mapping, Optional -from subprocess import CalledProcessError, PIPE, Popen, STDOUT -import xml.etree.ElementTree as et - -from mkdocstrings.handlers.base import BaseHandler - -class Definition: - '''A definition extracted by Doxygen.''' - def __init__(self, name: str, kind: Optional[str] = None, - node: Optional[et.Element] = None, - is_member: bool = False): - self.name = name - self.kind = kind if kind is not None else node.get('kind') - self.id = name if not is_member else None - self.params = None - self.members = None - -# A map from Doxygen to HTML tags. -tag_map = { - 'bold': 'b', - 'emphasis': 'em', - 'computeroutput': 'code', - 'para': 'p', - 'programlisting': 'pre', - 'verbatim': 'pre' -} - -# A map from Doxygen tags to text. -tag_text_map = { - 'codeline': '', - 'highlight': '', - 'sp': ' ' -} - -def escape_html(s: str) -> str: - return s.replace("<", "<") - -def doxyxml2html(nodes: List[et.Element]): - out = '' - for n in nodes: - tag = tag_map.get(n.tag) - if not tag: - out += tag_text_map[n.tag] - out += '<' + tag + '>' if tag else '' - out += '' if tag == 'pre' else '' - if n.text: - out += escape_html(n.text) - out += doxyxml2html(n) - out += '' if tag == 'pre' else '' - out += '' if tag else '' - if n.tail: - out += n.tail - return out - -def convert_template_params(node: et.Element) -> Optional[List[Definition]]: - templateparamlist = node.find('templateparamlist') - if templateparamlist is None: - return None - params = [] - for param_node in templateparamlist.findall('param'): - name = param_node.find('declname') - param = Definition(name.text if name is not None else '', 'param') - param.type = param_node.find('type').text - params.append(param) - return params - -def get_description(node: et.Element) -> List[et.Element]: - return node.findall('briefdescription/para') + \ - node.findall('detaileddescription/para') - -def normalize_type(type: str) -> str: - type = type.replace('< ', '<').replace(' >', '>') - return type.replace(' &', '&').replace(' *', '*') - -def convert_type(type: et.Element) -> str: - if type is None: - return None - result = type.text if type.text else '' - for ref in type: - result += ref.text - if ref.tail: - result += ref.tail - result += type.tail.strip() - return normalize_type(result) - -def convert_params(func: et.Element) -> Definition: - params = [] - for p in func.findall('param'): - d = Definition(p.find('declname').text, 'param') - d.type = convert_type(p.find('type')) - params.append(d) - return params - -def convert_return_type(d: Definition, node: et.Element) -> None: - d.trailing_return_type = None - if d.type == 'auto' or d.type == 'constexpr auto': - parts = node.find('argsstring').text.split(' -> ') - if len(parts) > 1: - d.trailing_return_type = normalize_type(parts[1]) - -def render_param(param: Definition) -> str: - return param.type + (f' {param.name}' if len(param.name) > 0 else '') - -def render_decl(d: Definition) -> None: - text = '' - if d.id is not None: - text += f'\n' - text += '
'
-
-  text += '
' - if d.template_params is not None: - text += 'template <' - text += ', '.join([render_param(p) for p in d.template_params]) - text += '>\n' - text += '
' - - text += '
' - end = ';' - if d.kind == 'function' or d.kind == 'variable': - text += d.type + ' ' if len(d.type) > 0 else '' - elif d.kind == 'typedef': - text += 'using ' - elif d.kind == 'define': - end = '' - else: - text += d.kind + ' ' - text += d.name - - if d.params is not None: - params = ', '.join([ - (p.type + ' ' if p.type else '') + p.name for p in d.params]) - text += '(' + escape_html(params) + ')' - if d.trailing_return_type: - text += ' -⁠> ' + escape_html(d.trailing_return_type) - elif d.kind == 'typedef': - text += ' = ' + escape_html(d.type) - - text += end - text += '
' - text += '
\n' - if d.id is not None: - text += f'
\n' - return text - -class CxxHandler(BaseHandler): - def __init__(self, **kwargs: Any) -> None: - super().__init__(handler='cxx', **kwargs) - - headers = [ - 'args.h', 'base.h', 'chrono.h', 'color.h', 'compile.h', 'format.h', - 'os.h', 'ostream.h', 'printf.h', 'ranges.h', 'std.h', 'xchar.h' - ] - - # Run doxygen. - cmd = ['doxygen', '-'] - support_dir = Path(__file__).parents[3] - top_dir = os.path.dirname(support_dir) - include_dir = os.path.join(top_dir, 'include', 'fmt') - self._ns2doxyxml = {} - build_dir = os.path.join(top_dir, 'build') - os.makedirs(build_dir, exist_ok=True) - self._doxyxml_dir = os.path.join(build_dir, 'doxyxml') - p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) - _, _ = p.communicate(input=r''' - PROJECT_NAME = fmt - GENERATE_XML = YES - GENERATE_LATEX = NO - GENERATE_HTML = NO - INPUT = {0} - XML_OUTPUT = {1} - QUIET = YES - AUTOLINK_SUPPORT = NO - MACRO_EXPANSION = YES - PREDEFINED = _WIN32=1 \ - __linux__=1 \ - FMT_ENABLE_IF(...)= \ - FMT_USE_USER_DEFINED_LITERALS=1 \ - FMT_USE_ALIAS_TEMPLATES=1 \ - FMT_USE_NONTYPE_TEMPLATE_ARGS=1 \ - FMT_API= \ - "FMT_BEGIN_NAMESPACE=namespace fmt {{" \ - "FMT_END_NAMESPACE=}}" \ - "FMT_DOC=1" - '''.format( - ' '.join([os.path.join(include_dir, h) for h in headers]), - self._doxyxml_dir).encode('utf-8')) - if p.returncode != 0: - raise CalledProcessError(p.returncode, cmd) - - # Merge all file-level XMLs into one to simplify search. - self._file_doxyxml = None - for h in headers: - filename = h.replace(".h", "_8h.xml") - with open(os.path.join(self._doxyxml_dir, filename)) as f: - doxyxml = et.parse(f) - if self._file_doxyxml is None: - self._file_doxyxml = doxyxml - continue - root = self._file_doxyxml.getroot() - for node in doxyxml.getroot(): - root.append(node) - - def collect_compound(self, identifier: str, - cls: List[et.Element]) -> Definition: - '''Collect a compound definition such as a struct.''' - path = os.path.join(self._doxyxml_dir, cls[0].get('refid') + '.xml') - with open(path) as f: - xml = et.parse(f) - node = xml.find('compounddef') - d = Definition(identifier, node=node) - d.template_params = convert_template_params(node) - d.desc = get_description(node) - d.members = [] - for m in node.findall('sectiondef[@kind="public-attrib"]/memberdef') + \ - node.findall('sectiondef[@kind="public-func"]/memberdef'): - name = m.find('name').text - # Doxygen incorrectly classifies members of private unnamed unions as - # public members of the containing class. - if name.endswith('_'): - continue - desc = get_description(m) - if len(desc) == 0: - continue - kind = m.get('kind') - member = Definition(name if name else '', kind=kind, is_member=True) - type = m.find('type').text - member.type = type if type else '' - if kind == 'function': - member.params = convert_params(m) - convert_return_type(member, m) - member.template_params = None - member.desc = desc - d.members.append(member) - return d - - def collect(self, identifier: str, config: Mapping[str, Any]) -> Definition: - qual_name = 'fmt::' + identifier - - param_str = None - paren = qual_name.find('(') - if paren > 0: - qual_name, param_str = qual_name[:paren], qual_name[paren + 1:-1] - - colons = qual_name.rfind('::') - namespace, name = qual_name[:colons], qual_name[colons + 2:] - - # Load XML. - doxyxml = self._ns2doxyxml.get(namespace) - if doxyxml is None: - path = f'namespace{namespace.replace("::", "_1_1")}.xml' - with open(os.path.join(self._doxyxml_dir, path)) as f: - doxyxml = et.parse(f) - self._ns2doxyxml[namespace] = doxyxml - - nodes = doxyxml.findall( - f"compounddef/sectiondef/memberdef/name[.='{name}']/..") - if len(nodes) == 0: - nodes = self._file_doxyxml.findall( - f"compounddef/sectiondef/memberdef/name[.='{name}']/..") - candidates = [] - for node in nodes: - # Process a function or a typedef. - params = None - d = Definition(name, node=node) - if d.kind == 'function': - params = convert_params(node) - node_param_str = ', '.join([p.type for p in params]) - if param_str and param_str != node_param_str: - candidates.append(f'{name}({node_param_str})') - continue - elif d.kind == 'define': - params = [] - for p in node.findall('param'): - param = Definition(p.find('defname').text, kind='param') - param.type = None - params.append(param) - d.type = convert_type(node.find('type')) - d.template_params = convert_template_params(node) - d.params = params - convert_return_type(d, node) - d.desc = get_description(node) - return d - - cls = doxyxml.findall(f"compounddef/innerclass[.='{qual_name}']") - if not cls: - raise Exception(f'Cannot find {identifier}. Candidates: {candidates}') - return self.collect_compound(identifier, cls) - - def render(self, d: Definition, config: dict) -> str: - if d.id is not None: - self.do_heading('', 0, id=d.id) - text = '
\n' - text += render_decl(d) - text += '
\n' - text += doxyxml2html(d.desc) - if d.members is not None: - for m in d.members: - text += self.render(m, config) - text += '
\n' - text += '
\n' - return text - -def get_handler(theme: str, custom_templates: Optional[str] = None, - **config: Any) -> CxxHandler: - '''Return an instance of `CxxHandler`. - - Arguments: - theme: The theme to use when rendering contents. - custom_templates: Directory containing custom templates. - **config: Configuration passed to the handler. - ''' - return CxxHandler(theme=theme, custom_templates=custom_templates) diff --git a/third_party/fmt/support/python/mkdocstrings_handlers/cxx/templates/README b/third_party/fmt/support/python/mkdocstrings_handlers/cxx/templates/README deleted file mode 100644 index 7da18db5..00000000 --- a/third_party/fmt/support/python/mkdocstrings_handlers/cxx/templates/README +++ /dev/null @@ -1 +0,0 @@ -mkdocsstrings requires a handler to have a templates directory. diff --git a/third_party/fmt/test/CMakeLists.txt b/third_party/fmt/test/CMakeLists.txt deleted file mode 100644 index a14dfc24..00000000 --- a/third_party/fmt/test/CMakeLists.txt +++ /dev/null @@ -1,272 +0,0 @@ -add_subdirectory(gtest) - -include(CheckSymbolExists) - -set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc) -add_library(test-main STATIC ${TEST_MAIN_SRC}) -target_include_directories(test-main PUBLIC - $) -target_link_libraries(test-main gtest fmt) - -function(add_fmt_executable name) - add_executable(${name} ${ARGN}) - # (Wstringop-overflow) - [meta-bug] bogus/missing -Wstringop-overflow warnings - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443 - # Bogus -Wstringop-overflow warning - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100395 - # [10 Regression] spurious -Wstringop-overflow writing to a trailing array plus offset - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95353 - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND - NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) - target_compile_options(${name} PRIVATE -Wno-stringop-overflow) - # The linker flag is needed for LTO. - target_link_libraries(${name} -Wno-stringop-overflow) - endif () -endfunction() - -# Adds a test. -# Usage: add_fmt_test(name srcs...) -function(add_fmt_test name) - cmake_parse_arguments(ADD_FMT_TEST "HEADER_ONLY;MODULE" "" "" ${ARGN}) - - set(sources ${name}.cc ${ADD_FMT_TEST_UNPARSED_ARGUMENTS}) - if (ADD_FMT_TEST_HEADER_ONLY) - set(sources ${sources} ${TEST_MAIN_SRC} ../src/os.cc) - set(libs gtest fmt-header-only) - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables) - endif () - elseif (ADD_FMT_TEST_MODULE) - set(libs test-main test-module) - set_source_files_properties(${name}.cc PROPERTIES OBJECT_DEPENDS test-module) - else () - set(libs test-main fmt) - endif () - add_fmt_executable(${name} ${sources}) - target_link_libraries(${name} ${libs}) - - if (ADD_FMT_TEST_HEADER_ONLY AND NOT FMT_UNICODE) - target_compile_definitions(${name} PUBLIC FMT_UNICODE=0) - endif () - - # Define if certain C++ features can be used. - if (FMT_PEDANTIC) - target_compile_options(${name} PRIVATE ${PEDANTIC_COMPILE_FLAGS}) - endif () - if (FMT_WERROR) - target_compile_options(${name} PRIVATE ${WERROR_FLAG}) - endif () - add_test(NAME ${name} COMMAND ${name}) -endfunction() - -if (FMT_MODULE) - return () -endif () - -add_fmt_test(args-test) -add_fmt_test(base-test) -add_fmt_test(assert-test) -add_fmt_test(chrono-test) -add_fmt_test(color-test) -add_fmt_test(gtest-extra-test) -add_fmt_test(format-test mock-allocator.h) -if (MSVC) - target_compile_options(format-test PRIVATE /bigobj) -endif () -if (NOT (MSVC AND BUILD_SHARED_LIBS)) - add_fmt_test(format-impl-test HEADER_ONLY header-only-test.cc) -endif () -add_fmt_test(ostream-test) -add_fmt_test(compile-test) -add_fmt_test(compile-fp-test HEADER_ONLY) -if (MSVC) - # Without this option, MSVC returns 199711L for the __cplusplus macro. - target_compile_options(compile-fp-test PRIVATE /Zc:__cplusplus) -endif() -add_fmt_test(printf-test) -add_fmt_test(ranges-test ranges-odr-test.cc) - -add_fmt_test(scan-test HEADER_ONLY) -check_symbol_exists(strptime "time.h" HAVE_STRPTIME) -if (HAVE_STRPTIME) - target_compile_definitions(scan-test PRIVATE FMT_HAVE_STRPTIME) -endif () - -add_fmt_test(std-test) -try_compile(compile_result_unused - ${CMAKE_CURRENT_BINARY_DIR} - SOURCES ${CMAKE_CURRENT_LIST_DIR}/detect-stdfs.cc - OUTPUT_VARIABLE RAWOUTPUT) -string(REGEX REPLACE ".*libfound \"([^\"]*)\".*" "\\1" STDLIBFS "${RAWOUTPUT}") -if (STDLIBFS) - target_link_libraries(std-test ${STDLIBFS}) -endif () -add_fmt_test(unicode-test HEADER_ONLY) -if (MSVC) - target_compile_options(unicode-test PRIVATE /utf-8) -endif () -add_fmt_test(xchar-test) -add_fmt_test(enforce-checks-test) -target_compile_definitions(enforce-checks-test PRIVATE - -DFMT_ENFORCE_COMPILE_STRING) - -add_executable(perf-sanity perf-sanity.cc) -target_link_libraries(perf-sanity fmt::fmt) - -if (FMT_MODULE) - # The tests need {fmt} to be compiled as traditional library - # because of visibility of implementation details. - # If module support is present the module tests require a - # test-only module to be built from {fmt} - add_library(test-module OBJECT ${CMAKE_SOURCE_DIR}/src/fmt.cc) - target_compile_features(test-module PUBLIC cxx_std_11) - target_include_directories(test-module PUBLIC - $) - enable_module(test-module) - - add_fmt_test(module-test MODULE test-main.cc) - if (MSVC) - target_compile_options(test-module PRIVATE /utf-8 /Zc:__cplusplus - /Zc:externConstexpr /Zc:inline) - target_compile_options(module-test PRIVATE /utf-8 /Zc:__cplusplus - /Zc:externConstexpr /Zc:inline) - endif () -endif () - -if (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC) - foreach (flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if (${flag_var} MATCHES "^(/|-)(MT|MTd)") - set(MSVC_STATIC_RUNTIME ON) - break() - endif() - endforeach() -endif() - -if (NOT MSVC_STATIC_RUNTIME) - add_fmt_executable(posix-mock-test - posix-mock-test.cc ../src/format.cc ${TEST_MAIN_SRC}) - target_include_directories( - posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include) - target_link_libraries(posix-mock-test gtest) - if (FMT_PEDANTIC) - target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) - endif () - if (MSVC) - target_compile_options(posix-mock-test PRIVATE /utf-8) - endif () - add_test(NAME posix-mock-test COMMAND posix-mock-test) - add_fmt_test(os-test) -endif () - -message(STATUS "FMT_PEDANTIC: ${FMT_PEDANTIC}") - -if (FMT_PEDANTIC) - # Test that the library can be compiled with exceptions disabled. - # -fno-exception is broken in icc: https://github.com/fmtlib/fmt/issues/822. - if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - check_cxx_compiler_flag(-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG) - endif () - if (HAVE_FNO_EXCEPTIONS_FLAG) - add_library(noexception-test ../src/format.cc noexception-test.cc) - target_include_directories( - noexception-test PRIVATE ${PROJECT_SOURCE_DIR}/include) - target_compile_options(noexception-test PRIVATE -fno-exceptions) - target_compile_options(noexception-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) - endif () - - # Test that the library compiles without locale. - add_library(nolocale-test ../src/format.cc) - target_include_directories( - nolocale-test PRIVATE ${PROJECT_SOURCE_DIR}/include) - target_compile_definitions( - nolocale-test PRIVATE FMT_STATIC_THOUSANDS_SEPARATOR=1) -endif () - -# These tests are disabled on Windows because they take too long. -# They are disabled on GCC < 4.9 because it can not parse UDLs without -# a space after `operator""` but that is an incorrect syntax for any more -# modern compiler. -if (FMT_PEDANTIC AND NOT WIN32 AND NOT ( - CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND - CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)) - # Test if incorrect API usages produce compilation error. - add_test(compile-error-test ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/compile-error-test" - "${CMAKE_CURRENT_BINARY_DIR}/compile-error-test" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-options - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" - "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DCXX_STANDARD_FLAG=${CXX_STANDARD_FLAG}" - "-DFMT_DIR=${CMAKE_SOURCE_DIR}") - - # Test if the targets are found from the build directory. - add_test(find-package-test ${CMAKE_CTEST_COMMAND} - -C ${CMAKE_BUILD_TYPE} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/find-package-test" - "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-options - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" - "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DFMT_DIR=${PROJECT_BINARY_DIR}" - "-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}" - "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") - - # Test if the targets are found when add_subdirectory is used. - add_test(add-subdirectory-test ${CMAKE_CTEST_COMMAND} - -C ${CMAKE_BUILD_TYPE} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/add-subdirectory-test" - "${CMAKE_CURRENT_BINARY_DIR}/add-subdirectory-test" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-options - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}" - "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") -endif () - -# This test is disabled on Windows because it is POSIX-specific. -if (FMT_PEDANTIC AND NOT WIN32) - add_test(static-export-test ${CMAKE_CTEST_COMMAND} - -C ${CMAKE_BUILD_TYPE} - --build-and-test - "${CMAKE_CURRENT_SOURCE_DIR}/static-export-test" - "${CMAKE_CURRENT_BINARY_DIR}/static-export-test" - --build-generator ${CMAKE_GENERATOR} - --build-makeprogram ${CMAKE_MAKE_PROGRAM} - --build-options - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") -endif () - -# Activate optional CUDA tests if CUDA is found. For version selection see -# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features -if (FMT_CUDA_TEST) - if (${CMAKE_VERSION} VERSION_LESS 3.15) - find_package(CUDA 9.0) - else () - include(CheckLanguage) - check_language(CUDA) - if (CMAKE_CUDA_COMPILER) - enable_language(CUDA OPTIONAL) - set(CUDA_FOUND TRUE) - endif () - endif () - - if (CUDA_FOUND) - add_subdirectory(cuda-test) - add_test(NAME cuda-test COMMAND fmt-in-cuda-test) - endif () -endif () diff --git a/third_party/fmt/test/add-subdirectory-test/CMakeLists.txt b/third_party/fmt/test/add-subdirectory-test/CMakeLists.txt deleted file mode 100644 index 362b0494..00000000 --- a/third_party/fmt/test/add-subdirectory-test/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 3.8...3.25) - -project(fmt-test CXX) - -add_subdirectory(../.. fmt) - -add_executable(library-test main.cc) -target_include_directories(library-test PUBLIC SYSTEM .) -target_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) -target_link_libraries(library-test fmt::fmt) - -if (TARGET fmt::fmt-header-only) - add_executable(header-only-test main.cc) - target_include_directories(header-only-test PUBLIC SYSTEM .) - target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) - target_link_libraries(header-only-test fmt::fmt-header-only) -endif () diff --git a/third_party/fmt/test/add-subdirectory-test/main.cc b/third_party/fmt/test/add-subdirectory-test/main.cc deleted file mode 100644 index 1d31cb90..00000000 --- a/third_party/fmt/test/add-subdirectory-test/main.cc +++ /dev/null @@ -1,5 +0,0 @@ -#include "fmt/base.h" - -int main(int argc, char** argv) { - for (int i = 0; i < argc; ++i) fmt::print("{}: {}\n", i, argv[i]); -} diff --git a/third_party/fmt/test/args-test.cc b/third_party/fmt/test/args-test.cc deleted file mode 100644 index f99ff74e..00000000 --- a/third_party/fmt/test/args-test.cc +++ /dev/null @@ -1,188 +0,0 @@ -// Formatting library for C++ - dynamic argument store tests -// -// Copyright (c) 2012 - present, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -#include "fmt/args.h" - -#include - -#include "gtest/gtest.h" - -TEST(args_test, basic) { - fmt::dynamic_format_arg_store store; - store.push_back(42); - store.push_back("abc1"); - store.push_back(1.5f); - EXPECT_EQ("42 and abc1 and 1.5", fmt::vformat("{} and {} and {}", store)); -} - -TEST(args_test, strings_and_refs) { - // Unfortunately the tests are compiled with old ABI so strings use COW. - fmt::dynamic_format_arg_store store; - char str[] = "1234567890"; - store.push_back(str); - store.push_back(std::cref(str)); - store.push_back(fmt::string_view{str}); - str[0] = 'X'; - - auto result = fmt::vformat("{} and {} and {}", store); - EXPECT_EQ("1234567890 and X234567890 and X234567890", result); -} - -struct custom_type { - int i = 0; -}; - -FMT_BEGIN_NAMESPACE -template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - return ctx.begin(); - } - - template - auto format(const custom_type& p, FormatContext& ctx) const - -> decltype(ctx.out()) { - return fmt::format_to(ctx.out(), "cust={}", p.i); - } -}; -FMT_END_NAMESPACE - -TEST(args_test, custom_format) { - fmt::dynamic_format_arg_store store; - auto c = custom_type(); - store.push_back(c); - ++c.i; - store.push_back(c); - ++c.i; - store.push_back(std::cref(c)); - ++c.i; - auto result = fmt::vformat("{} and {} and {}", store); - EXPECT_EQ("cust=0 and cust=1 and cust=3", result); -} - -struct to_stringable { - friend fmt::string_view to_string_view(to_stringable) { return {}; } -}; - -FMT_BEGIN_NAMESPACE -template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - return ctx.begin(); - } - - auto format(to_stringable, format_context& ctx) const -> decltype(ctx.out()) { - return ctx.out(); - } -}; -FMT_END_NAMESPACE - -TEST(args_test, to_string_and_formatter) { - fmt::dynamic_format_arg_store store; - auto s = to_stringable(); - store.push_back(s); - store.push_back(std::cref(s)); - fmt::vformat("", store); -} - -TEST(args_test, named_int) { - fmt::dynamic_format_arg_store store; - store.push_back(fmt::arg("a1", 42)); - EXPECT_EQ("42", fmt::vformat("{a1}", store)); -} - -TEST(args_test, named_strings) { - fmt::dynamic_format_arg_store store; - char str[] = "1234567890"; - store.push_back(fmt::arg("a1", str)); - store.push_back(fmt::arg("a2", std::cref(str))); - str[0] = 'X'; - EXPECT_EQ("1234567890 and X234567890", fmt::vformat("{a1} and {a2}", store)); -} - -TEST(args_test, named_arg_by_ref) { - fmt::dynamic_format_arg_store store; - char band[] = "Rolling Stones"; - store.push_back(fmt::arg("band", std::cref(band))); - band[9] = 'c'; // Changing band affects the output. - EXPECT_EQ(fmt::vformat("{band}", store), "Rolling Scones"); -} - -TEST(args_test, named_custom_format) { - fmt::dynamic_format_arg_store store; - auto c = custom_type(); - store.push_back(fmt::arg("c1", c)); - ++c.i; - store.push_back(fmt::arg("c2", c)); - ++c.i; - store.push_back(fmt::arg("c_ref", std::cref(c))); - ++c.i; - auto result = fmt::vformat("{c1} and {c2} and {c_ref}", store); - EXPECT_EQ("cust=0 and cust=1 and cust=3", result); -} - -TEST(args_test, clear) { - fmt::dynamic_format_arg_store store; - store.push_back(42); - - auto result = fmt::vformat("{}", store); - EXPECT_EQ("42", result); - - store.push_back(43); - result = fmt::vformat("{} and {}", store); - EXPECT_EQ("42 and 43", result); - - store.clear(); - store.push_back(44); - result = fmt::vformat("{}", store); - EXPECT_EQ("44", result); -} - -TEST(args_test, reserve) { - fmt::dynamic_format_arg_store store; - store.reserve(2, 1); - store.push_back(1.5f); - store.push_back(fmt::arg("a", 42)); - auto result = fmt::vformat("{} and {a}", store); - EXPECT_EQ("1.5 and 42", result); -} - -struct copy_throwable { - copy_throwable() {} - copy_throwable(const copy_throwable&) { throw "deal with it"; } -}; - -FMT_BEGIN_NAMESPACE -template <> struct formatter { - auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { - return ctx.begin(); - } - auto format(copy_throwable, format_context& ctx) const - -> decltype(ctx.out()) { - return ctx.out(); - } -}; -FMT_END_NAMESPACE - -TEST(args_test, throw_on_copy) { - fmt::dynamic_format_arg_store store; - store.push_back(std::string("foo")); - try { - store.push_back(copy_throwable()); - } catch (...) { - } - EXPECT_EQ(fmt::vformat("{}", store), "foo"); -} - -TEST(args_test, move_constructor) { - using store_type = fmt::dynamic_format_arg_store; - auto store = std::unique_ptr(new store_type()); - store->push_back(42); - store->push_back(std::string("foo")); - store->push_back(fmt::arg("a1", "foo")); - auto moved_store = std::move(*store); - store.reset(); - EXPECT_EQ(fmt::vformat("{} {} {a1}", moved_store), "42 foo foo"); -} diff --git a/third_party/fmt/test/assert-test.cc b/third_party/fmt/test/assert-test.cc deleted file mode 100644 index 368fb587..00000000 --- a/third_party/fmt/test/assert-test.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Formatting library for C++ - FMT_ASSERT test -// -// It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks -// which are slow on some platforms. In other tests FMT_ASSERT is made to throw -// an exception which is much faster and easier to check. -// -// Copyright (c) 2012 - present, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -#include "fmt/base.h" -#include "gtest/gtest.h" - -TEST(assert_test, fail) { -#if GTEST_HAS_DEATH_TEST - EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!"); -#else - fmt::print("warning: death tests are not supported\n"); -#endif -} - -TEST(assert_test, dangling_else) { - bool test_condition = false; - bool executed_else = false; - if (test_condition) - FMT_ASSERT(true, ""); - else - executed_else = true; - EXPECT_TRUE(executed_else); -} diff --git a/third_party/fmt/test/base-test.cc b/third_party/fmt/test/base-test.cc deleted file mode 100644 index 76570036..00000000 --- a/third_party/fmt/test/base-test.cc +++ /dev/null @@ -1,899 +0,0 @@ -// Formatting library for C++ - core tests -// -// Copyright (c) 2012 - present, Victor Zverovich -// All rights reserved. -// -// For the license information refer to format.h. - -// clang-format off -#include "test-assert.h" -// clang-format on - -#include "fmt/base.h" - -#include // INT_MAX -#include // std::strlen -#include // std::equal_to -#include // std::back_insert_iterator, std::distance -#include // std::numeric_limits -#include // std::string -#include // std::is_same - -#include "gmock/gmock.h" - -using fmt::string_view; -using fmt::detail::buffer; - -using testing::_; -using testing::Invoke; -using testing::Return; - -#ifdef FMT_FORMAT_H_ -# error core-test includes format.h -#endif - -fmt::appender copy(fmt::string_view s, fmt::appender out) { - for (char c : s) *out++ = c; - return out; -} - -TEST(string_view_test, value_type) { - static_assert(std::is_same::value, ""); -} - -TEST(string_view_test, ctor) { - EXPECT_STREQ("abc", fmt::string_view("abc").data()); - EXPECT_EQ(3u, fmt::string_view("abc").size()); - - EXPECT_STREQ("defg", fmt::string_view(std::string("defg")).data()); - EXPECT_EQ(4u, fmt::string_view(std::string("defg")).size()); -} - -TEST(string_view_test, length) { - // Test that string_view::size() returns string length, not buffer size. - char str[100] = "some string"; - EXPECT_EQ(std::strlen(str), string_view(str).size()); - EXPECT_LT(std::strlen(str), sizeof(str)); -} - -// Check string_view's comparison operator. -template