[
  {
    "path": ".clang-format",
    "content": "# Run manually to reformat a file:\n# clang-format -i --style=file <file>\nLanguage: Cpp\nBasedOnStyle: Google\nIndentPPDirectives: AfterHash\nIndentCaseLabels: false\nAlwaysBreakTemplateDeclarations: false\nDerivePointerAlignment: false\nAllowShortCaseLabelsOnASingleLine: true\nQualifierAlignment: Left\nAlignConsecutiveShortCaseStatements:\n  Enabled: true\n  AcrossEmptyLines: true\n  AcrossComments: true\n  AlignCaseColons: false"
  },
  {
    "path": ".clang-tidy",
    "content": "Checks: modernize-use-trailing-return-type\nCheckOptions:\n  - key: modernize-use-trailing-return-type.TransformLambdas\n    value: none\n"
  },
  {
    "path": ".cmake-format",
    "content": "format:\n  separate_ctrl_name_with_space: true\nmarkup:\n  enable_markup: false\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: vitaut\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: \"github-actions\" # Necessary to update action hashes.\t\n    directory: \"/\"\n    schedule:\n      interval: \"monthly\"\n    # Allow up to 3 opened pull requests for github-actions versions.\n    open-pull-requests-limit: 3\n"
  },
  {
    "path": ".github/issue_template.md",
    "content": "<!--\nPlease make sure that the problem reproduces on the current master before\nsubmitting an issue.\nIf possible please provide a repro on Compiler Explorer:\nhttps://godbolt.org/z/fxccbh53W.\n-->\n"
  },
  {
    "path": ".github/pull_request_template.md",
    "content": "<!--\nPlease read the contribution guidelines before submitting a pull request:\nhttps://github.com/fmtlib/fmt/blob/master/CONTRIBUTING.md.\nBy submitting this pull request, you agree to license your contribution(s)\nunder the terms outlined in LICENSE.rst and represent that you have the right\nto do so.\n-->\n"
  },
  {
    "path": ".github/workflows/cifuzz.yml",
    "content": "name: CIFuzz\non: [pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  Fuzzing:\n    runs-on: ubuntu-latest\n    steps:\n    - name: Build fuzzers\n      id: build\n      uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@92182553173581f871130c71c71b17f003d47b0a\n      with:\n        oss-fuzz-project-name: 'fmt'\n        dry-run: false\n        language: c++\n\n    - name: Run fuzzers\n      uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@92182553173581f871130c71c71b17f003d47b0a\n      with:\n        oss-fuzz-project-name: 'fmt'\n        fuzz-seconds: 300\n        dry-run: false\n        language: c++\n\n    - name: Upload crash\n      uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0\n      if: failure() && steps.build.outcome == 'success'\n      with:\n        name: artifacts\n        path: ./out/artifacts\n"
  },
  {
    "path": ".github/workflows/doc.yml",
    "content": "name: doc\n\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  build:\n    runs-on: ubuntu-22.04\n\n    steps:\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n\n    - name: Add Ubuntu mirrors\n      run: |\n        # Github Actions caching proxy is at times unreliable\n        # see https://github.com/actions/runner-images/issues/7048\n        printf 'http://azure.archive.ubuntu.com/ubuntu\\tpriority:1\\n' | sudo tee /etc/apt/mirrors.txt\n        curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt\n        sudo sed -i 's~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:/etc/apt/mirrors.txt~' /etc/apt/sources.list\n\n    - name: Create build environment\n      run: |\n        sudo apt update\n        sudo apt install doxygen\n        pip install mkdocs-material==9.7.0 mkdocstrings==1.0.0 mike==2.1.3 typing_extensions==4.15.0\n        cmake -E make_directory ${{runner.workspace}}/build\n        # Workaround https://github.com/actions/checkout/issues/13:\n        git config --global user.name \"$(git --no-pager log --format=format:'%an' -n 1)\"\n        git config --global user.email \"$(git --no-pager log --format=format:'%ae' -n 1)\"\n\n    - name: Build\n      working-directory: ${{runner.workspace}}/build\n      run: $GITHUB_WORKSPACE/support/mkdocs deploy dev\n\n    - name: Deploy\n      env:\n        KEY: \"${{secrets.KEY}}\"\n      if: env.KEY != '' && github.ref == 'refs/heads/master'\n      working-directory: ${{runner.workspace}}/fmt/build/fmt.dev\n      run: git push https://$KEY@github.com/fmtlib/fmt.dev.git\n"
  },
  {
    "path": ".github/workflows/lint.yml",
    "content": "name: lint\n\non:\n  pull_request:\n    paths:\n      - '**.h'\n      - '**.cc'\n      - '**.cmake'\n      - '**/CMakeLists.txt'\n\npermissions:\n  contents: read\n\njobs:\n  clang-format:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n\n    - name: Install clang-format\n      run: |\n        wget https://apt.llvm.org/llvm.sh\n        sudo bash ./llvm.sh 21\n        sudo apt install clang-format-21\n\n    - name: Run clang-format\n      run: |\n        find include src -name '*.h' -o -name '*.cc' | \\\n          xargs clang-format-21 -i -style=file -fallback-style=none\n        git diff --exit-code\n\n  cmake-format:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n\n    - name: Install cmake-format\n      run: pip install cmakelang\n\n    - name: Run cmake-format\n      run: |\n        find . -name CMakeLists.txt -o -name '*.cmake' | \\\n          xargs cmake-format -i\n        git diff --exit-code\n"
  },
  {
    "path": ".github/workflows/linux.yml",
    "content": "name: linux\n\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  build:\n    runs-on: ubuntu-22.04\n    strategy:\n      matrix:\n        cxx: [g++-4.9, g++-11, clang++-3.6, clang++-11]\n        build_type: [Debug, Release]\n        std: [11]\n        shared: [\"\"]\n        include:\n          - cxx: g++-4.9\n          - cxx: clang++-3.6\n          - cxx: g++-11\n            build_type: Debug\n            std: 14\n            install: sudo apt install g++-11\n          - cxx: g++-11\n            build_type: Debug\n            std: 17\n          - cxx: g++-11\n            build_type: Debug\n            std: 20\n            install: sudo apt install g++-11\n          - cxx: g++-13\n            build_type: Release\n            std: 23\n            install: sudo apt install g++-13\n            shared: -DBUILD_SHARED_LIBS=ON\n          - cxx: clang++-11\n            build_type: Debug\n            std: 17\n            cxxflags: -stdlib=libc++\n            install: sudo apt install clang-11 libc++-11-dev libc++abi-11-dev\n          - cxx: clang++-11\n            install: sudo apt install clang-11\n          - cxx: clang++-11\n            build_type: Debug\n            fuzz: -DFMT_FUZZ=ON -DFMT_FUZZ_LINKMAIN=ON\n            std: 17\n            install: sudo apt install clang-11\n          - cxx: clang++-14\n            build_type: Debug\n            std: 20\n          - cxx: clang++-14\n            build_type: Debug\n            std: 20\n            cxxflags: -stdlib=libc++\n            install: sudo apt install libc++-14-dev libc++abi-14-dev\n\n    steps:\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n\n    - name: Set timezone\n      run: sudo timedatectl set-timezone 'Europe/Kyiv'\n\n    - name: Install GCC 4.9\n      run: |\n        sudo apt update\n        sudo apt install libatomic1 libc6-dev libgomp1 libitm1 libmpc3\n        # https://launchpad.net/ubuntu/xenial/amd64/g++-4.9/4.9.3-13ubuntu2\n        wget --no-verbose \\\n          http://launchpadlibrarian.net/230069137/libmpfr4_3.1.3-2_amd64.deb \\\n          http://launchpadlibrarian.net/253728424/libasan1_4.9.3-13ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/445346135/libubsan0_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346112/libcilkrts5_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/253728426/libgcc-4.9-dev_4.9.3-13ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/253728432/libstdc++-4.9-dev_4.9.3-13ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/253728314/gcc-4.9-base_4.9.3-13ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/445345919/gcc-5-base_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/253728399/cpp-4.9_4.9.3-13ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/253728404/gcc-4.9_4.9.3-13ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/253728401/g++-4.9_4.9.3-13ubuntu2_amd64.deb\n        sudo dpkg -i \\\n          libmpfr4_3.1.3-2_amd64.deb \\\n          libasan1_4.9.3-13ubuntu2_amd64.deb \\\n          libubsan0_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libcilkrts5_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libgcc-4.9-dev_4.9.3-13ubuntu2_amd64.deb \\\n          libstdc++-4.9-dev_4.9.3-13ubuntu2_amd64.deb \\\n          gcc-4.9-base_4.9.3-13ubuntu2_amd64.deb \\\n          gcc-5-base_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          cpp-4.9_4.9.3-13ubuntu2_amd64.deb \\\n          gcc-4.9_4.9.3-13ubuntu2_amd64.deb \\\n          g++-4.9_4.9.3-13ubuntu2_amd64.deb\n      if: ${{ matrix.cxx == 'g++-4.9' }}\n\n    - name: Install Clang 3.6\n      run: |\n        sudo apt update\n        sudo apt install libtinfo5\n        # https://code.launchpad.net/ubuntu/xenial/amd64/clang-3.6/1:3.6.2-3ubuntu2\n        wget --no-verbose \\\n          http://launchpadlibrarian.net/230019046/libffi6_3.2.1-4_amd64.deb \\\n          http://launchpadlibrarian.net/445346109/libasan2_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346135/libubsan0_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346112/libcilkrts5_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346128/libmpx0_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346113/libgcc-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346131/libstdc++-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/445346022/libobjc-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/254405108/libllvm3.6v5_3.6.2-3ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/254405097/libclang-common-3.6-dev_3.6.2-3ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/254405101/libclang1-3.6_3.6.2-3ubuntu2_amd64.deb \\\n          http://launchpadlibrarian.net/445345919/gcc-5-base_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          http://launchpadlibrarian.net/254405091/clang-3.6_3.6.2-3ubuntu2_amd64.deb\n        sudo dpkg -i \\\n          libffi6_3.2.1-4_amd64.deb \\\n          libasan2_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libubsan0_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libcilkrts5_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libmpx0_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libgcc-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libstdc++-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libobjc-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          libllvm3.6v5_3.6.2-3ubuntu2_amd64.deb \\\n          libclang-common-3.6-dev_3.6.2-3ubuntu2_amd64.deb \\\n          libclang1-3.6_3.6.2-3ubuntu2_amd64.deb \\\n          gcc-5-base_5.4.0-6ubuntu1~16.04.12_amd64.deb \\\n          clang-3.6_3.6.2-3ubuntu2_amd64.deb\n      if: ${{ matrix.cxx == 'clang++-3.6' }}\n\n    - name: Add repositories for newer GCC\n      run: |\n        sudo apt-add-repository ppa:ubuntu-toolchain-r/test\n      if: ${{ matrix.cxx == 'g++-13' }}\n\n    - name: Add Ubuntu mirrors\n      run: |\n        # GitHub Actions caching proxy is at times unreliable\n        # see https://github.com/actions/runner-images/issues/7048.\n        mirrors=/etc/apt/mirrors.txt\n        printf 'http://azure.archive.ubuntu.com/ubuntu\\tpriority:1\\n' | \\\n          sudo tee $mirrors\n        curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append $mirrors\n        sudo sed -i \\\n          \"s~http://azure.archive.ubuntu.com/ubuntu/~mirror+file:$mirrors~\" \\\n          /etc/apt/sources.list\n\n    - name: Create build environment\n      run: |\n        sudo apt update\n        ${{matrix.install}}\n        sudo apt install locales-all\n        cmake -E make_directory ${{runner.workspace}}/build\n\n    - name: Configure\n      working-directory: ${{runner.workspace}}/build\n      env:\n        CXX: ${{matrix.cxx}}\n        CXXFLAGS: ${{matrix.cxxflags}}\n      run: |\n        cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \\\n              -DCMAKE_CXX_STANDARD=${{matrix.std}} \\\n              -DCMAKE_CXX_VISIBILITY_PRESET=hidden \\\n              -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \\\n              -DFMT_DOC=OFF -DFMT_PEDANTIC=ON -DFMT_WERROR=ON \\\n              ${{matrix.fuzz}} ${{matrix.shared}} $GITHUB_WORKSPACE\n\n    - name: Build\n      working-directory: ${{runner.workspace}}/build\n      run: |\n        threads=`nproc`\n        cmake --build . --config ${{matrix.build_type}} --parallel $threads\n\n    - name: Test\n      working-directory: ${{runner.workspace}}/build\n      run: ctest -C ${{matrix.build_type}}\n      env:\n        CTEST_OUTPUT_ON_FAILURE: True\n"
  },
  {
    "path": ".github/workflows/macos.yml",
    "content": "name: macos\n\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  build:\n    strategy:\n      matrix:\n        os: [macos-14]\n        build_type: [Debug, Release]\n        std: [11, 17, 20, 23]\n        shared: [\"\"]\n        include:\n          - os: macos-14\n            std: 23\n            build_type: Release\n            shared: -DBUILD_SHARED_LIBS=ON\n\n    runs-on: '${{ matrix.os }}'\n\n    steps:\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n\n    - name: Set timezone\n      run: sudo systemsetup -settimezone 'Europe/Minsk'\n\n    - name: Select Xcode 14.3 (macOS 13)\n      run: sudo xcode-select -s \"/Applications/Xcode_14.3.app\"\n      if: ${{ matrix.os == 'macos-13' }}\n\n    - name: Create Build Environment\n      run: cmake -E make_directory ${{runner.workspace}}/build\n\n    - name: Configure\n      working-directory: ${{runner.workspace}}/build\n      run: |\n        cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \\\n              -DCMAKE_CXX_STANDARD=${{matrix.std}} \\\n              -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \\\n              -DFMT_DOC=OFF -DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE\n\n    - name: Build\n      working-directory: ${{runner.workspace}}/build\n      run: |\n        threads=`sysctl -n hw.logicalcpu`\n        cmake --build . --config ${{matrix.build_type}} --parallel $threads\n\n    - name: Test\n      working-directory: ${{runner.workspace}}/build\n      run: ctest -C ${{matrix.build_type}}\n      env:\n        CTEST_OUTPUT_ON_FAILURE: True\n"
  },
  {
    "path": ".github/workflows/scorecard.yml",
    "content": "# This workflow uses actions that are not certified by GitHub. They are provided\n# by a third-party and are governed by separate terms of service, privacy\n# policy, and support documentation.\n\nname: Scorecard supply-chain security\non:\n  # For Branch-Protection check. Only the default branch is supported. See\n  # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection\n  branch_protection_rule:\n  # To guarantee Maintained check is occasionally updated. See\n  # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained\n  schedule:\n    - cron: '26 14 * * 5'\n  push:\n    branches: [ \"master\" ]\n\n# Declare default permissions as read only.\npermissions: read-all\n\njobs:\n  analysis:\n    name: Scorecard analysis\n    runs-on: ubuntu-latest\n    permissions:\n      # Needed to upload the results to code-scanning dashboard.\n      security-events: write\n      # Needed to publish results and get a badge (see publish_results below).\n      id-token: write\n\n    steps:\n      - name: \"Checkout code\"\n        uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n        with:\n          persist-credentials: false\n\n      - name: \"Run analysis\"\n        uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2\n        with:\n          results_file: results.sarif\n          results_format: sarif\n          # (Optional) \"write\" PAT token. Uncomment the `repo_token` line below if:\n          # - you want to enable the Branch-Protection check on a *public* repository, or\n          # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.\n          # repo_token: ${{ secrets.SCORECARD_TOKEN }}\n\n          # Public repositories:\n          #   - Publish results to OpenSSF REST API for easy access by consumers\n          #   - Allows the repository to include the Scorecard badge.\n          #   - See https://github.com/ossf/scorecard-action#publishing-results.\n          publish_results: true\n\n      # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF\n      # format to the repository Actions tab.\n      - name: \"Upload artifact\"\n        uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0\n        with:\n          name: SARIF file\n          path: results.sarif\n          retention-days: 5\n\n      # Upload the results to GitHub's code scanning dashboard.\n      - name: \"Upload to code-scanning\"\n        uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v3.29.5\n        with:\n          sarif_file: results.sarif\n"
  },
  {
    "path": ".github/workflows/windows.yml",
    "content": "name: windows\n\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n  build:\n    runs-on: ${{matrix.os}}\n    strategy:\n      matrix:\n        # windows-2022 has MSVC 2022 installed:\n        # https://github.com/actions/virtual-environments.\n        os: [windows-2022]\n        platform: [Win32, x64]\n        toolset: [v142]\n        standard: [14, 17, 20]\n        shared: [\"\", -DBUILD_SHARED_LIBS=ON]\n        build_type: [Debug, Release]\n        exclude:\n          - { toolset: v142, standard: 14 }\n          - { platform: Win32, standard: 14 }\n          - { platform: Win32, standard: 20 }\n          - { platform: x64, standard: 14, shared: -DBUILD_SHARED_LIBS=ON }\n          - { platform: x64, standard: 20, shared: -DBUILD_SHARED_LIBS=ON }\n        include:\n          - os: windows-2022\n            platform: x64\n            toolset: v143\n            build_type: Debug\n            standard: 20\n\n    steps:\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n\n    - name: Set timezone\n      run: tzutil /s \"FLE Standard Time\"\n\n    - name: Create Build Environment\n      run: cmake -E make_directory ${{runner.workspace}}/build\n\n    - name: Configure\n      # Use a bash shell for $GITHUB_WORKSPACE.\n      shell: bash\n      working-directory: ${{runner.workspace}}/build\n      run: |\n        cmake -A ${{matrix.platform}} -T ${{matrix.toolset}} \\\n              -DCMAKE_CXX_STANDARD=${{matrix.standard}} \\\n              ${{matrix.shared}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \\\n              $GITHUB_WORKSPACE\n\n    - name: Build\n      working-directory: ${{runner.workspace}}/build\n      run: |\n        $threads = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors\n        cmake --build . --config ${{matrix.build_type}} --parallel $threads\n\n    - name: Test\n      working-directory: ${{runner.workspace}}/build\n      run: ctest -C ${{matrix.build_type}} -V\n      env:\n        CTEST_OUTPUT_ON_FAILURE: True\n\n  mingw:\n    runs-on: windows-latest\n    defaults:\n      run:\n        shell: msys2 {0}\n    strategy:\n      matrix:\n        sys: [ mingw64, ucrt64 ]\n    steps:\n    - name: Set timezone\n      run: tzutil /s \"FLE Standard Time\"\n      shell: cmd\n    - uses: msys2/setup-msys2@40677d36a502eb2cf0fb808cc9dec31bf6152638 # v2.28.0\n      with:\n        release: false\n        msystem: ${{matrix.sys}}\n        pacboy: cc:p cmake:p ninja:p lld:p\n    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0\n    - name: Configure\n      run: cmake -B ../build -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug\n      env: { LDFLAGS: -fuse-ld=lld }\n    - name: Build\n      run: cmake --build ../build\n    - name: Test\n      run: ctest -j `nproc` --test-dir ../build\n      env:\n        CTEST_OUTPUT_ON_FAILURE: True\n"
  },
  {
    "path": ".gitignore",
    "content": "*.a\n*.so*\n*.xcodeproj\n*~\n.vscode/\n.cache/\n.vs/\n/CMakeScripts\n/Testing\n/_CPack_Packages\n/install_manifest.txt\nCMakeCache.txt\nCMakeUserPresets.json\nCMakeFiles\nCPack*.cmake\nCTestTestfile.cmake\nFMT.build\nMakefile\nbin/\nbuild/\ncmake_install.cmake\nfmt-*.cmake\nfmt.pc\n"
  },
  {
    "path": "CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.8...3.28)\ninclude_guard(GLOBAL)\n\n# Fallback for using newer policies on CMake <3.12.\nif (${CMAKE_VERSION} VERSION_LESS 3.12)\n  cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})\nendif ()\n\n# Determine if fmt is built as a subproject (using add_subdirectory) or if it is\n# the master project.\nif (NOT DEFINED FMT_MASTER_PROJECT)\n  set(FMT_MASTER_PROJECT OFF)\n  # Checking project name is more reliable than checking source directories.\n  if (NOT DEFINED PROJECT_NAME)\n    set(FMT_MASTER_PROJECT ON)\n    message(STATUS \"CMake version: ${CMAKE_VERSION}\")\n  endif ()\nendif ()\n\n# Joins arguments and places the results in ${result_var}.\nfunction (join result_var)\n  set(result \"\")\n  foreach (arg ${ARGN})\n    set(result \"${result}${arg}\")\n  endforeach ()\n  set(${result_var}\n      \"${result}\"\n      PARENT_SCOPE)\nendfunction ()\n\n# Sets a cache variable with a docstring joined from multiple arguments:\n#   set_verbose(<variable> <value> CACHE <type> <docstring>...)\n# This allows splitting a long docstring for readability.\nfunction (set_verbose variable value _cache type)\n  join(doc ${ARGN})\n  set(${variable}\n      ${value}\n      CACHE ${type} ${doc})\nendfunction ()\n\n# Set the default CMAKE_BUILD_TYPE to Release.\n# This should be done before the project command since the latter can set\n# CMAKE_BUILD_TYPE itself (it does so for nmake).\nif (FMT_MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE)\n  set_verbose(\n    CMAKE_BUILD_TYPE Release CACHE STRING\n    \"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or \"\n    \"CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.\")\nendif ()\n\nproject(FMT CXX)\n\n# Determine support for the C++ module scanning and CXX_MODULE File_Sets\n# Requires C++20, CMake >= 3.28 and\n# Generators(Ninja >= 1.11 OR Visual Studio >= 17.4).\n# Compilers GCC>=14, Clang>=16 or MSVC >= 17.4\n# Source: https://cmake.org/cmake/help/latest/manual/cmake-cxxmodules.7.html\nset(FMT_USE_CMAKE_MODULES FALSE)\nif (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_CXX_STANDARD\n                                                 GREATER_EQUAL 20)\n  if (CMAKE_GENERATOR STREQUAL \"Ninja\")\n    execute_process(COMMAND \"${CMAKE_MAKE_PROGRAM}\" \"--version\"\n                    OUTPUT_VARIABLE NINJA_VERSION)\n    if (NINJA_VERSION VERSION_GREATER_EQUAL 1.11)\n      if ((CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\" AND CMAKE_CXX_COMPILER_VERSION\n                                                    GREATER_EQUAL 14)\n          OR (CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\"\n              AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 16)\n          OR (CMAKE_CXX_COMPILER_ID STREQUAL \"MSVC\" AND MSVC_VERSION\n                                                        GREATER_EQUAL 1934))\n        set(FMT_USE_CMAKE_MODULES TRUE)\n      endif ()\n    endif ()\n  elseif (CMAKE_GENERATOR MATCHES \"^Visual Studio\" AND MSVC_VERSION\n                                                       GREATER_EQUAL 1934)\n    set(FMT_USE_CMAKE_MODULES TRUE)\n  endif ()\nendif ()\n\noption(FMT_DOC \"Generate the doc target.\" ${FMT_MASTER_PROJECT})\noption(FMT_INSTALL \"Generate the install target.\" ${FMT_MASTER_PROJECT})\noption(FMT_TEST \"Generate the test target.\" ${FMT_MASTER_PROJECT})\noption(FMT_FUZZ \"Generate the fuzz target.\" OFF)\noption(FMT_CUDA_TEST \"Generate the cuda-test target.\" OFF)\noption(FMT_OS \"Include OS-specific APIs.\" ON)\noption(FMT_MODULE \"Build a module library.\" ${FMT_USE_CMAKE_MODULES})\noption(FMT_SYSTEM_HEADERS \"Expose headers with marking them as system.\" OFF)\noption(FMT_UNICODE \"Enable Unicode support.\" ON)\noption(FMT_PEDANTIC \"Enable extra warnings and expensive tests.\" OFF)\noption(FMT_WERROR \"Halt the compilation with an error on compiler warnings.\"\n       OFF)\n\nset(FMT_SYSTEM_HEADERS_ATTRIBUTE \"\")\nif (FMT_SYSTEM_HEADERS)\n  set(FMT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM)\nendif ()\n\ninclude(GNUInstallDirs) # CMAKE_INSTALL_INCLUDEDIR\n\nset_verbose(\n  FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING\n  \"Installation directory for include files, a relative path that \"\n  \"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.\")\n\nset(FMT_DEBUG_POSTFIX\n    d\n    CACHE STRING \"Debug library postfix.\")\n\n# Get version from base.h.\nfile(READ include/fmt/base.h base_h)\nif (NOT base_h MATCHES \"FMT_VERSION ([0-9]+)([0-9][0-9])([0-9][0-9])\")\n  message(FATAL_ERROR \"Cannot get FMT_VERSION from base.h.\")\nendif ()\n# Use math to skip leading zeros if any.\nmath(EXPR CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})\nmath(EXPR CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})\nmath(EXPR CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})\njoin(FMT_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.\n     ${CPACK_PACKAGE_VERSION_PATCH})\nmessage(STATUS \"{fmt} version: ${FMT_VERSION}\")\n\nmessage(STATUS \"Build type: ${CMAKE_BUILD_TYPE}\")\n\nif (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)\n  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)\nendif ()\n\nlist(APPEND CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/support/cmake\")\n\ninclude(CheckCXXCompilerFlag)\ninclude(JoinPaths)\n\nif (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET)\n  set_verbose(CMAKE_CXX_VISIBILITY_PRESET hidden CACHE STRING\n              \"Preset for the export of private symbols.\")\n  set_property(CACHE CMAKE_CXX_VISIBILITY_PRESET PROPERTY STRINGS hidden\n                                                          default)\nendif ()\n\nif (FMT_MASTER_PROJECT AND NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)\n  set_verbose(\n    CMAKE_VISIBILITY_INLINES_HIDDEN ON CACHE BOOL\n    \"Whether to add a compile flag to hide symbols of inline \" \"functions.\")\nendif ()\n\nif (CMAKE_CXX_COMPILER_ID MATCHES \"GNU\")\n  set(PEDANTIC_COMPILE_FLAGS\n      -pedantic-errors\n      -Wall\n      -Wextra\n      -pedantic\n      -Wold-style-cast\n      -Wundef\n      -Wredundant-decls\n      -Wwrite-strings\n      -Wpointer-arith\n      -Wcast-qual\n      -Wformat=2\n      -Wmissing-include-dirs\n      -Wcast-align\n      -Wctor-dtor-privacy\n      -Wdisabled-optimization\n      -Winvalid-pch\n      -Woverloaded-virtual\n      -Wconversion\n      -Wundef\n      -Wno-ctor-dtor-privacy\n      -Wno-format-nonliteral)\n  if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)\n    set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-dangling-else\n                               -Wno-unused-local-typedefs)\n  endif ()\n  if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)\n    set(PEDANTIC_COMPILE_FLAGS\n        ${PEDANTIC_COMPILE_FLAGS}\n        -Wdouble-promotion\n        -Wtrampolines\n        -Wzero-as-null-pointer-constant\n        -Wuseless-cast\n        -Wvector-operation-performance\n        -Wsized-deallocation\n        -Wshadow)\n  endif ()\n  if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)\n    set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wshift-overflow=2\n                               -Wduplicated-cond)\n    # Workaround for GCC 12-15 regression:\n    # a false positive null-dereference in vector.resize\n    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108860.\n    if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)\n      set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wnull-dereference)\n    endif ()\n  endif ()\n  set(WERROR_FLAG -Werror)\nendif ()\n\nif (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n  set(PEDANTIC_COMPILE_FLAGS\n      -Wall\n      -Wextra\n      -pedantic\n      -Wconversion\n      -Wundef\n      -Wdeprecated\n      -Wweak-vtables\n      -Wshadow\n      -Wno-gnu-zero-variadic-macro-arguments)\n  check_cxx_compiler_flag(-Wzero-as-null-pointer-constant HAS_NULLPTR_WARNING)\n  if (HAS_NULLPTR_WARNING)\n    set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS}\n                               -Wzero-as-null-pointer-constant)\n  endif ()\n  set(WERROR_FLAG -Werror)\nendif ()\n\nif (MSVC)\n  set(PEDANTIC_COMPILE_FLAGS /W3)\n  set(WERROR_FLAG /WX)\nendif ()\n\nif (FMT_MASTER_PROJECT AND CMAKE_GENERATOR MATCHES \"Visual Studio\")\n  # If Microsoft SDK is installed create script run-msbuild.bat that\n  # calls SetEnv.cmd to set up build environment and runs msbuild.\n  # It is useful when building Visual Studio projects with the SDK\n  # toolchain rather than Visual Studio.\n  include(FindSetEnv)\n  if (WINSDK_SETENV)\n    set(MSBUILD_SETUP \"call \\\"${WINSDK_SETENV}\\\"\")\n  endif ()\n  # Set FrameworkPathOverride to get rid of MSB3644 warnings.\n  join(netfxpath\n       \"C:\\\\Program Files\\\\Reference Assemblies\\\\Microsoft\\\\Framework\\\\\"\n       \".NETFramework\\\\v4.0\")\n  file(WRITE run-msbuild.bat \"${MSBUILD_SETUP}\n    ${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\\\"${netfxpath}\\\" %*\")\nendif ()\n\n# Sets up a top-level fmt target. Targets that depend on other top-level targets\n# should call this because they'll automatically get the required properties.\nfunction (setup_target target kind)\n  add_library(fmt::${target} ALIAS ${target})\n\n  target_include_directories(\n    ${target} ${FMT_SYSTEM_HEADERS_ATTRIBUTE} BEFORE ${kind}\n    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>\n    $<INSTALL_INTERFACE:${FMT_INC_DIR}>)\n\n  if (NOT MSVC)\n    # Unicode is always supported on compilers other than MSVC.\n  elseif (FMT_UNICODE)\n    # Unicode support requires compiling with /utf-8.\n    target_compile_options(\n      ${target} ${kind}\n      $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:MSVC>>:/utf-8>)\n  else ()\n    target_compile_definitions(${target} ${kind} FMT_UNICODE=0)\n  endif ()\n\n  set_target_properties(\n    ${target}\n    PROPERTIES VERSION ${FMT_VERSION}\n               SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}\n               DEBUG_POSTFIX \"${FMT_DEBUG_POSTFIX}\")\nendfunction ()\n\nset(FMT_HEADERS)\nforeach (\n  header\n  args.h\n  base.h\n  chrono.h\n  color.h\n  compile.h\n  core.h\n  format.h\n  format-inl.h\n  os.h\n  ostream.h\n  printf.h\n  ranges.h\n  std.h\n  xchar.h)\n  set(FMT_HEADERS ${FMT_HEADERS} include/fmt/${header})\nendforeach ()\n\n# Add the main fmt library.\nadd_library(fmt src/format.cc ${FMT_HEADERS} README.md ChangeLog.md)\nsetup_target(fmt PUBLIC)\nset_target_properties(fmt PROPERTIES PUBLIC_HEADER \"${FMT_HEADERS}\")\n\nif (FMT_OS)\n  target_sources(fmt PRIVATE src/os.cc)\nelse ()\n  target_compile_definitions(fmt PRIVATE FMT_OS=0)\nendif ()\n\nif (FMT_WERROR)\n  target_compile_options(fmt PRIVATE ${WERROR_FLAG})\nendif ()\nif (FMT_PEDANTIC)\n  target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS})\nendif ()\n\nif (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)\n  target_compile_features(fmt PUBLIC cxx_std_11)\nelse ()\n  message(WARNING \"Feature cxx_std_11 is unknown for the CXX compiler\")\nendif ()\n\n# Set FMT_LIB_NAME for pkg-config fmt.pc. We cannot use the OUTPUT_NAME target\n# property because it's not set by default.\nset(FMT_LIB_NAME fmt)\nif (CMAKE_BUILD_TYPE STREQUAL \"Debug\")\n  set(FMT_LIB_NAME ${FMT_LIB_NAME}${FMT_DEBUG_POSTFIX})\nendif ()\n\nif (BUILD_SHARED_LIBS)\n  target_compile_definitions(\n    fmt\n    PRIVATE FMT_LIB_EXPORT\n    INTERFACE FMT_SHARED)\nendif ()\nif (FMT_SAFE_DURATION_CAST)\n  target_compile_definitions(fmt PUBLIC FMT_SAFE_DURATION_CAST)\nendif ()\n\n# Adds a library compiled with C++20 module support.\n#\n# Usage:\n#   add_module_library(<name> [sources...] [USE_CMAKE_MODULES TRUE])\nfunction (add_module_library name)\n  cmake_parse_arguments(AML \"\" \"USE_CMAKE_MODULES\" \"\" ${ARGN})\n  set(sources ${AML_UNPARSED_ARGUMENTS})\n\n  add_library(${name})\n  set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)\n\n  # Modules require C++20.\n  target_compile_features(${name} PUBLIC cxx_std_20)\n\n  if (MSVC)\n    if (NOT CMAKE_GENERATOR STREQUAL \"Ninja\")\n      set(BMI_DIR \"${CMAKE_CURRENT_BINARY_DIR}\")\n      file(TO_NATIVE_PATH \"${BMI_DIR}/${name}.ifc\" BMI)\n      target_compile_options(\n        ${name}\n        PRIVATE /interface /ifcOutput ${BMI}\n        INTERFACE /reference fmt=${BMI})\n      set_target_properties(${name} PROPERTIES ADDITIONAL_CLEAN_FILES ${BMI})\n      set_source_files_properties(${BMI} PROPERTIES GENERATED ON)\n    endif ()\n  endif ()\n\n  if (${AML_USE_CMAKE_MODULES})\n    target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES FILES\n                                  ${sources})\n    return()\n  endif ()\n\n  if (CMAKE_COMPILER_IS_GNUCXX)\n    target_compile_options(${name} PUBLIC -fmodules-ts)\n  endif ()\n\n  # `std` is affected by CMake options and may be higher than C++20.\n  get_target_property(std ${name} CXX_STANDARD)\n\n  if (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n    set(pcms)\n    foreach (src ${sources})\n      get_filename_component(pcm ${src} NAME_WE)\n      set(pcm ${pcm}.pcm)\n\n      # Propagate -fmodule-file=*.pcm to targets that link with this library.\n      target_compile_options(\n        ${name} PUBLIC -fmodule-file=${CMAKE_CURRENT_BINARY_DIR}/${pcm})\n\n      # Use an absolute path to prevent target_link_libraries prepending -l\n      # to it.\n      set(pcms ${pcms} ${CMAKE_CURRENT_BINARY_DIR}/${pcm})\n      add_custom_command(\n        OUTPUT ${pcm}\n        COMMAND\n          ${CMAKE_CXX_COMPILER} -std=c++${std} -x c++-module --precompile -c -o\n          ${pcm} ${CMAKE_CURRENT_SOURCE_DIR}/${src}\n          \"-I$<JOIN:$<TARGET_PROPERTY:${name},INCLUDE_DIRECTORIES>,;-I>\"\n        # Required by the -I generator expression above.\n        COMMAND_EXPAND_LISTS\n        DEPENDS ${src})\n    endforeach ()\n\n    # Add .pcm files as sources to make sure they are built before the library.\n    set(sources)\n    foreach (pcm ${pcms})\n      get_filename_component(pcm_we ${pcm} NAME_WE)\n      set(obj ${pcm_we}.o)\n      # Use an absolute path to prevent target_link_libraries prepending -l.\n      set(sources ${sources} ${pcm} ${CMAKE_CURRENT_BINARY_DIR}/${obj})\n      add_custom_command(\n        OUTPUT ${obj}\n        COMMAND ${CMAKE_CXX_COMPILER} $<TARGET_PROPERTY:${name},COMPILE_OPTIONS>\n                -c -o ${obj} ${pcm}\n        DEPENDS ${pcm})\n    endforeach ()\n  endif ()\n  target_sources(${name} PRIVATE ${sources})\nendfunction ()\n\nif (FMT_MODULE)\n  add_module_library(fmt-module src/fmt.cc USE_CMAKE_MODULES\n                     ${FMT_USE_CMAKE_MODULES})\n  setup_target(fmt-module PUBLIC)\nendif ()\n\nadd_library(fmt-header-only INTERFACE)\n\ntarget_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)\ntarget_compile_features(fmt-header-only INTERFACE cxx_std_11)\nsetup_target(fmt-header-only INTERFACE)\n\nadd_library(fmt-c STATIC src/fmt-c.cc)\ntarget_compile_features(fmt-c INTERFACE c_std_11)\nif (MSVC)\n  target_compile_options(fmt-c PUBLIC /Zc:preprocessor)\nendif ()\ntarget_link_libraries(fmt-c PUBLIC fmt::fmt)\nadd_library(fmt::fmt-c ALIAS fmt-c)\n\nset_target_properties(fmt-c PROPERTIES PUBLIC_HEADER include/fmt/fmt-c.h)\n\n# Install targets.\nif (FMT_INSTALL)\n  include(CMakePackageConfigHelpers)\n  set_verbose(\n    FMT_CMAKE_DIR\n    ${CMAKE_INSTALL_LIBDIR}/cmake/fmt\n    CACHE\n    STRING\n    \"Installation directory for cmake files, a relative path that \"\n    \"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute \"\n    \"path.\")\n  set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake)\n  set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake)\n  set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc)\n  set(targets_export_name fmt-targets)\n\n  set_verbose(\n    FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING\n    \"Installation directory for libraries, a relative path that \"\n    \"will be joined to ${CMAKE_INSTALL_PREFIX} or an absolute path.\")\n\n  set_verbose(\n    FMT_PKGCONFIG_DIR\n    ${CMAKE_INSTALL_LIBDIR}/pkgconfig\n    CACHE\n    STRING\n    \"Installation directory for pkgconfig (.pc) files, a relative \"\n    \"path that will be joined with ${CMAKE_INSTALL_PREFIX} or an \"\n    \"absolute path.\")\n\n  # Generate the version, config and target files into the build directory.\n  write_basic_package_version_file(\n    ${version_config}\n    VERSION ${FMT_VERSION}\n    COMPATIBILITY AnyNewerVersion)\n\n  join_paths(libdir_for_pc_file \"\\${exec_prefix}\" \"${FMT_LIB_DIR}\")\n  join_paths(includedir_for_pc_file \"\\${prefix}\" \"${FMT_INC_DIR}\")\n\n  configure_file(\"${PROJECT_SOURCE_DIR}/support/cmake/fmt.pc.in\" \"${pkgconfig}\"\n                 @ONLY)\n  configure_package_config_file(\n    ${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in ${project_config}\n    INSTALL_DESTINATION ${FMT_CMAKE_DIR})\n\n  set(INSTALL_TARGETS fmt fmt-header-only fmt-c)\n\n  if (FMT_MODULE)\n    list(APPEND INSTALL_TARGETS fmt-module)\n    if (FMT_USE_CMAKE_MODULES)\n      set(INSTALL_FILE_SET FILE_SET fmt DESTINATION ${FMT_INC_DIR}/fmt)\n    endif ()\n  endif ()\n\n  # Install the library and headers.\n  install(\n    TARGETS ${INSTALL_TARGETS}\n    COMPONENT fmt_core\n    EXPORT ${targets_export_name}\n    LIBRARY DESTINATION ${FMT_LIB_DIR}\n    ARCHIVE DESTINATION ${FMT_LIB_DIR}\n    PUBLIC_HEADER DESTINATION ${FMT_INC_DIR}/fmt\n    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ${INSTALL_FILE_SET})\n\n  # Use a namespace because CMake provides better diagnostics for namespaced\n  # imported targets.\n  export(\n    TARGETS ${INSTALL_TARGETS}\n    NAMESPACE fmt::\n    FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake)\n\n  # Install version, config and target files.\n  install(\n    FILES ${project_config} ${version_config}\n    DESTINATION ${FMT_CMAKE_DIR}\n    COMPONENT fmt_core)\n  install(\n    EXPORT ${targets_export_name}\n    DESTINATION ${FMT_CMAKE_DIR}\n    NAMESPACE fmt::\n    COMPONENT fmt_core)\n\n  install(\n    FILES \"${pkgconfig}\"\n    DESTINATION \"${FMT_PKGCONFIG_DIR}\"\n    COMPONENT fmt_core)\nendif ()\n\nfunction (add_doc_target)\n  find_program(DOXYGEN doxygen PATHS \"$ENV{ProgramFiles}/doxygen/bin\"\n                                     \"$ENV{ProgramFiles\\(x86\\)}/doxygen/bin\")\n  if (NOT DOXYGEN)\n    message(STATUS \"Target 'doc' disabled because doxygen not found\")\n    return()\n  endif ()\n\n  find_program(MKDOCS mkdocs)\n  if (NOT MKDOCS)\n    message(STATUS \"Target 'doc' disabled because mkdocs not found\")\n    return()\n  endif ()\n\n  set(sources)\n  foreach (source api.md index.md syntax.md get-started.md fmt.css fmt.js)\n    set(sources ${sources} doc/${source})\n  endforeach ()\n\n  add_custom_target(\n    doc\n    COMMAND\n      ${CMAKE_COMMAND} -E env\n      PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/support/python ${MKDOCS} build -f\n      ${CMAKE_CURRENT_SOURCE_DIR}/support/mkdocs.yml\n      # MkDocs requires the site dir to be outside of the doc dir.\n      --site-dir ${CMAKE_CURRENT_BINARY_DIR}/doc-html --no-directory-urls\n    SOURCES ${sources})\n\n  install(\n    DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc-html/\n    DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/fmt\n    COMPONENT fmt_doc\n    OPTIONAL)\nendfunction ()\n\nif (FMT_DOC)\n  add_doc_target()\nendif ()\n\nif (FMT_TEST)\n  enable_testing()\n  add_subdirectory(test)\nendif ()\n\n# Control fuzzing independent of the unit tests.\nif (FMT_FUZZ)\n  add_subdirectory(test/fuzzing)\n\n  # The FMT_FUZZ macro is used to prevent resource exhaustion in fuzzing\n  # mode and make fuzzing practically possible. It is similar to\n  # FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION but uses a different name to\n  # avoid interfering with fuzzing of projects that use {fmt}.\n  # See also https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode.\n  target_compile_definitions(fmt PUBLIC FMT_FUZZ)\nendif ()\n\nset(gitignore ${PROJECT_SOURCE_DIR}/.gitignore)\nif (FMT_MASTER_PROJECT AND EXISTS ${gitignore})\n  # Get the list of ignored files from .gitignore.\n  file(STRINGS ${gitignore} lines)\n  list(REMOVE_ITEM lines /doc/html)\n  foreach (line ${lines})\n    string(REPLACE \".\" \"[.]\" line \"${line}\")\n    string(REPLACE \"*\" \".*\" line \"${line}\")\n    set(ignored_files ${ignored_files} \"${line}$\" \"${line}/\")\n  endforeach ()\n  set(ignored_files ${ignored_files} /.git /build/doxyxml .vagrant)\n\n  set(CPACK_SOURCE_GENERATOR ZIP)\n  set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})\n  set(CPACK_SOURCE_PACKAGE_FILE_NAME fmt-${FMT_VERSION})\n  set(CPACK_PACKAGE_NAME fmt)\n  set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md)\n  include(CPack)\nendif ()\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "Contributing to {fmt}\n=====================\n\nBy submitting a pull request or a patch, you represent that you have the right\nto license your contribution to the {fmt} project owners and the community,\nagree that your contributions are licensed under the {fmt} license, and agree\nto future changes to the licensing.\n\nAll C++ code must adhere to [Google C++ Style Guide](\nhttps://google.github.io/styleguide/cppguide.html) with the following\nexceptions:\n\n* Exceptions are permitted\n* snake_case should be used instead of UpperCamelCase for function and type\n  names\n\nAll documentation must adhere to the [Google Developer Documentation Style\nGuide](https://developers.google.com/style).\n\nThanks for contributing!\n"
  },
  {
    "path": "ChangeLog.md",
    "content": "# 12.1.0 - 2025-10-29\n\n- Optimized `buffer::append`, resulting in up to ~16% improvement on spdlog\n  benchmarks (https://github.com/fmtlib/fmt/pull/4541). Thanks @fyrsta7.\n\n- Worked around an ABI incompatibility in `std::locale_ref` between clang and\n  gcc (https://github.com/fmtlib/fmt/issues/4573).\n\n- Made `std::variant` and `std::expected` formatters work with `format_as`\n  (https://github.com/fmtlib/fmt/issues/4574,\n  https://github.com/fmtlib/fmt/pull/4575). Thanks @phprus.\n\n- Made `fmt::join<string_view>` work with C++ modules\n  (https://github.com/fmtlib/fmt/issues/4379,\n  https://github.com/fmtlib/fmt/pull/4577). Thanks @Arghnews.\n\n- Exported `fmt::is_compiled_string` and `operator\"\"_cf` from the module\n  (https://github.com/fmtlib/fmt/pull/4544). Thanks @CrackedMatter.\n\n- Fixed a compatibility issue with C++ modules in clang\n  (https://github.com/fmtlib/fmt/pull/4548). Thanks @tsarn.\n\n- Added support for cv-qualified types to the `std::optional` formatter\n  (https://github.com/fmtlib/fmt/issues/4561,\n  https://github.com/fmtlib/fmt/pull/4562). Thanks @OleksandrKvl.\n\n- Added demangling support (used in exception and `std::type_info` formatters)\n  for libc++ and clang-cl\n  (https://github.com/fmtlib/fmt/issues/4542,\n  https://github.com/fmtlib/fmt/pull/4560,\n  https://github.com/fmtlib/fmt/issues/4568,\n  https://github.com/fmtlib/fmt/pull/4571).\n  Thanks @FatihBAKIR and @rohitsutreja.\n\n- Switched to global `malloc`/`free` to enable allocator customization\n  (https://github.com/fmtlib/fmt/issues/4569,\n  https://github.com/fmtlib/fmt/pull/4570). Thanks @rohitsutreja.\n\n- Made the `FMT_USE_CONSTEVAL` macro configurable by users\n  (https://github.com/fmtlib/fmt/pull/4546). Thanks @SnapperTT.\n\n- Fixed compilation with locales disabled in the header-only mode\n  (https://github.com/fmtlib/fmt/issues/4550).\n\n- Fixed compilation with clang 21 and `-std=c++20`\n  (https://github.com/fmtlib/fmt/issues/4552).\n\n- Fixed a dynamic linking issue with clang-cl\n  (https://github.com/fmtlib/fmt/issues/4576,\n  https://github.com/fmtlib/fmt/pull/4584). Thanks @FatihBAKIR.\n\n- Fixed a warning suppression leakage on gcc\n  (https://github.com/fmtlib/fmt/pull/4588). Thanks @ZedThree.\n\n- Made more internal color APIs `constexpr`\n  (https://github.com/fmtlib/fmt/pull/4581). Thanks @ishani.\n\n- Fixed compatibility with clang as a host compiler for NVCC\n  (https://github.com/fmtlib/fmt/pull/4564). Thanks @valgur.\n\n- Fixed various warnings and lint issues\n  (https://github.com/fmtlib/fmt/issues/4565,\n  https://github.com/fmtlib/fmt/pull/4572,\n  https://github.com/fmtlib/fmt/pull/4557).\n  Thanks @LiangHuDream and @teruyamato0731.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/4549,\n  https://github.com/fmtlib/fmt/pull/4551,\n  https://github.com/fmtlib/fmt/issues/4566,\n  https://github.com/fmtlib/fmt/pull/4567,\n  https://github.com/fmtlib/fmt/pull/4578,).\n  Thanks @teruyamato0731, @petersteneteg and @zimmerman-dev.\n\n# 12.0.0 - 2025-09-17\n\n- Optimized the default floating point formatting\n  (https://github.com/fmtlib/fmt/issues/3675,\n  https://github.com/fmtlib/fmt/issues/4516). In particular, formatting a\n  `double` with format string compilation into a stack allocated buffer is\n  more than 60% faster in version 12.0 compared to 11.2 according to\n  [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark):\n\n  ```\n  Function  Time (ns)  Speedup\n  fmt11        34.471    1.00x\n  fmt12        21.000    1.64x\n  ```\n\n  <img width=\"766\" height=\"609\" src=\"https://github.com/user-attachments/assets/d7d768ad-7543-468c-b0bb-449abf73b31b\" />\n\n- Added `constexpr` support to `fmt::format`. For example:\n\n  ```c++\n  #include <fmt/compile.h>\n\n  using namespace fmt::literals;\n  std::string s = fmt::format(\"\"_cf, 42);\n  ```\n\n  now works at compile time provided that `std::string` supports `constexpr`\n  (https://github.com/fmtlib/fmt/issues/3403,\n  https://github.com/fmtlib/fmt/pull/4456). Thanks @msvetkin.\n\n- Added `FMT_STATIC_FORMAT` that allows formatting into a string of the exact\n  required size at compile time.\n\n  For example:\n\n  ```c++\n  #include <fmt/compile.h>\n\n  constexpr auto s = FMT_STATIC_FORMAT(\"{}\", 42);\n  ```\n\n  compiles to just\n\n  ```s\n  __ZL1s:\n        .asciiz \"42\"\n  ```\n\n  It can be accessed as a C string with `s.c_str()` or as a string view with\n  `s.str()`.\n\n- Improved C++20 module support\n  (https://github.com/fmtlib/fmt/pull/4451,\n  https://github.com/fmtlib/fmt/pull/4459,\n  https://github.com/fmtlib/fmt/pull/4476,\n  https://github.com/fmtlib/fmt/pull/4488,\n  https://github.com/fmtlib/fmt/issues/4491,\n  https://github.com/fmtlib/fmt/pull/4495).\n  Thanks @arBmind, @tkhyn, @Mishura4, @anonymouspc and @autoantwort.\n\n- Switched to using estimated display width in precision. For example:\n\n  ```c++\n  fmt::print(\"|{:.4}|\\n|1234|\\n\", \"🐱🐱🐱\");\n  ```\n\n  prints\n\n  ![](https://github.com/user-attachments/assets/6c4446b3-13eb-43b9-b74a-b4543540ad6a)\n\n  because `🐱` has an estimated width of 2\n  (https://github.com/fmtlib/fmt/issues/4272,\n  https://github.com/fmtlib/fmt/pull/4443,\n  https://github.com/fmtlib/fmt/pull/4475).\n  Thanks @nikhilreddydev and @localspook.\n\n- Fix interaction between debug presentation, precision, and width for strings\n  (https://github.com/fmtlib/fmt/pull/4478). Thanks @localspook.\n\n- Implemented allocator propagation on `basic_memory_buffer` move\n  (https://github.com/fmtlib/fmt/issues/4487,\n  https://github.com/fmtlib/fmt/pull/4490). Thanks @toprakmurat.\n\n- Fixed an ambiguity between `std::reference_wrapper<T>` and `format_as`\n  formatters (https://github.com/fmtlib/fmt/issues/4424,\n  https://github.com/fmtlib/fmt/pull/4434). Thanks @jeremy-rifkin.\n\n- Removed the following deprecated APIs:\n\n  - `has_formatter`: use `is_formattable` instead,\n  - `basic_format_args::parse_context_type`,\n    `basic_format_args::formatter_type` and similar aliases in context types,\n  - wide stream overload of `fmt::printf`,\n  - wide stream overloads of `fmt::print` that take text styles,\n  - `is_*char` traits,\n  - `fmt::localtime`.\n\n- Deprecated wide overloads of `fmt::fprintf` and `fmt::sprintf`.\n\n- Improved diagnostics for the incorrect usage of `fmt::ptr`\n  (https://github.com/fmtlib/fmt/pull/4453). Thanks @TobiSchluter.\n\n- Made handling of ANSI escape sequences more efficient\n  (https://github.com/fmtlib/fmt/pull/4511,\n  https://github.com/fmtlib/fmt/pull/4528).\n  Thanks @localspook and @Anas-Hamdane.\n\n- Fixed a buffer overflow on all emphasis flags set\n  (https://github.com/fmtlib/fmt/pull/4498). Thanks @dominicpoeschko.\n\n- Fixed an integer overflow for precision close to the max `int` value.\n\n- Fixed compatibility with WASI (https://github.com/fmtlib/fmt/issues/4496,\n  https://github.com/fmtlib/fmt/pull/4497). Thanks @whitequark.\n\n- Fixed `back_insert_iterator` detection, preventing a fallback on slower path\n  that handles arbitrary iterators (https://github.com/fmtlib/fmt/issues/4454).\n\n- Fixed handling of invalid glibc `FILE` buffers\n  (https://github.com/fmtlib/fmt/issues/4469).\n\n- Added `wchar_t` support to the `std::byte` formatter\n  (https://github.com/fmtlib/fmt/issues/4479,\n  https://github.com/fmtlib/fmt/pull/4480). Thanks @phprus.\n\n- Changed component prefix from `fmt-` to `fmt_` for compatibility with\n  NSIS/CPack on Windows, e.g. `fmt-doc` changed to `fmt_doc`\n  (https://github.com/fmtlib/fmt/issues/4441,\n  https://github.com/fmtlib/fmt/pull/4442). Thanks @n-stein.\n\n- Added the `FMT_CUSTOM_ASSERT_FAIL` macro to simplify providing a custom\n  `fmt::assert_fail` implementation (https://github.com/fmtlib/fmt/pull/4505).\n  Thanks @HazardyKnusperkeks.\n\n- Switched to `FMT_THROW` on reporting format errors so that it can be\n  overriden by users when exceptions are disabled\n  (https://github.com/fmtlib/fmt/pull/4521). Thanks @HazardyKnusperkeks.\n\n- Improved master project detection and disabled install targets when using\n  {fmt} as a subproject by default (https://github.com/fmtlib/fmt/pull/4536).\n  Thanks @crueter.\n\n- Made various code improvements\n  (https://github.com/fmtlib/fmt/pull/4445,\n  https://github.com/fmtlib/fmt/pull/4448,\n  https://github.com/fmtlib/fmt/pull/4473,\n  https://github.com/fmtlib/fmt/pull/4522).\n  Thanks @localspook, @tchaikov and @way4sahil.\n\n- Added Conan instructions to the docs\n  (https://github.com/fmtlib/fmt/pull/4537). Thanks @uilianries.\n\n- Removed Bazel files to avoid issues with downstream packaging\n  (https://github.com/fmtlib/fmt/pull/4530). Thanks @mering.\n\n- Added more entries for generated files to `.gitignore`\n  (https://github.com/fmtlib/fmt/pull/4355,\n  https://github.com/fmtlib/fmt/pull/4512).\n  Thanks @dinomight and @localspook.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/4447,\n  https://github.com/fmtlib/fmt/issues/4470,\n  https://github.com/fmtlib/fmt/pull/4474,\n  https://github.com/fmtlib/fmt/pull/4477,\n  https://github.com/fmtlib/fmt/pull/4471,\n  https://github.com/fmtlib/fmt/pull/4483,\n  https://github.com/fmtlib/fmt/pull/4515,\n  https://github.com/fmtlib/fmt/issues/4533,\n  https://github.com/fmtlib/fmt/pull/4534).\n  Thanks @dodomorandi, @localspook, @remyjette, @Tomek-Stolarczyk, @Mishura4,\n  @mattiasljungstrom and @FatihBAKIR.\n\n# 11.2.0 - 2025-05-03\n\n- Added the `s` specifier for `std::error_code`. It allows formatting an error\n  message as a string. For example:\n\n  ```c++\n  #include <fmt/std.h>\n\n  int main() {\n    auto ec = std::make_error_code(std::errc::no_such_file_or_directory);\n    fmt::print(\"{:s}\\n\", ec);\n  }\n  ```\n\n  prints\n\n  ```\n  No such file or directory\n  ```\n  (The actual message is platform-specific.)\n\n- Fixed formatting of `std::chrono::local_time` and `tm`\n  (https://github.com/fmtlib/fmt/issues/3815,\n  https://github.com/fmtlib/fmt/issues/4350).\n  For example ([godbolt](https://www.godbolt.org/z/8o4b1PPn5)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    std::chrono::zoned_time zt(\n      std::chrono::current_zone(),\n      std::chrono::system_clock::now());\n    fmt::print(\"{}\", zt.get_local_time());\n  }\n  ```\n\n  is now formatted consistenly across platforms.\n\n- Added diagnostics for cases when timezone information is not available.\n  For example:\n\n  ```c++\n  fmt::print(\"{:Z}\", std::chrono::local_seconds());\n  ```\n\n  now gives a compile-time error.\n\n- Deprecated `fmt::localtime` in favor of `std::localtime`.\n\n- Fixed compilation with GCC 15 and C++20 modules enabled\n  (https://github.com/fmtlib/fmt/pull/4347). Thanks @tkhyn.\n\n- Fixed handling of named arguments in format specs\n  (https://github.com/fmtlib/fmt/issues/4360,\n  https://github.com/fmtlib/fmt/pull/4361). Thanks @dinomight.\n\n- Added error reporting for duplicate named arguments\n  (https://github.com/fmtlib/fmt/issues/4282,\n  https://github.com/fmtlib/fmt/pull/4367). Thanks @dinomight.\n\n- Fixed formatting of `long` with `FMT_BUILTIN_TYPES=0`\n  (https://github.com/fmtlib/fmt/issues/4375,\n  https://github.com/fmtlib/fmt/issues/4394).\n\n- Optimized `text_style` using bit packing\n  (https://github.com/fmtlib/fmt/pull/4363). Thanks @localspook.\n\n- Added support for incomplete types (https://github.com/fmtlib/fmt/issues/3180,\n  https://github.com/fmtlib/fmt/pull/4383). Thanks @localspook.\n\n- Fixed a flush issue in `fmt::print` when using libstdc++\n  (https://github.com/fmtlib/fmt/issues/4398).\n\n- Fixed `fmt::println` usage with `FMT_ENFORCE_COMPILE_STRING` and legacy\n  compile-time checks (https://github.com/fmtlib/fmt/pull/4407).\n  Thanks @madmaxoft.\n\n- Removed legacy header `fmt/core.h` from docs\n  (https://github.com/fmtlib/fmt/pull/4421,\n  https://github.com/fmtlib/fmt/pull/4422). Thanks @krzysztofkortas.\n\n- Worked around limitations of `__builtin_strlen` during constant evaluation\n  (https://github.com/fmtlib/fmt/issues/4423,\n  https://github.com/fmtlib/fmt/pull/4429). Thanks @BRevzin.\n\n- Worked around a bug in MSVC v141 (https://github.com/fmtlib/fmt/issues/4412,\n  https://github.com/fmtlib/fmt/pull/4413). Thanks @hirohira9119.\n\n- Removed the `fmt_detail` namespace\n  (https://github.com/fmtlib/fmt/issues/4324).\n\n- Removed specializations of `std::is_floating_point` in tests\n  (https://github.com/fmtlib/fmt/issues/4417).\n\n- Fixed a CMake error when setting `CMAKE_MODULE_PATH` in the pedantic mode\n  (https://github.com/fmtlib/fmt/pull/4426). Thanks @rlalik.\n\n- Updated the Bazel config (https://github.com/fmtlib/fmt/pull/4400).\n  Thanks @Vertexwahn.\n\n# 11.1.4 - 2025-02-26\n\n- Fixed ABI compatibility with earlier 11.x versions on Windows\n  (https://github.com/fmtlib/fmt/issues/4359).\n\n- Improved the logic of switching between fixed and exponential format for\n  `float` (https://github.com/fmtlib/fmt/issues/3649).\n\n- Moved `is_compiled_string` to the public API\n  (https://github.com/fmtlib/fmt/issues/4335,\n  https://github.com/fmtlib/fmt/issues/4342). Thanks @SwooshyCueb.\n\n- Simplified implementation of `operator\"\"_cf`\n  (https://github.com/fmtlib/fmt/pull/4349). Thanks @localspook.\n\n- Fixed `__builtin_strlen` detection (https://github.com/fmtlib/fmt/pull/4329).\n  Thanks @localspook.\n\n- Fixed handling of BMI paths with the Ninja generator\n  (https://github.com/fmtlib/fmt/pull/4344). Thanks @tkhyn.\n\n- Fixed gcc 8.3 compile errors (https://github.com/fmtlib/fmt/issues/4331,\n  https://github.com/fmtlib/fmt/pull/4336). Thanks @sergiud.\n\n- Fixed a bogus MSVC warning (https://github.com/fmtlib/fmt/pull/4356).\n  Thanks @dinomight.\n\n# 11.1.3 - 2025-01-25\n\n- Fixed compilation on GCC 9.4 (https://github.com/fmtlib/fmt/issues/4313).\n\n- Worked around an internal compiler error when using C++20 modules with GCC\n  14.2 and earlier (https://github.com/fmtlib/fmt/issues/4295).\n\n- Worked around a bug in GCC 6 (https://github.com/fmtlib/fmt/issues/4318).\n\n- Fixed an issue caused by instantiating `formatter<const T>`\n  (https://github.com/fmtlib/fmt/issues/4303,\n  https://github.com/fmtlib/fmt/pull/4325). Thanks @timsong-cpp.\n\n- Fixed formatting into `std::ostreambuf_iterator` when using format string\n  compilation (https://github.com/fmtlib/fmt/issues/4309,\n  https://github.com/fmtlib/fmt/pull/4312). Thanks @phprus.\n\n- Restored a constraint on the map formatter so that it correctly reports as\n  unformattable when the element is (https://github.com/fmtlib/fmt/pull/4326).\n  Thanks @timsong-cpp.\n\n- Reduced the size of format specs (https://github.com/fmtlib/fmt/issues/4298).\n\n- Readded `args()` to `fmt::format_context`\n  (https://github.com/fmtlib/fmt/issues/4307,\n  https://github.com/fmtlib/fmt/pull/4310). Thanks @Erroneous1.\n\n- Fixed a bogus MSVC warning (https://github.com/fmtlib/fmt/issues/4314,\n  https://github.com/fmtlib/fmt/pull/4322). Thanks @ZehMatt.\n\n- Fixed a pedantic mode error in the CMake config\n  (https://github.com/fmtlib/fmt/pull/4327). Thanks @rlalik.\n\n# 11.1.2 - 2025-01-12\n\n- Fixed ABI compatibility with earlier 11.x versions\n  (https://github.com/fmtlib/fmt/issues/4292).\n\n- Added `wchar_t` support to the `std::bitset` formatter\n  (https://github.com/fmtlib/fmt/issues/4285,\n  https://github.com/fmtlib/fmt/pull/4286,\n  https://github.com/fmtlib/fmt/issues/4289,\n  https://github.com/fmtlib/fmt/pull/4290). Thanks @phprus.\n\n- Prefixed CMake components with `fmt-` to simplify usage of {fmt} via\n  `add_subdirectory` (https://github.com/fmtlib/fmt/issues/4283).\n\n- Updated docs for meson (https://github.com/fmtlib/fmt/pull/4291).\n  Thanks @trim21.\n\n- Fixed a compilation error in chrono on nvcc\n  (https://github.com/fmtlib/fmt/issues/4297,\n  https://github.com/fmtlib/fmt/pull/4301). Thanks @breyerml.\n\n- Fixed various warnings\n  (https://github.com/fmtlib/fmt/pull/4288,\n  https://github.com/fmtlib/fmt/pull/4299). Thanks @GamesTrap and @edo9300.\n\n# 11.1.1 - 2024-12-27\n\n- Fixed ABI compatibility with earlier 11.x versions\n  (https://github.com/fmtlib/fmt/issues/4278).\n\n- Defined CMake components (`core` and `doc`) to allow docs to be installed\n  separately (https://github.com/fmtlib/fmt/pull/4276).\n  Thanks @carlsmedstad.\n\n# 11.1.0 - 2024-12-25\n\n- Improved C++20 module support\n  (https://github.com/fmtlib/fmt/issues/4081,\n  https://github.com/fmtlib/fmt/pull/4083,\n  https://github.com/fmtlib/fmt/pull/4084,\n  https://github.com/fmtlib/fmt/pull/4152,\n  https://github.com/fmtlib/fmt/issues/4153,\n  https://github.com/fmtlib/fmt/pull/4169,\n  https://github.com/fmtlib/fmt/issues/4190,\n  https://github.com/fmtlib/fmt/issues/4234,\n  https://github.com/fmtlib/fmt/pull/4239).\n  Thanks @kamrann and @Arghnews.\n\n- Reduced debug (unoptimized) binary code size and the number of template\n  instantiations when passing formatting arguments. For example, unoptimized\n  binary code size for `fmt::print(\"{}\", 42)` was reduced by ~40% on GCC and\n  ~60% on clang (x86-64).\n\n  GCC:\n  - Before: 161 instructions of which 105 are in reusable functions\n    ([godbolt](https://www.godbolt.org/z/s9bGoo4ze)).\n  - After: 116 instructions of which 60 are in reusable functions\n    ([godbolt](https://www.godbolt.org/z/r7GGGxMs6)).\n\n  Clang:\n  - Before: 310 instructions of which 251 are in reusable functions\n    ([godbolt](https://www.godbolt.org/z/Ts88b7M9o)).\n  - After: 194 instructions of which 135 are in reusable functions\n    ([godbolt](https://www.godbolt.org/z/vcrjP8ceW)).\n\n- Added an experimental `fmt::writer` API that can be used for writing to\n  different destinations such as files or strings\n  (https://github.com/fmtlib/fmt/issues/2354).\n  For example ([godbolt](https://www.godbolt.org/z/rWoKfbP7e)):\n\n  ```c++\n  #include <fmt/os.h>\n\n  void write_text(fmt::writer w) {\n    w.print(\"The answer is {}.\", 42);\n  }\n\n  int main() {\n    // Write to FILE.\n    write_text(stdout);\n\n    // Write to fmt::ostream.\n    auto f = fmt::output_file(\"myfile\");\n    write_text(f);\n\n    // Write to std::string.\n    auto sb = fmt::string_buffer();\n    write_text(sb);\n    std::string s = sb.str();\n  }\n  ```\n\n- Added width and alignment support to the formatter of `std::error_code`.\n\n- Made `std::expected<void, E>` formattable\n  (https://github.com/fmtlib/fmt/issues/4145,\n  https://github.com/fmtlib/fmt/pull/4148).\n  For example ([godbolt](https://www.godbolt.org/z/hrj5c6G86)):\n\n  ```c++\n  fmt::print(\"{}\", std::expected<void, int>());\n  ```\n\n  prints\n\n  ```\n  expected()\n  ```\n\n  Thanks @phprus.\n\n- Made `fmt::is_formattable<void>` SFINAE-friendly\n  (https://github.com/fmtlib/fmt/issues/4147).\n\n- Added support for `_BitInt` formatting when using clang\n  (https://github.com/fmtlib/fmt/issues/4007,\n  https://github.com/fmtlib/fmt/pull/4072,\n  https://github.com/fmtlib/fmt/issues/4140,\n  https://github.com/fmtlib/fmt/issues/4173,\n  https://github.com/fmtlib/fmt/pull/4176).\n  For example ([godbolt](https://www.godbolt.org/z/KWjbWec5z)):\n\n  ```c++\n  using int42 = _BitInt(42);\n  fmt::print(\"{}\", int42(100));\n  ```\n\n  Thanks @Arghnews.\n\n- Added the `n` specifier for tuples and pairs\n  (https://github.com/fmtlib/fmt/pull/4107). Thanks @someonewithpc.\n\n- Added support for tuple-like types to `fmt::join`\n  (https://github.com/fmtlib/fmt/issues/4226,\n  https://github.com/fmtlib/fmt/pull/4230). Thanks @phprus.\n\n- Made more types formattable at compile time\n  (https://github.com/fmtlib/fmt/pull/4127). Thanks @AnthonyVH.\n\n- Implemented a more efficient compile-time `fmt::formatted_size`\n  (https://github.com/fmtlib/fmt/issues/4102,\n  https://github.com/fmtlib/fmt/pull/4103). Thanks @phprus.\n\n- Fixed compile-time formatting of some string types\n  (https://github.com/fmtlib/fmt/pull/4065). Thanks @torshepherd.\n\n- Made compiled version of `fmt::format_to` work with\n  `std::back_insert_iterator<std::vector<char>>`\n  (https://github.com/fmtlib/fmt/issues/4206,\n  https://github.com/fmtlib/fmt/pull/4211). Thanks @phprus.\n\n- Added a formatter for `std::reference_wrapper`\n  (https://github.com/fmtlib/fmt/pull/4163,\n  https://github.com/fmtlib/fmt/pull/4164). Thanks @yfeldblum and @phprus.\n\n- Added experimental padding support (glibc `strftime` extension) to `%m`, `%j`\n  and `%Y` (https://github.com/fmtlib/fmt/pull/4161). Thanks @KKhanhH.\n\n- Made microseconds formatted as `us` instead of `µs` if the Unicode support is\n  disabled (https://github.com/fmtlib/fmt/issues/4088).\n\n- Fixed an unreleased regression in transcoding of surrogate pairs\n  (https://github.com/fmtlib/fmt/issues/4094,\n  https://github.com/fmtlib/fmt/pull/4095). Thanks @phprus.\n\n- Made `fmt::appender` satisfy `std::output_iterator` concept\n  (https://github.com/fmtlib/fmt/issues/4092,\n  https://github.com/fmtlib/fmt/pull/4093). Thanks @phprus.\n\n- Made `std::iterator_traits<fmt::appender>` standard-conforming\n  (https://github.com/fmtlib/fmt/pull/4185). Thanks @CaseyCarter.\n\n- Made it easier to reuse `fmt::formatter<std::string_view>` for types with\n  an implicit conversion to `std::string_view`\n  (https://github.com/fmtlib/fmt/issues/4036,\n  https://github.com/fmtlib/fmt/pull/4055). Thanks @Arghnews.\n\n- Made it possible to disable `<filesystem>` use via `FMT_CPP_LIB_FILESYSTEM`\n  for compatibility with some video game console SDKs, e.g. Nintendo Switch SDK\n  (https://github.com/fmtlib/fmt/issues/4257,\n  https://github.com/fmtlib/fmt/pull/4258,\n  https://github.com/fmtlib/fmt/pull/4259). Thanks @W4RH4WK and @phprus.\n\n- Fixed compatibility with platforms that use 80-bit `long double`\n  (https://github.com/fmtlib/fmt/issues/4245,\n  https://github.com/fmtlib/fmt/pull/4246). Thanks @jsirpoma.\n\n- Added support for UTF-32 code units greater than `0xFFFF` in fill\n  (https://github.com/fmtlib/fmt/issues/4201).\n\n- Fixed handling of legacy encodings on Windows with GCC\n  (https://github.com/fmtlib/fmt/issues/4162).\n\n- Made `fmt::to_string` take `fmt::basic_memory_buffer` by const reference\n  (https://github.com/fmtlib/fmt/issues/4261,\n  https://github.com/fmtlib/fmt/pull/4262). Thanks @sascha-devel.\n\n- Added `fmt::dynamic_format_arg_store::size`\n  (https://github.com/fmtlib/fmt/pull/4270). Thanks @hannes-harnisch.\n\n- Removed the ability to control locale usage via an undocumented\n  `FMT_STATIC_THOUSANDS_SEPARATOR` in favor of `FMT_USE_LOCALE`.\n\n- Renamed `FMT_EXCEPTIONS` to `FMT_USE_EXCEPTIONS` for consistency with other\n  similar macros.\n\n- Improved include directory ordering to reduce the chance of including\n  incorrect headers when using multiple versions of {fmt}\n  (https://github.com/fmtlib/fmt/pull/4116). Thanks @cdzhan.\n\n- Made it possible to compile a subset of {fmt} without the C++ runtime.\n\n- Improved documentation and README\n  (https://github.com/fmtlib/fmt/pull/4066,\n  https://github.com/fmtlib/fmt/issues/4117,\n  https://github.com/fmtlib/fmt/issues/4203,\n  https://github.com/fmtlib/fmt/pull/4235). Thanks @zyctree and @nikola-sh.\n\n- Improved the documentation generator (https://github.com/fmtlib/fmt/pull/4110,\n  https://github.com/fmtlib/fmt/pull/4115). Thanks @rturrado.\n\n- Improved CI (https://github.com/fmtlib/fmt/pull/4155,\n  https://github.com/fmtlib/fmt/pull/4151). Thanks @phprus.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/2708,\n  https://github.com/fmtlib/fmt/issues/4091,\n  https://github.com/fmtlib/fmt/issues/4109,\n  https://github.com/fmtlib/fmt/issues/4113,\n  https://github.com/fmtlib/fmt/issues/4125,\n  https://github.com/fmtlib/fmt/issues/4129,\n  https://github.com/fmtlib/fmt/pull/4130,\n  https://github.com/fmtlib/fmt/pull/4131,\n  https://github.com/fmtlib/fmt/pull/4132,\n  https://github.com/fmtlib/fmt/issues/4133,\n  https://github.com/fmtlib/fmt/issues/4144,\n  https://github.com/fmtlib/fmt/issues/4150,\n  https://github.com/fmtlib/fmt/issues/4158,\n  https://github.com/fmtlib/fmt/pull/4159,\n  https://github.com/fmtlib/fmt/issues/4160,\n  https://github.com/fmtlib/fmt/pull/4170,\n  https://github.com/fmtlib/fmt/issues/4177,\n  https://github.com/fmtlib/fmt/pull/4187,\n  https://github.com/fmtlib/fmt/pull/4188,\n  https://github.com/fmtlib/fmt/pull/4194,\n  https://github.com/fmtlib/fmt/pull/4200,\n  https://github.com/fmtlib/fmt/issues/4205,\n  https://github.com/fmtlib/fmt/issues/4207,\n  https://github.com/fmtlib/fmt/pull/4208,\n  https://github.com/fmtlib/fmt/pull/4210,\n  https://github.com/fmtlib/fmt/issues/4220,\n  https://github.com/fmtlib/fmt/issues/4231,\n  https://github.com/fmtlib/fmt/issues/4232,\n  https://github.com/fmtlib/fmt/pull/4233,\n  https://github.com/fmtlib/fmt/pull/4236,\n  https://github.com/fmtlib/fmt/pull/4267,\n  https://github.com/fmtlib/fmt/pull/4271).\n  Thanks @torsten48, @Arghnews, @tinfoilboy, @aminya, @Ottani, @zeroomega,\n  @c4v4, @kongy, @vinayyadav3016, @sergio-nsk, @phprus and @YexuanXiao.\n\n# 11.0.2 - 2024-07-20\n\n- Fixed compatibility with non-POSIX systems\n  (https://github.com/fmtlib/fmt/issues/4054,\n  https://github.com/fmtlib/fmt/issues/4060).\n\n- Fixed performance regressions when using `std::back_insert_iterator` with\n  `fmt::format_to` (https://github.com/fmtlib/fmt/issues/4070).\n\n- Fixed handling of `std::generator` and move-only iterators\n  (https://github.com/fmtlib/fmt/issues/4053,\n  https://github.com/fmtlib/fmt/pull/4057). Thanks @Arghnews.\n\n- Made `formatter<std::string_view>::parse` work with types convertible to\n  `std::string_view` (https://github.com/fmtlib/fmt/issues/4036,\n  https://github.com/fmtlib/fmt/pull/4055). Thanks @Arghnews.\n\n- Made `volatile void*` formattable\n  (https://github.com/fmtlib/fmt/issues/4049,\n  https://github.com/fmtlib/fmt/pull/4056). Thanks @Arghnews.\n\n- Made `Glib::ustring` not be confused with `std::string`\n  (https://github.com/fmtlib/fmt/issues/4052).\n\n- Made `fmt::context` iterator compatible with STL algorithms that rely on\n  iterator category (https://github.com/fmtlib/fmt/issues/4079).\n\n# 11.0.1 - 2024-07-05\n\n- Fixed version number in the inline namespace\n  (https://github.com/fmtlib/fmt/issues/4047).\n\n- Fixed disabling Unicode support via CMake\n  (https://github.com/fmtlib/fmt/issues/4051).\n\n- Fixed deprecated `visit_format_arg` (https://github.com/fmtlib/fmt/pull/4043).\n  Thanks @nebkat.\n\n- Fixed handling of a sign and improved the `std::complex` formater\n  (https://github.com/fmtlib/fmt/pull/4034,\n  https://github.com/fmtlib/fmt/pull/4050). Thanks @tesch1 and @phprus.\n\n- Fixed ADL issues in `fmt::printf` when using C++20\n  (https://github.com/fmtlib/fmt/pull/4042). Thanks @toge.\n\n- Removed a redundant check in the formatter for `std::expected`\n  (https://github.com/fmtlib/fmt/pull/4040). Thanks @phprus.\n\n# 11.0.0 - 2024-07-01\n\n- Added `fmt/base.h` which provides a subset of the API with minimal include\n  dependencies and enough functionality to replace all uses of the `printf`\n  family of functions. This brings the compile time of code using {fmt} much\n  closer to the equivalent `printf` code as shown on the following benchmark\n  that compiles 100 source files:\n\n  | Method       | Compile Time (s) |\n  |--------------|------------------|\n  | printf       | 1.6              |\n  | IOStreams    | 25.9             |\n  | fmt 10.x     | 19.0             |\n  | fmt 11.0     | 4.8              |\n  | tinyformat   | 29.1             |\n  | Boost Format | 55.0             |\n\n  This gives almost 4x improvement in build speed compared to version 10.\n  Note that the benchmark is purely formatting code and includes. In real\n  projects the difference from `printf` will be smaller partly because common\n  standard headers will be included in almost any translation unit (TU) anyway.\n  In particular, in every case except `printf` above ~1s is spent in total on\n  including `<type_traits>` in all TUs.\n\n- Optimized includes in other headers such as `fmt/format.h` which is now\n  roughly equivalent to the old `fmt/core.h` in terms of build speed.\n\n- Migrated the documentation at https://fmt.dev/ from Sphinx to MkDocs.\n\n- Improved C++20 module support\n  (https://github.com/fmtlib/fmt/issues/3990,\n  https://github.com/fmtlib/fmt/pull/3991,\n  https://github.com/fmtlib/fmt/issues/3993,\n  https://github.com/fmtlib/fmt/pull/3994,\n  https://github.com/fmtlib/fmt/pull/3997,\n  https://github.com/fmtlib/fmt/pull/3998,\n  https://github.com/fmtlib/fmt/pull/4004,\n  https://github.com/fmtlib/fmt/pull/4005,\n  https://github.com/fmtlib/fmt/pull/4006,\n  https://github.com/fmtlib/fmt/pull/4013,\n  https://github.com/fmtlib/fmt/pull/4027,\n  https://github.com/fmtlib/fmt/pull/4029). In particular, native CMake support\n  for modules is now used if available. Thanks @yujincheng08 and @matt77hias.\n\n- Added an option to replace standard includes with `import std` enabled via\n  the `FMT_IMPORT_STD` macro (https://github.com/fmtlib/fmt/issues/3921,\n  https://github.com/fmtlib/fmt/pull/3928). Thanks @matt77hias.\n\n- Exported `fmt::range_format`, `fmt::range_format_kind` and\n  `fmt::compiled_string` from the `fmt` module\n  (https://github.com/fmtlib/fmt/pull/3970,\n  https://github.com/fmtlib/fmt/pull/3999).\n  Thanks @matt77hias and @yujincheng08.\n\n- Improved integration with stdio in `fmt::print`, enabling direct writes\n  into a C stream buffer in common cases. This may give significant\n  performance improvements ranging from tens of percent to [2x](\n  https://stackoverflow.com/a/78457454/471164) and eliminates dynamic memory\n  allocations on the buffer level. It is currently enabled for built-in and\n  string types with wider availability coming up in future releases.\n\n  For example, it gives ~24% improvement on a [simple benchmark](\n  https://isocpp.org/files/papers/P3107R5.html#perf) compiled with Apple clang\n  version 15.0.0 (clang-1500.1.0.2.5) and run on macOS 14.2.1:\n\n  ```\n  -------------------------------------------------------\n  Benchmark             Time             CPU   Iterations\n  -------------------------------------------------------\n  printf             81.8 ns         81.5 ns      8496899\n  fmt::print (10.x)  63.8 ns         61.9 ns     11524151\n  fmt::print (11.0)  51.3 ns         51.0 ns     13846580\n  ```\n\n- Improved safety of `fmt::format_to` when writing to an array\n  (https://github.com/fmtlib/fmt/pull/3805).\n  For example ([godbolt](https://www.godbolt.org/z/cYrn8dWY8)):\n\n  ```c++\n  auto volkswagen = char[4];\n  auto result = fmt::format_to(volkswagen, \"elephant\");\n  ```\n\n  no longer results in a buffer overflow. Instead the output will be truncated\n  and you can get the end iterator and whether truncation occurred from the\n  `result` object. Thanks @ThePhD.\n\n- Enabled Unicode support by default in MSVC, bringing it on par with other\n  compilers and making it unnecessary for users to enable it explicitly.\n  Most of {fmt} is encoding-agnostic but this prevents mojibake in places\n  where encoding matters such as path formatting and terminal output.\n  You can control the Unicode support via the CMake `FMT_UNICODE` option.\n  Note that some {fmt} packages such as the one in vcpkg have already been\n  compiled with Unicode enabled.\n\n- Added a formatter for `std::expected`\n  (https://github.com/fmtlib/fmt/pull/3834). Thanks @dominicpoeschko.\n\n- Added a formatter for `std::complex`\n  (https://github.com/fmtlib/fmt/issues/1467,\n  https://github.com/fmtlib/fmt/issues/3886,\n  https://github.com/fmtlib/fmt/pull/3892,\n  https://github.com/fmtlib/fmt/pull/3900). Thanks @phprus.\n\n- Added a formatter for `std::type_info`\n  (https://github.com/fmtlib/fmt/pull/3978). Thanks @matt77hias.\n\n- Specialized `formatter` for `std::basic_string` types with custom traits\n  and allocators (https://github.com/fmtlib/fmt/issues/3938,\n  https://github.com/fmtlib/fmt/pull/3943). Thanks @dieram3.\n\n- Added formatters for `std::chrono::day`, `std::chrono::month`,\n  `std::chrono::year` and `std::chrono::year_month_day`\n  (https://github.com/fmtlib/fmt/issues/3758,\n  https://github.com/fmtlib/fmt/issues/3772,\n  https://github.com/fmtlib/fmt/pull/3906,\n  https://github.com/fmtlib/fmt/pull/3913). For example:\n\n  ```c++\n  #include <fmt/chrono.h>\n  #include <fmt/color.h>\n\n  int main() {\n    fmt::print(fg(fmt::color::green), \"{}\\n\", std::chrono::day(7));\n  }\n  ```\n\n  prints a green day:\n\n  <img width=\"306\" alt=\"image\" src=\"https://github.com/fmtlib/fmt/assets/576385/6e395f8b-451a-4cf7-bccc-ee92ca0dec65\">\n\n  Thanks @zivshek.\n\n- Fixed handling of precision in `%S` (https://github.com/fmtlib/fmt/issues/3794,\n  https://github.com/fmtlib/fmt/pull/3814). Thanks @js324.\n\n- Added support for the `-` specifier (glibc `strftime` extension) to day of\n  the month (`%d`) and week of the year (`%W`, `%U`, `%V`) specifiers\n  (https://github.com/fmtlib/fmt/pull/3976). Thanks @ZaheenJ.\n\n- Fixed the scope of the `-` extension in chrono formatting so that it doesn't\n  apply to subsequent specifiers (https://github.com/fmtlib/fmt/issues/3811,\n  https://github.com/fmtlib/fmt/pull/3812). Thanks @phprus.\n\n- Improved handling of `time_point::min()`\n  (https://github.com/fmtlib/fmt/issues/3282).\n\n- Added support for character range formatting\n  (https://github.com/fmtlib/fmt/issues/3857,\n  https://github.com/fmtlib/fmt/pull/3863). Thanks @js324.\n\n- Added `string` and `debug_string` range formatters\n  (https://github.com/fmtlib/fmt/pull/3973,\n  https://github.com/fmtlib/fmt/pull/4024). Thanks @matt77hias.\n\n- Enabled ADL for `begin` and `end` in `fmt::join`\n  (https://github.com/fmtlib/fmt/issues/3813,\n  https://github.com/fmtlib/fmt/pull/3824). Thanks @bbolli.\n\n- Made contiguous iterator optimizations apply to `std::basic_string` iterators\n  (https://github.com/fmtlib/fmt/pull/3798). Thanks @phprus.\n\n- Added support for ranges with mutable `begin` and `end`\n  (https://github.com/fmtlib/fmt/issues/3752,\n  https://github.com/fmtlib/fmt/pull/3800,\n  https://github.com/fmtlib/fmt/pull/3955). Thanks @tcbrindle and @Arghnews.\n\n- Added support for move-only iterators to `fmt::join`\n  (https://github.com/fmtlib/fmt/issues/3802,\n  https://github.com/fmtlib/fmt/pull/3946). Thanks @Arghnews.\n\n- Moved range and iterator overloads of `fmt::join` to `fmt/ranges.h`, next\n  to other overloads.\n\n- Fixed handling of types with `begin` returning `void` such as Eigen matrices\n  (https://github.com/fmtlib/fmt/issues/3839,\n  https://github.com/fmtlib/fmt/pull/3964). Thanks @Arghnews.\n\n- Added an `fmt::formattable` concept (https://github.com/fmtlib/fmt/pull/3974).\n  Thanks @matt77hias.\n\n- Added support for `__float128` (https://github.com/fmtlib/fmt/issues/3494).\n\n- Fixed rounding issues when formatting `long double` with fixed precision\n  (https://github.com/fmtlib/fmt/issues/3539).\n\n- Made `fmt::isnan` not trigger floating-point exception for NaN values\n  (https://github.com/fmtlib/fmt/issues/3948,\n  https://github.com/fmtlib/fmt/pull/3951). Thanks @alexdewar.\n\n- Removed dependency on `<memory>` for `std::allocator_traits` when possible\n  (https://github.com/fmtlib/fmt/pull/3804). Thanks @phprus.\n\n- Enabled compile-time checks in formatting functions that take text colors and\n  styles.\n\n- Deprecated wide stream overloads of `fmt::print` that take text styles.\n\n- Made format string compilation work with clang 12 and later despite\n  only partial non-type template parameter support\n  (https://github.com/fmtlib/fmt/issues/4000,\n  https://github.com/fmtlib/fmt/pull/4001). Thanks @yujincheng08.\n\n- Made `fmt::iterator_buffer`'s move constructor `noexcept`\n  (https://github.com/fmtlib/fmt/pull/3808). Thanks @waywardmonkeys.\n\n- Started enforcing that `formatter::format` is const for compatibility\n  with `std::format` (https://github.com/fmtlib/fmt/issues/3447).\n\n- Added `fmt::basic_format_arg::visit` and deprecated `fmt::visit_format_arg`.\n\n- Made `fmt::basic_string_view` not constructible from `nullptr` for\n  consistency with `std::string_view` in C++23\n  (https://github.com/fmtlib/fmt/pull/3846). Thanks @dalle.\n\n- Fixed `fmt::group_digits` for negative integers\n  (https://github.com/fmtlib/fmt/issues/3891,\n  https://github.com/fmtlib/fmt/pull/3901). Thanks @phprus.\n\n- Fixed handling of negative ids in `fmt::basic_format_args::get`\n  (https://github.com/fmtlib/fmt/pull/3945). Thanks @marlenecota.\n\n- Fixed handling of a buffer boundary on flush\n  (https://github.com/fmtlib/fmt/issues/4229).\n\n- Improved named argument validation\n  (https://github.com/fmtlib/fmt/issues/3817).\n\n- Disabled copy construction/assignment for `fmt::format_arg_store` and\n  fixed moved construction (https://github.com/fmtlib/fmt/pull/3833).\n  Thanks @ivafanas.\n\n- Worked around a locale issue in RHEL/devtoolset\n  (https://github.com/fmtlib/fmt/issues/3858,\n  https://github.com/fmtlib/fmt/pull/3859). Thanks @g199209.\n\n- Added RTTI detection for MSVC (https://github.com/fmtlib/fmt/pull/3821,\n  https://github.com/fmtlib/fmt/pull/3963). Thanks @edo9300.\n\n- Migrated the documentation from Sphinx to MkDocs.\n\n- Improved documentation and README\n  (https://github.com/fmtlib/fmt/issues/3775,\n  https://github.com/fmtlib/fmt/pull/3784,\n  https://github.com/fmtlib/fmt/issues/3788,\n  https://github.com/fmtlib/fmt/pull/3789,\n  https://github.com/fmtlib/fmt/pull/3793,\n  https://github.com/fmtlib/fmt/issues/3818,\n  https://github.com/fmtlib/fmt/pull/3820,\n  https://github.com/fmtlib/fmt/pull/3822,\n  https://github.com/fmtlib/fmt/pull/3843,\n  https://github.com/fmtlib/fmt/pull/3890,\n  https://github.com/fmtlib/fmt/issues/3894,\n  https://github.com/fmtlib/fmt/pull/3895,\n  https://github.com/fmtlib/fmt/pull/3905,\n  https://github.com/fmtlib/fmt/issues/3942,\n  https://github.com/fmtlib/fmt/pull/4008).\n  Thanks @zencatalyst, WolleTD, @tupaschoal, @Dobiasd, @frank-weinberg, @bbolli,\n  @phprus, @waywardmonkeys, @js324 and @tchaikov.\n\n- Improved CI and tests\n  (https://github.com/fmtlib/fmt/issues/3878,\n  https://github.com/fmtlib/fmt/pull/3883,\n  https://github.com/fmtlib/fmt/issues/3897,\n  https://github.com/fmtlib/fmt/pull/3979,\n  https://github.com/fmtlib/fmt/pull/3980,\n  https://github.com/fmtlib/fmt/pull/3988,\n  https://github.com/fmtlib/fmt/pull/4010,\n  https://github.com/fmtlib/fmt/pull/4012,\n  https://github.com/fmtlib/fmt/pull/4038).\n  Thanks @vgorrX, @waywardmonkeys, @tchaikov and @phprus.\n\n- Fixed buffer overflow when using format string compilation with debug format\n  and `std::back_insert_iterator` (https://github.com/fmtlib/fmt/issues/3795,\n  https://github.com/fmtlib/fmt/pull/3797). Thanks @phprus.\n\n- Improved Bazel support\n  (https://github.com/fmtlib/fmt/pull/3792,\n  https://github.com/fmtlib/fmt/pull/3801,\n  https://github.com/fmtlib/fmt/pull/3962,\n  https://github.com/fmtlib/fmt/pull/3965). Thanks @Vertexwahn.\n\n- Improved/fixed the CMake config\n  (https://github.com/fmtlib/fmt/issues/3777,\n  https://github.com/fmtlib/fmt/pull/3783,\n  https://github.com/fmtlib/fmt/issues/3847,\n  https://github.com/fmtlib/fmt/pull/3907). Thanks @phprus and @xTachyon.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/3685,\n  https://github.com/fmtlib/fmt/issues/3769,\n  https://github.com/fmtlib/fmt/issues/3796,\n  https://github.com/fmtlib/fmt/issues/3803,\n  https://github.com/fmtlib/fmt/pull/3806,\n  https://github.com/fmtlib/fmt/pull/3807,\n  https://github.com/fmtlib/fmt/issues/3809,\n  https://github.com/fmtlib/fmt/pull/3810,\n  https://github.com/fmtlib/fmt/issues/3830,\n  https://github.com/fmtlib/fmt/pull/3832,\n  https://github.com/fmtlib/fmt/issues/3835,\n  https://github.com/fmtlib/fmt/pull/3844,\n  https://github.com/fmtlib/fmt/issues/3854,\n  https://github.com/fmtlib/fmt/pull/3856,\n  https://github.com/fmtlib/fmt/pull/3865,\n  https://github.com/fmtlib/fmt/pull/3866,\n  https://github.com/fmtlib/fmt/pull/3880,\n  https://github.com/fmtlib/fmt/issues/3881,\n  https://github.com/fmtlib/fmt/issues/3884,\n  https://github.com/fmtlib/fmt/issues/3898,\n  https://github.com/fmtlib/fmt/pull/3899,\n  https://github.com/fmtlib/fmt/pull/3909,\n  https://github.com/fmtlib/fmt/pull/3917,\n  https://github.com/fmtlib/fmt/pull/3923,\n  https://github.com/fmtlib/fmt/pull/3924,\n  https://github.com/fmtlib/fmt/issues/3925,\n  https://github.com/fmtlib/fmt/pull/3930,\n  https://github.com/fmtlib/fmt/pull/3931,\n  https://github.com/fmtlib/fmt/pull/3933,\n  https://github.com/fmtlib/fmt/issues/3935,\n  https://github.com/fmtlib/fmt/pull/3937,\n  https://github.com/fmtlib/fmt/pull/3967,\n  https://github.com/fmtlib/fmt/pull/3968,\n  https://github.com/fmtlib/fmt/pull/3972,\n  https://github.com/fmtlib/fmt/pull/3983,\n  https://github.com/fmtlib/fmt/issues/3992,\n  https://github.com/fmtlib/fmt/pull/3995,\n  https://github.com/fmtlib/fmt/pull/4009,\n  https://github.com/fmtlib/fmt/pull/4023).\n  Thanks @hmbj, @phprus, @res2k, @Baardi, @matt77hias, @waywardmonkeys, @hmbj,\n  @yakra, @prlw1, @Arghnews, @mtillmann0, @ShifftC, @eepp, @jimmy-park and\n  @ChristianGebhardt.\n\n# 10.2.1 - 2024-01-04\n\n- Fixed ABI compatibility with earlier 10.x versions\n  (https://github.com/fmtlib/fmt/issues/3785,\n  https://github.com/fmtlib/fmt/pull/3786). Thanks @saraedum.\n\n# 10.2.0 - 2024-01-01\n\n- Added support for the `%j` specifier (the number of days) for\n  `std::chrono::duration` (https://github.com/fmtlib/fmt/issues/3643,\n  https://github.com/fmtlib/fmt/pull/3732). Thanks @intelfx.\n\n- Added support for the chrono suffix for days and changed\n  the suffix for minutes from \"m\" to the correct \"min\"\n  (https://github.com/fmtlib/fmt/issues/3662,\n  https://github.com/fmtlib/fmt/pull/3664).\n  For example ([godbolt](https://godbolt.org/z/9KhMnq9ba)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    fmt::print(\"{}\\n\", std::chrono::days(42)); // prints \"42d\"\n  }\n  ```\n\n  Thanks @Richardk2n.\n\n- Fixed an overflow in `std::chrono::time_point` formatting with large dates\n  (https://github.com/fmtlib/fmt/issues/3725,\n  https://github.com/fmtlib/fmt/pull/3727). Thanks @cschreib.\n\n- Added a formatter for `std::source_location`\n  (https://github.com/fmtlib/fmt/pull/3730).\n  For example ([godbolt](https://godbolt.org/z/YajfKjhhr)):\n\n  ```c++\n  #include <source_location>\n  #include <fmt/std.h>\n\n  int main() {\n    fmt::print(\"{}\\n\", std::source_location::current());\n  }\n  ```\n\n  prints\n\n  ```\n  /app/example.cpp:5:51: int main()\n  ```\n\n  Thanks @felix642.\n\n- Added a formatter for `std::bitset`\n  (https://github.com/fmtlib/fmt/pull/3660).\n  For example ([godbolt](https://godbolt.org/z/bdEaGeYxe)):\n\n  ```c++\n  #include <bitset>\n  #include <fmt/std.h>\n\n  int main() {\n    fmt::print(\"{}\\n\", std::bitset<6>(42)); // prints \"101010\"\n  }\n  ```\n\n  Thanks @muggenhor.\n\n- Added an experimental `nested_formatter` that provides an easy way of\n  applying a formatter to one or more subobjects while automatically handling\n  width, fill and alignment. For example:\n\n  ```c++\n  #include <fmt/format.h>\n\n  struct point {\n    double x, y;\n  };\n\n  template <>\n  struct fmt::formatter<point> : nested_formatter<double> {\n    auto format(point p, format_context& ctx) const {\n      return write_padded(ctx, [=](auto out) {\n        return format_to(out, \"({}, {})\", nested(p.x), nested(p.y));\n      });\n    }\n  };\n\n  int main() {\n    fmt::print(\"[{:>20.2f}]\", point{1, 2});\n  }\n  ```\n\n  prints\n\n  ```\n  [          (1.00, 2.00)]\n  ```\n\n- Added the generic representation (`g`) to `std::filesystem::path`\n  (https://github.com/fmtlib/fmt/issues/3715,\n  https://github.com/fmtlib/fmt/pull/3729). For example:\n\n  ```c++\n  #include <filesystem>\n  #include <fmt/std.h>\n\n  int main() {\n    fmt::print(\"{:g}\\n\", std::filesystem::path(\"C:\\\\foo\"));\n  }\n  ```\n\n  prints `\"C:/foo\"` on Windows.\n\n  Thanks @js324.\n\n- Made `format_as` work with references\n  (https://github.com/fmtlib/fmt/pull/3739). Thanks @tchaikov.\n\n- Fixed formatting of invalid UTF-8 with precision\n  (https://github.com/fmtlib/fmt/issues/3284).\n\n- Fixed an inconsistency between `fmt::to_string` and `fmt::format`\n  (https://github.com/fmtlib/fmt/issues/3684).\n\n- Disallowed unsafe uses of `fmt::styled`\n  (https://github.com/fmtlib/fmt/issues/3625):\n\n  ```c++\n  auto s = fmt::styled(std::string(\"dangle\"), fmt::emphasis::bold);\n  fmt::print(\"{}\\n\", s); // compile error\n  ```\n\n  Pass `fmt::styled(...)` as a parameter instead.\n\n- Added a null check when formatting a C string with the `s` specifier\n  (https://github.com/fmtlib/fmt/issues/3706).\n\n- Disallowed the `c` specifier for `bool`\n  (https://github.com/fmtlib/fmt/issues/3726,\n  https://github.com/fmtlib/fmt/pull/3734). Thanks @js324.\n\n- Made the default formatting unlocalized in `fmt::ostream_formatter` for\n  consistency with the rest of the library\n  (https://github.com/fmtlib/fmt/issues/3460).\n\n- Fixed localized formatting in bases other than decimal\n  (https://github.com/fmtlib/fmt/issues/3693,\n  https://github.com/fmtlib/fmt/pull/3750). Thanks @js324.\n\n- Fixed a performance regression in experimental `fmt::ostream::print`\n  (https://github.com/fmtlib/fmt/issues/3674).\n\n- Added synchronization with the underlying output stream when writing to\n  the Windows console\n  (https://github.com/fmtlib/fmt/pull/3668,\n  https://github.com/fmtlib/fmt/issues/3688,\n  https://github.com/fmtlib/fmt/pull/3689).\n  Thanks @Roman-Koshelev and @dimztimz.\n\n- Changed to only export `format_error` when {fmt} is built as a shared\n  library (https://github.com/fmtlib/fmt/issues/3626,\n  https://github.com/fmtlib/fmt/pull/3627). Thanks @phprus.\n\n- Made `fmt::streamed` `constexpr`.\n  (https://github.com/fmtlib/fmt/pull/3650). Thanks @muggenhor.\n\n- Made `fmt::format_int` `constexpr`\n  (https://github.com/fmtlib/fmt/issues/4031,\n  https://github.com/fmtlib/fmt/pull/4032). Thanks @dixlorenz.\n\n- Enabled `consteval` on older versions of MSVC\n  (https://github.com/fmtlib/fmt/pull/3757). Thanks @phprus.\n\n- Added an option to build without `wchar_t` support on Windows\n  (https://github.com/fmtlib/fmt/issues/3631,\n  https://github.com/fmtlib/fmt/pull/3636). Thanks @glebm.\n\n- Improved build and CI configuration\n  (https://github.com/fmtlib/fmt/pull/3679,\n  https://github.com/fmtlib/fmt/issues/3701,\n  https://github.com/fmtlib/fmt/pull/3702,\n  https://github.com/fmtlib/fmt/pull/3749).\n  Thanks @jcar87, @pklima and @tchaikov.\n\n- Fixed various warnings, compilation and test issues\n  (https://github.com/fmtlib/fmt/issues/3607,\n  https://github.com/fmtlib/fmt/pull/3610,\n  https://github.com/fmtlib/fmt/pull/3624,\n  https://github.com/fmtlib/fmt/pull/3630,\n  https://github.com/fmtlib/fmt/pull/3634,\n  https://github.com/fmtlib/fmt/pull/3638,\n  https://github.com/fmtlib/fmt/issues/3645,\n  https://github.com/fmtlib/fmt/issues/3646,\n  https://github.com/fmtlib/fmt/pull/3647,\n  https://github.com/fmtlib/fmt/pull/3652,\n  https://github.com/fmtlib/fmt/issues/3654,\n  https://github.com/fmtlib/fmt/pull/3663,\n  https://github.com/fmtlib/fmt/issues/3670,\n  https://github.com/fmtlib/fmt/pull/3680,\n  https://github.com/fmtlib/fmt/issues/3694,\n  https://github.com/fmtlib/fmt/pull/3695,\n  https://github.com/fmtlib/fmt/pull/3699,\n  https://github.com/fmtlib/fmt/issues/3705,\n  https://github.com/fmtlib/fmt/issues/3710,\n  https://github.com/fmtlib/fmt/issues/3712,\n  https://github.com/fmtlib/fmt/pull/3713,\n  https://github.com/fmtlib/fmt/issues/3714,\n  https://github.com/fmtlib/fmt/pull/3716,\n  https://github.com/fmtlib/fmt/pull/3723,\n  https://github.com/fmtlib/fmt/issues/3738,\n  https://github.com/fmtlib/fmt/issues/3740,\n  https://github.com/fmtlib/fmt/pull/3741,\n  https://github.com/fmtlib/fmt/pull/3743,\n  https://github.com/fmtlib/fmt/issues/3745,\n  https://github.com/fmtlib/fmt/pull/3747,\n  https://github.com/fmtlib/fmt/pull/3748,\n  https://github.com/fmtlib/fmt/pull/3751,\n  https://github.com/fmtlib/fmt/pull/3754,\n  https://github.com/fmtlib/fmt/pull/3755,\n  https://github.com/fmtlib/fmt/issues/3760,\n  https://github.com/fmtlib/fmt/pull/3762,\n  https://github.com/fmtlib/fmt/issues/3763,\n  https://github.com/fmtlib/fmt/pull/3764,\n  https://github.com/fmtlib/fmt/issues/3774,\n  https://github.com/fmtlib/fmt/pull/3779).\n  Thanks @danakj, @vinayyadav3016, @cyyever, @phprus, @qimiko, @saschasc,\n  @gsjaardema, @lazka, @Zhaojun-Liu, @carlsmedstad, @hotwatermorning,\n  @cptFracassa, @kuguma, @PeterJohnson, @H1X4Dev, @asantoni, @eltociear,\n  @msimberg, @tchaikov, @waywardmonkeys.\n\n- Improved documentation and README\n  (https://github.com/fmtlib/fmt/issues/2086,\n  https://github.com/fmtlib/fmt/issues/3637,\n  https://github.com/fmtlib/fmt/pull/3642,\n  https://github.com/fmtlib/fmt/pull/3653,\n  https://github.com/fmtlib/fmt/pull/3655,\n  https://github.com/fmtlib/fmt/pull/3661,\n  https://github.com/fmtlib/fmt/issues/3673,\n  https://github.com/fmtlib/fmt/pull/3677,\n  https://github.com/fmtlib/fmt/pull/3737,\n  https://github.com/fmtlib/fmt/issues/3742,\n  https://github.com/fmtlib/fmt/pull/3744).\n  Thanks @idzm, @perlun, @joycebrum, @fennewald, @reinhardt1053, @GeorgeLS.\n\n- Updated CI dependencies\n  (https://github.com/fmtlib/fmt/pull/3615,\n  https://github.com/fmtlib/fmt/pull/3622,\n  https://github.com/fmtlib/fmt/pull/3623,\n  https://github.com/fmtlib/fmt/pull/3666,\n  https://github.com/fmtlib/fmt/pull/3696,\n  https://github.com/fmtlib/fmt/pull/3697,\n  https://github.com/fmtlib/fmt/pull/3759,\n  https://github.com/fmtlib/fmt/pull/3782).\n\n# 10.1.1 - 2023-08-28\n\n- Added formatters for `std::atomic` and `atomic_flag`\n  (https://github.com/fmtlib/fmt/pull/3574,\n  https://github.com/fmtlib/fmt/pull/3594).\n  Thanks @wangzw and @AlexGuteniev.\n- Fixed an error about partial specialization of `formatter<string>`\n  after instantiation when compiled with gcc and C++20\n  (https://github.com/fmtlib/fmt/issues/3584).\n- Fixed compilation as a C++20 module with gcc and clang\n  (https://github.com/fmtlib/fmt/issues/3587,\n  https://github.com/fmtlib/fmt/pull/3597,\n  https://github.com/fmtlib/fmt/pull/3605).\n  Thanks @MathewBensonCode.\n- Made `fmt::to_string` work with types that have `format_as`\n  overloads (https://github.com/fmtlib/fmt/pull/3575). Thanks @phprus.\n- Made `formatted_size` work with integral format specifiers at\n  compile time (https://github.com/fmtlib/fmt/pull/3591).\n  Thanks @elbeno.\n- Fixed a warning about the `no_unique_address` attribute on clang-cl\n  (https://github.com/fmtlib/fmt/pull/3599). Thanks @lukester1975.\n- Improved compatibility with the legacy GBK encoding\n  (https://github.com/fmtlib/fmt/issues/3598,\n  https://github.com/fmtlib/fmt/pull/3599). Thanks @YuHuanTin.\n- Added OpenSSF Scorecard analysis\n  (https://github.com/fmtlib/fmt/issues/3530,\n  https://github.com/fmtlib/fmt/pull/3571). Thanks @joycebrum.\n- Updated CI dependencies\n  (https://github.com/fmtlib/fmt/pull/3591,\n  https://github.com/fmtlib/fmt/pull/3592,\n  https://github.com/fmtlib/fmt/pull/3593,\n  https://github.com/fmtlib/fmt/pull/3602).\n\n# 10.1.0 - 2023-08-12\n\n- Optimized format string compilation resulting in up to 40% speed up\n  in compiled `format_to` and \\~4x speed up in compiled `format_to_n`\n  on a concatenation benchmark\n  (https://github.com/fmtlib/fmt/issues/3133,\n  https://github.com/fmtlib/fmt/issues/3484).\n\n  {fmt} 10.0:\n\n      ---------------------------------------------------------\n      Benchmark               Time             CPU   Iterations\n      ---------------------------------------------------------\n      BM_format_to         78.9 ns         78.9 ns      8881746\n      BM_format_to_n        568 ns          568 ns      1232089\n\n  {fmt} 10.1:\n\n      ---------------------------------------------------------\n      Benchmark               Time             CPU   Iterations\n      ---------------------------------------------------------\n      BM_format_to         54.9 ns         54.9 ns     12727944\n      BM_format_to_n        133 ns          133 ns      5257795\n\n- Optimized storage of an empty allocator in `basic_memory_buffer`\n  (https://github.com/fmtlib/fmt/pull/3485). Thanks @Minty-Meeo.\n\n- Added formatters for proxy references to elements of\n  `std::vector<bool>` and `std::bitset<N>`\n  (https://github.com/fmtlib/fmt/issues/3567,\n  https://github.com/fmtlib/fmt/pull/3570). For example\n  ([godbolt](https://godbolt.org/z/zYb79Pvn8)):\n\n  ```c++\n  #include <vector>\n  #include <fmt/std.h>\n\n  int main() {\n    auto v = std::vector<bool>{true};\n    fmt::print(\"{}\", v[0]);\n  }\n  ```\n\n  Thanks @phprus and @felix642.\n\n- Fixed an ambiguous formatter specialization for containers that look\n  like container adaptors such as `boost::flat_set`\n  (https://github.com/fmtlib/fmt/issues/3556,\n  https://github.com/fmtlib/fmt/pull/3561). Thanks @5chmidti.\n\n- Fixed compilation when formatting durations not convertible from\n  `std::chrono::seconds`\n  (https://github.com/fmtlib/fmt/pull/3430). Thanks @patlkli.\n\n- Made the `formatter` specialization for `char*` const-correct\n  (https://github.com/fmtlib/fmt/pull/3432). Thanks @timsong-cpp.\n\n- Made `{}` and `{:}` handled consistently during compile-time checks\n  (https://github.com/fmtlib/fmt/issues/3526).\n\n- Disallowed passing temporaries to `make_format_args` to improve API\n  safety by preventing dangling references.\n\n- Improved the compile-time error for unformattable types\n  (https://github.com/fmtlib/fmt/pull/3478). Thanks @BRevzin.\n\n- Improved the floating-point formatter\n  (https://github.com/fmtlib/fmt/pull/3448,\n  https://github.com/fmtlib/fmt/pull/3450).\n  Thanks @florimond-collette.\n\n- Fixed handling of precision for `long double` larger than 64 bits.\n  (https://github.com/fmtlib/fmt/issues/3539,\n  https://github.com/fmtlib/fmt/issues/3564).\n\n- Made floating-point and chrono tests less platform-dependent\n  (https://github.com/fmtlib/fmt/issues/3337,\n  https://github.com/fmtlib/fmt/issues/3433,\n  https://github.com/fmtlib/fmt/pull/3434). Thanks @phprus.\n\n- Removed the remnants of the Grisu floating-point formatter that has\n  been replaced by Dragonbox in earlier versions.\n\n- Added `throw_format_error` to the public API\n  (https://github.com/fmtlib/fmt/pull/3551). Thanks @mjerabek.\n\n- Made `FMT_THROW` assert even if assertions are disabled when\n  compiling with exceptions disabled\n  (https://github.com/fmtlib/fmt/issues/3418,\n  https://github.com/fmtlib/fmt/pull/3439). Thanks @BRevzin.\n\n- Made `format_as` and `std::filesystem::path` formatter work with\n  exotic code unit types.\n  (https://github.com/fmtlib/fmt/pull/3457,\n  https://github.com/fmtlib/fmt/pull/3476). Thanks @gix and @hmbj.\n\n- Added support for the `?` format specifier to\n  `std::filesystem::path` and made the default unescaped for\n  consistency with strings.\n\n- Deprecated the wide stream overload of `printf`.\n\n- Removed unused `basic_printf_parse_context`.\n\n- Improved RTTI detection used when formatting exceptions\n  (https://github.com/fmtlib/fmt/pull/3468). Thanks @danakj.\n\n- Improved compatibility with VxWorks7\n  (https://github.com/fmtlib/fmt/pull/3467). Thanks @wenshan1.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/3174,\n  https://github.com/fmtlib/fmt/issues/3423,\n  https://github.com/fmtlib/fmt/pull/3454,\n  https://github.com/fmtlib/fmt/issues/3458,\n  https://github.com/fmtlib/fmt/pull/3461,\n  https://github.com/fmtlib/fmt/issues/3487,\n  https://github.com/fmtlib/fmt/pull/3515).\n  Thanks @zencatalyst, @rlalik and @mikecrowe.\n\n- Improved build and CI configurations\n  (https://github.com/fmtlib/fmt/issues/3449,\n  https://github.com/fmtlib/fmt/pull/3451,\n  https://github.com/fmtlib/fmt/pull/3452,\n  https://github.com/fmtlib/fmt/pull/3453,\n  https://github.com/fmtlib/fmt/pull/3459,\n  https://github.com/fmtlib/fmt/issues/3481,\n  https://github.com/fmtlib/fmt/pull/3486,\n  https://github.com/fmtlib/fmt/issues/3489,\n  https://github.com/fmtlib/fmt/pull/3496,\n  https://github.com/fmtlib/fmt/issues/3517,\n  https://github.com/fmtlib/fmt/pull/3523,\n  https://github.com/fmtlib/fmt/pull/3563).\n  Thanks @joycebrum, @glebm, @phprus, @petrmanek, @setoye and @abouvier.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/3408,\n  https://github.com/fmtlib/fmt/issues/3424,\n  https://github.com/fmtlib/fmt/issues/3444,\n  https://github.com/fmtlib/fmt/pull/3446,\n  https://github.com/fmtlib/fmt/pull/3475,\n  https://github.com/fmtlib/fmt/pull/3482,\n  https://github.com/fmtlib/fmt/issues/3492,\n  https://github.com/fmtlib/fmt/pull/3493,\n  https://github.com/fmtlib/fmt/pull/3508,\n  https://github.com/fmtlib/fmt/issues/3509,\n  https://github.com/fmtlib/fmt/issues/3533,\n  https://github.com/fmtlib/fmt/pull/3542,\n  https://github.com/fmtlib/fmt/issues/3543,\n  https://github.com/fmtlib/fmt/issues/3540,\n  https://github.com/fmtlib/fmt/pull/3544,\n  https://github.com/fmtlib/fmt/issues/3548,\n  https://github.com/fmtlib/fmt/pull/3549,\n  https://github.com/fmtlib/fmt/pull/3550,\n  https://github.com/fmtlib/fmt/pull/3552).\n  Thanks @adesitter, @hmbj, @Minty-Meeo, @phprus, @TobiSchluter,\n  @kieranclancy, @alexeedm, @jurihock, @Ozomahtli and @razaqq.\n\n# 10.0.0 - 2023-05-09\n\n- Replaced Grisu with a new floating-point formatting algorithm for\n  given precision (https://github.com/fmtlib/fmt/issues/3262,\n  https://github.com/fmtlib/fmt/issues/2750,\n  https://github.com/fmtlib/fmt/pull/3269,\n  https://github.com/fmtlib/fmt/pull/3276). The new algorithm\n  is based on Dragonbox already used for the shortest representation\n  and gives substantial performance improvement:\n\n  ![](https://user-images.githubusercontent.com/33922675/211956670-84891a09-6867-47d9-82fc-3230da7abe0f.png)\n\n  -   Red: new algorithm\n  -   Green: new algorithm with `FMT_USE_FULL_CACHE_DRAGONBOX` defined\n      to 1\n  -   Blue: old algorithm\n\n  Thanks @jk-jeon.\n\n- Replaced `snprintf`-based hex float formatter with an internal\n  implementation (https://github.com/fmtlib/fmt/pull/3179,\n  https://github.com/fmtlib/fmt/pull/3203). This removes the\n  last usage of `s(n)printf` in {fmt}. Thanks @phprus.\n\n- Fixed alignment of floating-point numbers with localization\n  (https://github.com/fmtlib/fmt/issues/3263,\n  https://github.com/fmtlib/fmt/pull/3272). Thanks @ShawnZhong.\n\n- Made handling of `#` consistent with `std::format`.\n\n- Improved C++20 module support\n  (https://github.com/fmtlib/fmt/pull/3134,\n  https://github.com/fmtlib/fmt/pull/3254,\n  https://github.com/fmtlib/fmt/pull/3386,\n  https://github.com/fmtlib/fmt/pull/3387,\n  https://github.com/fmtlib/fmt/pull/3388,\n  https://github.com/fmtlib/fmt/pull/3392,\n  https://github.com/fmtlib/fmt/pull/3397,\n  https://github.com/fmtlib/fmt/pull/3399,\n  https://github.com/fmtlib/fmt/pull/3400).\n  Thanks @laitingsheng, @Orvid and @DanielaE.\n  \n- Switched to the [modules CMake library](https://github.com/vitaut/modules)\n  which allows building {fmt} as a C++20 module with clang:\n\n      CXX=clang++ cmake -DFMT_MODULE=ON .\n      make\n\n- Made `format_as` work with any user-defined type and not just enums.\n  For example ([godbolt](https://godbolt.org/z/b7rqhq5Kh)):\n\n  ```c++\n  #include <fmt/format.h>\n\n  struct floaty_mc_floatface {\n    double value;\n  };\n\n  auto format_as(floaty_mc_floatface f) { return f.value; }\n\n  int main() {\n    fmt::print(\"{:8}\\n\", floaty_mc_floatface{0.42}); // prints \"    0.42\"\n  }\n  ```\n\n- Removed deprecated implicit conversions for enums and conversions to\n  primitive types for compatibility with `std::format` and to prevent\n  potential ODR violations. Use `format_as` instead.\n\n- Added support for fill, align and width to the time point formatter\n  (https://github.com/fmtlib/fmt/issues/3237,\n  https://github.com/fmtlib/fmt/pull/3260,\n  https://github.com/fmtlib/fmt/pull/3275). For example\n  ([godbolt](https://godbolt.org/z/rKP6MGz6c)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    // prints \"    2023\"\n    fmt::print(\"{:>8%Y}\\n\", std::chrono::system_clock::now());\n  }\n  ```\n\n  Thanks @ShawnZhong.\n\n- Implemented formatting of subseconds\n  (https://github.com/fmtlib/fmt/issues/2207,\n  https://github.com/fmtlib/fmt/issues/3117,\n  https://github.com/fmtlib/fmt/pull/3115,\n  https://github.com/fmtlib/fmt/pull/3143,\n  https://github.com/fmtlib/fmt/pull/3144,\n  https://github.com/fmtlib/fmt/pull/3349). For example\n  ([godbolt](https://godbolt.org/z/45738oGEo)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    // prints 01.234567\n    fmt::print(\"{:%S}\\n\", std::chrono::microseconds(1234567));\n  }\n  ```\n\n  Thanks @patrickroocks @phprus and @BRevzin.\n\n- Added precision support to `%S`\n  (https://github.com/fmtlib/fmt/pull/3148). Thanks @SappyJoy\n\n- Added support for `std::utc_time`\n  (https://github.com/fmtlib/fmt/issues/3098,\n  https://github.com/fmtlib/fmt/pull/3110). Thanks @patrickroocks.\n\n- Switched formatting of `std::chrono::system_clock` from local time\n  to UTC for compatibility with the standard\n  (https://github.com/fmtlib/fmt/issues/3199,\n  https://github.com/fmtlib/fmt/pull/3230). Thanks @ned14.\n\n- Added support for `%Ez` and `%Oz` to chrono formatters.\n  (https://github.com/fmtlib/fmt/issues/3220,\n  https://github.com/fmtlib/fmt/pull/3222). Thanks @phprus.\n\n- Improved validation of format specifiers for `std::chrono::duration`\n  (https://github.com/fmtlib/fmt/issues/3219,\n  https://github.com/fmtlib/fmt/pull/3232). Thanks @ShawnZhong.\n\n- Fixed formatting of time points before the epoch\n  (https://github.com/fmtlib/fmt/issues/3117,\n  https://github.com/fmtlib/fmt/pull/3261). For example\n  ([godbolt](https://godbolt.org/z/f7bcznb3W)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    auto t = std::chrono::system_clock::from_time_t(0) -\n             std::chrono::milliseconds(250);\n    fmt::print(\"{:%S}\\n\", t); // prints 59.750000000\n  }\n  ```\n\n  Thanks @ShawnZhong.\n\n- Experimental: implemented glibc extension for padding seconds,\n  minutes and hours\n  (https://github.com/fmtlib/fmt/issues/2959,\n  https://github.com/fmtlib/fmt/pull/3271). Thanks @ShawnZhong.\n\n- Added a formatter for `std::exception`\n  (https://github.com/fmtlib/fmt/issues/2977,\n  https://github.com/fmtlib/fmt/issues/3012,\n  https://github.com/fmtlib/fmt/pull/3062,\n  https://github.com/fmtlib/fmt/pull/3076,\n  https://github.com/fmtlib/fmt/pull/3119). For example\n  ([godbolt](https://godbolt.org/z/8xoWGs9e4)):\n\n  ```c++\n  #include <fmt/std.h>\n  #include <vector>\n\n  int main() {\n    try {\n      std::vector<bool>().at(0);\n    } catch(const std::exception& e) {\n      fmt::print(\"{}\", e);\n    }\n  }\n  ```\n\n  prints:\n\n      vector<bool>::_M_range_check: __n (which is 0) >= this->size() (which is 0)\n\n  on libstdc++. Thanks @zach2good and @phprus.\n\n- Moved `std::error_code` formatter from `fmt/os.h` to `fmt/std.h`.\n  (https://github.com/fmtlib/fmt/pull/3125). Thanks @phprus.\n\n- Added formatters for standard container adapters:\n  `std::priority_queue`, `std::queue` and `std::stack`\n  (https://github.com/fmtlib/fmt/issues/3215,\n  https://github.com/fmtlib/fmt/pull/3279). For example\n  ([godbolt](https://godbolt.org/z/74h1xY9qK)):\n\n  ```c++\n  #include <fmt/ranges.h>\n  #include <stack>\n  #include <vector>\n\n  int main() {\n    auto s = std::stack<bool, std::vector<bool>>();\n    for (auto b: {true, false, true}) s.push(b);\n    fmt::print(\"{}\\n\", s); // prints [true, false, true]\n  }\n  ```\n\n  Thanks @ShawnZhong.\n\n- Added a formatter for `std::optional` to `fmt/std.h`\n  (https://github.com/fmtlib/fmt/issues/1367,\n  https://github.com/fmtlib/fmt/pull/3303).\n  Thanks @tom-huntington.\n\n- Fixed formatting of valueless by exception variants\n  (https://github.com/fmtlib/fmt/pull/3347). Thanks @TheOmegaCarrot.\n\n- Made `fmt::ptr` accept `unique_ptr` with a custom deleter\n  (https://github.com/fmtlib/fmt/pull/3177). Thanks @hmbj.\n\n- Fixed formatting of noncopyable ranges and nested ranges of chars\n  (https://github.com/fmtlib/fmt/pull/3158\n  https://github.com/fmtlib/fmt/issues/3286,\n  https://github.com/fmtlib/fmt/pull/3290). Thanks @BRevzin.\n\n- Fixed issues with formatting of paths and ranges of paths\n  (https://github.com/fmtlib/fmt/issues/3319,\n  https://github.com/fmtlib/fmt/pull/3321\n  https://github.com/fmtlib/fmt/issues/3322). Thanks @phprus.\n\n- Improved handling of invalid Unicode in paths.\n\n- Enabled compile-time checks on Apple clang 14 and later\n  (https://github.com/fmtlib/fmt/pull/3331). Thanks @cloyce.\n\n- Improved compile-time checks of named arguments\n  (https://github.com/fmtlib/fmt/issues/3105,\n  https://github.com/fmtlib/fmt/pull/3214). Thanks @rbrich.\n\n- Fixed formatting when both alignment and `0` are given\n  (https://github.com/fmtlib/fmt/issues/3236,\n  https://github.com/fmtlib/fmt/pull/3248). Thanks @ShawnZhong.\n\n- Improved Unicode support in the experimental file API on Windows\n  (https://github.com/fmtlib/fmt/issues/3234,\n  https://github.com/fmtlib/fmt/pull/3293). Thanks @Fros1er.\n\n- Unified UTF transcoding\n  (https://github.com/fmtlib/fmt/pull/3416). Thanks @phprus.\n\n- Added support for UTF-8 digit separators via an experimental locale\n  facet (https://github.com/fmtlib/fmt/issues/1861). For\n  example ([godbolt](https://godbolt.org/z/f7bcznb3W)):\n\n  ```c++\n  auto loc = std::locale(\n    std::locale(), new fmt::format_facet<std::locale>(\"’\"));\n  auto s = fmt::format(loc, \"{:L}\", 1000);\n  ```\n\n  where `’` is U+2019 used as a digit separator in the de_CH locale.\n\n- Added an overload of `formatted_size` that takes a locale\n  (https://github.com/fmtlib/fmt/issues/3084,\n  https://github.com/fmtlib/fmt/pull/3087). Thanks @gerboengels.\n\n- Removed the deprecated `FMT_DEPRECATED_OSTREAM`.\n\n- Fixed a UB when using a null `std::string_view` with\n  `fmt::to_string` or format string compilation\n  (https://github.com/fmtlib/fmt/issues/3241,\n  https://github.com/fmtlib/fmt/pull/3244). Thanks @phprus.\n\n- Added `starts_with` to the fallback `string_view` implementation\n  (https://github.com/fmtlib/fmt/pull/3080). Thanks @phprus.\n\n- Added `fmt::basic_format_string::get()` for compatibility with\n  `basic_format_string`\n  (https://github.com/fmtlib/fmt/pull/3111). Thanks @huangqinjin.\n\n- Added `println` for compatibility with C++23\n  (https://github.com/fmtlib/fmt/pull/3267). Thanks @ShawnZhong.\n\n- Renamed the `FMT_EXPORT` macro for shared library usage to\n  `FMT_LIB_EXPORT`.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/3108,\n  https://github.com/fmtlib/fmt/issues/3169,\n  https://github.com/fmtlib/fmt/pull/3243).\n  https://github.com/fmtlib/fmt/pull/3404,\n  https://github.com/fmtlib/fmt/pull/4002).\n  Thanks @Cleroth, @Vertexwahn and @yujincheng08.\n\n- Improved build configuration and tests\n  (https://github.com/fmtlib/fmt/pull/3118,\n  https://github.com/fmtlib/fmt/pull/3120,\n  https://github.com/fmtlib/fmt/pull/3188,\n  https://github.com/fmtlib/fmt/issues/3189,\n  https://github.com/fmtlib/fmt/pull/3198,\n  https://github.com/fmtlib/fmt/pull/3205,\n  https://github.com/fmtlib/fmt/pull/3207,\n  https://github.com/fmtlib/fmt/pull/3210,\n  https://github.com/fmtlib/fmt/pull/3240,\n  https://github.com/fmtlib/fmt/pull/3256,\n  https://github.com/fmtlib/fmt/pull/3264,\n  https://github.com/fmtlib/fmt/issues/3299,\n  https://github.com/fmtlib/fmt/pull/3302,\n  https://github.com/fmtlib/fmt/pull/3312,\n  https://github.com/fmtlib/fmt/issues/3317,\n  https://github.com/fmtlib/fmt/pull/3328,\n  https://github.com/fmtlib/fmt/pull/3333,\n  https://github.com/fmtlib/fmt/pull/3369,\n  https://github.com/fmtlib/fmt/issues/3373,\n  https://github.com/fmtlib/fmt/pull/3395,\n  https://github.com/fmtlib/fmt/pull/3406,\n  https://github.com/fmtlib/fmt/pull/3411).\n  Thanks @dimztimz, @phprus, @DavidKorczynski, @ChrisThrasher,\n  @FrancoisCarouge, @kennyweiss, @luzpaz, @codeinred, @Mixaill, @joycebrum,\n  @kevinhwang and @Vertexwahn.\n\n- Fixed a regression in handling empty format specifiers after a colon\n  (`{:}`) (https://github.com/fmtlib/fmt/pull/3086). Thanks @oxidase.\n\n- Worked around a broken implementation of\n  `std::is_constant_evaluated` in some versions of libstdc++ on clang\n  (https://github.com/fmtlib/fmt/issues/3247,\n  https://github.com/fmtlib/fmt/pull/3281). Thanks @phprus.\n\n- Fixed formatting of volatile variables\n  (https://github.com/fmtlib/fmt/pull/3068).\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/3057,\n  https://github.com/fmtlib/fmt/pull/3066,\n  https://github.com/fmtlib/fmt/pull/3072,\n  https://github.com/fmtlib/fmt/pull/3082,\n  https://github.com/fmtlib/fmt/pull/3091,\n  https://github.com/fmtlib/fmt/issues/3092,\n  https://github.com/fmtlib/fmt/pull/3093,\n  https://github.com/fmtlib/fmt/pull/3095,\n  https://github.com/fmtlib/fmt/issues/3096,\n  https://github.com/fmtlib/fmt/pull/3097,\n  https://github.com/fmtlib/fmt/issues/3128,\n  https://github.com/fmtlib/fmt/pull/3129,\n  https://github.com/fmtlib/fmt/pull/3137,\n  https://github.com/fmtlib/fmt/pull/3139,\n  https://github.com/fmtlib/fmt/issues/3140,\n  https://github.com/fmtlib/fmt/pull/3142,\n  https://github.com/fmtlib/fmt/issues/3149,\n  https://github.com/fmtlib/fmt/pull/3150,\n  https://github.com/fmtlib/fmt/issues/3154,\n  https://github.com/fmtlib/fmt/issues/3163,\n  https://github.com/fmtlib/fmt/issues/3178,\n  https://github.com/fmtlib/fmt/pull/3184,\n  https://github.com/fmtlib/fmt/pull/3196,\n  https://github.com/fmtlib/fmt/issues/3204,\n  https://github.com/fmtlib/fmt/pull/3206,\n  https://github.com/fmtlib/fmt/pull/3208,\n  https://github.com/fmtlib/fmt/issues/3213,\n  https://github.com/fmtlib/fmt/pull/3216,\n  https://github.com/fmtlib/fmt/issues/3224,\n  https://github.com/fmtlib/fmt/issues/3226,\n  https://github.com/fmtlib/fmt/issues/3228,\n  https://github.com/fmtlib/fmt/pull/3229,\n  https://github.com/fmtlib/fmt/pull/3259,\n  https://github.com/fmtlib/fmt/issues/3274,\n  https://github.com/fmtlib/fmt/issues/3287,\n  https://github.com/fmtlib/fmt/pull/3288,\n  https://github.com/fmtlib/fmt/issues/3292,\n  https://github.com/fmtlib/fmt/pull/3295,\n  https://github.com/fmtlib/fmt/pull/3296,\n  https://github.com/fmtlib/fmt/issues/3298,\n  https://github.com/fmtlib/fmt/issues/3325,\n  https://github.com/fmtlib/fmt/pull/3326,\n  https://github.com/fmtlib/fmt/issues/3334,\n  https://github.com/fmtlib/fmt/issues/3342,\n  https://github.com/fmtlib/fmt/pull/3343,\n  https://github.com/fmtlib/fmt/issues/3351,\n  https://github.com/fmtlib/fmt/pull/3352,\n  https://github.com/fmtlib/fmt/pull/3362,\n  https://github.com/fmtlib/fmt/issues/3365,\n  https://github.com/fmtlib/fmt/pull/3366,\n  https://github.com/fmtlib/fmt/pull/3374,\n  https://github.com/fmtlib/fmt/issues/3377,\n  https://github.com/fmtlib/fmt/pull/3378,\n  https://github.com/fmtlib/fmt/issues/3381,\n  https://github.com/fmtlib/fmt/pull/3398,\n  https://github.com/fmtlib/fmt/pull/3413,\n  https://github.com/fmtlib/fmt/issues/3415).\n  Thanks @phprus, @gsjaardema, @NewbieOrange, @EngineLessCC, @asmaloney,\n  @HazardyKnusperkeks, @sergiud, @Youw, @thesmurph, @czudziakm,\n  @Roman-Koshelev, @chronoxor, @ShawnZhong, @russelltg, @glebm, @tmartin-gh,\n  @Zhaojun-Liu, @louiswins and @mogemimi.\n\n# 9.1.0 - 2022-08-27\n\n- `fmt::formatted_size` now works at compile time\n  (https://github.com/fmtlib/fmt/pull/3026). For example\n  ([godbolt](https://godbolt.org/z/1MW5rMdf8)):\n\n  ```c++\n  #include <fmt/compile.h>\n\n  int main() {\n    using namespace fmt::literals;\n    constexpr size_t n = fmt::formatted_size(\"{}\"_cf, 42);\n    fmt::print(\"{}\\n\", n); // prints 2\n  }\n  ```\n\n  Thanks @marksantaniello.\n\n- Fixed handling of invalid UTF-8\n  (https://github.com/fmtlib/fmt/pull/3038,\n  https://github.com/fmtlib/fmt/pull/3044,\n  https://github.com/fmtlib/fmt/pull/3056).\n  Thanks @phprus and @skeeto.\n\n- Improved Unicode support in `ostream` overloads of `print`\n  (https://github.com/fmtlib/fmt/pull/2994,\n  https://github.com/fmtlib/fmt/pull/3001,\n  https://github.com/fmtlib/fmt/pull/3025). Thanks @dimztimz.\n\n- Fixed handling of the sign specifier in localized formatting on\n  systems with 32-bit `wchar_t`\n  (https://github.com/fmtlib/fmt/issues/3041).\n\n- Added support for wide streams to `fmt::streamed`\n  (https://github.com/fmtlib/fmt/pull/2994). Thanks @phprus.\n\n- Added the `n` specifier that disables the output of delimiters when\n  formatting ranges (https://github.com/fmtlib/fmt/pull/2981,\n  https://github.com/fmtlib/fmt/pull/2983). For example\n  ([godbolt](https://godbolt.org/z/roKqGdj8c)):\n\n  ```c++\n  #include <fmt/ranges.h>\n  #include <vector>\n\n  int main() {\n    auto v = std::vector{1, 2, 3};\n    fmt::print(\"{:n}\\n\", v); // prints 1, 2, 3\n  }\n  ```\n\n  Thanks @BRevzin.\n\n- Worked around problematic `std::string_view` constructors introduced\n  in C++23 (https://github.com/fmtlib/fmt/issues/3030,\n  https://github.com/fmtlib/fmt/issues/3050). Thanks @strega-nil-ms.\n\n- Improve handling (exclusion) of recursive ranges\n  (https://github.com/fmtlib/fmt/issues/2968,\n  https://github.com/fmtlib/fmt/pull/2974). Thanks @Dani-Hub.\n\n- Improved error reporting in format string compilation\n  (https://github.com/fmtlib/fmt/issues/3055).\n\n- Improved the implementation of\n  [Dragonbox](https://github.com/jk-jeon/dragonbox), the algorithm\n  used for the default floating-point formatting\n  (https://github.com/fmtlib/fmt/pull/2984). Thanks @jk-jeon.\n\n- Fixed issues with floating-point formatting on exotic platforms.\n\n- Improved the implementation of chrono formatting\n  (https://github.com/fmtlib/fmt/pull/3010). Thanks @phprus.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/pull/2966,\n  https://github.com/fmtlib/fmt/pull/3009,\n  https://github.com/fmtlib/fmt/issues/3020,\n  https://github.com/fmtlib/fmt/pull/3037).\n  Thanks @mwinterb, @jcelerier and @remiburtin.\n\n- Improved build configuration\n  (https://github.com/fmtlib/fmt/pull/2991,\n  https://github.com/fmtlib/fmt/pull/2995,\n  https://github.com/fmtlib/fmt/issues/3004,\n  https://github.com/fmtlib/fmt/pull/3007,\n  https://github.com/fmtlib/fmt/pull/3040).\n  Thanks @dimztimz and @hwhsu1231.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/2969,\n  https://github.com/fmtlib/fmt/pull/2971,\n  https://github.com/fmtlib/fmt/issues/2975,\n  https://github.com/fmtlib/fmt/pull/2982,\n  https://github.com/fmtlib/fmt/pull/2985,\n  https://github.com/fmtlib/fmt/issues/2988,\n  https://github.com/fmtlib/fmt/issues/2989,\n  https://github.com/fmtlib/fmt/issues/3000,\n  https://github.com/fmtlib/fmt/issues/3006,\n  https://github.com/fmtlib/fmt/issues/3014,\n  https://github.com/fmtlib/fmt/issues/3015,\n  https://github.com/fmtlib/fmt/pull/3021,\n  https://github.com/fmtlib/fmt/issues/3023,\n  https://github.com/fmtlib/fmt/pull/3024,\n  https://github.com/fmtlib/fmt/pull/3029,\n  https://github.com/fmtlib/fmt/pull/3043,\n  https://github.com/fmtlib/fmt/issues/3052,\n  https://github.com/fmtlib/fmt/pull/3053,\n  https://github.com/fmtlib/fmt/pull/3054).\n  Thanks @h-friederich, @dimztimz, @olupton, @bernhardmgruber and @phprus.\n\n# 9.0.0 - 2022-07-04\n\n- Switched to the internal floating point formatter for all decimal\n  presentation formats. In particular this results in consistent\n  rounding on all platforms and removing the `s[n]printf` fallback for\n  decimal FP formatting.\n\n- Compile-time floating point formatting no longer requires the\n  header-only mode. For example\n  ([godbolt](https://godbolt.org/z/G37PTeG3b)):\n\n  ```c++\n  #include <array>\n  #include <fmt/compile.h>\n\n  consteval auto compile_time_dtoa(double value) -> std::array<char, 10> {\n    auto result = std::array<char, 10>();\n    fmt::format_to(result.data(), FMT_COMPILE(\"{}\"), value);\n    return result;\n  }\n\n  constexpr auto answer = compile_time_dtoa(0.42);\n  ```\n\n  works with the default settings.\n\n- Improved the implementation of\n  [Dragonbox](https://github.com/jk-jeon/dragonbox), the algorithm\n  used for the default floating-point formatting\n  (https://github.com/fmtlib/fmt/pull/2713,\n  https://github.com/fmtlib/fmt/pull/2750). Thanks @jk-jeon.\n\n- Made `fmt::to_string` work with `__float128`. This uses the internal\n  FP formatter and works even on system without `__float128` support\n  in `[s]printf`.\n\n- Disabled automatic `std::ostream` insertion operator (`operator<<`)\n  discovery when `fmt/ostream.h` is included to prevent ODR\n  violations. You can get the old behavior by defining\n  `FMT_DEPRECATED_OSTREAM` but this will be removed in the next major\n  release. Use `fmt::streamed` or `fmt::ostream_formatter` to enable\n  formatting via `std::ostream` instead.\n\n- Added `fmt::ostream_formatter` that can be used to write `formatter`\n  specializations that perform formatting via `std::ostream`. For\n  example ([godbolt](https://godbolt.org/z/5sEc5qMsf)):\n\n  ```c++\n  #include <fmt/ostream.h>\n\n  struct date {\n    int year, month, day;\n\n    friend std::ostream& operator<<(std::ostream& os, const date& d) {\n      return os << d.year << '-' << d.month << '-' << d.day;\n    }\n  };\n\n  template <> struct fmt::formatter<date> : ostream_formatter {};\n\n  std::string s = fmt::format(\"The date is {}\", date{2012, 12, 9});\n  // s == \"The date is 2012-12-9\"\n  ```\n\n- Added the `fmt::streamed` function that takes an object and formats\n  it via `std::ostream`. For example\n  ([godbolt](https://godbolt.org/z/5G3346G1f)):\n\n  ```c++\n  #include <thread>\n  #include <fmt/ostream.h>\n\n  int main() {\n    fmt::print(\"Current thread id: {}\\n\",\n               fmt::streamed(std::this_thread::get_id()));\n  }\n  ```\n\n  Note that `fmt/std.h` provides a `formatter` specialization for\n  `std::thread::id` so you don\\'t need to format it via\n  `std::ostream`.\n\n- Deprecated implicit conversions of unscoped enums to integers for\n  consistency with scoped enums.\n\n- Added an argument-dependent lookup based `format_as` extension API\n  to simplify formatting of enums.\n\n- Added experimental `std::variant` formatting support\n  (https://github.com/fmtlib/fmt/pull/2941). For example\n  ([godbolt](https://godbolt.org/z/KG9z6cq68)):\n\n  ```c++\n  #include <variant>\n  #include <fmt/std.h>\n\n  int main() {\n    auto v = std::variant<int, std::string>(42);\n    fmt::print(\"{}\\n\", v);\n  }\n  ```\n\n  prints:\n\n      variant(42)\n\n  Thanks @jehelset.\n\n- Added experimental `std::filesystem::path` formatting support\n  (https://github.com/fmtlib/fmt/issues/2865,\n  https://github.com/fmtlib/fmt/pull/2902,\n  https://github.com/fmtlib/fmt/issues/2917,\n  https://github.com/fmtlib/fmt/pull/2918). For example\n  ([godbolt](https://godbolt.org/z/o44dMexEb)):\n\n  ```c++\n  #include <filesystem>\n  #include <fmt/std.h>\n\n  int main() {\n    fmt::print(\"There is no place like {}.\", std::filesystem::path(\"/home\"));\n  }\n  ```\n\n  prints:\n\n      There is no place like \"/home\".\n\n  Thanks @phprus.\n\n- Added a `std::thread::id` formatter to `fmt/std.h`. For example\n  ([godbolt](https://godbolt.org/z/j1azbYf3E)):\n\n  ```c++\n  #include <thread>\n  #include <fmt/std.h>\n\n  int main() {\n    fmt::print(\"Current thread id: {}\\n\", std::this_thread::get_id());\n  }\n  ```\n\n- Added `fmt::styled` that applies a text style to an individual\n  argument (https://github.com/fmtlib/fmt/pull/2793). For\n  example ([godbolt](https://godbolt.org/z/vWGW7v5M6)):\n\n  ```c++\n  #include <fmt/chrono.h>\n  #include <fmt/color.h>\n\n  int main() {\n    auto now = std::chrono::system_clock::now();\n    fmt::print(\n      \"[{}] {}: {}\\n\",\n      fmt::styled(now, fmt::emphasis::bold),\n      fmt::styled(\"error\", fg(fmt::color::red)),\n      \"something went wrong\");\n  }\n  ```\n\n  prints\n\n  ![](https://user-images.githubusercontent.com/576385/175071215-12809244-dab0-4005-96d8-7cd911c964d5.png)\n\n  Thanks @rbrugo.\n\n- Made `fmt::print` overload for text styles correctly handle UTF-8\n  (https://github.com/fmtlib/fmt/issues/2681,\n  https://github.com/fmtlib/fmt/pull/2701). Thanks @AlexGuteniev.\n\n- Fixed Unicode handling when writing to an ostream.\n\n- Added support for nested specifiers to range formatting\n  (https://github.com/fmtlib/fmt/pull/2673). For example\n  ([godbolt](https://godbolt.org/z/xd3Gj38cf)):\n\n  ```c++\n  #include <vector>\n  #include <fmt/ranges.h>\n\n  int main() {\n    fmt::print(\"{::#x}\\n\", std::vector{10, 20, 30});\n  }\n  ```\n\n  prints `[0xa, 0x14, 0x1e]`.\n\n  Thanks @BRevzin.\n\n- Implemented escaping of wide strings in ranges\n  (https://github.com/fmtlib/fmt/pull/2904). Thanks @phprus.\n\n- Added support for ranges with `begin` / `end` found via the\n  argument-dependent lookup\n  (https://github.com/fmtlib/fmt/pull/2807). Thanks @rbrugo.\n\n- Fixed formatting of certain kinds of ranges of ranges\n  (https://github.com/fmtlib/fmt/pull/2787). Thanks @BRevzin.\n\n- Fixed handling of maps with element types other than `std::pair`\n  (https://github.com/fmtlib/fmt/pull/2944). Thanks @BrukerJWD.\n\n- Made tuple formatter enabled only if elements are formattable\n  (https://github.com/fmtlib/fmt/issues/2939,\n  https://github.com/fmtlib/fmt/pull/2940). Thanks @jehelset.\n\n- Made `fmt::join` compatible with format string compilation\n  (https://github.com/fmtlib/fmt/issues/2719,\n  https://github.com/fmtlib/fmt/pull/2720). Thanks @phprus.\n\n- Made compile-time checks work with named arguments of custom types\n  and `std::ostream` `print` overloads\n  (https://github.com/fmtlib/fmt/issues/2816,\n  https://github.com/fmtlib/fmt/issues/2817,\n  https://github.com/fmtlib/fmt/pull/2819). Thanks @timsong-cpp.\n\n- Removed `make_args_checked` because it is no longer needed for\n  compile-time checks\n  (https://github.com/fmtlib/fmt/pull/2760). Thanks @phprus.\n\n- Removed the following deprecated APIs: `_format`, `arg_join`, the\n  `format_to` overload that takes a memory buffer, `[v]fprintf` that\n  takes an `ostream`.\n\n- Removed the deprecated implicit conversion of `[const] signed char*`\n  and `[const] unsigned char*` to C strings.\n\n- Removed the deprecated `fmt/locale.h`.\n\n- Replaced the deprecated `fileno()` with `descriptor()` in\n  `buffered_file`.\n\n- Moved `to_string_view` to the `detail` namespace since it\\'s an\n  implementation detail.\n\n- Made access mode of a created file consistent with `fopen` by\n  setting `S_IWGRP` and `S_IWOTH`\n  (https://github.com/fmtlib/fmt/pull/2733). Thanks @arogge.\n\n- Removed a redundant buffer resize when formatting to `std::ostream`\n  (https://github.com/fmtlib/fmt/issues/2842,\n  https://github.com/fmtlib/fmt/pull/2843). Thanks @jcelerier.\n\n- Made precision computation for strings consistent with width\n  (https://github.com/fmtlib/fmt/issues/2888).\n\n- Fixed handling of locale separators in floating point formatting\n  (https://github.com/fmtlib/fmt/issues/2830).\n\n- Made sign specifiers work with `__int128_t`\n  (https://github.com/fmtlib/fmt/issues/2773).\n\n- Improved support for systems such as CHERI with extra data stored in\n  pointers (https://github.com/fmtlib/fmt/pull/2932).\n  Thanks @davidchisnall.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/pull/2706,\n  https://github.com/fmtlib/fmt/pull/2712,\n  https://github.com/fmtlib/fmt/pull/2789,\n  https://github.com/fmtlib/fmt/pull/2803,\n  https://github.com/fmtlib/fmt/pull/2805,\n  https://github.com/fmtlib/fmt/pull/2815,\n  https://github.com/fmtlib/fmt/pull/2924).\n  Thanks @BRevzin, @Pokechu22, @setoye, @rtobar, @rbrugo, @anoonD and\n  @leha-bot.\n\n- Improved build configuration\n  (https://github.com/fmtlib/fmt/pull/2766,\n  https://github.com/fmtlib/fmt/pull/2772,\n  https://github.com/fmtlib/fmt/pull/2836,\n  https://github.com/fmtlib/fmt/pull/2852,\n  https://github.com/fmtlib/fmt/pull/2907,\n  https://github.com/fmtlib/fmt/pull/2913,\n  https://github.com/fmtlib/fmt/pull/2914).\n  Thanks @kambala-decapitator, @mattiasljungstrom, @kieselnb, @nathannaveen\n  and @Vertexwahn.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/2408,\n  https://github.com/fmtlib/fmt/issues/2507,\n  https://github.com/fmtlib/fmt/issues/2697,\n  https://github.com/fmtlib/fmt/issues/2715,\n  https://github.com/fmtlib/fmt/issues/2717,\n  https://github.com/fmtlib/fmt/pull/2722,\n  https://github.com/fmtlib/fmt/pull/2724,\n  https://github.com/fmtlib/fmt/pull/2725,\n  https://github.com/fmtlib/fmt/issues/2726,\n  https://github.com/fmtlib/fmt/pull/2728,\n  https://github.com/fmtlib/fmt/pull/2732,\n  https://github.com/fmtlib/fmt/issues/2738,\n  https://github.com/fmtlib/fmt/pull/2742,\n  https://github.com/fmtlib/fmt/issues/2744,\n  https://github.com/fmtlib/fmt/issues/2745,\n  https://github.com/fmtlib/fmt/issues/2746,\n  https://github.com/fmtlib/fmt/issues/2754,\n  https://github.com/fmtlib/fmt/pull/2755,\n  https://github.com/fmtlib/fmt/issues/2757,\n  https://github.com/fmtlib/fmt/pull/2758,\n  https://github.com/fmtlib/fmt/issues/2761,\n  https://github.com/fmtlib/fmt/pull/2762,\n  https://github.com/fmtlib/fmt/issues/2763,\n  https://github.com/fmtlib/fmt/pull/2765,\n  https://github.com/fmtlib/fmt/issues/2769,\n  https://github.com/fmtlib/fmt/pull/2770,\n  https://github.com/fmtlib/fmt/issues/2771,\n  https://github.com/fmtlib/fmt/issues/2777,\n  https://github.com/fmtlib/fmt/pull/2779,\n  https://github.com/fmtlib/fmt/pull/2782,\n  https://github.com/fmtlib/fmt/pull/2783,\n  https://github.com/fmtlib/fmt/issues/2794,\n  https://github.com/fmtlib/fmt/issues/2796,\n  https://github.com/fmtlib/fmt/pull/2797,\n  https://github.com/fmtlib/fmt/pull/2801,\n  https://github.com/fmtlib/fmt/pull/2802,\n  https://github.com/fmtlib/fmt/issues/2808,\n  https://github.com/fmtlib/fmt/issues/2818,\n  https://github.com/fmtlib/fmt/pull/2819,\n  https://github.com/fmtlib/fmt/issues/2829,\n  https://github.com/fmtlib/fmt/issues/2835,\n  https://github.com/fmtlib/fmt/issues/2848,\n  https://github.com/fmtlib/fmt/issues/2860,\n  https://github.com/fmtlib/fmt/pull/2861,\n  https://github.com/fmtlib/fmt/pull/2882,\n  https://github.com/fmtlib/fmt/issues/2886,\n  https://github.com/fmtlib/fmt/issues/2891,\n  https://github.com/fmtlib/fmt/pull/2892,\n  https://github.com/fmtlib/fmt/issues/2895,\n  https://github.com/fmtlib/fmt/issues/2896,\n  https://github.com/fmtlib/fmt/pull/2903,\n  https://github.com/fmtlib/fmt/issues/2906,\n  https://github.com/fmtlib/fmt/issues/2908,\n  https://github.com/fmtlib/fmt/pull/2909,\n  https://github.com/fmtlib/fmt/issues/2920,\n  https://github.com/fmtlib/fmt/pull/2922,\n  https://github.com/fmtlib/fmt/pull/2927,\n  https://github.com/fmtlib/fmt/pull/2929,\n  https://github.com/fmtlib/fmt/issues/2936,\n  https://github.com/fmtlib/fmt/pull/2937,\n  https://github.com/fmtlib/fmt/pull/2938,\n  https://github.com/fmtlib/fmt/pull/2951,\n  https://github.com/fmtlib/fmt/issues/2954,\n  https://github.com/fmtlib/fmt/pull/2957,\n  https://github.com/fmtlib/fmt/issues/2958,\n  https://github.com/fmtlib/fmt/pull/2960).\n  Thanks @matrackif @Tobi823, @ivan-volnov, @VasiliPupkin256,\n  @federico-busato, @barcharcraz, @jk-jeon, @HazardyKnusperkeks, @dalboris,\n  @seanm, @gsjaardema, @timsong-cpp, @seanm, @frithrah, @chronoxor, @Agga,\n  @madmaxoft, @JurajX, @phprus and @Dani-Hub.\n\n# 8.1.1 - 2022-01-06\n\n- Restored ABI compatibility with version 8.0.x\n  (https://github.com/fmtlib/fmt/issues/2695,\n  https://github.com/fmtlib/fmt/pull/2696). Thanks @saraedum.\n- Fixed chrono formatting on big endian systems\n  (https://github.com/fmtlib/fmt/issues/2698,\n  https://github.com/fmtlib/fmt/pull/2699).\n  Thanks @phprus and @xvitaly.\n- Fixed a linkage error with mingw\n  (https://github.com/fmtlib/fmt/issues/2691,\n  https://github.com/fmtlib/fmt/pull/2692). Thanks @rbberger.\n\n# 8.1.0 - 2022-01-02\n\n- Optimized chrono formatting\n  (https://github.com/fmtlib/fmt/pull/2500,\n  https://github.com/fmtlib/fmt/pull/2537,\n  https://github.com/fmtlib/fmt/issues/2541,\n  https://github.com/fmtlib/fmt/pull/2544,\n  https://github.com/fmtlib/fmt/pull/2550,\n  https://github.com/fmtlib/fmt/pull/2551,\n  https://github.com/fmtlib/fmt/pull/2576,\n  https://github.com/fmtlib/fmt/issues/2577,\n  https://github.com/fmtlib/fmt/pull/2586,\n  https://github.com/fmtlib/fmt/pull/2591,\n  https://github.com/fmtlib/fmt/pull/2594,\n  https://github.com/fmtlib/fmt/pull/2602,\n  https://github.com/fmtlib/fmt/pull/2617,\n  https://github.com/fmtlib/fmt/issues/2628,\n  https://github.com/fmtlib/fmt/pull/2633,\n  https://github.com/fmtlib/fmt/issues/2670,\n  https://github.com/fmtlib/fmt/pull/2671).\n\n  Processing of some specifiers such as `%z` and `%Y` is now up to\n  10-20 times faster, for example on GCC 11 with libstdc++:\n\n      ----------------------------------------------------------------------------\n      Benchmark                                  Before             After\n      ----------------------------------------------------------------------------\n      FMTFormatter_z                             261 ns             26.3 ns\n      FMTFormatterCompile_z                      246 ns             11.6 ns\n      FMTFormatter_Y                             263 ns             26.1 ns\n      FMTFormatterCompile_Y                      244 ns             10.5 ns\n      ----------------------------------------------------------------------------\n\n  Thanks @phprus and @toughengineer.\n\n- Implemented subsecond formatting for chrono durations\n  (https://github.com/fmtlib/fmt/pull/2623). For example\n  ([godbolt](https://godbolt.org/z/es7vWTETe)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    fmt::print(\"{:%S}\", std::chrono::milliseconds(1234));\n  }\n  ```\n\n  prints \\\"01.234\\\".\n\n  Thanks @matrackif.\n\n- Fixed handling of precision 0 when formatting chrono durations\n  (https://github.com/fmtlib/fmt/issues/2587,\n  https://github.com/fmtlib/fmt/pull/2588). Thanks @lukester1975.\n\n- Fixed an overflow on invalid inputs in the `tm` formatter\n  (https://github.com/fmtlib/fmt/pull/2564). Thanks @phprus.\n\n- Added `fmt::group_digits` that formats integers with a non-localized\n  digit separator (comma) for groups of three digits. For example\n  ([godbolt](https://godbolt.org/z/TxGxG9Poq)):\n\n  ```c++\n  #include <fmt/format.h>\n\n  int main() {\n    fmt::print(\"{} dollars\", fmt::group_digits(1000000));\n  }\n  ```\n\n  prints \\\"1,000,000 dollars\\\".\n\n- Added support for faint, conceal, reverse and blink text styles\n  (https://github.com/fmtlib/fmt/pull/2394):\n\n  <https://user-images.githubusercontent.com/576385/147710227-c68f5317-f8fa-42c3-9123-7c4ba3c398cb.mp4>\n\n  Thanks @benit8 and @data-man.\n\n- Added experimental support for compile-time floating point\n  formatting (https://github.com/fmtlib/fmt/pull/2426,\n  https://github.com/fmtlib/fmt/pull/2470). It is currently\n  limited to the header-only mode. Thanks @alexezeder.\n\n- Added UDL-based named argument support to compile-time format string\n  checks (https://github.com/fmtlib/fmt/issues/2640,\n  https://github.com/fmtlib/fmt/pull/2649). For example\n  ([godbolt](https://godbolt.org/z/ohGbbvonv)):\n\n  ```c++\n  #include <fmt/format.h>\n\n  int main() {\n    using namespace fmt::literals;\n    fmt::print(\"{answer:s}\", \"answer\"_a=42);\n  }\n  ```\n\n  gives a compile-time error on compilers with C++20 `consteval` and\n  non-type template parameter support (gcc 10+) because `s` is not a\n  valid format specifier for an integer.\n\n  Thanks @alexezeder.\n\n- Implemented escaping of string range elements. For example\n  ([godbolt](https://godbolt.org/z/rKvM1vKf3)):\n\n  ```c++\n  #include <fmt/ranges.h>\n  #include <vector>\n\n  int main() {\n    fmt::print(\"{}\", std::vector<std::string>{\"\\naan\"});\n  }\n  ```\n\n  is now printed as:\n\n      [\"\\naan\"]\n\n  instead of:\n\n      [\"\n      aan\"]\n\n- Added an experimental `?` specifier for escaping strings.\n  (https://github.com/fmtlib/fmt/pull/2674). Thanks @BRevzin.\n\n- Switched to JSON-like representation of maps and sets for\n  consistency with Python\\'s `str.format`. For example\n  ([godbolt](https://godbolt.org/z/seKjoY9W5)):\n\n  ```c++\n  #include <fmt/ranges.h>\n  #include <map>\n\n  int main() {\n    fmt::print(\"{}\", std::map<std::string, int>{{\"answer\", 42}});\n  }\n  ```\n\n  is now printed as:\n\n      {\"answer\": 42}\n\n- Extended `fmt::join` to support C++20-only ranges\n  (https://github.com/fmtlib/fmt/pull/2549). Thanks @BRevzin.\n\n- Optimized handling of non-const-iterable ranges and implemented\n  initial support for non-const-formattable types.\n\n- Disabled implicit conversions of scoped enums to integers that was\n  accidentally introduced in earlier versions\n  (https://github.com/fmtlib/fmt/pull/1841).\n\n- Deprecated implicit conversion of `[const] signed char*` and\n  `[const] unsigned char*` to C strings.\n\n- Deprecated `_format`, a legacy UDL-based format API\n  (https://github.com/fmtlib/fmt/pull/2646). Thanks @alexezeder.\n\n- Marked `format`, `formatted_size` and `to_string` as `[[nodiscard]]`\n  (https://github.com/fmtlib/fmt/pull/2612). @0x8000-0000.\n\n- Added missing diagnostic when trying to format function and member\n  pointers as well as objects convertible to pointers which is\n  explicitly disallowed\n  (https://github.com/fmtlib/fmt/issues/2598,\n  https://github.com/fmtlib/fmt/pull/2609,\n  https://github.com/fmtlib/fmt/pull/2610). Thanks @AlexGuteniev.\n\n- Optimized writing to a contiguous buffer with `format_to_n`\n  (https://github.com/fmtlib/fmt/pull/2489). Thanks @Roman-Koshelev.\n\n- Optimized writing to non-`char` buffers\n  (https://github.com/fmtlib/fmt/pull/2477). Thanks @Roman-Koshelev.\n\n- Decimal point is now localized when using the `L` specifier.\n\n- Improved floating point formatter implementation\n  (https://github.com/fmtlib/fmt/pull/2498,\n  https://github.com/fmtlib/fmt/pull/2499). Thanks @Roman-Koshelev.\n\n- Fixed handling of very large precision in fixed format\n  (https://github.com/fmtlib/fmt/pull/2616).\n\n- Made a table of cached powers used in FP formatting static\n  (https://github.com/fmtlib/fmt/pull/2509). Thanks @jk-jeon.\n\n- Resolved a lookup ambiguity with C++20 format-related functions due\n  to ADL (https://github.com/fmtlib/fmt/issues/2639,\n  https://github.com/fmtlib/fmt/pull/2641). Thanks @mkurdej.\n\n- Removed unnecessary inline namespace qualification\n  (https://github.com/fmtlib/fmt/issues/2642,\n  https://github.com/fmtlib/fmt/pull/2643). Thanks @mkurdej.\n\n- Implemented argument forwarding in `format_to_n`\n  (https://github.com/fmtlib/fmt/issues/2462,\n  https://github.com/fmtlib/fmt/pull/2463). Thanks @owent.\n\n- Fixed handling of implicit conversions in `fmt::to_string` and\n  format string compilation\n  (https://github.com/fmtlib/fmt/issues/2565).\n\n- Changed the default access mode of files created by\n  `fmt::output_file` to `-rw-r--r--` for consistency with `fopen`\n  (https://github.com/fmtlib/fmt/issues/2530).\n\n- Make `fmt::ostream::flush` public\n  (https://github.com/fmtlib/fmt/issues/2435).\n\n- Improved C++14/17 attribute detection\n  (https://github.com/fmtlib/fmt/pull/2615). Thanks @AlexGuteniev.\n\n- Improved `consteval` detection for MSVC\n  (https://github.com/fmtlib/fmt/pull/2559). Thanks @DanielaE.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/2406,\n  https://github.com/fmtlib/fmt/pull/2446,\n  https://github.com/fmtlib/fmt/issues/2493,\n  https://github.com/fmtlib/fmt/issues/2513,\n  https://github.com/fmtlib/fmt/pull/2515,\n  https://github.com/fmtlib/fmt/issues/2522,\n  https://github.com/fmtlib/fmt/pull/2562,\n  https://github.com/fmtlib/fmt/pull/2575,\n  https://github.com/fmtlib/fmt/pull/2606,\n  https://github.com/fmtlib/fmt/pull/2620,\n  https://github.com/fmtlib/fmt/issues/2676).\n  Thanks @sobolevn, @UnePierre, @zhsj, @phprus, @ericcurtin and @Lounarok.\n\n- Improved fuzzers and added a fuzzer for chrono timepoint formatting\n  (https://github.com/fmtlib/fmt/pull/2461,\n  https://github.com/fmtlib/fmt/pull/2469). @pauldreik,\n\n- Added the `FMT_SYSTEM_HEADERS` CMake option setting which marks\n  {fmt}\\'s headers as system. It can be used to suppress warnings\n  (https://github.com/fmtlib/fmt/issues/2644,\n  https://github.com/fmtlib/fmt/pull/2651). Thanks @alexezeder.\n\n- Added the Bazel build system support\n  (https://github.com/fmtlib/fmt/pull/2505,\n  https://github.com/fmtlib/fmt/pull/2516). Thanks @Vertexwahn.\n\n- Improved build configuration and tests\n  (https://github.com/fmtlib/fmt/issues/2437,\n  https://github.com/fmtlib/fmt/pull/2558,\n  https://github.com/fmtlib/fmt/pull/2648,\n  https://github.com/fmtlib/fmt/pull/2650,\n  https://github.com/fmtlib/fmt/pull/2663,\n  https://github.com/fmtlib/fmt/pull/2677).\n  Thanks @DanielaE, @alexezeder and @phprus.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/2353,\n  https://github.com/fmtlib/fmt/pull/2356,\n  https://github.com/fmtlib/fmt/pull/2399,\n  https://github.com/fmtlib/fmt/issues/2408,\n  https://github.com/fmtlib/fmt/pull/2414,\n  https://github.com/fmtlib/fmt/pull/2427,\n  https://github.com/fmtlib/fmt/pull/2432,\n  https://github.com/fmtlib/fmt/pull/2442,\n  https://github.com/fmtlib/fmt/pull/2434,\n  https://github.com/fmtlib/fmt/issues/2439,\n  https://github.com/fmtlib/fmt/pull/2447,\n  https://github.com/fmtlib/fmt/pull/2450,\n  https://github.com/fmtlib/fmt/issues/2455,\n  https://github.com/fmtlib/fmt/issues/2465,\n  https://github.com/fmtlib/fmt/issues/2472,\n  https://github.com/fmtlib/fmt/issues/2474,\n  https://github.com/fmtlib/fmt/pull/2476,\n  https://github.com/fmtlib/fmt/issues/2478,\n  https://github.com/fmtlib/fmt/issues/2479,\n  https://github.com/fmtlib/fmt/issues/2481,\n  https://github.com/fmtlib/fmt/pull/2482,\n  https://github.com/fmtlib/fmt/pull/2483,\n  https://github.com/fmtlib/fmt/issues/2490,\n  https://github.com/fmtlib/fmt/pull/2491,\n  https://github.com/fmtlib/fmt/pull/2510,\n  https://github.com/fmtlib/fmt/pull/2518,\n  https://github.com/fmtlib/fmt/issues/2528,\n  https://github.com/fmtlib/fmt/pull/2529,\n  https://github.com/fmtlib/fmt/pull/2539,\n  https://github.com/fmtlib/fmt/issues/2540,\n  https://github.com/fmtlib/fmt/pull/2545,\n  https://github.com/fmtlib/fmt/pull/2555,\n  https://github.com/fmtlib/fmt/issues/2557,\n  https://github.com/fmtlib/fmt/issues/2570,\n  https://github.com/fmtlib/fmt/pull/2573,\n  https://github.com/fmtlib/fmt/pull/2582,\n  https://github.com/fmtlib/fmt/issues/2605,\n  https://github.com/fmtlib/fmt/pull/2611,\n  https://github.com/fmtlib/fmt/pull/2647,\n  https://github.com/fmtlib/fmt/issues/2627,\n  https://github.com/fmtlib/fmt/pull/2630,\n  https://github.com/fmtlib/fmt/issues/2635,\n  https://github.com/fmtlib/fmt/issues/2638,\n  https://github.com/fmtlib/fmt/issues/2653,\n  https://github.com/fmtlib/fmt/issues/2654,\n  https://github.com/fmtlib/fmt/issues/2661,\n  https://github.com/fmtlib/fmt/pull/2664,\n  https://github.com/fmtlib/fmt/pull/2684).\n  Thanks @DanielaE, @mwinterb, @cdacamar, @TrebledJ, @bodomartin, @cquammen,\n  @white238, @mmarkeloff, @palacaze, @jcelerier, @mborn-adi, @BrukerJWD,\n  @spyridon97, @phprus, @oliverlee, @joshessman-llnl, @akohlmey, @timkalu,\n  @olupton, @Acretock, @alexezeder, @andrewcorrigan, @lucpelletier and\n  @HazardyKnusperkeks.\n\n# 8.0.1 - 2021-07-02\n\n- Fixed the version number in the inline namespace\n  (https://github.com/fmtlib/fmt/issues/2374).\n- Added a missing presentation type check for `std::string`\n  (https://github.com/fmtlib/fmt/issues/2402).\n- Fixed a linkage error when mixing code built with clang and gcc\n  (https://github.com/fmtlib/fmt/issues/2377).\n- Fixed documentation issues\n  (https://github.com/fmtlib/fmt/pull/2396,\n  https://github.com/fmtlib/fmt/issues/2403,\n  https://github.com/fmtlib/fmt/issues/2406). Thanks @mkurdej.\n- Removed dead code in FP formatter (\n  https://github.com/fmtlib/fmt/pull/2398). Thanks @javierhonduco.\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/2351,\n  https://github.com/fmtlib/fmt/issues/2359,\n  https://github.com/fmtlib/fmt/pull/2365,\n  https://github.com/fmtlib/fmt/issues/2368,\n  https://github.com/fmtlib/fmt/pull/2370,\n  https://github.com/fmtlib/fmt/pull/2376,\n  https://github.com/fmtlib/fmt/pull/2381,\n  https://github.com/fmtlib/fmt/pull/2382,\n  https://github.com/fmtlib/fmt/issues/2386,\n  https://github.com/fmtlib/fmt/pull/2389,\n  https://github.com/fmtlib/fmt/pull/2395,\n  https://github.com/fmtlib/fmt/pull/2397,\n  https://github.com/fmtlib/fmt/issues/2400,\n  https://github.com/fmtlib/fmt/issues/2401,\n  https://github.com/fmtlib/fmt/pull/2407).\n  Thanks @zx2c4, @AidanSun05, @mattiasljungstrom, @joemmett, @erengy,\n  @patlkli, @gsjaardema and @phprus.\n\n# 8.0.0 - 2021-06-21\n\n- Enabled compile-time format string checks by default. For example\n  ([godbolt](https://godbolt.org/z/sMxcohGjz)):\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{:d}\", \"I am not a number\");\n  }\n  ```\n\n  gives a compile-time error on compilers with C++20 `consteval`\n  support (gcc 10+, clang 11+) because `d` is not a valid format\n  specifier for a string.\n\n  To pass a runtime string wrap it in `fmt::runtime`:\n\n  ```c++\n  fmt::print(fmt::runtime(\"{:d}\"), \"I am not a number\");\n  ```\n\n- Added compile-time formatting\n  (https://github.com/fmtlib/fmt/pull/2019,\n  https://github.com/fmtlib/fmt/pull/2044,\n  https://github.com/fmtlib/fmt/pull/2056,\n  https://github.com/fmtlib/fmt/pull/2072,\n  https://github.com/fmtlib/fmt/pull/2075,\n  https://github.com/fmtlib/fmt/issues/2078,\n  https://github.com/fmtlib/fmt/pull/2129,\n  https://github.com/fmtlib/fmt/pull/2326). For example\n  ([godbolt](https://godbolt.org/z/Mxx9d89jM)):\n\n  ```c++\n  #include <fmt/compile.h>\n\n  consteval auto compile_time_itoa(int value) -> std::array<char, 10> {\n    auto result = std::array<char, 10>();\n    fmt::format_to(result.data(), FMT_COMPILE(\"{}\"), value);\n    return result;\n  }\n\n  constexpr auto answer = compile_time_itoa(42);\n  ```\n\n  Most of the formatting functionality is available at compile time\n  with a notable exception of floating-point numbers and pointers.\n  Thanks @alexezeder.\n\n- Optimized handling of format specifiers during format string\n  compilation. For example, hexadecimal formatting (`\"{:x}\"`) is now\n  3-7x faster than before when using `format_to` with format string\n  compilation and a stack-allocated buffer\n  (https://github.com/fmtlib/fmt/issues/1944).\n\n  Before (7.1.3):\n\n      ----------------------------------------------------------------------------\n      Benchmark                                  Time             CPU   Iterations\n      ----------------------------------------------------------------------------\n      FMTCompileOld/0                         15.5 ns         15.5 ns     43302898\n      FMTCompileOld/42                        16.6 ns         16.6 ns     43278267\n      FMTCompileOld/273123                    18.7 ns         18.6 ns     37035861\n      FMTCompileOld/9223372036854775807       19.4 ns         19.4 ns     35243000\n      ----------------------------------------------------------------------------\n\n  After (8.x):\n\n      ----------------------------------------------------------------------------\n      Benchmark                                  Time             CPU   Iterations\n      ----------------------------------------------------------------------------\n      FMTCompileNew/0                         1.99 ns         1.99 ns    360523686\n      FMTCompileNew/42                        2.33 ns         2.33 ns    279865664\n      FMTCompileNew/273123                    3.72 ns         3.71 ns    190230315\n      FMTCompileNew/9223372036854775807       5.28 ns         5.26 ns    130711631\n      ----------------------------------------------------------------------------\n\n  It is even faster than `std::to_chars` from libc++ compiled with\n  clang on macOS:\n\n      ----------------------------------------------------------------------------\n      Benchmark                                  Time             CPU   Iterations\n      ----------------------------------------------------------------------------\n      ToChars/0                               4.42 ns         4.41 ns    160196630\n      ToChars/42                              5.00 ns         4.98 ns    140735201\n      ToChars/273123                          7.26 ns         7.24 ns     95784130\n      ToChars/9223372036854775807             8.77 ns         8.75 ns     75872534\n      ----------------------------------------------------------------------------\n\n  In other cases, especially involving `std::string` construction, the\n  speed up is usually lower because handling format specifiers takes a\n  smaller fraction of the total time.\n\n- Added the `_cf` user-defined literal to represent a compiled format\n  string. It can be used instead of the `FMT_COMPILE` macro\n  (https://github.com/fmtlib/fmt/pull/2043,\n  https://github.com/fmtlib/fmt/pull/2242):\n\n  ```c++\n  #include <fmt/compile.h>\n\n  using namespace fmt::literals;\n  auto s = fmt::format(FMT_COMPILE(\"{}\"), 42); // 🙁 not modern\n  auto s = fmt::format(\"{}\"_cf, 42);           // 🙂 modern as hell\n  ```\n\n  It requires compiler support for class types in non-type template\n  parameters (a C++20 feature) which is available in GCC 9.3+.\n  Thanks @alexezeder.\n\n- Format string compilation now requires `format` functions of\n  `formatter` specializations for user-defined types to be `const`:\n\n  ```c++\n  template <> struct fmt::formatter<my_type>: formatter<string_view> {\n    template <typename FormatContext>\n    auto format(my_type obj, FormatContext& ctx) const {  // Note const here.\n      // ...\n    }\n  };\n  ```\n\n- Added UDL-based named argument support to format string compilation\n  (https://github.com/fmtlib/fmt/pull/2243,\n  https://github.com/fmtlib/fmt/pull/2281). For example:\n\n  ```c++\n  #include <fmt/compile.h>\n\n  using namespace fmt::literals;\n  auto s = fmt::format(FMT_COMPILE(\"{answer}\"), \"answer\"_a = 42);\n  ```\n\n  Here the argument named \\\"answer\\\" is resolved at compile time with\n  no runtime overhead. Thanks @alexezeder.\n\n- Added format string compilation support to `fmt::print`\n  (https://github.com/fmtlib/fmt/issues/2280,\n  https://github.com/fmtlib/fmt/pull/2304). Thanks @alexezeder.\n\n- Added initial support for compiling {fmt} as a C++20 module\n  (https://github.com/fmtlib/fmt/pull/2235,\n  https://github.com/fmtlib/fmt/pull/2240,\n  https://github.com/fmtlib/fmt/pull/2260,\n  https://github.com/fmtlib/fmt/pull/2282,\n  https://github.com/fmtlib/fmt/pull/2283,\n  https://github.com/fmtlib/fmt/pull/2288,\n  https://github.com/fmtlib/fmt/pull/2298,\n  https://github.com/fmtlib/fmt/pull/2306,\n  https://github.com/fmtlib/fmt/pull/2307,\n  https://github.com/fmtlib/fmt/pull/2309,\n  https://github.com/fmtlib/fmt/pull/2318,\n  https://github.com/fmtlib/fmt/pull/2324,\n  https://github.com/fmtlib/fmt/pull/2332,\n  https://github.com/fmtlib/fmt/pull/2340). Thanks @DanielaE.\n\n- Made symbols private by default reducing shared library size\n  (https://github.com/fmtlib/fmt/pull/2301). For example\n  there was a \\~15% reported reduction on one platform. Thanks @sergiud.\n\n- Optimized includes making the result of preprocessing `fmt/format.h`\n  \\~20% smaller with libstdc++/C++20 and slightly improving build\n  times (https://github.com/fmtlib/fmt/issues/1998).\n\n- Added support of ranges with non-const `begin` / `end`\n  (https://github.com/fmtlib/fmt/pull/1953). Thanks @kitegi.\n\n- Added support of `std::byte` and other formattable types to\n  `fmt::join` (https://github.com/fmtlib/fmt/issues/1981,\n  https://github.com/fmtlib/fmt/issues/2040,\n  https://github.com/fmtlib/fmt/pull/2050,\n  https://github.com/fmtlib/fmt/issues/2262). For example:\n\n  ```c++\n  #include <fmt/format.h>\n  #include <cstddef>\n  #include <vector>\n\n  int main() {\n    auto bytes = std::vector{std::byte(4), std::byte(2)};\n    fmt::print(\"{}\", fmt::join(bytes, \"\"));\n  }\n  ```\n\n  prints \\\"42\\\".\n\n  Thanks @kamibo.\n\n- Implemented the default format for `std::chrono::system_clock`\n  (https://github.com/fmtlib/fmt/issues/2319,\n  https://github.com/fmtlib/fmt/pull/2345). For example:\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    fmt::print(\"{}\", std::chrono::system_clock::now());\n  }\n  ```\n\n  prints \\\"2021-06-18 15:22:00\\\" (the output depends on the current\n  date and time). Thanks @sunmy2019.\n\n- Made more chrono specifiers locale independent by default. Use the\n  `'L'` specifier to get localized formatting. For example:\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    std::locale::global(std::locale(\"ru_RU.UTF-8\"));\n    auto monday = std::chrono::weekday(1);\n    fmt::print(\"{}\\n\", monday);   // prints \"Mon\"\n    fmt::print(\"{:L}\\n\", monday); // prints \"пн\"\n  }\n  ```\n\n- Improved locale handling in chrono formatting\n  (https://github.com/fmtlib/fmt/issues/2337,\n  https://github.com/fmtlib/fmt/pull/2349,\n  https://github.com/fmtlib/fmt/pull/2350). Thanks @phprus.\n\n- Deprecated `fmt/locale.h` moving the formatting functions that take\n  a locale to `fmt/format.h` (`char`) and `fmt/xchar` (other\n  overloads). This doesn\\'t introduce a dependency on `<locale>` so\n  there is virtually no compile time effect.\n\n- Deprecated an undocumented `format_to` overload that takes\n  `basic_memory_buffer`.\n\n- Made parameter order in `vformat_to` consistent with `format_to`\n  (https://github.com/fmtlib/fmt/issues/2327).\n\n- Added support for time points with arbitrary durations\n  (https://github.com/fmtlib/fmt/issues/2208). For example:\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    using tp = std::chrono::time_point<\n      std::chrono::system_clock, std::chrono::seconds>;\n    fmt::print(\"{:%S}\", tp(std::chrono::seconds(42)));\n  }\n  ```\n\n  prints \\\"42\\\".\n\n- Formatting floating-point numbers no longer produces trailing zeros\n  by default for consistency with `std::format`. For example:\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{0:.3}\", 1.1);\n  }\n  ```\n\n  prints \\\"1.1\\\". Use the `'#'` specifier to keep trailing zeros.\n\n- Dropped a limit on the number of elements in a range and replaced\n  `{}` with `[]` as range delimiters for consistency with Python\\'s\n  `str.format`.\n\n- The `'L'` specifier for locale-specific numeric formatting can now\n  be combined with presentation specifiers as in `std::format`. For\n  example:\n\n  ```c++\n  #include <fmt/core.h>\n  #include <locale>\n\n  int main() {\n    std::locale::global(std::locale(\"fr_FR.UTF-8\"));\n    fmt::print(\"{0:.2Lf}\", 0.42);\n  }\n  ```\n\n  prints \\\"0,42\\\". The deprecated `'n'` specifier has been removed.\n\n- Made the `0` specifier ignored for infinity and NaN\n  (https://github.com/fmtlib/fmt/issues/2305,\n  https://github.com/fmtlib/fmt/pull/2310). Thanks @Liedtke.\n\n- Made the hexfloat formatting use the right alignment by default\n  (https://github.com/fmtlib/fmt/issues/2308,\n  https://github.com/fmtlib/fmt/pull/2317). Thanks @Liedtke.\n\n- Removed the deprecated numeric alignment (`'='`). Use the `'0'`\n  specifier instead.\n\n- Removed the deprecated `fmt/posix.h` header that has been replaced\n  with `fmt/os.h`.\n\n- Removed the deprecated `format_to_n_context`, `format_to_n_args` and\n  `make_format_to_n_args`. They have been replaced with\n  `format_context`, `` format_args` and ``make_format_args\\`\\`\n  respectively.\n\n- Moved `wchar_t`-specific functions and types to `fmt/xchar.h`. You\n  can define `FMT_DEPRECATED_INCLUDE_XCHAR` to automatically include\n  `fmt/xchar.h` from `fmt/format.h` but this will be disabled in the\n  next major release.\n\n- Fixed handling of the `'+'` specifier in localized formatting\n  (https://github.com/fmtlib/fmt/issues/2133).\n\n- Added support for the `'s'` format specifier that gives textual\n  representation of `bool`\n  (https://github.com/fmtlib/fmt/issues/2094,\n  https://github.com/fmtlib/fmt/pull/2109). For example:\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{:s}\", true);\n  }\n  ```\n\n  prints \\\"true\\\". Thanks @powercoderlol.\n\n- Made `fmt::ptr` work with function pointers\n  (https://github.com/fmtlib/fmt/pull/2131). For example:\n\n  ```c++\n  #include <fmt/format.h>\n\n  int main() {\n    fmt::print(\"My main: {}\\n\", fmt::ptr(main));\n  }\n  ```\n\n  Thanks @mikecrowe.\n\n- The undocumented support for specializing `formatter` for pointer\n  types has been removed.\n\n- Fixed `fmt::formatted_size` with format string compilation\n  (https://github.com/fmtlib/fmt/pull/2141,\n  https://github.com/fmtlib/fmt/pull/2161). Thanks @alexezeder.\n\n- Fixed handling of empty format strings during format string\n  compilation (https://github.com/fmtlib/fmt/issues/2042):\n\n  ```c++\n  auto s = fmt::format(FMT_COMPILE(\"\"));\n  ```\n\n  Thanks @alexezeder.\n\n- Fixed handling of enums in `fmt::to_string`\n  (https://github.com/fmtlib/fmt/issues/2036).\n\n- Improved width computation\n  (https://github.com/fmtlib/fmt/issues/2033,\n  https://github.com/fmtlib/fmt/issues/2091). For example:\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{:-<10}{}\\n\", \"你好\", \"世界\");\n    fmt::print(\"{:-<10}{}\\n\", \"hello\", \"world\");\n  }\n  ```\n\n  prints\n\n  ![](https://user-images.githubusercontent.com/576385/119840373-cea3ca80-beb9-11eb-91e0-54266c48e181.png)\n\n  on a modern terminal.\n\n- The experimental fast output stream (`fmt::ostream`) is now\n  truncated by default for consistency with `fopen`\n  (https://github.com/fmtlib/fmt/issues/2018). For example:\n\n  ```c++\n  #include <fmt/os.h>\n\n  int main() {\n    fmt::ostream out1 = fmt::output_file(\"guide\");\n    out1.print(\"Zaphod\");\n    out1.close();\n    fmt::ostream out2 = fmt::output_file(\"guide\");\n    out2.print(\"Ford\");\n  }\n  ```\n\n  writes \\\"Ford\\\" to the file \\\"guide\\\". To preserve the old file\n  content if any pass `fmt::file::WRONLY | fmt::file::CREATE` flags to\n  `fmt::output_file`.\n\n- Fixed moving of `fmt::ostream` that holds buffered data\n  (https://github.com/fmtlib/fmt/issues/2197,\n  https://github.com/fmtlib/fmt/pull/2198). Thanks @vtta.\n\n- Replaced the `fmt::system_error` exception with a function of the\n  same name that constructs `std::system_error`\n  (https://github.com/fmtlib/fmt/issues/2266).\n\n- Replaced the `fmt::windows_error` exception with a function of the\n  same name that constructs `std::system_error` with the category\n  returned by `fmt::system_category()`\n  (https://github.com/fmtlib/fmt/issues/2274,\n  https://github.com/fmtlib/fmt/pull/2275). The latter is\n  similar to `std::system_category` but correctly handles UTF-8.\n  Thanks @phprus.\n\n- Replaced `fmt::error_code` with `std::error_code` and made it\n  formattable (https://github.com/fmtlib/fmt/issues/2269,\n  https://github.com/fmtlib/fmt/pull/2270,\n  https://github.com/fmtlib/fmt/pull/2273). Thanks @phprus.\n\n- Added speech synthesis support\n  (https://github.com/fmtlib/fmt/pull/2206).\n\n- Made `format_to` work with a memory buffer that has a custom\n  allocator (https://github.com/fmtlib/fmt/pull/2300).\n  Thanks @voxmea.\n\n- Added `Allocator::max_size` support to `basic_memory_buffer`.\n  (https://github.com/fmtlib/fmt/pull/1960). Thanks @phprus.\n\n- Added wide string support to `fmt::join`\n  (https://github.com/fmtlib/fmt/pull/2236). Thanks @crbrz.\n\n- Made iterators passed to `formatter` specializations via a format\n  context satisfy C++20 `std::output_iterator` requirements\n  (https://github.com/fmtlib/fmt/issues/2156,\n  https://github.com/fmtlib/fmt/pull/2158,\n  https://github.com/fmtlib/fmt/issues/2195,\n  https://github.com/fmtlib/fmt/pull/2204). Thanks @randomnetcat.\n\n- Optimized the `printf` implementation\n  (https://github.com/fmtlib/fmt/pull/1982,\n  https://github.com/fmtlib/fmt/pull/1984,\n  https://github.com/fmtlib/fmt/pull/2016,\n  https://github.com/fmtlib/fmt/pull/2164).\n  Thanks @rimathia and @moiwi.\n\n- Improved detection of `constexpr` `char_traits`\n  (https://github.com/fmtlib/fmt/pull/2246,\n  https://github.com/fmtlib/fmt/pull/2257). Thanks @phprus.\n\n- Fixed writing to `stdout` when it is redirected to `NUL` on Windows\n  (https://github.com/fmtlib/fmt/issues/2080).\n\n- Fixed exception propagation from iterators\n  (https://github.com/fmtlib/fmt/issues/2097).\n\n- Improved `strftime` error handling\n  (https://github.com/fmtlib/fmt/issues/2238,\n  https://github.com/fmtlib/fmt/pull/2244). Thanks @yumeyao.\n\n- Stopped using deprecated GCC UDL template extension.\n\n- Added `fmt/args.h` to the install target\n  (https://github.com/fmtlib/fmt/issues/2096).\n\n- Error messages are now passed to assert when exceptions are disabled\n  (https://github.com/fmtlib/fmt/pull/2145). Thanks @NobodyXu.\n\n- Added the `FMT_MASTER_PROJECT` CMake option to control build and\n  install targets when {fmt} is included via `add_subdirectory`\n  (https://github.com/fmtlib/fmt/issues/2098,\n  https://github.com/fmtlib/fmt/pull/2100).\n  Thanks @randomizedthinking.\n\n- Improved build configuration\n  (https://github.com/fmtlib/fmt/pull/2026,\n  https://github.com/fmtlib/fmt/pull/2122).\n  Thanks @luncliff and @ibaned.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/1947,\n  https://github.com/fmtlib/fmt/pull/1959,\n  https://github.com/fmtlib/fmt/pull/1963,\n  https://github.com/fmtlib/fmt/pull/1965,\n  https://github.com/fmtlib/fmt/issues/1966,\n  https://github.com/fmtlib/fmt/pull/1974,\n  https://github.com/fmtlib/fmt/pull/1975,\n  https://github.com/fmtlib/fmt/pull/1990,\n  https://github.com/fmtlib/fmt/issues/2000,\n  https://github.com/fmtlib/fmt/pull/2001,\n  https://github.com/fmtlib/fmt/issues/2002,\n  https://github.com/fmtlib/fmt/issues/2004,\n  https://github.com/fmtlib/fmt/pull/2006,\n  https://github.com/fmtlib/fmt/pull/2009,\n  https://github.com/fmtlib/fmt/pull/2010,\n  https://github.com/fmtlib/fmt/issues/2038,\n  https://github.com/fmtlib/fmt/issues/2039,\n  https://github.com/fmtlib/fmt/issues/2047,\n  https://github.com/fmtlib/fmt/pull/2053,\n  https://github.com/fmtlib/fmt/issues/2059,\n  https://github.com/fmtlib/fmt/pull/2065,\n  https://github.com/fmtlib/fmt/pull/2067,\n  https://github.com/fmtlib/fmt/pull/2068,\n  https://github.com/fmtlib/fmt/pull/2073,\n  https://github.com/fmtlib/fmt/issues/2103,\n  https://github.com/fmtlib/fmt/issues/2105,\n  https://github.com/fmtlib/fmt/pull/2106,\n  https://github.com/fmtlib/fmt/pull/2107,\n  https://github.com/fmtlib/fmt/issues/2116,\n  https://github.com/fmtlib/fmt/pull/2117,\n  https://github.com/fmtlib/fmt/issues/2118,\n  https://github.com/fmtlib/fmt/pull/2119,\n  https://github.com/fmtlib/fmt/issues/2127,\n  https://github.com/fmtlib/fmt/pull/2128,\n  https://github.com/fmtlib/fmt/issues/2140,\n  https://github.com/fmtlib/fmt/issues/2142,\n  https://github.com/fmtlib/fmt/pull/2143,\n  https://github.com/fmtlib/fmt/pull/2144,\n  https://github.com/fmtlib/fmt/issues/2147,\n  https://github.com/fmtlib/fmt/issues/2148,\n  https://github.com/fmtlib/fmt/issues/2149,\n  https://github.com/fmtlib/fmt/pull/2152,\n  https://github.com/fmtlib/fmt/pull/2160,\n  https://github.com/fmtlib/fmt/issues/2170,\n  https://github.com/fmtlib/fmt/issues/2175,\n  https://github.com/fmtlib/fmt/issues/2176,\n  https://github.com/fmtlib/fmt/pull/2177,\n  https://github.com/fmtlib/fmt/issues/2178,\n  https://github.com/fmtlib/fmt/pull/2179,\n  https://github.com/fmtlib/fmt/issues/2180,\n  https://github.com/fmtlib/fmt/issues/2181,\n  https://github.com/fmtlib/fmt/pull/2183,\n  https://github.com/fmtlib/fmt/issues/2184,\n  https://github.com/fmtlib/fmt/issues/2185,\n  https://github.com/fmtlib/fmt/pull/2186,\n  https://github.com/fmtlib/fmt/pull/2187,\n  https://github.com/fmtlib/fmt/pull/2190,\n  https://github.com/fmtlib/fmt/pull/2192,\n  https://github.com/fmtlib/fmt/pull/2194,\n  https://github.com/fmtlib/fmt/pull/2205,\n  https://github.com/fmtlib/fmt/issues/2210,\n  https://github.com/fmtlib/fmt/pull/2211,\n  https://github.com/fmtlib/fmt/pull/2215,\n  https://github.com/fmtlib/fmt/pull/2216,\n  https://github.com/fmtlib/fmt/pull/2218,\n  https://github.com/fmtlib/fmt/pull/2220,\n  https://github.com/fmtlib/fmt/issues/2228,\n  https://github.com/fmtlib/fmt/pull/2229,\n  https://github.com/fmtlib/fmt/pull/2230,\n  https://github.com/fmtlib/fmt/issues/2233,\n  https://github.com/fmtlib/fmt/pull/2239,\n  https://github.com/fmtlib/fmt/issues/2248,\n  https://github.com/fmtlib/fmt/issues/2252,\n  https://github.com/fmtlib/fmt/pull/2253,\n  https://github.com/fmtlib/fmt/pull/2255,\n  https://github.com/fmtlib/fmt/issues/2261,\n  https://github.com/fmtlib/fmt/issues/2278,\n  https://github.com/fmtlib/fmt/issues/2284,\n  https://github.com/fmtlib/fmt/pull/2287,\n  https://github.com/fmtlib/fmt/pull/2289,\n  https://github.com/fmtlib/fmt/pull/2290,\n  https://github.com/fmtlib/fmt/pull/2293,\n  https://github.com/fmtlib/fmt/issues/2295,\n  https://github.com/fmtlib/fmt/pull/2296,\n  https://github.com/fmtlib/fmt/pull/2297,\n  https://github.com/fmtlib/fmt/issues/2311,\n  https://github.com/fmtlib/fmt/pull/2313,\n  https://github.com/fmtlib/fmt/pull/2315,\n  https://github.com/fmtlib/fmt/issues/2320,\n  https://github.com/fmtlib/fmt/pull/2321,\n  https://github.com/fmtlib/fmt/pull/2323,\n  https://github.com/fmtlib/fmt/issues/2328,\n  https://github.com/fmtlib/fmt/pull/2329,\n  https://github.com/fmtlib/fmt/pull/2333,\n  https://github.com/fmtlib/fmt/pull/2338,\n  https://github.com/fmtlib/fmt/pull/2341).\n  Thanks @darklukee, @fagg, @killerbot242, @jgopel, @yeswalrus, @Finkman,\n  @HazardyKnusperkeks, @dkavolis, @concatime, @chronoxor, @summivox, @yNeo,\n  @Apache-HB, @alexezeder, @toojays, @Brainy0207, @vadz, @imsherlock, @phprus,\n  @white238, @yafshar, @BillyDonahue, @jstaahl, @denchat, @DanielaE,\n  @ilyakurdyukov, @ilmai, @JessyDL, @sergiud, @mwinterb, @sven-herrmann,\n  @jmelas, @twoixter, @crbrz and @upsj.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/1986,\n  https://github.com/fmtlib/fmt/pull/2051,\n  https://github.com/fmtlib/fmt/issues/2057,\n  https://github.com/fmtlib/fmt/pull/2081,\n  https://github.com/fmtlib/fmt/issues/2084,\n  https://github.com/fmtlib/fmt/pull/2312).\n  Thanks @imba-tjd, @0x416c69 and @mordante.\n\n- Continuous integration and test improvements\n  (https://github.com/fmtlib/fmt/issues/1969,\n  https://github.com/fmtlib/fmt/pull/1991,\n  https://github.com/fmtlib/fmt/pull/2020,\n  https://github.com/fmtlib/fmt/pull/2110,\n  https://github.com/fmtlib/fmt/pull/2114,\n  https://github.com/fmtlib/fmt/issues/2196,\n  https://github.com/fmtlib/fmt/pull/2217,\n  https://github.com/fmtlib/fmt/pull/2247,\n  https://github.com/fmtlib/fmt/pull/2256,\n  https://github.com/fmtlib/fmt/pull/2336,\n  https://github.com/fmtlib/fmt/pull/2346).\n  Thanks @jgopel, @alexezeder and @DanielaE.\n\nThe change log for versions 0.8.0 - 7.1.3 is available [here](\ndoc/ChangeLog-old.md).\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "<img src=\"https://user-images.githubusercontent.com/576385/156254208-f5b743a9-88cf-439d-b0c0-923d53e8d551.png\" alt=\"{fmt}\" width=\"25%\"/>\n\n[![image](https://github.com/fmtlib/fmt/actions/workflows/linux.yml/badge.svg?branch=master)](https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux)\n[![image](https://github.com/fmtlib/fmt/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/fmtlib/fmt/actions?query=workflow%3Amacos)\n[![image](https://github.com/fmtlib/fmt/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows)\n[![fmt is continuously fuzzed at oss-fuzz](https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?\\%0Acolspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\\%0ASummary&q=proj%3Dfmt&can=1)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8880/badge)](https://www.bestpractices.dev/projects/8880)\n[![image](https://api.securityscorecards.dev/projects/github.com/fmtlib/fmt/badge)](https://securityscorecards.dev/viewer/?uri=github.com/fmtlib/fmt)\n[![Ask questions at StackOverflow with the tag fmt](https://img.shields.io/badge/stackoverflow-fmt-blue.svg)](https://stackoverflow.com/questions/tagged/fmt)\n\n**{fmt}** is an open-source formatting library providing a fast and safe\nalternative to C stdio and C++ iostreams.\n\nIf you like this project, please consider donating to one of the funds\nthat help victims of the war in Ukraine: <https://u24.gov.ua/>.\n\n[Documentation](https://fmt.dev)\n\n[Cheat Sheets](https://hackingcpp.com/cpp/libs/fmt.html)\n\nQ&A: ask questions on [StackOverflow with the tag\nfmt](https://stackoverflow.com/questions/tagged/fmt).\n\nTry {fmt} in [Compiler Explorer](https://godbolt.org/z/8Mx1EW73v).\n\n# Features\n\n- Simple [format API](https://fmt.dev/latest/api/) with positional\n  arguments for localization\n- Implementation of [C++20\n  std::format](https://en.cppreference.com/w/cpp/utility/format) and\n  [C++23 std::print](https://en.cppreference.com/w/cpp/io/print)\n- [Format string syntax](https://fmt.dev/latest/syntax/) similar\n  to Python\\'s\n  [format](https://docs.python.org/3/library/stdtypes.html#str.format)\n- Fast IEEE 754 floating-point formatter with correct rounding,\n  shortness and round-trip guarantees using the\n  [Dragonbox](https://github.com/jk-jeon/dragonbox) algorithm\n- Portable Unicode support\n- Safe [printf\n  implementation](https://fmt.dev/latest/api/#printf-formatting)\n  including the POSIX extension for positional arguments\n- Extensibility: [support for user-defined\n  types](https://fmt.dev/latest/api/#formatting-user-defined-types)\n- High performance: faster than common standard library\n  implementations of `(s)printf`, iostreams, `to_string` and\n  `to_chars`, see [Speed tests](#speed-tests) and [Converting a\n  hundred million integers to strings per\n  second](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html)\n- Small code size both in terms of source code with the minimum\n  configuration consisting of just three files, `base.h`, `format.h`\n  and `format-inl.h`, and compiled code; see [Compile time and code\n  bloat](#compile-time-and-code-bloat)\n- Reliability: the library has an extensive set of\n  [tests](https://github.com/fmtlib/fmt/tree/master/test) and is\n  [continuously fuzzed](https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1)\n- Safety: the library is fully type-safe, errors in format strings can\n  be reported at compile time, automatic memory management prevents\n  buffer overflow errors\n- Ease of use: small self-contained code base, no external\n  dependencies, permissive MIT\n  [license](https://github.com/fmtlib/fmt/blob/master/LICENSE)\n- [Portability](https://fmt.dev/latest/#portability) with\n  consistent output across platforms and support for older compilers\n- Clean warning-free codebase even on high warning levels such as\n  `-Wall -Wextra -pedantic`\n- Locale independence by default\n- Optional header-only configuration enabled with the\n  `FMT_HEADER_ONLY` macro\n\nSee the [documentation](https://fmt.dev) for more details.\n\n# Examples\n\n**Print to stdout** ([run](https://godbolt.org/z/Tevcjh))\n\n``` c++\n#include <fmt/base.h>\n\nint main() {\n  fmt::print(\"Hello, world!\\n\");\n}\n```\n\n**Format a string** ([run](https://godbolt.org/z/oK8h33))\n\n``` c++\nstd::string s = fmt::format(\"The answer is {}.\", 42);\n// s == \"The answer is 42.\"\n```\n\n**Format a string using positional arguments**\n([run](https://godbolt.org/z/Yn7Txe))\n\n``` c++\nstd::string s = fmt::format(\"I'd rather be {1} than {0}.\", \"right\", \"happy\");\n// s == \"I'd rather be happy than right.\"\n```\n\n**Print dates and times** ([run](https://godbolt.org/z/c31ExdY3W))\n\n``` c++\n#include <fmt/chrono.h>\n\nint main() {\n  auto now = std::chrono::system_clock::now();\n  fmt::print(\"Date and time: {}\\n\", now);\n  fmt::print(\"Time: {:%H:%M}\\n\", now);\n}\n```\n\nOutput:\n\n    Date and time: 2023-12-26 19:10:31.557195597\n    Time: 19:10\n\n**Print a container** ([run](https://godbolt.org/z/MxM1YqjE7))\n\n``` c++\n#include <vector>\n#include <fmt/ranges.h>\n\nint main() {\n  std::vector<int> v = {1, 2, 3};\n  fmt::print(\"{}\\n\", v);\n}\n```\n\nOutput:\n\n    [1, 2, 3]\n\n**Check a format string at compile time**\n\n``` c++\nstd::string s = fmt::format(\"{:d}\", \"I am not a number\");\n```\n\nThis gives a compile-time error in C++20 because `d` is an invalid\nformat specifier for a string.\n\n**Write a file from a single thread**\n\n``` c++\n#include <fmt/os.h>\n\nint main() {\n  auto out = fmt::output_file(\"guide.txt\");\n  out.print(\"Don't {}\", \"Panic\");\n}\n```\n\nThis can be [up to 9 times faster than `fprintf`](\nhttp://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html).\n\n**Print with colors and text styles**\n\n``` c++\n#include <fmt/color.h>\n\nint main() {\n  fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,\n             \"Hello, {}!\\n\", \"world\");\n  fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |\n             fmt::emphasis::underline, \"Olá, {}!\\n\", \"Mundo\");\n  fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,\n             \"你好{}！\\n\", \"世界\");\n}\n```\n\nOutput on a modern terminal with Unicode support:\n\n![image](https://github.com/fmtlib/fmt/assets/%0A576385/2a93c904-d6fa-4aa6-b453-2618e1c327d7)\n\n# Benchmarks\n\n## Speed tests\n\n| Library           | Method        | Run Time, s |\n|-------------------|---------------|-------------|\n| libc              | printf        |   0.66      |\n| libc++            | std::ostream  |   1.63      |\n| {fmt} 12.1        | fmt::print    |   0.44      |\n| Boost Format 1.88 | boost::format |   3.89      |\n| Folly Format      | folly::format |   1.28      |\n\n{fmt} is the fastest of the benchmarked methods, \\~50% faster than\n`printf`.\n\nThe above results were generated by building `tinyformat_test.cpp` on\nmacOS 15.6.1 with `clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT`, and\ntaking the best of three runs. In the test, the format string\n`\"%0.10f:%04d:%+g:%s:%p:%c:%%\\n\"` or equivalent is filled 2,000,000\ntimes with output sent to `/dev/null`; for further details refer to the\n[source](https://github.com/fmtlib/format-benchmark/blob/master/src/tinyformat-test.cc).\n\n{fmt} is up to 20-30x faster than `std::ostringstream` and `sprintf` on\nIEEE754 `float` and `double` formatting\n([dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark)) and faster\nthan [double-conversion](https://github.com/google/double-conversion)\nand [ryu](https://github.com/ulfjack/ryu):\n\n[![image](https://user-images.githubusercontent.com/576385/95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png)](https://fmt.dev/unknown_mac64_clang12.0.html)\n\n## Compile time and code bloat\n\nThe script [bloat-test.py][test] from [format-benchmark][bench] tests compile\ntime and code bloat for nontrivial projects. It generates 100 translation units\nand uses `printf()` or its alternative five times in each to simulate a\nmedium-sized project. The resulting executable size and compile time (Apple\nclang version 15.0.0 (clang-1500.1.0.2.5), macOS Sonoma, best of three) is shown\nin the following tables.\n\n[test]: https://github.com/fmtlib/format-benchmark/blob/master/bloat-test.py\n[bench]: https://github.com/fmtlib/format-benchmark\n\n**Optimized build (-O3)**\n\n| Method          | Compile Time, s | Executable size, KiB | Stripped size, KiB |\n|-----------------|-----------------|----------------------|--------------------|\n| printf          |             1.6 |                   54 |                 50 |\n| IOStreams       |            28.4 |                   98 |                 84 |\n| {fmt} `1122268` |             5.0 |                   54 |                 50 |\n| tinyformat      |            32.6 |                  164 |                136 |\n| Boost Format    |            55.0 |                  530 |                317 |\n\n{fmt} is fast to compile and is comparable to `printf` in terms of per-call\nbinary size (within a rounding error on this system).\n\n**Non-optimized build**\n\n| Method          | Compile Time, s | Executable size, KiB | Stripped size, KiB |\n|-----------------|-----------------|----------------------|--------------------|\n| printf          |             1.4 |                   54 |                 50 |\n| IOStreams       |            27.0 |                   88 |                 68 |\n| {fmt} `1122268` |             4.7 |                   87 |                 84 |\n| tinyformat      |            28.1 |                  185 |                145 |\n| Boost Format    |            38.9 |                  678 |                381 |\n\n`libc`, `lib(std)c++`, and `libfmt` are all linked as shared libraries\nto compare formatting function overhead only. Boost Format is a\nheader-only library so it doesn\\'t provide any linkage options.\n\n## Running the tests\n\nPlease refer to [Building the\nlibrary](https://fmt.dev/latest/get-started/#building-from-source) for\ninstructions on how to build the library and run the unit tests.\n\nBenchmarks reside in a separate repository,\n[format-benchmarks](https://github.com/fmtlib/format-benchmark), so to\nrun the benchmarks you first need to clone this repository and generate\nMakefiles with CMake:\n\n    $ git clone --recursive https://github.com/fmtlib/format-benchmark.git\n    $ cd format-benchmark\n    $ cmake .\n\nThen you can run the speed test:\n\n    $ make speed-test\n\nor the bloat test:\n\n    $ make bloat-test\n\n# Migrating code\n\n[clang-tidy](https://clang.llvm.org/extra/clang-tidy/) v18 provides the\n[modernize-use-std-print](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-std-print.html)\ncheck that is capable of converting occurrences of `printf` and\n`fprintf` to `fmt::print` if configured to do so. (By default it\nconverts to `std::print`.)\n\n# Notable projects using this library\n\n- [0 A.D.](https://play0ad.com/): a free, open-source, cross-platform\n  real-time strategy game\n- [AMPL/MP](https://github.com/ampl/mp): an open-source library for\n  mathematical programming\n- [Apple's FoundationDB](https://github.com/apple/foundationdb): an open-source,\n  distributed, transactional key-value store\n- [Aseprite](https://github.com/aseprite/aseprite): animated sprite\n  editor & pixel art tool\n- [AvioBook](https://www.aviobook.aero/en): a comprehensive aircraft\n  operations suite\n- [Blizzard Battle.net](https://battle.net/): an online gaming\n  platform\n- [Celestia](https://celestia.space/): real-time 3D visualization of\n  space\n- [Ceph](https://ceph.com/): a scalable distributed storage system\n- [ccache](https://ccache.dev/): a compiler cache\n- [ClickHouse](https://github.com/ClickHouse/ClickHouse): an\n  analytical database management system\n- [ContextVision](https://www.contextvision.com/): medical imaging software\n- [Contour](https://github.com/contour-terminal/contour/): a modern\n  terminal emulator\n- [CUAUV](https://cuauv.org/): Cornell University\\'s autonomous\n  underwater vehicle\n- [Drake](https://drake.mit.edu/): a planning, control, and analysis\n  toolbox for nonlinear dynamical systems (MIT)\n- [Envoy](https://github.com/envoyproxy/envoy): C++ L7 proxy and\n  communication bus (Lyft)\n- [FiveM](https://fivem.net/): a modification framework for GTA V\n- [fmtlog](https://github.com/MengRao/fmtlog): a performant\n  fmtlib-style logging library with latency in nanoseconds\n- [Folly](https://github.com/facebook/folly): Facebook open-source\n  library\n- [GemRB](https://gemrb.org/): a portable open-source implementation\n  of Bioware's Infinity Engine\n- [Grand Mountain\n  Adventure](https://store.steampowered.com/app/1247360/Grand_Mountain_Adventure/):\n  a beautiful open-world ski & snowboarding game\n- [HarpyWar/pvpgn](https://github.com/pvpgn/pvpgn-server): Player vs\n  Player Gaming Network with tweaks\n- [KBEngine](https://github.com/kbengine/kbengine): an open-source\n  MMOG server engine\n- [Keypirinha](https://keypirinha.com/): a semantic launcher for\n  Windows\n- [Kodi](https://kodi.tv/) (formerly xbmc): home theater software\n- [Knuth](https://kth.cash/): high-performance Bitcoin full-node\n- [libunicode](https://github.com/contour-terminal/libunicode/): a\n  modern C++17 Unicode library\n- [MariaDB](https://mariadb.org/): relational database management\n  system\n- [Microsoft Verona](https://github.com/microsoft/verona): research\n  programming language for concurrent ownership\n- [MongoDB](https://mongodb.com/): distributed document database\n- [MongoDB Smasher](https://github.com/duckie/mongo_smasher): a small\n  tool to generate randomized datasets\n- [OpenSpace](https://openspaceproject.com/): an open-source\n  astrovisualization framework\n- [PenUltima Online (POL)](https://www.polserver.com/): an MMO server,\n  compatible with most Ultima Online clients\n- [PyTorch](https://github.com/pytorch/pytorch): an open-source\n  machine learning library\n- [quasardb](https://www.quasardb.net/): a distributed,\n  high-performance, associative database\n- [Quill](https://github.com/odygrd/quill): asynchronous low-latency\n  logging library\n- [QKW](https://github.com/ravijanjam/qkw): generalizing aliasing to\n  simplify navigation, and execute complex multi-line terminal\n  command sequences\n- [redis-cerberus](https://github.com/HunanTV/redis-cerberus): a Redis\n  cluster proxy\n- [redpanda](https://vectorized.io/redpanda): a 10x faster Kafka®\n  replacement for mission-critical systems written in C++\n- [rpclib](http://rpclib.net/): a modern C++ msgpack-RPC server and\n  client library\n- [Salesforce Analytics\n  Cloud](https://www.salesforce.com/analytics-cloud/overview/):\n  business intelligence software\n- [Scylla](https://www.scylladb.com/): a Cassandra-compatible NoSQL\n  data store that can handle 1 million transactions per second on a\n  single server\n- [Seastar](http://www.seastar-project.org/): an advanced, open-source\n  C++ framework for high-performance server applications on modern\n  hardware\n- [spdlog](https://github.com/gabime/spdlog): super fast C++ logging\n  library\n- [Stellar](https://www.stellar.org/): financial platform\n- [Touch Surgery](https://www.touchsurgery.com/): surgery simulator\n- [TrinityCore](https://github.com/TrinityCore/TrinityCore):\n  open-source MMORPG framework\n- [🐙 userver framework](https://userver.tech/): open-source\n  asynchronous framework with a rich set of abstractions and database\n  drivers\n- [Windows Terminal](https://github.com/microsoft/terminal): the new\n  Windows terminal\n\n[More\\...](https://github.com/search?q=fmtlib&type=Code)\n\nIf you are aware of other projects using this library, please let me\nknow by [email](mailto:victor.zverovich@gmail.com) or by submitting an\n[issue](https://github.com/fmtlib/fmt/issues).\n\n# Motivation\n\nSo why yet another formatting library?\n\nThere are plenty of methods for doing this task, from standard ones like\nthe printf family of function and iostreams to Boost Format and\nFastFormat libraries. The reason for creating a new library is that\nevery existing solution that I found either had serious issues or\ndidn\\'t provide all the features I needed.\n\n## printf\n\nThe good thing about `printf` is that it is pretty fast and readily\navailable being a part of the C standard library. The main drawback is\nthat it doesn\\'t support user-defined types. `printf` also has safety\nissues although they are somewhat mitigated with [\\_\\_attribute\\_\\_\n((format (printf,\n\\...))](https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html) in\nGCC. There is a POSIX extension that adds positional arguments required\nfor\n[i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization)\nto `printf` but it is not a part of C99 and may not be available on some\nplatforms.\n\n## iostreams\n\nThe main issue with iostreams is best illustrated with an example:\n\n``` c++\nstd::cout << std::setprecision(2) << std::fixed << 1.23456 << \"\\n\";\n```\n\nwhich is a lot of typing compared to printf:\n\n``` c++\nprintf(\"%.2f\\n\", 1.23456);\n```\n\nMatthew Wilson, the author of FastFormat, called this \\\"chevron hell\\\".\niostreams don\\'t support positional arguments by design.\n\nThe good part is that iostreams support user-defined types and are safe\nalthough error handling is awkward.\n\n## Boost Format\n\nThis is a very powerful library that supports both `printf`-like format\nstrings and positional arguments. Its main drawback is performance.\nAccording to various benchmarks, it is much slower than other methods\nconsidered here. Boost Format also has excessive build times and severe\ncode bloat issues (see [Benchmarks](#benchmarks)).\n\n## FastFormat\n\nThis is an interesting library that is fast, safe and has positional\narguments. However, it has significant limitations, citing its author:\n\n> Three features that have no hope of being accommodated within the\n> current design are:\n>\n> - Leading zeros (or any other non-space padding)\n> - Octal/hexadecimal encoding\n> - Runtime width/alignment specification\n\nIt is also quite big and has a heavy dependency, on STLSoft, which might be\ntoo restrictive for use in some projects.\n\n## Boost Spirit.Karma\n\nThis is not a formatting library but I decided to include it here for\ncompleteness. As iostreams, it suffers from the problem of mixing\nverbatim text with arguments. The library is pretty fast, but slower on\ninteger formatting than `fmt::format_to` with format string compilation\non Karma\\'s own benchmark, see [Converting a hundred million integers to\nstrings per\nsecond](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html).\n\n# License\n\n{fmt} is distributed under the MIT\n[license](https://github.com/fmtlib/fmt/blob/master/LICENSE).\n\n# Documentation License\n\nThe [Format String Syntax](https://fmt.dev/latest/syntax/) section\nin the documentation is based on the one from Python [string module\ndocumentation](https://docs.python.org/3/library/string.html#module-string).\nFor this reason, the documentation is distributed under the Python\nSoftware Foundation license available in\n[doc/python-license.txt](https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt).\nIt only applies if you distribute the documentation of {fmt}.\n\n# Maintainers\n\nThe {fmt} library is maintained by Victor Zverovich\n([vitaut](https://github.com/vitaut)) with contributions from many other\npeople. See\n[Contributors](https://github.com/fmtlib/fmt/graphs/contributors) and\n[Releases](https://github.com/fmtlib/fmt/releases) for some of the\nnames. Let us know if your contribution is not listed or mentioned\nincorrectly and we\\'ll make it right.\n\n# Security Policy\n\nTo report a security issue, please disclose it at [security\nadvisory](https://github.com/fmtlib/fmt/security/advisories/new).\n\nThis project is maintained by a team of volunteers on a\nreasonable-effort basis. As such, please give us at least *90* days to\nwork on a fix before public exposure.\n"
  },
  {
    "path": "doc/ChangeLog-old.md",
    "content": "# 7.1.3 - 2020-11-24\n\n- Fixed handling of buffer boundaries in `format_to_n`\n  (https://github.com/fmtlib/fmt/issues/1996,\n  https://github.com/fmtlib/fmt/issues/2029).\n- Fixed linkage errors when linking with a shared library\n  (https://github.com/fmtlib/fmt/issues/2011).\n- Reintroduced ostream support to range formatters\n  (https://github.com/fmtlib/fmt/issues/2014).\n- Worked around an issue with mixing std versions in gcc\n  (https://github.com/fmtlib/fmt/issues/2017).\n\n# 7.1.2 - 2020-11-04\n\n- Fixed floating point formatting with large precision\n  (https://github.com/fmtlib/fmt/issues/1976).\n\n# 7.1.1 - 2020-11-01\n\n- Fixed ABI compatibility with 7.0.x\n  (https://github.com/fmtlib/fmt/issues/1961).\n- Added the `FMT_ARM_ABI_COMPATIBILITY` macro to work around ABI\n  incompatibility between GCC and Clang on ARM\n  (https://github.com/fmtlib/fmt/issues/1919).\n- Worked around a SFINAE bug in GCC 8\n  (https://github.com/fmtlib/fmt/issues/1957).\n- Fixed linkage errors when building with GCC\\'s LTO\n  (https://github.com/fmtlib/fmt/issues/1955).\n- Fixed a compilation error when building without `__builtin_clz` or\n  equivalent (https://github.com/fmtlib/fmt/pull/1968).\n  Thanks @tohammer.\n- Fixed a sign conversion warning\n  (https://github.com/fmtlib/fmt/pull/1964). Thanks @OptoCloud.\n\n# 7.1.0 - 2020-10-25\n\n- Switched from\n  [Grisu3](https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf)\n  to [Dragonbox](https://github.com/jk-jeon/dragonbox) for the default\n  floating-point formatting which gives the shortest decimal\n  representation with round-trip guarantee and correct rounding\n  (https://github.com/fmtlib/fmt/pull/1882,\n  https://github.com/fmtlib/fmt/pull/1887,\n  https://github.com/fmtlib/fmt/pull/1894). This makes {fmt}\n  up to 20-30x faster than common implementations of\n  `std::ostringstream` and `sprintf` on\n  [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) and\n  faster than double-conversion and Ryū:\n\n  ![](https://user-images.githubusercontent.com/576385/95684665-11719600-0ba8-11eb-8e5b-972ff4e49428.png)\n\n  It is possible to get even better performance at the cost of larger\n  binary size by compiling with the `FMT_USE_FULL_CACHE_DRAGONBOX`\n  macro set to 1.\n\n  Thanks @jk-jeon.\n\n- Added an experimental unsynchronized file output API which, together\n  with [format string\n  compilation](https://fmt.dev/latest/api.html#compile-api), can give\n  [5-9 times speed up compared to\n  fprintf](https://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html)\n  on common platforms ([godbolt](https://godbolt.org/z/nsTcG8)):\n\n  ```c++\n  #include <fmt/os.h>\n\n  int main() {\n    auto f = fmt::output_file(\"guide\");\n    f.print(\"The answer is {}.\", 42);\n  }\n  ```\n\n- Added a formatter for `std::chrono::time_point<system_clock>`\n  (https://github.com/fmtlib/fmt/issues/1819,\n  https://github.com/fmtlib/fmt/pull/1837). For example\n  ([godbolt](https://godbolt.org/z/c4M6fh)):\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    auto now = std::chrono::system_clock::now();\n    fmt::print(\"The time is {:%H:%M:%S}.\\n\", now);\n  }\n  ```\n\n  Thanks @adamburgess.\n\n- Added support for ranges with non-const `begin`/`end` to `fmt::join`\n  (https://github.com/fmtlib/fmt/issues/1784,\n  https://github.com/fmtlib/fmt/pull/1786). For example\n  ([godbolt](https://godbolt.org/z/jP63Tv)):\n\n  ```c++\n  #include <fmt/ranges.h>\n  #include <range/v3/view/filter.hpp>\n\n  int main() {\n    using std::literals::string_literals::operator\"\"s;\n    auto strs = std::array{\"a\"s, \"bb\"s, \"ccc\"s};\n    auto range = strs | ranges::views::filter(\n      [] (const std::string &x) { return x.size() != 2; }\n    );\n    fmt::print(\"{}\\n\", fmt::join(range, \"\"));\n  }\n  ```\n\n  prints \\\"accc\\\".\n\n  Thanks @tonyelewis.\n\n- Added a `memory_buffer::append` overload that takes a range\n  (https://github.com/fmtlib/fmt/pull/1806). Thanks @BRevzin.\n\n- Improved handling of single code units in `FMT_COMPILE`. For\n  example:\n\n  ```c++\n  #include <fmt/compile.h>\n\n  char* f(char* buf) {\n    return fmt::format_to(buf, FMT_COMPILE(\"x{}\"), 42);\n  }\n  ```\n\n  compiles to just ([godbolt](https://godbolt.org/z/5vncz3)):\n\n  ```asm\n  _Z1fPc:\n    movb $120, (%rdi)\n    xorl %edx, %edx\n    cmpl $42, _ZN3fmt2v76detail10basic_dataIvE23zero_or_powers_of_10_32E+8(%rip)\n    movl $3, %eax\n    seta %dl\n    subl %edx, %eax\n    movzwl _ZN3fmt2v76detail10basic_dataIvE6digitsE+84(%rip), %edx\n    cltq\n    addq %rdi, %rax\n    movw %dx, -2(%rax)\n    ret\n  ```\n\n  Here a single `mov` instruction writes `'x'` (`$120`) to the output\n  buffer.\n\n- Added dynamic width support to format string compilation\n  (https://github.com/fmtlib/fmt/issues/1809).\n\n- Improved error reporting for unformattable types: now you\\'ll get\n  the type name directly in the error message instead of the note:\n\n  ```c++\n  #include <fmt/core.h>\n\n  struct how_about_no {};\n\n  int main() {\n    fmt::print(\"{}\", how_about_no());\n  }\n  ```\n\n  Error ([godbolt](https://godbolt.org/z/GoxM4e)):\n\n  `fmt/core.h:1438:3: error: static_assert failed due to requirement 'fmt::v7::formattable<how_about_no>()' \"Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt\" ...`\n\n- Added the\n  [make_args_checked](https://fmt.dev/7.1.0/api.html#argument-lists)\n  function template that allows you to write formatting functions with\n  compile-time format string checks and avoid binary code bloat\n  ([godbolt](https://godbolt.org/z/PEf9qr)):\n\n  ```c++\n  void vlog(const char* file, int line, fmt::string_view format,\n            fmt::format_args args) {\n    fmt::print(\"{}: {}: \", file, line);\n    fmt::vprint(format, args);\n  }\n\n  template <typename S, typename... Args>\n  void log(const char* file, int line, const S& format, Args&&... args) {\n    vlog(file, line, format,\n        fmt::make_args_checked<Args...>(format, args...));\n  }\n\n  #define MY_LOG(format, ...) \\\n    log(__FILE__, __LINE__, FMT_STRING(format), __VA_ARGS__)\n\n  MY_LOG(\"invalid squishiness: {}\", 42);\n  ```\n\n- Replaced `snprintf` fallback with a faster internal IEEE 754 `float`\n  and `double` formatter for arbitrary precision. For example\n  ([godbolt](https://godbolt.org/z/dPhWvj)):\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{:.500}\\n\", 4.9406564584124654E-324);\n  }\n  ```\n\n  prints\n\n  `4.9406564584124654417656879286822137236505980261432476442558568250067550727020875186529983636163599237979656469544571773092665671035593979639877479601078187812630071319031140452784581716784898210368871863605699873072305000638740915356498438731247339727316961514003171538539807412623856559117102665855668676818703956031062493194527159149245532930545654440112748012970999954193198940908041656332452475714786901472678015935523861155013480352649347201937902681071074917033322268447533357208324319360923829e-324`.\n\n- Made `format_to_n` and `formatted_size` part of the [core\n  API](https://fmt.dev/latest/api.html#core-api)\n  ([godbolt](https://godbolt.org/z/sPjY1K)):\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    char buffer[10];\n    auto result = fmt::format_to_n(buffer, sizeof(buffer), \"{}\", 42);\n  }\n  ```\n\n- Added `fmt::format_to_n` overload with format string compilation\n  (https://github.com/fmtlib/fmt/issues/1764,\n  https://github.com/fmtlib/fmt/pull/1767,\n  https://github.com/fmtlib/fmt/pull/1869). For example\n  ([godbolt](https://godbolt.org/z/93h86q)):\n\n  ```c++\n  #include <fmt/compile.h>\n\n  int main() {\n    char buffer[8];\n    fmt::format_to_n(buffer, sizeof(buffer), FMT_COMPILE(\"{}\"), 42);\n  }\n  ```\n\n  Thanks @Kurkin and @alexezeder.\n\n- Added `fmt::format_to` overload that take `text_style`\n  (https://github.com/fmtlib/fmt/issues/1593,\n  https://github.com/fmtlib/fmt/issues/1842,\n  https://github.com/fmtlib/fmt/pull/1843). For example\n  ([godbolt](https://godbolt.org/z/91153r)):\n\n  ```c++\n  #include <fmt/color.h>\n\n  int main() {\n    std::string out;\n    fmt::format_to(std::back_inserter(out),\n                   fmt::emphasis::bold | fg(fmt::color::red),\n                   \"The answer is {}.\", 42);\n  }\n  ```\n\n  Thanks @Naios.\n\n- Made the `'#'` specifier emit trailing zeros in addition to the\n  decimal point (https://github.com/fmtlib/fmt/issues/1797).\n  For example ([godbolt](https://godbolt.org/z/bhdcW9)):\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{:#.2g}\", 0.5);\n  }\n  ```\n\n  prints `0.50`.\n\n- Changed the default floating point format to not include `.0` for\n  consistency with `std::format` and `std::to_chars`\n  (https://github.com/fmtlib/fmt/issues/1893,\n  https://github.com/fmtlib/fmt/issues/1943). It is possible\n  to get the decimal point and trailing zero with the `#` specifier.\n\n- Fixed an issue with floating-point formatting that could result in\n  addition of a non-significant trailing zero in rare cases e.g.\n  `1.00e-34` instead of `1.0e-34`\n  (https://github.com/fmtlib/fmt/issues/1873,\n  https://github.com/fmtlib/fmt/issues/1917).\n\n- Made `fmt::to_string` fallback on `ostream` insertion operator if\n  the `formatter` specialization is not provided\n  (https://github.com/fmtlib/fmt/issues/1815,\n  https://github.com/fmtlib/fmt/pull/1829). Thanks @alexezeder.\n\n- Added support for the append mode to the experimental file API and\n  improved `fcntl.h` detection.\n  (https://github.com/fmtlib/fmt/pull/1847,\n  https://github.com/fmtlib/fmt/pull/1848). Thanks @t-wiser.\n\n- Fixed handling of types that have both an implicit conversion\n  operator and an overloaded `ostream` insertion operator\n  (https://github.com/fmtlib/fmt/issues/1766).\n\n- Fixed a slicing issue in an internal iterator type\n  (https://github.com/fmtlib/fmt/pull/1822). Thanks @BRevzin.\n\n- Fixed an issue in locale-specific integer formatting\n  (https://github.com/fmtlib/fmt/issues/1927).\n\n- Fixed handling of exotic code unit types\n  (https://github.com/fmtlib/fmt/issues/1870,\n  https://github.com/fmtlib/fmt/issues/1932).\n\n- Improved `FMT_ALWAYS_INLINE`\n  (https://github.com/fmtlib/fmt/pull/1878). Thanks @jk-jeon.\n\n- Removed dependency on `windows.h`\n  (https://github.com/fmtlib/fmt/pull/1900). Thanks @bernd5.\n\n- Optimized counting of decimal digits on MSVC\n  (https://github.com/fmtlib/fmt/pull/1890). Thanks @mwinterb.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/1772,\n  https://github.com/fmtlib/fmt/pull/1775,\n  https://github.com/fmtlib/fmt/pull/1792,\n  https://github.com/fmtlib/fmt/pull/1838,\n  https://github.com/fmtlib/fmt/pull/1888,\n  https://github.com/fmtlib/fmt/pull/1918,\n  https://github.com/fmtlib/fmt/pull/1939).\n  Thanks @leolchat, @pepsiman, @Klaim, @ravijanjam, @francesco-st and @udnaan.\n\n- Added the `FMT_REDUCE_INT_INSTANTIATIONS` CMake option that reduces\n  the binary code size at the cost of some integer formatting\n  performance. This can be useful for extremely memory-constrained\n  embedded systems\n  (https://github.com/fmtlib/fmt/issues/1778,\n  https://github.com/fmtlib/fmt/pull/1781). Thanks @kammce.\n\n- Added the `FMT_USE_INLINE_NAMESPACES` macro to control usage of\n  inline namespaces\n  (https://github.com/fmtlib/fmt/pull/1945). Thanks @darklukee.\n\n- Improved build configuration\n  (https://github.com/fmtlib/fmt/pull/1760,\n  https://github.com/fmtlib/fmt/pull/1770,\n  https://github.com/fmtlib/fmt/issues/1779,\n  https://github.com/fmtlib/fmt/pull/1783,\n  https://github.com/fmtlib/fmt/pull/1823).\n  Thanks @dvetutnev, @xvitaly, @tambry, @medithe and @martinwuehrer.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/1790,\n  https://github.com/fmtlib/fmt/pull/1802,\n  https://github.com/fmtlib/fmt/pull/1808,\n  https://github.com/fmtlib/fmt/issues/1810,\n  https://github.com/fmtlib/fmt/issues/1811,\n  https://github.com/fmtlib/fmt/pull/1812,\n  https://github.com/fmtlib/fmt/pull/1814,\n  https://github.com/fmtlib/fmt/pull/1816,\n  https://github.com/fmtlib/fmt/pull/1817,\n  https://github.com/fmtlib/fmt/pull/1818,\n  https://github.com/fmtlib/fmt/issues/1825,\n  https://github.com/fmtlib/fmt/pull/1836,\n  https://github.com/fmtlib/fmt/pull/1855,\n  https://github.com/fmtlib/fmt/pull/1856,\n  https://github.com/fmtlib/fmt/pull/1860,\n  https://github.com/fmtlib/fmt/pull/1877,\n  https://github.com/fmtlib/fmt/pull/1879,\n  https://github.com/fmtlib/fmt/pull/1880,\n  https://github.com/fmtlib/fmt/issues/1896,\n  https://github.com/fmtlib/fmt/pull/1897,\n  https://github.com/fmtlib/fmt/pull/1898,\n  https://github.com/fmtlib/fmt/issues/1904,\n  https://github.com/fmtlib/fmt/pull/1908,\n  https://github.com/fmtlib/fmt/issues/1911,\n  https://github.com/fmtlib/fmt/issues/1912,\n  https://github.com/fmtlib/fmt/issues/1928,\n  https://github.com/fmtlib/fmt/pull/1929,\n  https://github.com/fmtlib/fmt/issues/1935,\n  https://github.com/fmtlib/fmt/pull/1937,\n  https://github.com/fmtlib/fmt/pull/1942,\n  https://github.com/fmtlib/fmt/issues/1949).\n  Thanks @TheQwertiest, @medithe, @martinwuehrer, @n16h7hunt3r, @Othereum,\n  @gsjaardema, @AlexanderLanin, @gcerretani, @chronoxor, @noizefloor,\n  @akohlmey, @jk-jeon, @rimathia, @rglarix, @moiwi, @heckad, @MarcDirven.\n  @BartSiwek and @darklukee.\n\n# 7.0.3 - 2020-08-06\n\n- Worked around broken `numeric_limits` for 128-bit integers\n  (https://github.com/fmtlib/fmt/issues/1787).\n- Added error reporting on missing named arguments\n  (https://github.com/fmtlib/fmt/issues/1796).\n- Stopped using 128-bit integers with clang-cl\n  (https://github.com/fmtlib/fmt/pull/1800). Thanks @Kingcom.\n- Fixed issues in locale-specific integer formatting\n  (https://github.com/fmtlib/fmt/issues/1782,\n  https://github.com/fmtlib/fmt/issues/1801).\n\n# 7.0.2 - 2020-07-29\n\n- Worked around broken `numeric_limits` for 128-bit integers\n  (https://github.com/fmtlib/fmt/issues/1725).\n- Fixed compatibility with CMake 3.4\n  (https://github.com/fmtlib/fmt/issues/1779).\n- Fixed handling of digit separators in locale-specific formatting\n  (https://github.com/fmtlib/fmt/issues/1782).\n\n# 7.0.1 - 2020-07-07\n\n- Updated the inline version namespace name.\n- Worked around a gcc bug in mangling of alias templates\n  (https://github.com/fmtlib/fmt/issues/1753).\n- Fixed a linkage error on Windows\n  (https://github.com/fmtlib/fmt/issues/1757). Thanks @Kurkin.\n- Fixed minor issues with the documentation.\n\n# 7.0.0 - 2020-07-05\n\n- Reduced the library size. For example, on macOS a stripped test\n  binary statically linked with {fmt} [shrank from \\~368k to less than\n  100k](http://www.zverovich.net/2020/05/21/reducing-library-size.html).\n\n- Added a simpler and more efficient [format string compilation\n  API](https://fmt.dev/7.0.0/api.html#compile-api):\n\n  ```c++\n  #include <fmt/compile.h>\n\n  // Converts 42 into std::string using the most efficient method and no\n  // runtime format string processing.\n  std::string s = fmt::format(FMT_COMPILE(\"{}\"), 42);\n  ```\n\n  The old `fmt::compile` API is now deprecated.\n\n- Optimized integer formatting: `format_to` with format string\n  compilation and a stack-allocated buffer is now [faster than\n  to_chars on both libc++ and\n  libstdc++](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html).\n\n- Optimized handling of small format strings. For example,\n\n  ```c++\n  fmt::format(\"Result: {}: ({},{},{},{})\", str1, str2, str3, str4, str5)\n  ```\n\n  is now \\~40% faster\n  (https://github.com/fmtlib/fmt/issues/1685).\n\n- Applied extern templates to improve compile times when using the\n  core API and `fmt/format.h`\n  (https://github.com/fmtlib/fmt/issues/1452). For example,\n  on macOS with clang the compile time of a test translation unit\n  dropped from 2.3s to 0.3s with `-O2` and from 0.6s to 0.3s with the\n  default settings (`-O0`).\n\n  Before (`-O2`):\n\n      % time c++ -c test.cc -I include -std=c++17 -O2\n      c++ -c test.cc -I include -std=c++17 -O2  2.22s user 0.08s system 99% cpu 2.311 total\n\n  After (`-O2`):\n\n      % time c++ -c test.cc -I include -std=c++17 -O2\n      c++ -c test.cc -I include -std=c++17 -O2  0.26s user 0.04s system 98% cpu 0.303 total\n\n  Before (default):\n\n      % time c++ -c test.cc -I include -std=c++17\n      c++ -c test.cc -I include -std=c++17  0.53s user 0.06s system 98% cpu 0.601 total\n\n  After (default):\n\n      % time c++ -c test.cc -I include -std=c++17\n      c++ -c test.cc -I include -std=c++17  0.24s user 0.06s system 98% cpu 0.301 total\n\n  It is still recommended to use `fmt/core.h` instead of\n  `fmt/format.h` but the compile time difference is now smaller.\n  Thanks @alex3d for the suggestion.\n\n- Named arguments are now stored on stack (no dynamic memory\n  allocations) and the compiled code is more compact and efficient.\n  For example\n\n  ```c++\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"The answer is {answer}\\n\", fmt::arg(\"answer\", 42));\n  }\n  ```\n\n  compiles to just ([godbolt](https://godbolt.org/z/NcfEp_))\n\n  ```asm\n  .LC0:\n          .string \"answer\"\n  .LC1:\n          .string \"The answer is {answer}\\n\"\n  main:\n          sub     rsp, 56\n          mov     edi, OFFSET FLAT:.LC1\n          mov     esi, 23\n          movabs  rdx, 4611686018427387905\n          lea     rax, [rsp+32]\n          lea     rcx, [rsp+16]\n          mov     QWORD PTR [rsp+8], 1\n          mov     QWORD PTR [rsp], rax\n          mov     DWORD PTR [rsp+16], 42\n          mov     QWORD PTR [rsp+32], OFFSET FLAT:.LC0\n          mov     DWORD PTR [rsp+40], 0\n          call    fmt::v6::vprint(fmt::v6::basic_string_view<char>,\n                                  fmt::v6::format_args)\n          xor     eax, eax\n          add     rsp, 56\n          ret\n\n      .L.str.1:\n              .asciz  \"answer\"\n  ```\n\n- Implemented compile-time checks for dynamic width and precision\n  (https://github.com/fmtlib/fmt/issues/1614):\n\n  ```c++\n  #include <fmt/format.h>\n\n  int main() {\n    fmt::print(FMT_STRING(\"{0:{1}}\"), 42);\n  }\n  ```\n\n  now gives a compilation error because argument 1 doesn\\'t exist:\n\n      In file included from test.cc:1:\n      include/fmt/format.h:2726:27: error: constexpr variable 'invalid_format' must be\n      initialized by a constant expression\n        FMT_CONSTEXPR_DECL bool invalid_format =\n                                ^\n      ...\n      include/fmt/core.h:569:26: note: in call to\n      '&checker(s, {}).context_->on_error(&\"argument not found\"[0])'\n          if (id >= num_args_) on_error(\"argument not found\");\n                              ^\n\n- Added sentinel support to `fmt::join`\n  (https://github.com/fmtlib/fmt/pull/1689)\n\n  ```c++\n  struct zstring_sentinel {};\n  bool operator==(const char* p, zstring_sentinel) { return *p == '\\0'; }\n  bool operator!=(const char* p, zstring_sentinel) { return *p != '\\0'; }\n\n  struct zstring {\n    const char* p;\n    const char* begin() const { return p; }\n    zstring_sentinel end() const { return {}; }\n  };\n\n  auto s = fmt::format(\"{}\", fmt::join(zstring{\"hello\"}, \"_\"));\n  // s == \"h_e_l_l_o\"\n  ```\n\n  Thanks @BRevzin.\n\n- Added support for named arguments, `clear` and `reserve` to\n  `dynamic_format_arg_store`\n  (https://github.com/fmtlib/fmt/issues/1655,\n  https://github.com/fmtlib/fmt/pull/1663,\n  https://github.com/fmtlib/fmt/pull/1674,\n  https://github.com/fmtlib/fmt/pull/1677). Thanks @vsolontsov-ll.\n\n- Added support for the `'c'` format specifier to integral types for\n  compatibility with `std::format`\n  (https://github.com/fmtlib/fmt/issues/1652).\n\n- Replaced the `'n'` format specifier with `'L'` for compatibility\n  with `std::format`\n  (https://github.com/fmtlib/fmt/issues/1624). The `'n'`\n  specifier can be enabled via the `FMT_DEPRECATED_N_SPECIFIER` macro.\n\n- The `'='` format specifier is now disabled by default for\n  compatibility with `std::format`. It can be enabled via the\n  `FMT_DEPRECATED_NUMERIC_ALIGN` macro.\n\n- Removed the following deprecated APIs:\n\n  -   `FMT_STRING_ALIAS` and `fmt` macros - replaced by `FMT_STRING`\n  -   `fmt::basic_string_view::char_type` - replaced by\n      `fmt::basic_string_view::value_type`\n  -   `convert_to_int`\n  -   `format_arg_store::types`\n  -   `*parse_context` - replaced by `*format_parse_context`\n  -   `FMT_DEPRECATED_INCLUDE_OS`\n  -   `FMT_DEPRECATED_PERCENT` - incompatible with `std::format`\n  -   `*writer` - replaced by compiled format API\n\n- Renamed the `internal` namespace to `detail`\n  (https://github.com/fmtlib/fmt/issues/1538). The former is\n  still provided as an alias if the `FMT_USE_INTERNAL` macro is\n  defined.\n\n- Improved compatibility between `fmt::printf` with the standard specs\n  (https://github.com/fmtlib/fmt/issues/1595,\n  https://github.com/fmtlib/fmt/pull/1682,\n  https://github.com/fmtlib/fmt/pull/1683,\n  https://github.com/fmtlib/fmt/pull/1687,\n  https://github.com/fmtlib/fmt/pull/1699). Thanks @rimathia.\n\n- Fixed handling of `operator<<` overloads that use `copyfmt`\n  (https://github.com/fmtlib/fmt/issues/1666).\n\n- Added the `FMT_OS` CMake option to control inclusion of OS-specific\n  APIs in the fmt target. This can be useful for embedded platforms\n  (https://github.com/fmtlib/fmt/issues/1654,\n  https://github.com/fmtlib/fmt/pull/1656). Thanks @kwesolowski.\n\n- Replaced `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` with the\n  `FMT_FUZZ` macro to prevent interfering with fuzzing of projects\n  using {fmt} (https://github.com/fmtlib/fmt/pull/1650).\n  Thanks @asraa.\n\n- Fixed compatibility with emscripten\n  (https://github.com/fmtlib/fmt/issues/1636,\n  https://github.com/fmtlib/fmt/pull/1637). Thanks @ArthurSonzogni.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/704,\n  https://github.com/fmtlib/fmt/pull/1643,\n  https://github.com/fmtlib/fmt/pull/1660,\n  https://github.com/fmtlib/fmt/pull/1681,\n  https://github.com/fmtlib/fmt/pull/1691,\n  https://github.com/fmtlib/fmt/pull/1706,\n  https://github.com/fmtlib/fmt/pull/1714,\n  https://github.com/fmtlib/fmt/pull/1721,\n  https://github.com/fmtlib/fmt/pull/1739,\n  https://github.com/fmtlib/fmt/pull/1740,\n  https://github.com/fmtlib/fmt/pull/1741,\n  https://github.com/fmtlib/fmt/pull/1751).\n  Thanks @senior7515, @lsr0, @puetzk, @fpelliccioni, Alexey Kuzmenko, @jelly,\n  @claremacrae, @jiapengwen, @gsjaardema and @alexey-milovidov.\n\n- Implemented various build configuration fixes and improvements\n  (https://github.com/fmtlib/fmt/pull/1603,\n  https://github.com/fmtlib/fmt/pull/1657,\n  https://github.com/fmtlib/fmt/pull/1702,\n  https://github.com/fmtlib/fmt/pull/1728).\n  Thanks @scramsby, @jtojnar, @orivej and @flagarde.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/1616,\n  https://github.com/fmtlib/fmt/issues/1620,\n  https://github.com/fmtlib/fmt/issues/1622,\n  https://github.com/fmtlib/fmt/issues/1625,\n  https://github.com/fmtlib/fmt/pull/1627,\n  https://github.com/fmtlib/fmt/issues/1628,\n  https://github.com/fmtlib/fmt/pull/1629,\n  https://github.com/fmtlib/fmt/issues/1631,\n  https://github.com/fmtlib/fmt/pull/1633,\n  https://github.com/fmtlib/fmt/pull/1649,\n  https://github.com/fmtlib/fmt/issues/1658,\n  https://github.com/fmtlib/fmt/pull/1661,\n  https://github.com/fmtlib/fmt/pull/1667,\n  https://github.com/fmtlib/fmt/issues/1668,\n  https://github.com/fmtlib/fmt/pull/1669,\n  https://github.com/fmtlib/fmt/issues/1692,\n  https://github.com/fmtlib/fmt/pull/1696,\n  https://github.com/fmtlib/fmt/pull/1697,\n  https://github.com/fmtlib/fmt/issues/1707,\n  https://github.com/fmtlib/fmt/pull/1712,\n  https://github.com/fmtlib/fmt/pull/1716,\n  https://github.com/fmtlib/fmt/pull/1722,\n  https://github.com/fmtlib/fmt/issues/1724,\n  https://github.com/fmtlib/fmt/pull/1729,\n  https://github.com/fmtlib/fmt/pull/1738,\n  https://github.com/fmtlib/fmt/issues/1742,\n  https://github.com/fmtlib/fmt/issues/1743,\n  https://github.com/fmtlib/fmt/pull/1744,\n  https://github.com/fmtlib/fmt/issues/1747,\n  https://github.com/fmtlib/fmt/pull/1750).\n  Thanks @gsjaardema, @gabime, @johnor, @Kurkin, @invexed, @peterbell10,\n  @daixtrose, @petrutlucian94, @Neargye, @ambitslix, @gabime,\n  @tohammer and @0x8000-0000.\n\n# 6.2.1 - 2020-05-09\n\n- Fixed ostream support in `sprintf`\n  (https://github.com/fmtlib/fmt/issues/1631).\n- Fixed type detection when using implicit conversion to `string_view`\n  and ostream `operator<<` inconsistently\n  (https://github.com/fmtlib/fmt/issues/1662).\n\n# 6.2.0 - 2020-04-05\n\n- Improved error reporting when trying to format an object of a\n  non-formattable type:\n\n  ```c++\n  fmt::format(\"{}\", S());\n  ```\n\n  now gives:\n\n      include/fmt/core.h:1015:5: error: static_assert failed due to requirement\n      'formattable' \"Cannot format argument. To make type T formattable provide a\n      formatter<T> specialization:\n      https://fmt.dev/latest/api.html#formatting-user-defined-types\"\n          static_assert(\n          ^\n      ...\n      note: in instantiation of function template specialization\n      'fmt::v6::format<char [3], S, char>' requested here\n        fmt::format(\"{}\", S());\n             ^\n\n  if `S` is not formattable.\n\n- Reduced the library size by \\~10%.\n\n- Always print decimal point if `#` is specified\n  (https://github.com/fmtlib/fmt/issues/1476,\n  https://github.com/fmtlib/fmt/issues/1498):\n\n  ```c++\n  fmt::print(\"{:#.0f}\", 42.0);\n  ```\n\n  now prints `42.`\n\n- Implemented the `'L'` specifier for locale-specific numeric\n  formatting to improve compatibility with `std::format`. The `'n'`\n  specifier is now deprecated and will be removed in the next major\n  release.\n\n- Moved OS-specific APIs such as `windows_error` from `fmt/format.h`\n  to `fmt/os.h`. You can define `FMT_DEPRECATED_INCLUDE_OS` to\n  automatically include `fmt/os.h` from `fmt/format.h` for\n  compatibility but this will be disabled in the next major release.\n\n- Added precision overflow detection in floating-point formatting.\n\n- Implemented detection of invalid use of `fmt::arg`.\n\n- Used `type_identity` to block unnecessary template argument\n  deduction. Thanks Tim Song.\n\n- Improved UTF-8 handling\n  (https://github.com/fmtlib/fmt/issues/1109):\n\n  ```c++\n  fmt::print(\"┌{0:─^{2}}┐\\n\"\n             \"│{1: ^{2}}│\\n\"\n             \"└{0:─^{2}}┘\\n\", \"\", \"Прывітанне, свет!\", 21);\n  ```\n\n  now prints:\n\n      ┌─────────────────────┐\n      │  Прывітанне, свет!  │\n      └─────────────────────┘\n\n  on systems that support Unicode.\n\n- Added experimental dynamic argument storage\n  (https://github.com/fmtlib/fmt/issues/1170,\n  https://github.com/fmtlib/fmt/pull/1584):\n\n  ```c++\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  store.push_back(\"answer\");\n  store.push_back(42);\n  fmt::vprint(\"The {} is {}.\\n\", store);\n  ```\n\n  prints:\n\n      The answer is 42.\n\n  Thanks @vsolontsov-ll.\n\n- Made `fmt::join` accept `initializer_list`\n  (https://github.com/fmtlib/fmt/pull/1591). Thanks @Rapotkinnik.\n\n- Fixed handling of empty tuples\n  (https://github.com/fmtlib/fmt/issues/1588).\n\n- Fixed handling of output iterators in `format_to_n`\n  (https://github.com/fmtlib/fmt/issues/1506).\n\n- Fixed formatting of `std::chrono::duration` types to wide output\n  (https://github.com/fmtlib/fmt/pull/1533). Thanks @zeffy.\n\n- Added const `begin` and `end` overload to buffers\n  (https://github.com/fmtlib/fmt/pull/1553). Thanks @dominicpoeschko.\n\n- Added the ability to disable floating-point formatting via\n  `FMT_USE_FLOAT`, `FMT_USE_DOUBLE` and `FMT_USE_LONG_DOUBLE` macros\n  for extremely memory-constrained embedded system\n  (https://github.com/fmtlib/fmt/pull/1590). Thanks @albaguirre.\n\n- Made `FMT_STRING` work with `constexpr` `string_view`\n  (https://github.com/fmtlib/fmt/pull/1589). Thanks @scramsby.\n\n- Implemented a minor optimization in the format string parser\n  (https://github.com/fmtlib/fmt/pull/1560). Thanks @IkarusDeveloper.\n\n- Improved attribute detection\n  (https://github.com/fmtlib/fmt/pull/1469,\n  https://github.com/fmtlib/fmt/pull/1475,\n  https://github.com/fmtlib/fmt/pull/1576).\n  Thanks @federico-busato, @chronoxor and @refnum.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/pull/1481,\n  https://github.com/fmtlib/fmt/pull/1523).\n  Thanks @JackBoosY and @imba-tjd.\n\n- Fixed symbol visibility on Linux when compiling with\n  `-fvisibility=hidden`\n  (https://github.com/fmtlib/fmt/pull/1535). Thanks @milianw.\n\n- Implemented various build configuration fixes and improvements\n  (https://github.com/fmtlib/fmt/issues/1264,\n  https://github.com/fmtlib/fmt/issues/1460,\n  https://github.com/fmtlib/fmt/pull/1534,\n  https://github.com/fmtlib/fmt/issues/1536,\n  https://github.com/fmtlib/fmt/issues/1545,\n  https://github.com/fmtlib/fmt/pull/1546,\n  https://github.com/fmtlib/fmt/issues/1566,\n  https://github.com/fmtlib/fmt/pull/1582,\n  https://github.com/fmtlib/fmt/issues/1597,\n  https://github.com/fmtlib/fmt/pull/1598).\n  Thanks @ambitslix, @jwillikers and @stac47.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/1433,\n  https://github.com/fmtlib/fmt/issues/1461,\n  https://github.com/fmtlib/fmt/pull/1470,\n  https://github.com/fmtlib/fmt/pull/1480,\n  https://github.com/fmtlib/fmt/pull/1485,\n  https://github.com/fmtlib/fmt/pull/1492,\n  https://github.com/fmtlib/fmt/issues/1493,\n  https://github.com/fmtlib/fmt/issues/1504,\n  https://github.com/fmtlib/fmt/pull/1505,\n  https://github.com/fmtlib/fmt/pull/1512,\n  https://github.com/fmtlib/fmt/issues/1515,\n  https://github.com/fmtlib/fmt/pull/1516,\n  https://github.com/fmtlib/fmt/pull/1518,\n  https://github.com/fmtlib/fmt/pull/1519,\n  https://github.com/fmtlib/fmt/pull/1520,\n  https://github.com/fmtlib/fmt/pull/1521,\n  https://github.com/fmtlib/fmt/pull/1522,\n  https://github.com/fmtlib/fmt/issues/1524,\n  https://github.com/fmtlib/fmt/pull/1530,\n  https://github.com/fmtlib/fmt/issues/1531,\n  https://github.com/fmtlib/fmt/pull/1532,\n  https://github.com/fmtlib/fmt/issues/1539,\n  https://github.com/fmtlib/fmt/issues/1547,\n  https://github.com/fmtlib/fmt/issues/1548,\n  https://github.com/fmtlib/fmt/pull/1554,\n  https://github.com/fmtlib/fmt/issues/1567,\n  https://github.com/fmtlib/fmt/pull/1568,\n  https://github.com/fmtlib/fmt/pull/1569,\n  https://github.com/fmtlib/fmt/pull/1571,\n  https://github.com/fmtlib/fmt/pull/1573,\n  https://github.com/fmtlib/fmt/pull/1575,\n  https://github.com/fmtlib/fmt/pull/1581,\n  https://github.com/fmtlib/fmt/issues/1583,\n  https://github.com/fmtlib/fmt/issues/1586,\n  https://github.com/fmtlib/fmt/issues/1587,\n  https://github.com/fmtlib/fmt/issues/1594,\n  https://github.com/fmtlib/fmt/pull/1596,\n  https://github.com/fmtlib/fmt/issues/1604,\n  https://github.com/fmtlib/fmt/pull/1606,\n  https://github.com/fmtlib/fmt/issues/1607,\n  https://github.com/fmtlib/fmt/issues/1609).\n  Thanks @marti4d, @iPherian, @parkertomatoes, @gsjaardema, @chronoxor,\n  @DanielaE, @torsten48, @tohammer, @lefticus, @ryusakki, @adnsv, @fghzxm,\n  @refnum, @pramodk, @Spirrwell and @scramsby.\n\n# 6.1.2 - 2019-12-11\n\n- Fixed ABI compatibility with `libfmt.so.6.0.0`\n  (https://github.com/fmtlib/fmt/issues/1471).\n- Fixed handling types convertible to `std::string_view`\n  (https://github.com/fmtlib/fmt/pull/1451). Thanks @denizevrenci.\n- Made CUDA test an opt-in enabled via the `FMT_CUDA_TEST` CMake\n  option.\n- Fixed sign conversion warnings\n  (https://github.com/fmtlib/fmt/pull/1440). Thanks @0x8000-0000.\n\n# 6.1.1 - 2019-12-04\n\n- Fixed shared library build on Windows\n  (https://github.com/fmtlib/fmt/pull/1443,\n  https://github.com/fmtlib/fmt/issues/1445,\n  https://github.com/fmtlib/fmt/pull/1446,\n  https://github.com/fmtlib/fmt/issues/1450).\n  Thanks @egorpugin and @bbolli.\n- Added a missing decimal point in exponent notation with trailing\n  zeros.\n- Removed deprecated `format_arg_store::TYPES`.\n\n# 6.1.0 - 2019-12-01\n\n- {fmt} now formats IEEE 754 `float` and `double` using the shortest\n  decimal representation with correct rounding by default:\n\n  ```c++\n  #include <cmath>\n  #include <fmt/core.h>\n\n  int main() {\n    fmt::print(\"{}\", M_PI);\n  }\n  ```\n\n  prints `3.141592653589793`.\n\n- Made the fast binary to decimal floating-point formatter the\n  default, simplified it and improved performance. {fmt} is now 15\n  times faster than libc++\\'s `std::ostringstream`, 11 times faster\n  than `printf` and 10% faster than double-conversion on\n  [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark):\n\n  | Function      | Time (ns) | Speedup |\n  | ------------- | --------: | ------: |\n  | ostringstream | 1,346.30  | 1.00x   |\n  | ostrstream    | 1,195.74  | 1.13x   |\n  | sprintf       | 995.08    | 1.35x   |\n  | doubleconv    | 99.10     | 13.59x  |\n  | fmt           | 88.34     | 15.24x  |\n\n  ![](https://user-images.githubusercontent.com/576385/69767160-cdaca400-112f-11ea-9fc5-347c9f83caad.png)\n\n- {fmt} no longer converts `float` arguments to `double`. In\n  particular this improves the default (shortest) representation of\n  floats and makes `fmt::format` consistent with `std::format` specs\n  (https://github.com/fmtlib/fmt/issues/1336,\n  https://github.com/fmtlib/fmt/issues/1353,\n  https://github.com/fmtlib/fmt/pull/1360,\n  https://github.com/fmtlib/fmt/pull/1361):\n\n  ```c++\n  fmt::print(\"{}\", 0.1f);\n  ```\n\n  prints `0.1` instead of `0.10000000149011612`.\n\n  Thanks @orivej.\n\n- Made floating-point formatting output consistent with\n  `printf`/iostreams\n  (https://github.com/fmtlib/fmt/issues/1376,\n  https://github.com/fmtlib/fmt/issues/1417).\n\n- Added support for 128-bit integers\n  (https://github.com/fmtlib/fmt/pull/1287):\n\n  ```c++\n  fmt::print(\"{}\", std::numeric_limits<__int128_t>::max());\n  ```\n\n  prints `170141183460469231731687303715884105727`.\n\n  Thanks @denizevrenci.\n\n- The overload of `print` that takes `text_style` is now atomic, i.e.\n  the output from different threads doesn\\'t interleave\n  (https://github.com/fmtlib/fmt/pull/1351). Thanks @tankiJong.\n\n- Made compile time in the header-only mode \\~20% faster by reducing\n  the number of template instantiations. `wchar_t` overload of\n  `vprint` was moved from `fmt/core.h` to `fmt/format.h`.\n\n- Added an overload of `fmt::join` that works with tuples\n  (https://github.com/fmtlib/fmt/issues/1322,\n  https://github.com/fmtlib/fmt/pull/1330):\n\n  ```c++\n  #include <tuple>\n  #include <fmt/ranges.h>\n\n  int main() {\n    std::tuple<char, int, float> t{'a', 1, 2.0f};\n    fmt::print(\"{}\", t);\n  }\n  ```\n\n  prints `('a', 1, 2.0)`.\n\n  Thanks @jeremyong.\n\n- Changed formatting of octal zero with prefix from \\\"00\\\" to \\\"0\\\":\n\n  ```c++\n  fmt::print(\"{:#o}\", 0);\n  ```\n\n  prints `0`.\n\n- The locale is now passed to ostream insertion (`<<`) operators\n  (https://github.com/fmtlib/fmt/pull/1406):\n\n  ```c++\n  #include <fmt/locale.h>\n  #include <fmt/ostream.h>\n\n  struct S {\n    double value;\n  };\n\n  std::ostream& operator<<(std::ostream& os, S s) {\n    return os << s.value;\n  }\n\n  int main() {\n    auto s = fmt::format(std::locale(\"fr_FR.UTF-8\"), \"{}\", S{0.42});\n    // s == \"0,42\"\n  }\n  ```\n\n  Thanks @dlaugt.\n\n- Locale-specific number formatting now uses grouping\n  (https://github.com/fmtlib/fmt/issues/1393,\n  https://github.com/fmtlib/fmt/pull/1394). Thanks @skrdaniel.\n\n- Fixed handling of types with deleted implicit rvalue conversion to\n  `const char**` (https://github.com/fmtlib/fmt/issues/1421):\n\n  ```c++\n  struct mystring {\n    operator const char*() const&;\n    operator const char*() &;\n    operator const char*() const&& = delete;\n    operator const char*() && = delete;\n  };\n  mystring str;\n  fmt::print(\"{}\", str); // now compiles\n  ```\n\n- Enums are now mapped to correct underlying types instead of `int`\n  (https://github.com/fmtlib/fmt/pull/1286). Thanks @agmt.\n\n- Enum classes are no longer implicitly converted to `int`\n  (https://github.com/fmtlib/fmt/issues/1424).\n\n- Added `basic_format_parse_context` for consistency with C++20\n  `std::format` and deprecated `basic_parse_context`.\n\n- Fixed handling of UTF-8 in precision\n  (https://github.com/fmtlib/fmt/issues/1389,\n  https://github.com/fmtlib/fmt/pull/1390). Thanks @tajtiattila.\n\n- {fmt} can now be installed on Linux, macOS and Windows with\n  [Conda](https://docs.conda.io/en/latest/) using its\n  [conda-forge](https://conda-forge.org)\n  [package](https://github.com/conda-forge/fmt-feedstock)\n  (https://github.com/fmtlib/fmt/pull/1410):\n\n      conda install -c conda-forge fmt\n\n  Thanks @tdegeus.\n\n- Added a CUDA test (https://github.com/fmtlib/fmt/pull/1285,\n  https://github.com/fmtlib/fmt/pull/1317).\n  Thanks @luncliff and @risa2000.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/pull/1276,\n  https://github.com/fmtlib/fmt/issues/1291,\n  https://github.com/fmtlib/fmt/issues/1296,\n  https://github.com/fmtlib/fmt/pull/1315,\n  https://github.com/fmtlib/fmt/pull/1332,\n  https://github.com/fmtlib/fmt/pull/1337,\n  https://github.com/fmtlib/fmt/issues/1395\n  https://github.com/fmtlib/fmt/pull/1418).\n  Thanks @waywardmonkeys, @pauldreik and @jackoalan.\n\n- Various code improvements\n  (https://github.com/fmtlib/fmt/pull/1358,\n  https://github.com/fmtlib/fmt/pull/1407).\n  Thanks @orivej and @dpacbach.\n\n- Fixed compile-time format string checks for user-defined types\n  (https://github.com/fmtlib/fmt/issues/1292).\n\n- Worked around a false positive in `unsigned-integer-overflow` sanitizer\n  (https://github.com/fmtlib/fmt/issues/1377).\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/issues/1273,\n  https://github.com/fmtlib/fmt/pull/1278,\n  https://github.com/fmtlib/fmt/pull/1280,\n  https://github.com/fmtlib/fmt/issues/1281,\n  https://github.com/fmtlib/fmt/issues/1288,\n  https://github.com/fmtlib/fmt/pull/1290,\n  https://github.com/fmtlib/fmt/pull/1301,\n  https://github.com/fmtlib/fmt/issues/1305,\n  https://github.com/fmtlib/fmt/issues/1306,\n  https://github.com/fmtlib/fmt/issues/1309,\n  https://github.com/fmtlib/fmt/pull/1312,\n  https://github.com/fmtlib/fmt/issues/1313,\n  https://github.com/fmtlib/fmt/issues/1316,\n  https://github.com/fmtlib/fmt/issues/1319,\n  https://github.com/fmtlib/fmt/pull/1320,\n  https://github.com/fmtlib/fmt/pull/1326,\n  https://github.com/fmtlib/fmt/pull/1328,\n  https://github.com/fmtlib/fmt/issues/1344,\n  https://github.com/fmtlib/fmt/pull/1345,\n  https://github.com/fmtlib/fmt/pull/1347,\n  https://github.com/fmtlib/fmt/pull/1349,\n  https://github.com/fmtlib/fmt/issues/1354,\n  https://github.com/fmtlib/fmt/issues/1362,\n  https://github.com/fmtlib/fmt/issues/1366,\n  https://github.com/fmtlib/fmt/pull/1364,\n  https://github.com/fmtlib/fmt/pull/1370,\n  https://github.com/fmtlib/fmt/pull/1371,\n  https://github.com/fmtlib/fmt/issues/1385,\n  https://github.com/fmtlib/fmt/issues/1388,\n  https://github.com/fmtlib/fmt/pull/1397,\n  https://github.com/fmtlib/fmt/pull/1414,\n  https://github.com/fmtlib/fmt/pull/1416,\n  https://github.com/fmtlib/fmt/issues/1422\n  https://github.com/fmtlib/fmt/pull/1427,\n  https://github.com/fmtlib/fmt/issues/1431,\n  https://github.com/fmtlib/fmt/pull/1433).\n  Thanks @hhb, @gsjaardema, @gabime, @neheb, @vedranmiletic, @dkavolis,\n  @mwinterb, @orivej, @denizevrenci, @leonklingele, @chronoxor, @kent-tri,\n  @0x8000-0000 and @marti4d.\n\n# 6.0.0 - 2019-08-26\n\n- Switched to the [MIT license](\n  https://github.com/fmtlib/fmt/blob/5a4b24613ba16cc689977c3b5bd8274a3ba1dd1f/LICENSE.rst)\n  with an optional exception that allows distributing binary code\n  without attribution.\n\n- Floating-point formatting is now locale-independent by default:\n\n  ```c++\n  #include <locale>\n  #include <fmt/core.h>\n\n  int main() {\n    std::locale::global(std::locale(\"ru_RU.UTF-8\"));\n    fmt::print(\"value = {}\", 4.2);\n  }\n  ```\n\n  prints \\\"value = 4.2\\\" regardless of the locale.\n\n  For locale-specific formatting use the `n` specifier:\n\n  ```c++\n  std::locale::global(std::locale(\"ru_RU.UTF-8\"));\n  fmt::print(\"value = {:n}\", 4.2);\n  ```\n\n  prints \\\"value = 4,2\\\".\n\n- Added an experimental Grisu floating-point formatting algorithm\n  implementation (disabled by default). To enable it compile with the\n  `FMT_USE_GRISU` macro defined to 1:\n\n  ```c++\n  #define FMT_USE_GRISU 1\n  #include <fmt/format.h>\n\n  auto s = fmt::format(\"{}\", 4.2); // formats 4.2 using Grisu\n  ```\n\n  With Grisu enabled, {fmt} is 13x faster than `std::ostringstream`\n  (libc++) and 10x faster than `sprintf` on\n  [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) ([full\n  results](https://fmt.dev/unknown_mac64_clang10.0.html)):\n\n  ![](https://user-images.githubusercontent.com/576385/54883977-9fe8c000-4e28-11e9-8bde-272d122e7c52.jpg)\n\n- Separated formatting and parsing contexts for consistency with\n  [C++20 std::format](http://eel.is/c++draft/format), removing the\n  undocumented `basic_format_context::parse_context()` function.\n\n- Added [oss-fuzz](https://github.com/google/oss-fuzz) support\n  (https://github.com/fmtlib/fmt/pull/1199). Thanks @pauldreik.\n\n- `formatter` specializations now always take precedence over\n  `operator<<` (https://github.com/fmtlib/fmt/issues/952):\n\n  ```c++\n  #include <iostream>\n  #include <fmt/ostream.h>\n\n  struct S {};\n\n  std::ostream& operator<<(std::ostream& os, S) {\n    return os << 1;\n  }\n\n  template <>\n  struct fmt::formatter<S> : fmt::formatter<int> {\n    auto format(S, format_context& ctx) {\n      return formatter<int>::format(2, ctx);\n    }\n  };\n\n  int main() {\n    std::cout << S() << \"\\n\"; // prints 1 using operator<<\n    fmt::print(\"{}\\n\", S());  // prints 2 using formatter\n  }\n  ```\n\n- Introduced the experimental `fmt::compile` function that does format\n  string compilation\n  (https://github.com/fmtlib/fmt/issues/618,\n  https://github.com/fmtlib/fmt/issues/1169,\n  https://github.com/fmtlib/fmt/pull/1171):\n\n  ```c++\n  #include <fmt/compile.h>\n\n  auto f = fmt::compile<int>(\"{}\");\n  std::string s = fmt::format(f, 42); // can be called multiple times to\n                                      // format different values\n  // s == \"42\"\n  ```\n\n  It moves the cost of parsing a format string outside of the format\n  function which can be beneficial when identically formatting many\n  objects of the same types. Thanks @stryku.\n\n- Added experimental `%` format specifier that formats floating-point\n  values as percentages\n  (https://github.com/fmtlib/fmt/pull/1060,\n  https://github.com/fmtlib/fmt/pull/1069,\n  https://github.com/fmtlib/fmt/pull/1071):\n\n  ```c++\n  auto s = fmt::format(\"{:.1%}\", 0.42); // s == \"42.0%\"\n  ```\n\n  Thanks @gawain-bolton.\n\n- Implemented precision for floating-point durations\n  (https://github.com/fmtlib/fmt/issues/1004,\n  https://github.com/fmtlib/fmt/pull/1012):\n\n  ```c++\n  auto s = fmt::format(\"{:.1}\", std::chrono::duration<double>(1.234));\n  // s == 1.2s\n  ```\n\n  Thanks @DanielaE.\n\n- Implemented `chrono` format specifiers `%Q` and `%q` that give the\n  value and the unit respectively\n  (https://github.com/fmtlib/fmt/pull/1019):\n\n  ```c++\n  auto value = fmt::format(\"{:%Q}\", 42s); // value == \"42\"\n  auto unit  = fmt::format(\"{:%q}\", 42s); // unit == \"s\"\n  ```\n\n  Thanks @DanielaE.\n\n- Fixed handling of dynamic width in chrono formatter:\n\n  ```c++\n  auto s = fmt::format(\"{0:{1}%H:%M:%S}\", std::chrono::seconds(12345), 12);\n  //                        ^ width argument index                     ^ width\n  // s == \"03:25:45    \"\n  ```\n\n  Thanks Howard Hinnant.\n\n- Removed deprecated `fmt/time.h`. Use `fmt/chrono.h` instead.\n\n- Added `fmt::format` and `fmt::vformat` overloads that take\n  `text_style` (https://github.com/fmtlib/fmt/issues/993,\n  https://github.com/fmtlib/fmt/pull/994):\n\n  ```c++\n  #include <fmt/color.h>\n\n  std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),\n                                    \"The answer is {}.\", 42);\n  ```\n\n  Thanks @Naios.\n\n- Removed the deprecated color API (`print_colored`). Use the new API,\n  namely `print` overloads that take `text_style` instead.\n\n- Made `std::unique_ptr` and `std::shared_ptr` formattable as pointers\n  via `fmt::ptr` (https://github.com/fmtlib/fmt/pull/1121):\n\n  ```c++\n  std::unique_ptr<int> p = ...;\n  fmt::print(\"{}\", fmt::ptr(p)); // prints p as a pointer\n  ```\n\n  Thanks @sighingnow.\n\n- Made `print` and `vprint` report I/O errors\n  (https://github.com/fmtlib/fmt/issues/1098,\n  https://github.com/fmtlib/fmt/pull/1099). Thanks @BillyDonahue.\n\n- Marked deprecated APIs with the `[[deprecated]]` attribute and\n  removed internal uses of deprecated APIs\n  (https://github.com/fmtlib/fmt/pull/1022). Thanks @eliaskosunen.\n\n- Modernized the codebase using more C++11 features and removing\n  workarounds. Most importantly, `buffer_context` is now an alias\n  template, so use `buffer_context<T>` instead of\n  `buffer_context<T>::type`. These features require GCC 4.8 or later.\n\n- `formatter` specializations now always take precedence over implicit\n  conversions to `int` and the undocumented `convert_to_int` trait is\n  now deprecated.\n\n- Moved the undocumented `basic_writer`, `writer`, and `wwriter` types\n  to the `internal` namespace.\n\n- Removed deprecated `basic_format_context::begin()`. Use `out()`\n  instead.\n\n- Disallowed passing the result of `join` as an lvalue to prevent\n  misuse.\n\n- Refactored the undocumented structs that represent parsed format\n  specifiers to simplify the API and allow multibyte fill.\n\n- Moved SFINAE to template parameters to reduce symbol sizes.\n\n- Switched to `fputws` for writing wide strings so that it\\'s no\n  longer required to call `_setmode` on Windows\n  (https://github.com/fmtlib/fmt/issues/1229,\n  https://github.com/fmtlib/fmt/pull/1243). Thanks @jackoalan.\n\n- Improved literal-based API\n  (https://github.com/fmtlib/fmt/pull/1254). Thanks @sylveon.\n\n- Added support for exotic platforms without `uintptr_t` such as IBM i\n  (AS/400) which has 128-bit pointers and only 64-bit integers\n  (https://github.com/fmtlib/fmt/issues/1059).\n\n- Added [Sublime Text syntax highlighting config](\n  https://github.com/fmtlib/fmt/blob/master/support/C%2B%2B.sublime-syntax)\n  (https://github.com/fmtlib/fmt/issues/1037). Thanks @Kronuz.\n\n- Added the `FMT_ENFORCE_COMPILE_STRING` macro to enforce the use of\n  compile-time format strings\n  (https://github.com/fmtlib/fmt/pull/1231). Thanks @jackoalan.\n\n- Stopped setting `CMAKE_BUILD_TYPE` if {fmt} is a subproject\n  (https://github.com/fmtlib/fmt/issues/1081).\n\n- Various build improvements\n  (https://github.com/fmtlib/fmt/pull/1039,\n  https://github.com/fmtlib/fmt/pull/1078,\n  https://github.com/fmtlib/fmt/pull/1091,\n  https://github.com/fmtlib/fmt/pull/1103,\n  https://github.com/fmtlib/fmt/pull/1177).\n  Thanks @luncliff, @jasonszang, @olafhering, @Lecetem and @pauldreik.\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/1049,\n  https://github.com/fmtlib/fmt/pull/1051,\n  https://github.com/fmtlib/fmt/pull/1083,\n  https://github.com/fmtlib/fmt/pull/1113,\n  https://github.com/fmtlib/fmt/pull/1114,\n  https://github.com/fmtlib/fmt/issues/1146,\n  https://github.com/fmtlib/fmt/issues/1180,\n  https://github.com/fmtlib/fmt/pull/1250,\n  https://github.com/fmtlib/fmt/pull/1252,\n  https://github.com/fmtlib/fmt/pull/1265).\n  Thanks @mikelui, @foonathan, @BillyDonahue, @jwakely, @kaisbe and\n  @sdebionne.\n\n- Fixed ambiguous formatter specialization in `fmt/ranges.h`\n  (https://github.com/fmtlib/fmt/issues/1123).\n\n- Fixed formatting of a non-empty `std::filesystem::path` which is an\n  infinitely deep range of its components\n  (https://github.com/fmtlib/fmt/issues/1268).\n\n- Fixed handling of general output iterators when formatting\n  characters (https://github.com/fmtlib/fmt/issues/1056,\n  https://github.com/fmtlib/fmt/pull/1058). Thanks @abolz.\n\n- Fixed handling of output iterators in `formatter` specialization for\n  ranges (https://github.com/fmtlib/fmt/issues/1064).\n\n- Fixed handling of exotic character types\n  (https://github.com/fmtlib/fmt/issues/1188).\n\n- Made chrono formatting work with exceptions disabled\n  (https://github.com/fmtlib/fmt/issues/1062).\n\n- Fixed DLL visibility issues\n  (https://github.com/fmtlib/fmt/pull/1134,\n  https://github.com/fmtlib/fmt/pull/1147). Thanks @denchat.\n\n- Disabled the use of UDL template extension on GCC 9\n  (https://github.com/fmtlib/fmt/issues/1148).\n\n- Removed misplaced `format` compile-time checks from `printf`\n  (https://github.com/fmtlib/fmt/issues/1173).\n\n- Fixed issues in the experimental floating-point formatter\n  (https://github.com/fmtlib/fmt/issues/1072,\n  https://github.com/fmtlib/fmt/issues/1129,\n  https://github.com/fmtlib/fmt/issues/1153,\n  https://github.com/fmtlib/fmt/pull/1155,\n  https://github.com/fmtlib/fmt/issues/1210,\n  https://github.com/fmtlib/fmt/issues/1222). Thanks @alabuzhev.\n\n- Fixed bugs discovered by fuzzing or during fuzzing integration\n  (https://github.com/fmtlib/fmt/issues/1124,\n  https://github.com/fmtlib/fmt/issues/1127,\n  https://github.com/fmtlib/fmt/issues/1132,\n  https://github.com/fmtlib/fmt/pull/1135,\n  https://github.com/fmtlib/fmt/issues/1136,\n  https://github.com/fmtlib/fmt/issues/1141,\n  https://github.com/fmtlib/fmt/issues/1142,\n  https://github.com/fmtlib/fmt/issues/1178,\n  https://github.com/fmtlib/fmt/issues/1179,\n  https://github.com/fmtlib/fmt/issues/1194). Thanks @pauldreik.\n\n- Fixed building tests on FreeBSD and Hurd\n  (https://github.com/fmtlib/fmt/issues/1043). Thanks @jackyf.\n\n- Fixed various warnings and compilation issues\n  (https://github.com/fmtlib/fmt/pull/998,\n  https://github.com/fmtlib/fmt/pull/1006,\n  https://github.com/fmtlib/fmt/issues/1008,\n  https://github.com/fmtlib/fmt/issues/1011,\n  https://github.com/fmtlib/fmt/issues/1025,\n  https://github.com/fmtlib/fmt/pull/1027,\n  https://github.com/fmtlib/fmt/pull/1028,\n  https://github.com/fmtlib/fmt/pull/1029,\n  https://github.com/fmtlib/fmt/pull/1030,\n  https://github.com/fmtlib/fmt/pull/1031,\n  https://github.com/fmtlib/fmt/pull/1054,\n  https://github.com/fmtlib/fmt/issues/1063,\n  https://github.com/fmtlib/fmt/pull/1068,\n  https://github.com/fmtlib/fmt/pull/1074,\n  https://github.com/fmtlib/fmt/pull/1075,\n  https://github.com/fmtlib/fmt/pull/1079,\n  https://github.com/fmtlib/fmt/pull/1086,\n  https://github.com/fmtlib/fmt/issues/1088,\n  https://github.com/fmtlib/fmt/pull/1089,\n  https://github.com/fmtlib/fmt/pull/1094,\n  https://github.com/fmtlib/fmt/issues/1101,\n  https://github.com/fmtlib/fmt/pull/1102,\n  https://github.com/fmtlib/fmt/issues/1105,\n  https://github.com/fmtlib/fmt/pull/1107,\n  https://github.com/fmtlib/fmt/issues/1115,\n  https://github.com/fmtlib/fmt/issues/1117,\n  https://github.com/fmtlib/fmt/issues/1118,\n  https://github.com/fmtlib/fmt/issues/1120,\n  https://github.com/fmtlib/fmt/issues/1123,\n  https://github.com/fmtlib/fmt/pull/1139,\n  https://github.com/fmtlib/fmt/issues/1140,\n  https://github.com/fmtlib/fmt/issues/1143,\n  https://github.com/fmtlib/fmt/pull/1144,\n  https://github.com/fmtlib/fmt/pull/1150,\n  https://github.com/fmtlib/fmt/pull/1151,\n  https://github.com/fmtlib/fmt/issues/1152,\n  https://github.com/fmtlib/fmt/issues/1154,\n  https://github.com/fmtlib/fmt/issues/1156,\n  https://github.com/fmtlib/fmt/pull/1159,\n  https://github.com/fmtlib/fmt/issues/1175,\n  https://github.com/fmtlib/fmt/issues/1181,\n  https://github.com/fmtlib/fmt/issues/1186,\n  https://github.com/fmtlib/fmt/pull/1187,\n  https://github.com/fmtlib/fmt/pull/1191,\n  https://github.com/fmtlib/fmt/issues/1197,\n  https://github.com/fmtlib/fmt/issues/1200,\n  https://github.com/fmtlib/fmt/issues/1203,\n  https://github.com/fmtlib/fmt/issues/1205,\n  https://github.com/fmtlib/fmt/pull/1206,\n  https://github.com/fmtlib/fmt/issues/1213,\n  https://github.com/fmtlib/fmt/issues/1214,\n  https://github.com/fmtlib/fmt/pull/1217,\n  https://github.com/fmtlib/fmt/issues/1228,\n  https://github.com/fmtlib/fmt/pull/1230,\n  https://github.com/fmtlib/fmt/issues/1232,\n  https://github.com/fmtlib/fmt/pull/1235,\n  https://github.com/fmtlib/fmt/pull/1236,\n  https://github.com/fmtlib/fmt/issues/1240).\n  Thanks @DanielaE, @mwinterb, @eliaskosunen, @morinmorin, @ricco19,\n  @waywardmonkeys, @chronoxor, @remyabel, @pauldreik, @gsjaardema, @rcane,\n  @mocabe, @denchat, @cjdb, @HazardyKnusperkeks, @vedranmiletic, @jackoalan,\n  @DaanDeMeyer and @starkmapper.\n\n# 5.3.0 - 2018-12-28\n\n- Introduced experimental chrono formatting support:\n\n  ```c++\n  #include <fmt/chrono.h>\n\n  int main() {\n    using namespace std::literals::chrono_literals;\n    fmt::print(\"Default format: {} {}\\n\", 42s, 100ms);\n    fmt::print(\"strftime-like format: {:%H:%M:%S}\\n\", 3h + 15min + 30s);\n  }\n  ```\n\n  prints:\n\n      Default format: 42s 100ms\n      strftime-like format: 03:15:30\n\n- Added experimental support for emphasis (bold, italic, underline,\n  strikethrough), colored output to a file stream, and improved\n  colored formatting API\n  (https://github.com/fmtlib/fmt/pull/961,\n  https://github.com/fmtlib/fmt/pull/967,\n  https://github.com/fmtlib/fmt/pull/973):\n\n  ```c++\n  #include <fmt/color.h>\n\n  int main() {\n    fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,\n               \"Hello, {}!\\n\", \"world\");\n    fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |\n               fmt::emphasis::underline, \"Olá, {}!\\n\", \"Mundo\");\n    fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,\n               \"你好{}！\\n\", \"世界\");\n  }\n  ```\n\n  prints the following on modern terminals with RGB color support:\n\n  ![](https://github.com/fmtlib/fmt/assets/%0A576385/2a93c904-d6fa-4aa6-b453-2618e1c327d7)\n\n  Thanks @Rakete1111.\n\n- Added support for 4-bit terminal colors\n  (https://github.com/fmtlib/fmt/issues/968,\n  https://github.com/fmtlib/fmt/pull/974)\n\n  ```c++\n  #include <fmt/color.h>\n\n  int main() {\n    print(fg(fmt::terminal_color::red), \"stop\\n\");\n  }\n  ```\n\n  Note that these colors vary by terminal:\n\n  ![](https://user-images.githubusercontent.com/576385/50405925-dbfc7e00-0770-11e9-9b85-333fab0af9ac.png)\n\n  Thanks @Rakete1111.\n\n- Parameterized formatting functions on the type of the format string\n  (https://github.com/fmtlib/fmt/issues/880,\n  https://github.com/fmtlib/fmt/pull/881,\n  https://github.com/fmtlib/fmt/pull/883,\n  https://github.com/fmtlib/fmt/pull/885,\n  https://github.com/fmtlib/fmt/pull/897,\n  https://github.com/fmtlib/fmt/issues/920). Any object of\n  type `S` that has an overloaded `to_string_view(const S&)` returning\n  `fmt::string_view` can be used as a format string:\n\n  ```c++\n  namespace my_ns {\n  inline string_view to_string_view(const my_string& s) {\n    return {s.data(), s.length()};\n  }\n  }\n\n  std::string message = fmt::format(my_string(\"The answer is {}.\"), 42);\n  ```\n\n  Thanks @DanielaE.\n\n- Made `std::string_view` work as a format string\n  (https://github.com/fmtlib/fmt/pull/898):\n\n  ```c++\n  auto message = fmt::format(std::string_view(\"The answer is {}.\"), 42);\n  ```\n\n  Thanks @DanielaE.\n\n- Added wide string support to compile-time format string checks\n  (https://github.com/fmtlib/fmt/pull/924):\n\n  ```c++\n  print(fmt(L\"{:f}\"), 42); // compile-time error: invalid type specifier\n  ```\n\n  Thanks @XZiar.\n\n- Made colored print functions work with wide strings\n  (https://github.com/fmtlib/fmt/pull/867):\n\n  ```c++\n  #include <fmt/color.h>\n\n  int main() {\n    print(fg(fmt::color::red), L\"{}\\n\", 42);\n  }\n  ```\n\n  Thanks @DanielaE.\n\n- Introduced experimental Unicode support\n  (https://github.com/fmtlib/fmt/issues/628,\n  https://github.com/fmtlib/fmt/pull/891):\n\n  ```c++\n  using namespace fmt::literals;\n  auto s = fmt::format(\"{:*^5}\"_u, \"🤡\"_u); // s == \"**🤡**\"_u\n  ```\n\n- Improved locale support:\n\n  ```c++\n  #include <fmt/locale.h>\n\n  struct numpunct : std::numpunct<char> {\n   protected:\n    char do_thousands_sep() const override { return '~'; }\n  };\n\n  std::locale loc;\n  auto s = fmt::format(std::locale(loc, new numpunct()), \"{:n}\", 1234567);\n  // s == \"1~234~567\"\n  ```\n\n- Constrained formatting functions on proper iterator types\n  (https://github.com/fmtlib/fmt/pull/921). Thanks @DanielaE.\n\n- Added `make_printf_args` and `make_wprintf_args` functions\n  (https://github.com/fmtlib/fmt/pull/934). Thanks @tnovotny.\n\n- Deprecated `fmt::visit`, `parse_context`, and `wparse_context`. Use\n  `fmt::visit_format_arg`, `format_parse_context`, and\n  `wformat_parse_context` instead.\n\n- Removed undocumented `basic_fixed_buffer` which has been superseded\n  by the iterator-based API\n  (https://github.com/fmtlib/fmt/issues/873,\n  https://github.com/fmtlib/fmt/pull/902). Thanks @superfunc.\n\n- Disallowed repeated leading zeros in an argument ID:\n\n  ```c++\n  fmt::print(\"{000}\", 42); // error\n  ```\n\n- Reintroduced support for gcc 4.4.\n\n- Fixed compilation on platforms with exotic `double`\n  (https://github.com/fmtlib/fmt/issues/878).\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/issues/164,\n  https://github.com/fmtlib/fmt/issues/877,\n  https://github.com/fmtlib/fmt/pull/901,\n  https://github.com/fmtlib/fmt/pull/906,\n  https://github.com/fmtlib/fmt/pull/979).\n  Thanks @kookjr, @DarkDimius and @HecticSerenity.\n\n- Added pkgconfig support which makes it easier to consume the library\n  from meson and other build systems\n  (https://github.com/fmtlib/fmt/pull/916). Thanks @colemickens.\n\n- Various build improvements\n  (https://github.com/fmtlib/fmt/pull/909,\n  https://github.com/fmtlib/fmt/pull/926,\n  https://github.com/fmtlib/fmt/pull/937,\n  https://github.com/fmtlib/fmt/pull/953,\n  https://github.com/fmtlib/fmt/pull/959).\n  Thanks @tchaikov, @luncliff, @AndreasSchoenle, @hotwatermorning and @Zefz.\n\n- Improved `string_view` construction performance\n  (https://github.com/fmtlib/fmt/pull/914). Thanks @gabime.\n\n- Fixed non-matching char types\n  (https://github.com/fmtlib/fmt/pull/895). Thanks @DanielaE.\n\n- Fixed `format_to_n` with `std::back_insert_iterator`\n  (https://github.com/fmtlib/fmt/pull/913). Thanks @DanielaE.\n\n- Fixed locale-dependent formatting\n  (https://github.com/fmtlib/fmt/issues/905).\n\n- Fixed various compiler warnings and errors\n  (https://github.com/fmtlib/fmt/pull/882,\n  https://github.com/fmtlib/fmt/pull/886,\n  https://github.com/fmtlib/fmt/pull/933,\n  https://github.com/fmtlib/fmt/pull/941,\n  https://github.com/fmtlib/fmt/issues/931,\n  https://github.com/fmtlib/fmt/pull/943,\n  https://github.com/fmtlib/fmt/pull/954,\n  https://github.com/fmtlib/fmt/pull/956,\n  https://github.com/fmtlib/fmt/pull/962,\n  https://github.com/fmtlib/fmt/issues/965,\n  https://github.com/fmtlib/fmt/issues/977,\n  https://github.com/fmtlib/fmt/pull/983,\n  https://github.com/fmtlib/fmt/pull/989).\n  Thanks @Luthaf, @stevenhoving, @christinaa, @lgritz, @DanielaE,\n  @0x8000-0000 and @liuping1997.\n\n# 5.2.1 - 2018-09-21\n\n- Fixed `visit` lookup issues on gcc 7 & 8\n  (https://github.com/fmtlib/fmt/pull/870). Thanks @medithe.\n- Fixed linkage errors on older gcc.\n- Prevented `fmt/range.h` from specializing `fmt::basic_string_view`\n  (https://github.com/fmtlib/fmt/issues/865,\n  https://github.com/fmtlib/fmt/pull/868). Thanks @hhggit.\n- Improved error message when formatting unknown types\n  (https://github.com/fmtlib/fmt/pull/872). Thanks @foonathan.\n- Disabled templated user-defined literals when compiled under nvcc\n  (https://github.com/fmtlib/fmt/pull/875). Thanks @CandyGumdrop.\n- Fixed `format_to` formatting to `wmemory_buffer`\n  (https://github.com/fmtlib/fmt/issues/874).\n\n# 5.2.0 - 2018-09-13\n\n- Optimized format string parsing and argument processing which\n  resulted in up to 5x speed up on long format strings and significant\n  performance boost on various benchmarks. For example, version 5.2 is\n  2.22x faster than 5.1 on decimal integer formatting with `format_to`\n  (macOS, clang-902.0.39.2):\n\n  | Method                     | Time, s         | Speedup |\n  | -------------------------- | --------------: | ------: |\n  | fmt::format 5.1            | 0.58            |         |\n  | fmt::format 5.2            | 0.35            |   1.66x |\n  | fmt::format_to 5.1         | 0.51            |         |\n  | fmt::format_to 5.2         | 0.23            |   2.22x |\n  | sprintf                    | 0.71            |         |\n  | std::to_string             | 1.01            |         |\n  | std::stringstream          | 1.73            |         |\n\n- Changed the `fmt` macro from opt-out to opt-in to prevent name\n  collisions. To enable it define the `FMT_STRING_ALIAS` macro to 1\n  before including `fmt/format.h`:\n\n  ```c++\n  #define FMT_STRING_ALIAS 1\n  #include <fmt/format.h>\n  std::string answer = format(fmt(\"{}\"), 42);\n  ```\n\n- Added compile-time format string checks to `format_to` overload that\n  takes `fmt::memory_buffer`\n  (https://github.com/fmtlib/fmt/issues/783):\n\n  ```c++\n  fmt::memory_buffer buf;\n  // Compile-time error: invalid type specifier.\n  fmt::format_to(buf, fmt(\"{:d}\"), \"foo\");\n  ```\n\n- Moved experimental color support to `fmt/color.h` and enabled the\n  new API by default. The old API can be enabled by defining the\n  `FMT_DEPRECATED_COLORS` macro.\n\n- Added formatting support for types explicitly convertible to\n  `fmt::string_view`:\n\n  ```c++\n  struct foo {\n    explicit operator fmt::string_view() const { return \"foo\"; }\n  };\n  auto s = format(\"{}\", foo());\n  ```\n\n  In particular, this makes formatting function work with\n  `folly::StringPiece`.\n\n- Implemented preliminary support for `char*_t` by replacing the\n  `format` function overloads with a single function template\n  parameterized on the string type.\n\n- Added support for dynamic argument lists\n  (https://github.com/fmtlib/fmt/issues/814,\n  https://github.com/fmtlib/fmt/pull/819). Thanks @MikePopoloski.\n\n- Reduced executable size overhead for embedded targets using newlib\n  nano by making locale dependency optional\n  (https://github.com/fmtlib/fmt/pull/839). Thanks @teajay-fr.\n\n- Keep `noexcept` specifier when exceptions are disabled\n  (https://github.com/fmtlib/fmt/issues/801,\n  https://github.com/fmtlib/fmt/pull/810). Thanks @qis.\n\n- Fixed formatting of user-defined types providing `operator<<` with\n  `format_to_n` (https://github.com/fmtlib/fmt/pull/806).\n  Thanks @mkurdej.\n\n- Fixed dynamic linkage of new symbols\n  (https://github.com/fmtlib/fmt/issues/808).\n\n- Fixed global initialization issue\n  (https://github.com/fmtlib/fmt/issues/807):\n\n  ```c++\n  // This works on compilers with constexpr support.\n  static const std::string answer = fmt::format(\"{}\", 42);\n  ```\n\n- Fixed various compiler warnings and errors\n  (https://github.com/fmtlib/fmt/pull/804,\n  https://github.com/fmtlib/fmt/issues/809,\n  https://github.com/fmtlib/fmt/pull/811,\n  https://github.com/fmtlib/fmt/issues/822,\n  https://github.com/fmtlib/fmt/pull/827,\n  https://github.com/fmtlib/fmt/issues/830,\n  https://github.com/fmtlib/fmt/pull/838,\n  https://github.com/fmtlib/fmt/issues/843,\n  https://github.com/fmtlib/fmt/pull/844,\n  https://github.com/fmtlib/fmt/issues/851,\n  https://github.com/fmtlib/fmt/pull/852,\n  https://github.com/fmtlib/fmt/pull/854).\n  Thanks @henryiii, @medithe, and @eliasdaler.\n\n# 5.1.0 - 2018-07-05\n\n- Added experimental support for RGB color output enabled with the\n  `FMT_EXTENDED_COLORS` macro:\n\n  ```c++\n  #define FMT_EXTENDED_COLORS\n  #define FMT_HEADER_ONLY // or compile fmt with FMT_EXTENDED_COLORS defined\n  #include <fmt/format.h>\n\n  fmt::print(fmt::color::steel_blue, \"Some beautiful text\");\n  ```\n\n  The old API (the `print_colored` and `vprint_colored` functions and\n  the `color` enum) is now deprecated.\n  (https://github.com/fmtlib/fmt/issues/762\n  https://github.com/fmtlib/fmt/pull/767). thanks @Remotion.\n\n- Added quotes to strings in ranges and tuples\n  (https://github.com/fmtlib/fmt/pull/766). Thanks @Remotion.\n\n- Made `format_to` work with `basic_memory_buffer`\n  (https://github.com/fmtlib/fmt/issues/776).\n\n- Added `vformat_to_n` and `wchar_t` overload of `format_to_n`\n  (https://github.com/fmtlib/fmt/issues/764,\n  https://github.com/fmtlib/fmt/issues/769).\n\n- Made `is_range` and `is_tuple_like` part of public (experimental)\n  API to allow specialization for user-defined types\n  (https://github.com/fmtlib/fmt/issues/751,\n  https://github.com/fmtlib/fmt/pull/759). Thanks @drrlvn.\n\n- Added more compilers to continuous integration and increased\n  `FMT_PEDANTIC` warning levels\n  (https://github.com/fmtlib/fmt/pull/736). Thanks @eliaskosunen.\n\n- Fixed compilation with MSVC 2013.\n\n- Fixed handling of user-defined types in `format_to`\n  (https://github.com/fmtlib/fmt/issues/793).\n\n- Forced linking of inline `vformat` functions into the library\n  (https://github.com/fmtlib/fmt/issues/795).\n\n- Fixed incorrect call to on_align in `'{:}='`\n  (https://github.com/fmtlib/fmt/issues/750).\n\n- Fixed floating-point formatting to a non-back_insert_iterator with\n  sign & numeric alignment specified\n  (https://github.com/fmtlib/fmt/issues/756).\n\n- Fixed formatting to an array with `format_to_n`\n  (https://github.com/fmtlib/fmt/issues/778).\n\n- Fixed formatting of more than 15 named arguments\n  (https://github.com/fmtlib/fmt/issues/754).\n\n- Fixed handling of compile-time strings when including\n  `fmt/ostream.h`. (https://github.com/fmtlib/fmt/issues/768).\n\n- Fixed various compiler warnings and errors\n  (https://github.com/fmtlib/fmt/issues/742,\n  https://github.com/fmtlib/fmt/issues/748,\n  https://github.com/fmtlib/fmt/issues/752,\n  https://github.com/fmtlib/fmt/issues/770,\n  https://github.com/fmtlib/fmt/pull/775,\n  https://github.com/fmtlib/fmt/issues/779,\n  https://github.com/fmtlib/fmt/pull/780,\n  https://github.com/fmtlib/fmt/pull/790,\n  https://github.com/fmtlib/fmt/pull/792,\n  https://github.com/fmtlib/fmt/pull/800).\n  Thanks @Remotion, @gabime, @foonathan, @Dark-Passenger and @0x8000-0000.\n\n# 5.0.0 - 2018-05-21\n\n- Added a requirement for partial C++11 support, most importantly\n  variadic templates and type traits, and dropped `FMT_VARIADIC_*`\n  emulation macros. Variadic templates are available since GCC 4.4,\n  Clang 2.9 and MSVC 18.0 (2013). For older compilers use {fmt}\n  [version 4.x](https://github.com/fmtlib/fmt/releases/tag/4.1.0)\n  which continues to be maintained and works with C++98 compilers.\n\n- Renamed symbols to follow standard C++ naming conventions and\n  proposed a subset of the library for standardization in [P0645R2\n  Text Formatting](https://wg21.link/P0645).\n\n- Implemented `constexpr` parsing of format strings and [compile-time\n  format string\n  checks](https://fmt.dev/latest/api.html#compile-time-format-string-checks).\n  For example\n\n  ```c++\n  #include <fmt/format.h>\n\n  std::string s = format(fmt(\"{:d}\"), \"foo\");\n  ```\n\n  gives a compile-time error because `d` is an invalid specifier for\n  strings ([godbolt](https://godbolt.org/g/rnCy9Q)):\n\n      ...\n      <source>:4:19: note: in instantiation of function template specialization 'fmt::v5::format<S, char [4]>' requested here\n        std::string s = format(fmt(\"{:d}\"), \"foo\");\n                        ^\n      format.h:1337:13: note: non-constexpr function 'on_error' cannot be used in a constant expression\n          handler.on_error(\"invalid type specifier\");\n\n  Compile-time checks require relaxed `constexpr` (C++14 feature)\n  support. If the latter is not available, checks will be performed at\n  runtime.\n\n- Separated format string parsing and formatting in the extension API\n  to enable compile-time format string processing. For example\n\n  ```c++\n  struct Answer {};\n\n  namespace fmt {\n  template <>\n  struct formatter<Answer> {\n    constexpr auto parse(parse_context& ctx) {\n      auto it = ctx.begin();\n      spec = *it;\n      if (spec != 'd' && spec != 's')\n        throw format_error(\"invalid specifier\");\n      return ++it;\n    }\n\n    template <typename FormatContext>\n    auto format(Answer, FormatContext& ctx) {\n      return spec == 's' ?\n        format_to(ctx.begin(), \"{}\", \"fourty-two\") :\n        format_to(ctx.begin(), \"{}\", 42);\n    }\n\n    char spec = 0;\n  };\n  }\n\n  std::string s = format(fmt(\"{:x}\"), Answer());\n  ```\n\n  gives a compile-time error due to invalid format specifier\n  ([godbolt](https://godbolt.org/g/2jQ1Dv)):\n\n      ...\n      <source>:12:45: error: expression '<throw-expression>' is not a constant expression\n             throw format_error(\"invalid specifier\");\n\n- Added [iterator\n  support](https://fmt.dev/latest/api.html#output-iterator-support):\n\n  ```c++\n  #include <vector>\n  #include <fmt/format.h>\n\n  std::vector<char> out;\n  fmt::format_to(std::back_inserter(out), \"{}\", 42);\n  ```\n\n- Added the\n  [format_to_n](https://fmt.dev/latest/api.html#_CPPv2N3fmt11format_to_nE8OutputItNSt6size_tE11string_viewDpRK4Args)\n  function that restricts the output to the specified number of\n  characters (https://github.com/fmtlib/fmt/issues/298):\n\n  ```c++\n  char out[4];\n  fmt::format_to_n(out, sizeof(out), \"{}\", 12345);\n  // out == \"1234\" (without terminating '\\0')\n  ```\n\n- Added the [formatted_size](\n  https://fmt.dev/latest/api.html#_CPPv2N3fmt14formatted_sizeE11string_viewDpRK4Args)\n  function for computing the output size:\n\n  ```c++\n  #include <fmt/format.h>\n\n  auto size = fmt::formatted_size(\"{}\", 12345); // size == 5\n  ```\n\n- Improved compile times by reducing dependencies on standard headers\n  and providing a lightweight [core\n  API](https://fmt.dev/latest/api.html#core-api):\n\n  ```c++\n  #include <fmt/core.h>\n\n  fmt::print(\"The answer is {}.\", 42);\n  ```\n\n  See [Compile time and code\n  bloat](https://github.com/fmtlib/fmt#compile-time-and-code-bloat).\n\n- Added the [make_format_args](\n  https://fmt.dev/latest/api.html#_CPPv2N3fmt16make_format_argsEDpRK4Args)\n  function for capturing formatting arguments:\n\n  ```c++\n  // Prints formatted error message.\n  void vreport_error(const char *format, fmt::format_args args) {\n    fmt::print(\"Error: \");\n    fmt::vprint(format, args);\n  }\n  template <typename... Args>\n  void report_error(const char *format, const Args & ... args) {\n    vreport_error(format, fmt::make_format_args(args...));\n  }\n  ```\n\n- Added the `make_printf_args` function for capturing `printf`\n  arguments (https://github.com/fmtlib/fmt/issues/687,\n  https://github.com/fmtlib/fmt/pull/694). Thanks @Kronuz.\n\n- Added prefix `v` to non-variadic functions taking `format_args` to\n  distinguish them from variadic ones:\n\n  ```c++\n  std::string vformat(string_view format_str, format_args args);\n\n  template <typename... Args>\n  std::string format(string_view format_str, const Args & ... args);\n  ```\n\n- Added experimental support for formatting ranges, containers and\n  tuple-like types in `fmt/ranges.h`\n  (https://github.com/fmtlib/fmt/pull/735):\n\n  ```c++\n  #include <fmt/ranges.h>\n\n  std::vector<int> v = {1, 2, 3};\n  fmt::print(\"{}\", v); // prints {1, 2, 3}\n  ```\n\n  Thanks @Remotion.\n\n- Implemented `wchar_t` date and time formatting\n  (https://github.com/fmtlib/fmt/pull/712):\n\n  ```c++\n  #include <fmt/time.h>\n\n  std::time_t t = std::time(nullptr);\n  auto s = fmt::format(L\"The date is {:%Y-%m-%d}.\", *std::localtime(&t));\n  ```\n\n  Thanks @DanielaE.\n\n- Provided more wide string overloads\n  (https://github.com/fmtlib/fmt/pull/724). Thanks @DanielaE.\n\n- Switched from a custom null-terminated string view class to\n  `string_view` in the format API and provided `fmt::string_view`\n  which implements a subset of `std::string_view` API for pre-C++17\n  systems.\n\n- Added support for `std::experimental::string_view`\n  (https://github.com/fmtlib/fmt/pull/607):\n\n  ```c++\n  #include <fmt/core.h>\n  #include <experimental/string_view>\n\n  fmt::print(\"{}\", std::experimental::string_view(\"foo\"));\n  ```\n\n  Thanks @virgiliofornazin.\n\n- Allowed mixing named and automatic arguments:\n\n  ```c++\n  fmt::format(\"{} {two}\", 1, fmt::arg(\"two\", 2));\n  ```\n\n- Removed the write API in favor of the [format\n  API](https://fmt.dev/latest/api.html#format-api) with compile-time\n  handling of format strings.\n\n- Disallowed formatting of multibyte strings into a wide character\n  target (https://github.com/fmtlib/fmt/pull/606).\n\n- Improved documentation\n  (https://github.com/fmtlib/fmt/pull/515,\n  https://github.com/fmtlib/fmt/issues/614,\n  https://github.com/fmtlib/fmt/pull/617,\n  https://github.com/fmtlib/fmt/pull/661,\n  https://github.com/fmtlib/fmt/pull/680).\n  Thanks @ibell, @mihaitodor and @johnthagen.\n\n- Implemented more efficient handling of large number of format\n  arguments.\n\n- Introduced an inline namespace for symbol versioning.\n\n- Added debug postfix `d` to the `fmt` library name\n  (https://github.com/fmtlib/fmt/issues/636).\n\n- Removed unnecessary `fmt/` prefix in includes\n  (https://github.com/fmtlib/fmt/pull/397). Thanks @chronoxor.\n\n- Moved `fmt/*.h` to `include/fmt/*.h` to prevent irrelevant files and\n  directories appearing on the include search paths when fmt is used\n  as a subproject and moved source files to the `src` directory.\n\n- Added qmake project file `support/fmt.pro`\n  (https://github.com/fmtlib/fmt/pull/641). Thanks @cowo78.\n\n- Added Gradle build file `support/build.gradle`\n  (https://github.com/fmtlib/fmt/pull/649). Thanks @luncliff.\n\n- Removed `FMT_CPPFORMAT` CMake option.\n\n- Fixed a name conflict with the macro `CHAR_WIDTH` in glibc\n  (https://github.com/fmtlib/fmt/pull/616). Thanks @aroig.\n\n- Fixed handling of nested braces in `fmt::join`\n  (https://github.com/fmtlib/fmt/issues/638).\n\n- Added `SOURCELINK_SUFFIX` for compatibility with Sphinx 1.5\n  (https://github.com/fmtlib/fmt/pull/497). Thanks @ginggs.\n\n- Added a missing `inline` in the header-only mode\n  (https://github.com/fmtlib/fmt/pull/626). Thanks @aroig.\n\n- Fixed various compiler warnings\n  (https://github.com/fmtlib/fmt/pull/640,\n  https://github.com/fmtlib/fmt/pull/656,\n  https://github.com/fmtlib/fmt/pull/679,\n  https://github.com/fmtlib/fmt/pull/681,\n  https://github.com/fmtlib/fmt/pull/705,\n  https://github.com/fmtlib/fmt/issues/715,\n  https://github.com/fmtlib/fmt/pull/717,\n  https://github.com/fmtlib/fmt/pull/720,\n  https://github.com/fmtlib/fmt/pull/723,\n  https://github.com/fmtlib/fmt/pull/726,\n  https://github.com/fmtlib/fmt/pull/730,\n  https://github.com/fmtlib/fmt/pull/739).\n  Thanks @peterbell10, @LarsGullik, @foonathan, @eliaskosunen,\n  @christianparpart, @DanielaE and @mwinterb.\n\n- Worked around an MSVC bug and fixed several warnings\n  (https://github.com/fmtlib/fmt/pull/653). Thanks @alabuzhev.\n\n- Worked around GCC bug 67371\n  (https://github.com/fmtlib/fmt/issues/682).\n\n- Fixed compilation with `-fno-exceptions`\n  (https://github.com/fmtlib/fmt/pull/655). Thanks @chenxiaolong.\n\n- Made `constexpr remove_prefix` gcc version check tighter\n  (https://github.com/fmtlib/fmt/issues/648).\n\n- Renamed internal type enum constants to prevent collision with\n  poorly written C libraries\n  (https://github.com/fmtlib/fmt/issues/644).\n\n- Added detection of `wostream operator<<`\n  (https://github.com/fmtlib/fmt/issues/650).\n\n- Fixed compilation on OpenBSD\n  (https://github.com/fmtlib/fmt/pull/660). Thanks @hubslave.\n\n- Fixed compilation on FreeBSD 12\n  (https://github.com/fmtlib/fmt/pull/732). Thanks @dankm.\n\n- Fixed compilation when there is a mismatch between `-std` options\n  between the library and user code\n  (https://github.com/fmtlib/fmt/issues/664).\n\n- Fixed compilation with GCC 7 and `-std=c++11`\n  (https://github.com/fmtlib/fmt/issues/734).\n\n- Improved generated binary code on GCC 7 and older\n  (https://github.com/fmtlib/fmt/issues/668).\n\n- Fixed handling of numeric alignment with no width\n  (https://github.com/fmtlib/fmt/issues/675).\n\n- Fixed handling of empty strings in UTF8/16 converters\n  (https://github.com/fmtlib/fmt/pull/676). Thanks @vgalka-sl.\n\n- Fixed formatting of an empty `string_view`\n  (https://github.com/fmtlib/fmt/issues/689).\n\n- Fixed detection of `string_view` on libc++\n  (https://github.com/fmtlib/fmt/issues/686).\n\n- Fixed DLL issues (https://github.com/fmtlib/fmt/pull/696).\n  Thanks @sebkoenig.\n\n- Fixed compile checks for mixing narrow and wide strings\n  (https://github.com/fmtlib/fmt/issues/690).\n\n- Disabled unsafe implicit conversion to `std::string`\n  (https://github.com/fmtlib/fmt/issues/729).\n\n- Fixed handling of reused format specs (as in `fmt::join`) for\n  pointers (https://github.com/fmtlib/fmt/pull/725). Thanks @mwinterb.\n\n- Fixed installation of `fmt/ranges.h`\n  (https://github.com/fmtlib/fmt/pull/738). Thanks @sv1990.\n\n# 4.1.0 - 2017-12-20\n\n- Added `fmt::to_wstring()` in addition to `fmt::to_string()`\n  (https://github.com/fmtlib/fmt/pull/559). Thanks @alabuzhev.\n- Added support for C++17 `std::string_view`\n  (https://github.com/fmtlib/fmt/pull/571 and\n  https://github.com/fmtlib/fmt/pull/578).\n  Thanks @thelostt and @mwinterb.\n- Enabled stream exceptions to catch errors\n  (https://github.com/fmtlib/fmt/issues/581). Thanks @crusader-mike.\n- Allowed formatting of class hierarchies with `fmt::format_arg()`\n  (https://github.com/fmtlib/fmt/pull/547). Thanks @rollbear.\n- Removed limitations on character types\n  (https://github.com/fmtlib/fmt/pull/563). Thanks @Yelnats321.\n- Conditionally enabled use of `std::allocator_traits`\n  (https://github.com/fmtlib/fmt/pull/583). Thanks @mwinterb.\n- Added support for `const` variadic member function emulation with\n  `FMT_VARIADIC_CONST`\n  (https://github.com/fmtlib/fmt/pull/591). Thanks @ludekvodicka.\n- Various bugfixes: bad overflow check, unsupported implicit type\n  conversion when determining formatting function, test segfaults\n  (https://github.com/fmtlib/fmt/issues/551), ill-formed\n  macros (https://github.com/fmtlib/fmt/pull/542) and\n  ambiguous overloads\n  (https://github.com/fmtlib/fmt/issues/580). Thanks @xylosper.\n- Prevented warnings on MSVC\n  (https://github.com/fmtlib/fmt/pull/605,\n  https://github.com/fmtlib/fmt/pull/602, and\n  https://github.com/fmtlib/fmt/pull/545), clang\n  (https://github.com/fmtlib/fmt/pull/582), GCC\n  (https://github.com/fmtlib/fmt/issues/573), various\n  conversion warnings (https://github.com/fmtlib/fmt/pull/609,\n  https://github.com/fmtlib/fmt/pull/567,\n  https://github.com/fmtlib/fmt/pull/553 and\n  https://github.com/fmtlib/fmt/pull/553), and added\n  `override` and `[[noreturn]]`\n  (https://github.com/fmtlib/fmt/pull/549 and\n  https://github.com/fmtlib/fmt/issues/555).\n  Thanks @alabuzhev, @virgiliofornazin, @alexanderbock, @yumetodo, @VaderY,\n  @jpcima, @thelostt and @Manu343726.\n- Improved CMake: Used `GNUInstallDirs` to set installation location\n  (https://github.com/fmtlib/fmt/pull/610) and fixed warnings\n  (https://github.com/fmtlib/fmt/pull/536 and\n  https://github.com/fmtlib/fmt/pull/556).\n  Thanks @mikecrowe, @evgen231 and @henryiii.\n\n# 4.0.0 - 2017-06-27\n\n- Removed old compatibility headers `cppformat/*.h` and CMake options\n  (https://github.com/fmtlib/fmt/pull/527). Thanks @maddinat0r.\n\n- Added `string.h` containing `fmt::to_string()` as alternative to\n  `std::to_string()` as well as other string writer functionality\n  (https://github.com/fmtlib/fmt/issues/326 and\n  https://github.com/fmtlib/fmt/pull/441):\n\n  ```c++\n  #include \"fmt/string.h\"\n\n  std::string answer = fmt::to_string(42);\n  ```\n\n  Thanks @glebov-andrey.\n\n- Moved `fmt::printf()` to new `printf.h` header and allowed `%s` as\n  generic specifier (https://github.com/fmtlib/fmt/pull/453),\n  made `%.f` more conformant to regular `printf()`\n  (https://github.com/fmtlib/fmt/pull/490), added custom\n  writer support (https://github.com/fmtlib/fmt/issues/476)\n  and implemented missing custom argument formatting\n  (https://github.com/fmtlib/fmt/pull/339 and\n  https://github.com/fmtlib/fmt/pull/340):\n\n  ```c++\n  #include \"fmt/printf.h\"\n\n  // %s format specifier can be used with any argument type.\n  fmt::printf(\"%s\", 42);\n  ```\n\n  Thanks @mojoBrendan, @manylegged and @spacemoose.\n  See also https://github.com/fmtlib/fmt/issues/360,\n  https://github.com/fmtlib/fmt/issues/335 and\n  https://github.com/fmtlib/fmt/issues/331.\n\n- Added `container.h` containing a `BasicContainerWriter` to write to\n  containers like `std::vector`\n  (https://github.com/fmtlib/fmt/pull/450). Thanks @polyvertex.\n\n- Added `fmt::join()` function that takes a range and formats its\n  elements separated by a given string\n  (https://github.com/fmtlib/fmt/pull/466):\n\n  ```c++\n  #include \"fmt/format.h\"\n\n  std::vector<double> v = {1.2, 3.4, 5.6};\n  // Prints \"(+01.20, +03.40, +05.60)\".\n  fmt::print(\"({:+06.2f})\", fmt::join(v.begin(), v.end(), \", \"));\n  ```\n\n  Thanks @olivier80.\n\n- Added support for custom formatting specifications to simplify\n  customization of built-in formatting\n  (https://github.com/fmtlib/fmt/pull/444). Thanks @polyvertex.\n  See also https://github.com/fmtlib/fmt/issues/439.\n\n- Added `fmt::format_system_error()` for error code formatting\n  (https://github.com/fmtlib/fmt/issues/323 and\n  https://github.com/fmtlib/fmt/pull/526). Thanks @maddinat0r.\n\n- Added thread-safe `fmt::localtime()` and `fmt::gmtime()` as\n  replacement for the standard version to `time.h`\n  (https://github.com/fmtlib/fmt/pull/396). Thanks @codicodi.\n\n- Internal improvements to `NamedArg` and `ArgLists`\n  (https://github.com/fmtlib/fmt/pull/389 and\n  https://github.com/fmtlib/fmt/pull/390). Thanks @chronoxor.\n\n- Fixed crash due to bug in `FormatBuf`\n  (https://github.com/fmtlib/fmt/pull/493). Thanks @effzeh. See also\n  https://github.com/fmtlib/fmt/issues/480 and\n  https://github.com/fmtlib/fmt/issues/491.\n\n- Fixed handling of wide strings in `fmt::StringWriter`.\n\n- Improved compiler error messages\n  (https://github.com/fmtlib/fmt/issues/357).\n\n- Fixed various warnings and issues with various compilers\n  (https://github.com/fmtlib/fmt/pull/494,\n  https://github.com/fmtlib/fmt/pull/499,\n  https://github.com/fmtlib/fmt/pull/483,\n  https://github.com/fmtlib/fmt/pull/485,\n  https://github.com/fmtlib/fmt/pull/482,\n  https://github.com/fmtlib/fmt/pull/475,\n  https://github.com/fmtlib/fmt/pull/473 and\n  https://github.com/fmtlib/fmt/pull/414).\n  Thanks @chronoxor, @zhaohuaxishi, @pkestene, @dschmidt and @0x414c.\n\n- Improved CMake: targets are now namespaced\n  (https://github.com/fmtlib/fmt/pull/511 and\n  https://github.com/fmtlib/fmt/pull/513), supported\n  header-only `printf.h`\n  (https://github.com/fmtlib/fmt/pull/354), fixed issue with\n  minimal supported library subset\n  (https://github.com/fmtlib/fmt/issues/418,\n  https://github.com/fmtlib/fmt/pull/419 and\n  https://github.com/fmtlib/fmt/pull/420).\n  Thanks @bjoernthiel, @niosHD, @LogicalKnight and @alabuzhev.\n\n- Improved documentation (https://github.com/fmtlib/fmt/pull/393).\n  Thanks @pwm1234.\n\n# 3.0.2 - 2017-06-14\n\n- Added `FMT_VERSION` macro\n  (https://github.com/fmtlib/fmt/issues/411).\n- Used `FMT_NULL` instead of literal `0`\n  (https://github.com/fmtlib/fmt/pull/409). Thanks @alabuzhev.\n- Added extern templates for `format_float`\n  (https://github.com/fmtlib/fmt/issues/413).\n- Fixed implicit conversion issue\n  (https://github.com/fmtlib/fmt/issues/507).\n- Fixed signbit detection\n  (https://github.com/fmtlib/fmt/issues/423).\n- Fixed naming collision\n  (https://github.com/fmtlib/fmt/issues/425).\n- Fixed missing intrinsic for C++/CLI\n  (https://github.com/fmtlib/fmt/pull/457). Thanks @calumr.\n- Fixed Android detection\n  (https://github.com/fmtlib/fmt/pull/458). Thanks @Gachapen.\n- Use lean `windows.h` if not in header-only mode\n  (https://github.com/fmtlib/fmt/pull/503). Thanks @Quentin01.\n- Fixed issue with CMake exporting C++11 flag\n  (https://github.com/fmtlib/fmt/pull/455). Thanks @EricWF.\n- Fixed issue with nvcc and MSVC compiler bug and MinGW\n  (https://github.com/fmtlib/fmt/issues/505).\n- Fixed DLL issues (https://github.com/fmtlib/fmt/pull/469 and\n  https://github.com/fmtlib/fmt/pull/502).\n  Thanks @richardeakin and @AndreasSchoenle.\n- Fixed test compilation under FreeBSD\n  (https://github.com/fmtlib/fmt/issues/433).\n- Fixed various warnings\n  (https://github.com/fmtlib/fmt/pull/403,\n  https://github.com/fmtlib/fmt/pull/410 and\n  https://github.com/fmtlib/fmt/pull/510).\n  Thanks @Lecetem, @chenhayat and @trozen.\n- Worked around a broken `__builtin_clz` in clang with MS codegen\n  (https://github.com/fmtlib/fmt/issues/519).\n- Removed redundant include\n  (https://github.com/fmtlib/fmt/issues/479).\n- Fixed documentation issues.\n\n# 3.0.1 - 2016-11-01\n\n- Fixed handling of thousands separator\n  (https://github.com/fmtlib/fmt/issues/353).\n- Fixed handling of `unsigned char` strings\n  (https://github.com/fmtlib/fmt/issues/373).\n- Corrected buffer growth when formatting time\n  (https://github.com/fmtlib/fmt/issues/367).\n- Removed warnings under MSVC and clang\n  (https://github.com/fmtlib/fmt/issues/318,\n  https://github.com/fmtlib/fmt/issues/250, also merged\n  https://github.com/fmtlib/fmt/pull/385 and\n  https://github.com/fmtlib/fmt/pull/361).\n  Thanks @jcelerier and @nmoehrle.\n- Fixed compilation issues under Android\n  (https://github.com/fmtlib/fmt/pull/327,\n  https://github.com/fmtlib/fmt/issues/345 and\n  https://github.com/fmtlib/fmt/pull/381), FreeBSD\n  (https://github.com/fmtlib/fmt/pull/358), Cygwin\n  (https://github.com/fmtlib/fmt/issues/388), MinGW\n  (https://github.com/fmtlib/fmt/issues/355) as well as other\n  issues (https://github.com/fmtlib/fmt/issues/350,\n  https://github.com/fmtlib/fmt/issues/355,\n  https://github.com/fmtlib/fmt/pull/348,\n  https://github.com/fmtlib/fmt/pull/402,\n  https://github.com/fmtlib/fmt/pull/405).\n  Thanks @dpantele, @hghwng, @arvedarved, @LogicalKnight and @JanHellwig.\n- Fixed some documentation issues and extended specification\n  (https://github.com/fmtlib/fmt/issues/320,\n  https://github.com/fmtlib/fmt/pull/333,\n  https://github.com/fmtlib/fmt/issues/347,\n  https://github.com/fmtlib/fmt/pull/362). Thanks @smellman.\n\n# 3.0.0 - 2016-05-07\n\n- The project has been renamed from C++ Format (cppformat) to fmt for\n  consistency with the used namespace and macro prefix\n  (https://github.com/fmtlib/fmt/issues/307). Library headers\n  are now located in the `fmt` directory:\n\n  ```c++\n  #include \"fmt/format.h\"\n  ```\n\n  Including `format.h` from the `cppformat` directory is deprecated\n  but works via a proxy header which will be removed in the next major\n  version.\n\n  The documentation is now available at <https://fmt.dev>.\n\n- Added support for\n  [strftime](http://en.cppreference.com/w/cpp/chrono/c/strftime)-like\n  [date and time\n  formatting](https://fmt.dev/3.0.0/api.html#date-and-time-formatting)\n  (https://github.com/fmtlib/fmt/issues/283):\n\n  ```c++\n  #include \"fmt/time.h\"\n\n  std::time_t t = std::time(nullptr);\n  // Prints \"The date is 2016-04-29.\" (with the current date)\n  fmt::print(\"The date is {:%Y-%m-%d}.\", *std::localtime(&t));\n  ```\n\n- `std::ostream` support including formatting of user-defined types\n  that provide overloaded `operator<<` has been moved to\n  `fmt/ostream.h`:\n\n  ```c++\n  #include \"fmt/ostream.h\"\n\n  class Date {\n    int year_, month_, day_;\n  public:\n    Date(int year, int month, int day) : year_(year), month_(month), day_(day) {}\n\n    friend std::ostream &operator<<(std::ostream &os, const Date &d) {\n      return os << d.year_ << '-' << d.month_ << '-' << d.day_;\n    }\n  };\n\n  std::string s = fmt::format(\"The date is {}\", Date(2012, 12, 9));\n  // s == \"The date is 2012-12-9\"\n  ```\n\n- Added support for [custom argument\n  formatters](https://fmt.dev/3.0.0/api.html#argument-formatters)\n  (https://github.com/fmtlib/fmt/issues/235).\n\n- Added support for locale-specific integer formatting with the `n`\n  specifier (https://github.com/fmtlib/fmt/issues/305):\n\n  ```c++\n  std::setlocale(LC_ALL, \"en_US.utf8\");\n  fmt::print(\"cppformat: {:n}\\n\", 1234567); // prints 1,234,567\n  ```\n\n- Sign is now preserved when formatting an integer with an incorrect\n  `printf` format specifier\n  (https://github.com/fmtlib/fmt/issues/265):\n\n  ```c++\n  fmt::printf(\"%lld\", -42); // prints -42\n  ```\n\n  Note that it would be an undefined behavior in `std::printf`.\n\n- Length modifiers such as `ll` are now optional in printf formatting\n  functions and the correct type is determined automatically\n  (https://github.com/fmtlib/fmt/issues/255):\n\n  ```c++\n  fmt::printf(\"%d\", std::numeric_limits<long long>::max());\n  ```\n\n  Note that it would be an undefined behavior in `std::printf`.\n\n- Added initial support for custom formatters\n  (https://github.com/fmtlib/fmt/issues/231).\n\n- Fixed detection of user-defined literal support on Intel C++\n  compiler (https://github.com/fmtlib/fmt/issues/311,\n  https://github.com/fmtlib/fmt/pull/312).\n  Thanks @dean0x7d and @speth.\n\n- Reduced compile time\n  (https://github.com/fmtlib/fmt/pull/243,\n  https://github.com/fmtlib/fmt/pull/249,\n  https://github.com/fmtlib/fmt/issues/317):\n\n  ![](https://cloud.githubusercontent.com/assets/4831417/11614060/b9e826d2-9c36-11e5-8666-d4131bf503ef.png)\n\n  ![](https://cloud.githubusercontent.com/assets/4831417/11614080/6ac903cc-9c37-11e5-8165-26df6efae364.png)\n\n  Thanks @dean0x7d.\n\n- Compile test fixes (https://github.com/fmtlib/fmt/pull/313).\n  Thanks @dean0x7d.\n\n- Documentation fixes (https://github.com/fmtlib/fmt/pull/239,\n  https://github.com/fmtlib/fmt/issues/248,\n  https://github.com/fmtlib/fmt/issues/252,\n  https://github.com/fmtlib/fmt/pull/258,\n  https://github.com/fmtlib/fmt/issues/260,\n  https://github.com/fmtlib/fmt/issues/301,\n  https://github.com/fmtlib/fmt/pull/309).\n  Thanks @ReadmeCritic @Gachapen and @jwilk.\n\n- Fixed compiler and sanitizer warnings\n  (https://github.com/fmtlib/fmt/issues/244,\n  https://github.com/fmtlib/fmt/pull/256,\n  https://github.com/fmtlib/fmt/pull/259,\n  https://github.com/fmtlib/fmt/issues/263,\n  https://github.com/fmtlib/fmt/issues/274,\n  https://github.com/fmtlib/fmt/pull/277,\n  https://github.com/fmtlib/fmt/pull/286,\n  https://github.com/fmtlib/fmt/issues/291,\n  https://github.com/fmtlib/fmt/issues/296,\n  https://github.com/fmtlib/fmt/issues/308).\n  Thanks @mwinterb, @pweiskircher and @Naios.\n\n- Improved compatibility with Windows Store apps\n  (https://github.com/fmtlib/fmt/issues/280,\n  https://github.com/fmtlib/fmt/pull/285) Thanks @mwinterb.\n\n- Added tests of compatibility with older C++ standards\n  (https://github.com/fmtlib/fmt/pull/273). Thanks @niosHD.\n\n- Fixed Android build\n  (https://github.com/fmtlib/fmt/pull/271). Thanks @newnon.\n\n- Changed `ArgMap` to be backed by a vector instead of a map.\n  (https://github.com/fmtlib/fmt/issues/261,\n  https://github.com/fmtlib/fmt/pull/262). Thanks @mwinterb.\n\n- Added `fprintf` overload that writes to a `std::ostream`\n  (https://github.com/fmtlib/fmt/pull/251).\n  Thanks @nickhutchinson.\n\n- Export symbols when building a Windows DLL\n  (https://github.com/fmtlib/fmt/pull/245).\n  Thanks @macdems.\n\n- Fixed compilation on Cygwin\n  (https://github.com/fmtlib/fmt/issues/304).\n\n- Implemented a workaround for a bug in Apple LLVM version 4.2 of\n  clang (https://github.com/fmtlib/fmt/issues/276).\n\n- Implemented a workaround for Google Test bug\n  https://github.com/google/googletest/issues/705 on gcc 6\n  (https://github.com/fmtlib/fmt/issues/268). Thanks @octoploid.\n\n- Removed Biicode support because the latter has been discontinued.\n\n# 2.1.1 - 2016-04-11\n\n- The install location for generated CMake files is now configurable\n  via the `FMT_CMAKE_DIR` CMake variable\n  (https://github.com/fmtlib/fmt/pull/299). Thanks @niosHD.\n- Documentation fixes\n  (https://github.com/fmtlib/fmt/issues/252).\n\n# 2.1.0 - 2016-03-21\n\n- Project layout and build system improvements\n  (https://github.com/fmtlib/fmt/pull/267):\n\n  -   The code have been moved to the `cppformat` directory. Including\n      `format.h` from the top-level directory is deprecated but works\n      via a proxy header which will be removed in the next major\n      version.\n  -   C++ Format CMake targets now have proper interface definitions.\n  -   Installed version of the library now supports the header-only\n      configuration.\n  -   Targets `doc`, `install`, and `test` are now disabled if C++\n      Format is included as a CMake subproject. They can be enabled by\n      setting `FMT_DOC`, `FMT_INSTALL`, and `FMT_TEST` in the parent\n      project.\n\n  Thanks @niosHD.\n\n# 2.0.1 - 2016-03-13\n\n- Improved CMake find and package support\n  (https://github.com/fmtlib/fmt/issues/264). Thanks @niosHD.\n- Fix compile error with Android NDK and mingw32\n  (https://github.com/fmtlib/fmt/issues/241). Thanks @Gachapen.\n- Documentation fixes\n  (https://github.com/fmtlib/fmt/issues/248,\n  https://github.com/fmtlib/fmt/issues/260).\n\n# 2.0.0 - 2015-12-01\n\n## General\n\n- \\[Breaking\\] Named arguments\n  (https://github.com/fmtlib/fmt/pull/169,\n  https://github.com/fmtlib/fmt/pull/173,\n  https://github.com/fmtlib/fmt/pull/174):\n\n  ```c++\n  fmt::print(\"The answer is {answer}.\", fmt::arg(\"answer\", 42));\n  ```\n\n  Thanks @jamboree.\n\n- \\[Experimental\\] User-defined literals for format and named\n  arguments (https://github.com/fmtlib/fmt/pull/204,\n  https://github.com/fmtlib/fmt/pull/206,\n  https://github.com/fmtlib/fmt/pull/207):\n\n  ```c++\n  using namespace fmt::literals;\n  fmt::print(\"The answer is {answer}.\", \"answer\"_a=42);\n  ```\n\n  Thanks @dean0x7d.\n\n- \\[Breaking\\] Formatting of more than 16 arguments is now supported\n  when using variadic templates\n  (https://github.com/fmtlib/fmt/issues/141). Thanks @Shauren.\n\n- Runtime width specification\n  (https://github.com/fmtlib/fmt/pull/168):\n\n  ```c++\n  fmt::format(\"{0:{1}}\", 42, 5); // gives \"   42\"\n  ```\n\n  Thanks @jamboree.\n\n- \\[Breaking\\] Enums are now formatted with an overloaded\n  `std::ostream` insertion operator (`operator<<`) if available\n  (https://github.com/fmtlib/fmt/issues/232).\n\n- \\[Breaking\\] Changed default `bool` format to textual, \\\"true\\\" or\n  \\\"false\\\" (https://github.com/fmtlib/fmt/issues/170):\n\n  ```c++\n  fmt::print(\"{}\", true); // prints \"true\"\n  ```\n\n  To print `bool` as a number use numeric format specifier such as\n  `d`:\n\n  ```c++\n  fmt::print(\"{:d}\", true); // prints \"1\"\n  ```\n\n- `fmt::printf` and `fmt::sprintf` now support formatting of `bool`\n  with the `%s` specifier giving textual output, \\\"true\\\" or \\\"false\\\"\n  (https://github.com/fmtlib/fmt/pull/223):\n\n  ```c++\n  fmt::printf(\"%s\", true); // prints \"true\"\n  ```\n\n  Thanks @LarsGullik.\n\n- \\[Breaking\\] `signed char` and `unsigned char` are now formatted as\n  integers by default\n  (https://github.com/fmtlib/fmt/pull/217).\n\n- \\[Breaking\\] Pointers to C strings can now be formatted with the `p`\n  specifier (https://github.com/fmtlib/fmt/pull/223):\n\n  ```c++\n  fmt::print(\"{:p}\", \"test\"); // prints pointer value\n  ```\n\n  Thanks @LarsGullik.\n\n- \\[Breaking\\] `fmt::printf` and `fmt::sprintf` now print null\n  pointers as `(nil)` and null strings as `(null)` for consistency\n  with glibc (https://github.com/fmtlib/fmt/pull/226).\n  Thanks @LarsGullik.\n\n- \\[Breaking\\] `fmt::(s)printf` now supports formatting of objects of\n  user-defined types that provide an overloaded `std::ostream`\n  insertion operator (`operator<<`)\n  (https://github.com/fmtlib/fmt/issues/201):\n\n  ```c++\n  fmt::printf(\"The date is %s\", Date(2012, 12, 9));\n  ```\n\n- \\[Breaking\\] The `Buffer` template is now part of the public API and\n  can be used to implement custom memory buffers\n  (https://github.com/fmtlib/fmt/issues/140). Thanks @polyvertex.\n\n- \\[Breaking\\] Improved compatibility between `BasicStringRef` and\n  [std::experimental::basic_string_view](\n  http://en.cppreference.com/w/cpp/experimental/basic_string_view)\n  (https://github.com/fmtlib/fmt/issues/100,\n  https://github.com/fmtlib/fmt/issues/159,\n  https://github.com/fmtlib/fmt/issues/183):\n\n  -   Comparison operators now compare string content, not pointers\n  -   `BasicStringRef::c_str` replaced by `BasicStringRef::data`\n  -   `BasicStringRef` is no longer assumed to be null-terminated\n\n  References to null-terminated strings are now represented by a new\n  class, `BasicCStringRef`.\n\n- Dependency on pthreads introduced by Google Test is now optional\n  (https://github.com/fmtlib/fmt/issues/185).\n\n- New CMake options `FMT_DOC`, `FMT_INSTALL` and `FMT_TEST` to control\n  generation of `doc`, `install` and `test` targets respectively, on\n  by default (https://github.com/fmtlib/fmt/issues/197,\n  https://github.com/fmtlib/fmt/issues/198,\n  https://github.com/fmtlib/fmt/issues/200). Thanks @maddinat0r.\n\n- `noexcept` is now used when compiling with MSVC2015\n  (https://github.com/fmtlib/fmt/pull/215). Thanks @dmkrepo.\n\n- Added an option to disable use of `windows.h` when\n  `FMT_USE_WINDOWS_H` is defined as 0 before including `format.h`\n  (https://github.com/fmtlib/fmt/issues/171). Thanks @alfps.\n\n- \\[Breaking\\] `windows.h` is now included with `NOMINMAX` unless\n  `FMT_WIN_MINMAX` is defined. This is done to prevent breaking code\n  using `std::min` and `std::max` and only affects the header-only\n  configuration (https://github.com/fmtlib/fmt/issues/152,\n  https://github.com/fmtlib/fmt/pull/153,\n  https://github.com/fmtlib/fmt/pull/154). Thanks @DevO2012.\n\n- Improved support for custom character types\n  (https://github.com/fmtlib/fmt/issues/171). Thanks @alfps.\n\n- Added an option to disable use of IOStreams when `FMT_USE_IOSTREAMS`\n  is defined as 0 before including `format.h`\n  (https://github.com/fmtlib/fmt/issues/205,\n  https://github.com/fmtlib/fmt/pull/208). Thanks @JodiTheTigger.\n\n- Improved detection of `isnan`, `isinf` and `signbit`.\n\n## Optimization\n\n- Made formatting of user-defined types more efficient with a custom\n  stream buffer (https://github.com/fmtlib/fmt/issues/92,\n  https://github.com/fmtlib/fmt/pull/230). Thanks @NotImplemented.\n- Further improved performance of `fmt::Writer` on integer formatting\n  and fixed a minor regression. Now it is \\~7% faster than\n  `karma::generate` on Karma\\'s benchmark\n  (https://github.com/fmtlib/fmt/issues/186).\n- \\[Breaking\\] Reduced [compiled code\n  size](https://github.com/fmtlib/fmt#compile-time-and-code-bloat)\n  (https://github.com/fmtlib/fmt/issues/143,\n  https://github.com/fmtlib/fmt/pull/149).\n\n## Distribution\n\n- \\[Breaking\\] Headers are now installed in\n  `${CMAKE_INSTALL_PREFIX}/include/cppformat`\n  (https://github.com/fmtlib/fmt/issues/178). Thanks @jackyf.\n\n- \\[Breaking\\] Changed the library name from `format` to `cppformat`\n  for consistency with the project name and to avoid potential\n  conflicts (https://github.com/fmtlib/fmt/issues/178).\n  Thanks @jackyf.\n\n- C++ Format is now available in [Debian](https://www.debian.org/)\n  GNU/Linux\n  ([stretch](https://packages.debian.org/source/stretch/cppformat),\n  [sid](https://packages.debian.org/source/sid/cppformat)) and derived\n  distributions such as\n  [Ubuntu](https://launchpad.net/ubuntu/+source/cppformat) 15.10 and\n  later (https://github.com/fmtlib/fmt/issues/155):\n\n      $ sudo apt-get install libcppformat1-dev\n\n  Thanks @jackyf.\n\n- [Packages for Fedora and\n  RHEL](https://admin.fedoraproject.org/pkgdb/package/cppformat/) are\n  now available. Thanks Dave Johansen.\n\n- C++ Format can now be installed via [Homebrew](http://brew.sh/) on\n  OS X (https://github.com/fmtlib/fmt/issues/157):\n\n      $ brew install cppformat\n\n  Thanks @ortho and Anatoliy Bulukin.\n\n## Documentation\n\n- Migrated from ReadTheDocs to GitHub Pages for better responsiveness\n  and reliability (https://github.com/fmtlib/fmt/issues/128).\n  New documentation address is <http://cppformat.github.io/>.\n- Added [Building thedocumentation](\n  https://fmt.dev/2.0.0/usage.html#building-the-documentation)\n  section to the documentation.\n- Documentation build script is now compatible with Python 3 and newer\n  pip versions. (https://github.com/fmtlib/fmt/pull/189,\n  https://github.com/fmtlib/fmt/issues/209).\n  Thanks @JodiTheTigger and @xentec.\n- Documentation fixes and improvements\n  (https://github.com/fmtlib/fmt/issues/36,\n  https://github.com/fmtlib/fmt/issues/75,\n  https://github.com/fmtlib/fmt/issues/125,\n  https://github.com/fmtlib/fmt/pull/160,\n  https://github.com/fmtlib/fmt/pull/161,\n  https://github.com/fmtlib/fmt/issues/162,\n  https://github.com/fmtlib/fmt/issues/165,\n  https://github.com/fmtlib/fmt/issues/210). \n  Thanks @syohex.\n- Fixed out-of-tree documentation build\n  (https://github.com/fmtlib/fmt/issues/177). Thanks @jackyf.\n\n## Fixes\n\n- Fixed `initializer_list` detection\n  (https://github.com/fmtlib/fmt/issues/136). Thanks @Gachapen.\n\n- \\[Breaking\\] Fixed formatting of enums with numeric format\n  specifiers in `fmt::(s)printf`\n  (https://github.com/fmtlib/fmt/issues/131,\n  https://github.com/fmtlib/fmt/issues/139):\n\n  ```c++\n  enum { ANSWER = 42 };\n  fmt::printf(\"%d\", ANSWER);\n  ```\n\n  Thanks @Naios.\n\n- Improved compatibility with old versions of MinGW\n  (https://github.com/fmtlib/fmt/issues/129,\n  https://github.com/fmtlib/fmt/pull/130,\n  https://github.com/fmtlib/fmt/issues/132). Thanks @cstamford.\n\n- Fixed a compile error on MSVC with disabled exceptions\n  (https://github.com/fmtlib/fmt/issues/144).\n\n- Added a workaround for broken implementation of variadic templates\n  in MSVC2012 (https://github.com/fmtlib/fmt/issues/148).\n\n- Placed the anonymous namespace within `fmt` namespace for the\n  header-only configuration (https://github.com/fmtlib/fmt/issues/171).\n  Thanks @alfps.\n\n- Fixed issues reported by Coverity Scan\n  (https://github.com/fmtlib/fmt/issues/187,\n  https://github.com/fmtlib/fmt/issues/192).\n\n- Implemented a workaround for a name lookup bug in MSVC2010\n  (https://github.com/fmtlib/fmt/issues/188).\n\n- Fixed compiler warnings\n  (https://github.com/fmtlib/fmt/issues/95,\n  https://github.com/fmtlib/fmt/issues/96,\n  https://github.com/fmtlib/fmt/pull/114,\n  https://github.com/fmtlib/fmt/issues/135,\n  https://github.com/fmtlib/fmt/issues/142,\n  https://github.com/fmtlib/fmt/issues/145,\n  https://github.com/fmtlib/fmt/issues/146,\n  https://github.com/fmtlib/fmt/issues/158,\n  https://github.com/fmtlib/fmt/issues/163,\n  https://github.com/fmtlib/fmt/issues/175,\n  https://github.com/fmtlib/fmt/issues/190,\n  https://github.com/fmtlib/fmt/pull/191,\n  https://github.com/fmtlib/fmt/issues/194,\n  https://github.com/fmtlib/fmt/pull/196,\n  https://github.com/fmtlib/fmt/issues/216,\n  https://github.com/fmtlib/fmt/pull/218,\n  https://github.com/fmtlib/fmt/pull/220,\n  https://github.com/fmtlib/fmt/pull/229,\n  https://github.com/fmtlib/fmt/issues/233,\n  https://github.com/fmtlib/fmt/issues/234,\n  https://github.com/fmtlib/fmt/pull/236,\n  https://github.com/fmtlib/fmt/issues/281,\n  https://github.com/fmtlib/fmt/issues/289).\n  Thanks @seanmiddleditch, @dixlorenz, @CarterLi, @Naios, @fmatthew5876,\n  @LevskiWeng, @rpopescu, @gabime, @cubicool, @jkflying, @LogicalKnight,\n  @inguin and @Jopie64.\n\n- Fixed portability issues (mostly causing test failures) on ARM,\n  ppc64, ppc64le, s390x and SunOS 5.11 i386\n  (https://github.com/fmtlib/fmt/issues/138,\n  https://github.com/fmtlib/fmt/issues/179,\n  https://github.com/fmtlib/fmt/issues/180,\n  https://github.com/fmtlib/fmt/issues/202,\n  https://github.com/fmtlib/fmt/issues/225, [Red Hat Bugzilla\n  Bug 1260297](https://bugzilla.redhat.com/show_bug.cgi?id=1260297)).\n  Thanks @Naios, @jackyf and Dave Johansen.\n\n- Fixed a name conflict with macro `free` defined in `crtdbg.h` when\n  `_CRTDBG_MAP_ALLOC` is set (https://github.com/fmtlib/fmt/issues/211).\n\n- Fixed shared library build on OS X\n  (https://github.com/fmtlib/fmt/pull/212). Thanks @dean0x7d.\n\n- Fixed an overload conflict on MSVC when `/Zc:wchar_t-` option is\n  specified (https://github.com/fmtlib/fmt/pull/214).\n  Thanks @slavanap.\n\n- Improved compatibility with MSVC 2008\n  (https://github.com/fmtlib/fmt/pull/236). Thanks @Jopie64.\n\n- Improved compatibility with bcc32\n  (https://github.com/fmtlib/fmt/issues/227).\n\n- Fixed `static_assert` detection on Clang\n  (https://github.com/fmtlib/fmt/pull/228). Thanks @dean0x7d.\n\n# 1.1.0 - 2015-03-06\n\n- Added `BasicArrayWriter`, a class template that provides operations\n  for formatting and writing data into a fixed-size array\n  (https://github.com/fmtlib/fmt/issues/105 and\n  https://github.com/fmtlib/fmt/issues/122):\n\n  ```c++\n  char buffer[100];\n  fmt::ArrayWriter w(buffer);\n  w.write(\"The answer is {}\", 42);\n  ```\n\n- Added [0 A.D.](http://play0ad.com/) and [PenUltima Online\n  (POL)](http://www.polserver.com/) to the list of notable projects\n  using C++ Format.\n\n- C++ Format now uses MSVC intrinsics for better formatting performance\n  (https://github.com/fmtlib/fmt/pull/115,\n  https://github.com/fmtlib/fmt/pull/116,\n  https://github.com/fmtlib/fmt/pull/118 and\n  https://github.com/fmtlib/fmt/pull/121). Previously these\n  optimizations where only used on GCC and Clang.\n  Thanks @CarterLi and @objectx.\n\n- CMake install target\n  (https://github.com/fmtlib/fmt/pull/119). Thanks @TrentHouliston.\n\n  You can now install C++ Format with `make install` command.\n\n- Improved [Biicode](http://www.biicode.com/) support\n  (https://github.com/fmtlib/fmt/pull/98 and\n  https://github.com/fmtlib/fmt/pull/104).\n  Thanks @MariadeAnton and @franramirez688.\n\n- Improved support for building with [Android NDK](\n  https://developer.android.com/tools/sdk/ndk/index.html)\n  (https://github.com/fmtlib/fmt/pull/107). Thanks @newnon.\n\n  The [android-ndk-example](https://github.com/fmtlib/android-ndk-example)\n  repository provides and example of using C++ Format with Android NDK:\n\n  ![](https://raw.githubusercontent.com/fmtlib/android-ndk-example/master/screenshot.png)\n\n- Improved documentation of `SystemError` and `WindowsError`\n  (https://github.com/fmtlib/fmt/issues/54).\n\n- Various code improvements\n  (https://github.com/fmtlib/fmt/pull/110,\n  https://github.com/fmtlib/fmt/pull/111\n  https://github.com/fmtlib/fmt/pull/112). Thanks @CarterLi.\n\n- Improved compile-time errors when formatting wide into narrow\n  strings (https://github.com/fmtlib/fmt/issues/117).\n\n- Fixed `BasicWriter::write` without formatting arguments when C++11\n  support is disabled\n  (https://github.com/fmtlib/fmt/issues/109).\n\n- Fixed header-only build on OS X with GCC 4.9\n  (https://github.com/fmtlib/fmt/issues/124).\n\n- Fixed packaging issues (https://github.com/fmtlib/fmt/issues/94).\n\n- Added [changelog](https://github.com/fmtlib/fmt/blob/master/ChangeLog.md)\n  (https://github.com/fmtlib/fmt/issues/103).\n\n# 1.0.0 - 2015-02-05\n\n- Add support for a header-only configuration when `FMT_HEADER_ONLY`\n  is defined before including `format.h`:\n\n  ```c++\n  #define FMT_HEADER_ONLY\n  #include \"format.h\"\n  ```\n\n- Compute string length in the constructor of `BasicStringRef` instead\n  of the `size` method\n  (https://github.com/fmtlib/fmt/issues/79). This eliminates\n  size computation for string literals on reasonable optimizing\n  compilers.\n\n- Fix formatting of types with overloaded `operator <<` for\n  `std::wostream` (https://github.com/fmtlib/fmt/issues/86):\n\n  ```c++\n  fmt::format(L\"The date is {0}\", Date(2012, 12, 9));\n  ```\n\n- Fix linkage of tests on Arch Linux\n  (https://github.com/fmtlib/fmt/issues/89).\n\n- Allow precision specifier for non-float arguments\n  (https://github.com/fmtlib/fmt/issues/90):\n\n  ```c++\n  fmt::print(\"{:.3}\\n\", \"Carpet\"); // prints \"Car\"\n  ```\n\n- Fix build on Android NDK (https://github.com/fmtlib/fmt/issues/93).\n\n- Improvements to documentation build procedure.\n\n- Remove `FMT_SHARED` CMake variable in favor of standard [BUILD_SHARED_LIBS](\n  http://www.cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html).\n\n- Fix error handling in `fmt::fprintf`.\n\n- Fix a number of warnings.\n\n# 0.12.0 - 2014-10-25\n\n- \\[Breaking\\] Improved separation between formatting and buffer\n  management. `Writer` is now a base class that cannot be instantiated\n  directly. The new `MemoryWriter` class implements the default buffer\n  management with small allocations done on stack. So `fmt::Writer`\n  should be replaced with `fmt::MemoryWriter` in variable\n  declarations.\n\n  Old code:\n\n  ```c++\n  fmt::Writer w;\n  ```\n\n  New code:\n\n  ```c++\n  fmt::MemoryWriter w;\n  ```\n\n  If you pass `fmt::Writer` by reference, you can continue to do so:\n\n  ```c++\n  void f(fmt::Writer &w);\n  ```\n\n  This doesn\\'t affect the formatting API.\n\n- Support for custom memory allocators\n  (https://github.com/fmtlib/fmt/issues/69)\n\n- Formatting functions now accept [signed char]{.title-ref} and\n  [unsigned char]{.title-ref} strings as arguments\n  (https://github.com/fmtlib/fmt/issues/73):\n\n  ```c++\n  auto s = format(\"GLSL version: {}\", glGetString(GL_VERSION));\n  ```\n\n- Reduced code bloat. According to the new [benchmark\n  results](https://github.com/fmtlib/fmt#compile-time-and-code-bloat),\n  cppformat is close to `printf` and by the order of magnitude better\n  than Boost Format in terms of compiled code size.\n\n- Improved appearance of the documentation on mobile by using the\n  [Sphinx Bootstrap\n  theme](http://ryan-roemer.github.io/sphinx-bootstrap-theme/):\n\n  | Old | New |\n  | --- | --- |\n  | ![](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) |\n\n# 0.11.0 - 2014-08-21\n\n- Safe printf implementation with a POSIX extension for positional\n  arguments:\n\n  ```c++\n  fmt::printf(\"Elapsed time: %.2f seconds\", 1.23);\n  fmt::printf(\"%1$s, %3$d %2$s\", weekday, month, day);\n  ```\n\n- Arguments of `char` type can now be formatted as integers (Issue\n  https://github.com/fmtlib/fmt/issues/55):\n\n  ```c++\n  fmt::format(\"0x{0:02X}\", 'a');\n  ```\n\n- Deprecated parts of the API removed.\n\n- The library is now built and tested on MinGW with Appveyor in\n  addition to existing test platforms Linux/GCC, OS X/Clang,\n  Windows/MSVC.\n\n# 0.10.0 - 2014-07-01\n\n**Improved API**\n\n- All formatting methods are now implemented as variadic functions\n  instead of using `operator<<` for feeding arbitrary arguments into a\n  temporary formatter object. This works both with C++11 where\n  variadic templates are used and with older standards where variadic\n  functions are emulated by providing lightweight wrapper functions\n  defined with the `FMT_VARIADIC` macro. You can use this macro for\n  defining your own portable variadic functions:\n\n  ```c++\n  void report_error(const char *format, const fmt::ArgList &args) {\n    fmt::print(\"Error: {}\");\n    fmt::print(format, args);\n  }\n  FMT_VARIADIC(void, report_error, const char *)\n\n  report_error(\"file not found: {}\", path);\n  ```\n\n  Apart from a more natural syntax, this also improves performance as\n  there is no need to construct temporary formatter objects and\n  control arguments\\' lifetimes. Because the wrapper functions are\n  very lightweight, this doesn\\'t cause code bloat even in pre-C++11\n  mode.\n\n- Simplified common case of formatting an `std::string`. Now it\n  requires a single function call:\n\n  ```c++\n  std::string s = format(\"The answer is {}.\", 42);\n  ```\n\n  Previously it required 2 function calls:\n\n  ```c++\n  std::string s = str(Format(\"The answer is {}.\") << 42);\n  ```\n\n  Instead of unsafe `c_str` function, `fmt::Writer` should be used\n  directly to bypass creation of `std::string`:\n\n  ```c++\n  fmt::Writer w;\n  w.write(\"The answer is {}.\", 42);\n  w.c_str();  // returns a C string\n  ```\n\n  This doesn\\'t do dynamic memory allocation for small strings and is\n  less error prone as the lifetime of the string is the same as for\n  `std::string::c_str` which is well understood (hopefully).\n\n- Improved consistency in naming functions that are a part of the\n  public API. Now all public functions are lowercase following the\n  standard library conventions. Previously it was a combination of\n  lowercase and CapitalizedWords. Issue\n  https://github.com/fmtlib/fmt/issues/50.\n\n- Old functions are marked as deprecated and will be removed in the\n  next release.\n\n**Other Changes**\n\n- Experimental support for printf format specifications (work in\n  progress):\n\n  ```c++\n  fmt::printf(\"The answer is %d.\", 42);\n  std::string s = fmt::sprintf(\"Look, a %s!\", \"string\");\n  ```\n\n- Support for hexadecimal floating point format specifiers `a` and\n  `A`:\n\n  ```c++\n  print(\"{:a}\", -42.0); // Prints -0x1.5p+5\n  print(\"{:A}\", -42.0); // Prints -0X1.5P+5\n  ```\n\n- CMake option `FMT_SHARED` that specifies whether to build format as\n  a shared library (off by default).\n\n# 0.9.0 - 2014-05-13\n\n- More efficient implementation of variadic formatting functions.\n\n- `Writer::Format` now has a variadic overload:\n\n  ```c++\n  Writer out;\n  out.Format(\"Look, I'm {}!\", \"variadic\");\n  ```\n\n- For efficiency and consistency with other overloads, variadic\n  overload of the `Format` function now returns `Writer` instead of\n  `std::string`. Use the `str` function to convert it to\n  `std::string`:\n\n  ```c++\n  std::string s = str(Format(\"Look, I'm {}!\", \"variadic\"));\n  ```\n\n- Replaced formatter actions with output sinks: `NoAction` -\\>\n  `NullSink`, `Write` -\\> `FileSink`, `ColorWriter` -\\>\n  `ANSITerminalSink`. This improves naming consistency and shouldn\\'t\n  affect client code unless these classes are used directly which\n  should be rarely needed.\n\n- Added `ThrowSystemError` function that formats a message and throws\n  `SystemError` containing the formatted message and system-specific\n  error description. For example, the following code\n\n  ```c++\n  FILE *f = fopen(filename, \"r\");\n  if (!f)\n    ThrowSystemError(errno, \"Failed to open file '{}'\") << filename;\n  ```\n\n  will throw `SystemError` exception with description \\\"Failed to open\n  file \\'\\<filename\\>\\': No such file or directory\\\" if file doesn\\'t\n  exist.\n\n- Support for AppVeyor continuous integration platform.\n\n- `Format` now throws `SystemError` in case of I/O errors.\n\n- Improve test infrastructure. Print functions are now tested by\n  redirecting the output to a pipe.\n\n# 0.8.0 - 2014-04-14\n\n- Initial release\n"
  },
  {
    "path": "doc/LICENSE-exception",
    "content": "Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n--- Optional exception to the license ---\n\nAs an exception, if, as a result of your compiling your source code, portions\nof this Software are embedded into a machine-executable object form of such\nsource code, you may redistribute such embedded portions in such object form\nwithout including the above copyright and permission notices.\n"
  },
  {
    "path": "doc/api.md",
    "content": "# API Reference\n\nThe {fmt} library API consists of the following components:\n\n- [`fmt/base.h`](#base-api): the base API providing main formatting functions\n  for `char`/UTF-8 with C++20 compile-time checks and minimal dependencies\n- [`fmt/format.h`](#format-api): `fmt::format` and other formatting functions\n  as well as locale support\n- [`fmt/ranges.h`](#ranges-api): formatting of ranges and tuples\n- [`fmt/chrono.h`](#chrono-api): date and time formatting\n- [`fmt/std.h`](#std-api): formatters for standard library types\n- [`fmt/compile.h`](#compile-api): format string compilation\n- [`fmt/color.h`](#color-api): terminal colors and text styles\n- [`fmt/os.h`](#os-api): system APIs\n- [`fmt/ostream.h`](#ostream-api): `std::ostream` support\n- [`fmt/args.h`](#args-api): dynamic argument lists\n- [`fmt/printf.h`](#printf-api): safe `printf`\n- [`fmt/xchar.h`](#xchar-api): optional `wchar_t` support\n\nAll functions and types provided by the library reside in namespace `fmt`\nand macros have prefix `FMT_`.\n\n## C++ Module API\n\nWith the C++ module API, the headers listed above don't need to be included.\nYou can use the `import fmt;` statement instead. All other functionality,\nlisted below, remains the same.\n\n## Base API\n\n`fmt/base.h` defines the base API which provides main formatting functions\nfor `char`/UTF-8 with C++20 compile-time checks. It has minimal include\ndependencies for better compile times. This header is only beneficial when\nusing {fmt} as a library (the default) and not in the header-only mode.\nIt also provides `formatter` specializations for the following types:\n\n- `int`, `long long`\n- `unsigned`, `unsigned long long`\n- `float`, `double`, `long double`\n- `bool`\n- `char`\n- `const char*`, [`fmt::string_view`](#basic_string_view)\n- `const void*`\n\nThe following functions use [format string syntax](syntax.md) similar to that\nof [str.format](https://docs.python.org/3/library/stdtypes.html#str.format)\nin Python. They take *fmt* and *args* as arguments.\n\n*fmt* is a format string that contains literal text and replacement fields\nsurrounded by braces `{}`. The fields are replaced with formatted arguments\nin the resulting string. [`fmt::format_string`](#format_string) is a format\nstring which can be implicitly constructed from a string literal or a\n`constexpr` string and is checked at compile time in C++20. To pass a runtime\nformat string wrap it in [`fmt::runtime`](#runtime).\n\n*args* is an argument list representing objects to be formatted.\n\nI/O errors are reported as [`std::system_error`](\nhttps://en.cppreference.com/w/cpp/error/system_error) exceptions unless\nspecified otherwise.\n\n::: print(format_string<T...>, T&&...)\n\n::: print(FILE*, format_string<T...>, T&&...)\n\n::: println(format_string<T...>, T&&...)\n\n::: println(FILE*, format_string<T...>, T&&...)\n\n::: format_to(OutputIt&&, format_string<T...>, T&&...)\n\n::: format_to_n(OutputIt, size_t, format_string<T...>, T&&...)\n\n::: format_to_n_result\n\n::: formatted_size(format_string<T...>, T&&...)\n\n<a id=\"udt\"></a>\n### Formatting User-Defined Types\n\nThe {fmt} library provides formatters for many standard C++ types.\nSee [`fmt/ranges.h`](#ranges-api) for ranges and tuples including standard\ncontainers such as `std::vector`, [`fmt/chrono.h`](#chrono-api) for date and\ntime formatting and [`fmt/std.h`](#std-api) for other standard library types.\n\nThere are two ways to make a user-defined type formattable: providing a\n`format_as` function or specializing the `formatter` struct template.\nFormatting of non-void pointer types is intentionally disallowed and they\ncannot be made formattable via either extension API.\n\nUse `format_as` if you want to make your type formattable as some other\ntype with the same format specifiers. The `format_as` function should\ntake an object of your type and return an object of a formattable type.\nIt should be defined in the same namespace as your type.\n\nExample ([run](https://godbolt.org/z/nvME4arz8)):\n\n    #include <fmt/format.h>\n\n    namespace kevin_namespacy {\n\n    enum class film {\n      house_of_cards, american_beauty, se7en = 7\n    };\n\n    auto format_as(film f) { return fmt::underlying(f); }\n\n    }\n\n    int main() {\n      fmt::print(\"{}\\n\", kevin_namespacy::film::se7en); // Output: 7\n    }\n\nUsing a specialization is more complex, but gives you full control over\nparsing and formatting. To use this method, specialize the `formatter`\nstruct template for your type and implement `parse` and `format`\nmethods.\n\nThe recommended way of defining a formatter is by reusing an existing\none via inheritance or composition. This way you can support standard\nformat specifiers without implementing them yourself. For example:\n\n```c++\n// color.h:\n#include <fmt/base.h>\n\nenum class color {red, green, blue};\n\ntemplate <> struct fmt::formatter<color>: formatter<string_view> {\n  // parse is inherited from formatter<string_view>.\n\n  auto format(color c, format_context& ctx) const\n    -> format_context::iterator;\n};\n```\n\n```c++\n// color.cc:\n#include \"color.h\"\n#include <fmt/format.h>\n\nauto fmt::formatter<color>::format(color c, format_context& ctx) const\n    -> format_context::iterator {\n  string_view name = \"unknown\";\n  switch (c) {\n  case color::red:   name = \"red\"; break;\n  case color::green: name = \"green\"; break;\n  case color::blue:  name = \"blue\"; break;\n  }\n  return formatter<string_view>::format(name, ctx);\n}\n```\n\nNote that `formatter<string_view>::format` is defined in `fmt/format.h`\nso it has to be included in the source file. Since `parse` is inherited\nfrom `formatter<string_view>` it will recognize all string format\nspecifications, for example\n\n```c++\nfmt::format(\"{:>10}\", color::blue)\n```\n\nwill return `\"      blue\"`.\n\n<!-- The experimental `nested_formatter` provides an easy way of applying a\nformatter to one or more subobjects.\n\nFor example:\n\n    #include <fmt/format.h>\n\n    struct point {\n      double x, y;\n    };\n\n    template <>\n    struct fmt::formatter<point> : nested_formatter<double> {\n      auto format(point p, format_context& ctx) const {\n        return write_padded(ctx, [=](auto out) {\n          return format_to(out, \"({}, {})\", this->nested(p.x),\n                           this->nested(p.y));\n        });\n      }\n    };\n\n    int main() {\n      fmt::print(\"[{:>20.2f}]\", point{1, 2});\n    }\n\nprints:\n\n    [          (1.00, 2.00)]\n\nNotice that fill, align and width are applied to the whole object which\nis the recommended behavior while the remaining specifiers apply to\nelements. -->\n\nIn general the formatter has the following form:\n\n    template <> struct fmt::formatter<T> {\n      // Parses format specifiers and stores them in the formatter.\n      //\n      // [ctx.begin(), ctx.end()) is a, possibly empty, character range that\n      // contains a part of the format string starting from the format\n      // specifications to be parsed, e.g. in\n      //\n      //   fmt::format(\"{:f} continued\", ...);\n      //\n      // the range will contain \"f} continued\". The formatter should parse\n      // specifiers until '}' or the end of the range. In this example the\n      // formatter should parse the 'f' specifier and return an iterator\n      // pointing to '}'.\n      constexpr auto parse(format_parse_context& ctx)\n        -> format_parse_context::iterator;\n\n      // Formats value using the parsed format specification stored in this\n      // formatter and writes the output to ctx.out().\n      auto format(const T& value, format_context& ctx) const\n        -> format_context::iterator;\n    };\n\nIt is recommended to at least support fill, align and width that apply\nto the whole object and have the same semantics as in standard\nformatters.\n\nYou can also write a formatter for a hierarchy of classes:\n\n```c++\n// demo.h:\n#include <type_traits>\n#include <fmt/format.h>\n\nstruct A {\n  virtual ~A() {}\n  virtual std::string name() const { return \"A\"; }\n};\n\nstruct B : A {\n  virtual std::string name() const { return \"B\"; }\n};\n\ntemplate <typename T>\nstruct fmt::formatter<T, std::enable_if_t<std::is_base_of_v<A, T>, char>> :\n    fmt::formatter<std::string> {\n  auto format(const A& a, format_context& ctx) const {\n    return formatter<std::string>::format(a.name(), ctx);\n  }\n};\n```\n\n```c++\n// demo.cc:\n#include \"demo.h\"\n#include <fmt/format.h>\n\nint main() {\n  B b;\n  A& a = b;\n  fmt::print(\"{}\", a); // Output: B\n}\n```\n\nProviding both a `formatter` specialization and a `format_as` overload is\ndisallowed.\n\n::: basic_format_parse_context\n\n::: context\n\n::: format_context\n\n### Compile-Time Checks\n\nCompile-time format string checks are enabled by default on compilers\nthat support C++20 `consteval`. On older compilers you can use the\n[FMT_STRING](#legacy-checks) macro defined in `fmt/format.h` instead.\n\nUnused arguments are allowed as in Python's `str.format` and ordinary functions.\n\nSee [Type Erasure](#type-erasure) for an example of how to enable compile-time\nchecks in your own functions with `fmt::format_string` while avoiding template\nbloat.\n\n::: fstring\n\n::: format_string\n\n::: runtime(string_view)\n\n### Type Erasure\n\nYou can create your own formatting function with compile-time checks and\nsmall binary footprint, for example ([run](https://godbolt.org/z/b9Pbasvzc)):\n\n```c++\n#include <fmt/format.h>\n\nvoid vlog(const char* file, int line,\n          fmt::string_view fmt, fmt::format_args args) {\n  fmt::print(\"{}: {}: {}\", file, line, fmt::vformat(fmt, args));\n}\n\ntemplate <typename... T>\nvoid log(const char* file, int line,\n         fmt::format_string<T...> fmt, T&&... args) {\n  vlog(file, line, fmt, fmt::make_format_args(args...));\n}\n\n#define MY_LOG(fmt, ...) log(__FILE__, __LINE__, fmt, __VA_ARGS__)\n\nMY_LOG(\"invalid squishiness: {}\", 42);\n```\n\nNote that `vlog` is not parameterized on argument types which improves\ncompile times and reduces binary code size compared to a fully\nparameterized version.\n\n::: make_format_args(T&...)\n\n::: basic_format_args\n\n::: format_args\n\n::: basic_format_arg\n\n### Named Arguments\n\n::: arg(const char*, const T&)\n\n### Compatibility\n\n::: basic_string_view\n\n::: string_view\n\n## Format API\n\n`fmt/format.h` defines the full format API providing additional\nformatting functions and locale support.\n\n<a id=\"format\"></a>\n::: format(format_string<T...>, T&&...)\n\n::: vformat(string_view, format_args)\n\n::: operator\"\"_a()\n\n### Utilities\n\n::: ptr(T)\n\n::: underlying(Enum)\n\n::: to_string(const T&)\n\n::: group_digits(T)\n\n::: detail::buffer\n\n::: basic_memory_buffer\n\n### System Errors\n\n{fmt} does not use `errno` to communicate errors to the user, but it may\ncall system functions which set `errno`. Users should not make any\nassumptions about the value of `errno` being preserved by library\nfunctions.\n\n::: system_error\n\n::: format_system_error\n\n### Custom Allocators\n\nThe {fmt} library supports custom dynamic memory allocators. A custom\nallocator class can be specified as a template argument to\n[`fmt::basic_memory_buffer`](#basic_memory_buffer):\n\n    using custom_memory_buffer = \n      fmt::basic_memory_buffer<char, fmt::inline_buffer_size, custom_allocator>;\n\nIt is also possible to write a formatting function that uses a custom\nallocator:\n\n    using custom_string =\n      std::basic_string<char, std::char_traits<char>, custom_allocator>;\n\n    auto vformat(custom_allocator alloc, fmt::string_view fmt,\n                 fmt::format_args args) -> custom_string {\n      auto buf = custom_memory_buffer(alloc);\n      fmt::vformat_to(std::back_inserter(buf), fmt, args);\n      return custom_string(buf.data(), buf.size(), alloc);\n    }\n\n    template <typename ...Args>\n    auto format(custom_allocator alloc, fmt::string_view fmt,\n                const Args& ... args) -> custom_string {\n      return vformat(alloc, fmt, fmt::make_format_args(args...));\n    }\n\nThe allocator will be used for the output container only. Formatting\nfunctions normally don't do any allocations for built-in and string\ntypes except for non-default floating-point formatting that occasionally\nfalls back on `sprintf`.\n\n### Locale\n\nAll formatting is locale-independent by default. Use the `'L'` format\nspecifier to insert the appropriate number separator characters from the\nlocale:\n\n    #include <fmt/format.h>\n    #include <locale>\n\n    std::locale::global(std::locale(\"en_US.UTF-8\"));\n    auto s = fmt::format(\"{:L}\", 1000000);  // s == \"1,000,000\"\n\n`fmt/format.h` provides the following overloads of formatting functions\nthat take `std::locale` as a parameter. The locale type is a template\nparameter to avoid the expensive `<locale>` include.\n\n::: format(locale_ref, format_string<T...>, T&&...)\n\n::: format_to(OutputIt, locale_ref, format_string<T...>, T&&...)\n\n::: formatted_size(locale_ref, format_string<T...>, T&&...)\n\n<a id=\"legacy-checks\"></a>\n### Legacy Compile-Time Checks\n\n`FMT_STRING` enables compile-time checks on older compilers. It requires\nC++14 or later and is a no-op in C++11.\n\n::: FMT_STRING\n\nTo force the use of legacy compile-time checks, define the preprocessor\nvariable `FMT_ENFORCE_COMPILE_STRING`. When set, functions accepting\n`FMT_STRING` will fail to compile with regular strings.\n\n<a id=\"ranges-api\"></a>\n## Range and Tuple Formatting\n\n`fmt/ranges.h` provides formatting support for ranges and tuples:\n\n    #include <fmt/ranges.h>\n\n    fmt::print(\"{}\", std::tuple<char, int>{'a', 42});\n    // Output: ('a', 42)\n\nUsing `fmt::join`, you can separate tuple elements with a custom separator:\n\n    #include <fmt/ranges.h>\n\n    auto t = std::tuple<int, char>{1, 'a'};\n    fmt::print(\"{}\", fmt::join(t, \", \"));\n    // Output: 1, a\n\n::: join(Range&&, string_view)\n\n::: join(It, Sentinel, string_view)\n\n::: join(std::initializer_list<T>, string_view)\n\n<a id=\"chrono-api\"></a>\n## Date and Time Formatting\n\n`fmt/chrono.h` provides formatters for\n\n- [`std::chrono::duration`](https://en.cppreference.com/w/cpp/chrono/duration)\n- [`std::chrono::time_point`](\n  https://en.cppreference.com/w/cpp/chrono/time_point)\n- [`std::tm`](https://en.cppreference.com/w/cpp/chrono/c/tm)\n\nThe format syntax is described in [Chrono Format Specifications](syntax.md#\nchrono-format-specifications).\n\n**Example**:\n\n    #include <fmt/chrono.h>\n\n    int main() {\n      auto now = std::chrono::system_clock::now();\n\n      fmt::print(\"The date is {:%Y-%m-%d}.\\n\", now);\n      // Output: The date is 2020-11-07.\n      // (with 2020-11-07 replaced by the current date)\n\n      using namespace std::literals::chrono_literals;\n\n      fmt::print(\"Default format: {} {}\\n\", 42s, 100ms);\n      // Output: Default format: 42s 100ms\n\n      fmt::print(\"strftime-like format: {:%H:%M:%S}\\n\", 3h + 15min + 30s);\n      // Output: strftime-like format: 03:15:30\n    }\n\n::: gmtime(std::time_t)\n\n<a id=\"std-api\"></a>\n## Standard Library Types Formatting\n\n`fmt/std.h` provides formatters for:\n\n- [`std::atomic`](https://en.cppreference.com/w/cpp/atomic/atomic)\n- [`std::atomic_flag`](https://en.cppreference.com/w/cpp/atomic/atomic_flag)\n- [`std::bitset`](https://en.cppreference.com/w/cpp/utility/bitset)\n- [`std::error_code`](https://en.cppreference.com/w/cpp/error/error_code)\n- [`std::exception`](https://en.cppreference.com/w/cpp/error/exception)\n- [`std::filesystem::path`](https://en.cppreference.com/w/cpp/filesystem/path)\n- [`std::monostate`](\n  https://en.cppreference.com/w/cpp/utility/variant/monostate)\n- [`std::optional`](https://en.cppreference.com/w/cpp/utility/optional)\n- [`std::source_location`](\n  https://en.cppreference.com/w/cpp/utility/source_location)\n- [`std::thread::id`](https://en.cppreference.com/w/cpp/thread/thread/id)\n- [`std::variant`](https://en.cppreference.com/w/cpp/utility/variant/variant)\n\n::: ptr(const std::unique_ptr<T, Deleter>&)\n\n::: ptr(const std::shared_ptr<T>&)\n\n### Variants\n\nA `std::variant` can be formatted only if every alternative is\nformattable, and requires the `__cpp_lib_variant` [library\nfeature](https://en.cppreference.com/w/cpp/feature_test).\n\n**Example**:\n\n    #include <fmt/std.h>\n\n    fmt::print(\"{}\", std::variant<char, float>('x'));\n    // Output: variant('x')\n\n    fmt::print(\"{}\", std::variant<std::monostate, char>());\n    // Output: variant(monostate)\n\n## Bit-Fields and Packed Structs\n\nTo format a bit-field or a field of a struct with `__attribute__((packed))`\napplied to it, you need to convert it to the underlying or compatible type via\na cast or a unary `+` ([godbolt](https://www.godbolt.org/z/3qKKs6T5Y)):\n\n```c++\nstruct smol {\n  int bit : 1;\n};\n\nauto s = smol();\nfmt::print(\"{}\", +s.bit);\n```\n\nThis is a known limitation of \"perfect\" forwarding in C++.\n\n<a id=\"compile-api\"></a>\n## Compile-Time Support\n\n`fmt/compile.h` provides format string compilation and compile-time\n(`constexpr`) formatting enabled via the `FMT_COMPILE` macro or the `_cf`\nuser-defined literal defined in namespace `fmt::literals`. Format strings\nmarked with `FMT_COMPILE` or `_cf` are parsed, checked and converted into\nefficient formatting code at compile-time. This supports arguments of built-in\nand string types as well as user-defined types with `format` methods taking\nthe format context type as a template parameter in their `formatter`\nspecializations. For example ([run](https://www.godbolt.org/z/3c13erEoq)):\n\n    struct point {\n      double x;\n      double y;\n    };\n\n    template <> struct fmt::formatter<point> {\n      constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }\n\n      template <typename FormatContext>\n      auto format(const point& p, FormatContext& ctx) const {\n        return format_to(ctx.out(), \"({}, {})\"_cf, p.x, p.y);\n      }\n    };\n\n    using namespace fmt::literals;\n    std::string s = fmt::format(\"{}\"_cf, point(4, 2));\n\nFormat string compilation can generate more binary code compared to the\ndefault API and is only recommended in places where formatting is a\nperformance bottleneck.\n\nThe same APIs support formatting at compile time e.g. in `constexpr`\nand `consteval` functions. Additionally there is an experimental\n`FMT_STATIC_FORMAT` that allows formatting into a string of the exact\nrequired size at compile time. Compile-time formatting works with built-in\nand user-defined formatters that have `constexpr` `format` methods.\nExample:\n\n    template <> struct fmt::formatter<point> {\n      constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }\n\n      template <typename FormatContext>\n      constexpr auto format(const point& p, FormatContext& ctx) const {\n        return format_to(ctx.out(), \"({}, {})\"_cf, p.x, p.y);\n      }\n    };\n\n    constexpr auto s = FMT_STATIC_FORMAT(\"{}\", point(4, 2));\n    const char* cstr = s.c_str(); // Points the static string \"(4, 2)\".\n\n::: operator\"\"_cf\n\n::: FMT_COMPILE\n\n::: FMT_STATIC_FORMAT\n\n<a id=\"color-api\"></a>\n## Terminal Colors and Text Styles\n\n`fmt/color.h` provides support for terminal color and text style output.\n\n::: print(text_style, format_string<T...>, T&&...)\n\n::: fg(detail::color_type)\n\n::: bg(detail::color_type)\n\n::: styled(const T&, text_style)\n\n<a id=\"os-api\"></a>\n## System APIs\n\n::: ostream\n\n::: output_file(cstring_view, T...)\n\n::: windows_error\n\n<a id=\"ostream-api\"></a>\n## `std::ostream` Support\n\n`fmt/ostream.h` provides `std::ostream` support including formatting of\nuser-defined types that have an overloaded insertion operator\n(`operator<<`). In order to make a type formattable via `std::ostream`\nyou should provide a `formatter` specialization inherited from\n`ostream_formatter`:\n\n    #include <fmt/ostream.h>\n\n    struct date {\n      int year, month, day;\n\n      friend std::ostream& operator<<(std::ostream& os, const date& d) {\n        return os << d.year << '-' << d.month << '-' << d.day;\n      }\n    };\n\n    template <> struct fmt::formatter<date> : ostream_formatter {};\n\n    std::string s = fmt::format(\"The date is {}\", date{2012, 12, 9});\n    // s == \"The date is 2012-12-9\"\n\n::: streamed(const T&)\n\n::: print(std::ostream&, format_string<T...>, T&&...)\n\n<a id=\"args-api\"></a>\n## Dynamic Argument Lists\n\nThe header `fmt/args.h` provides `dynamic_format_arg_store`, a builder-like API\nthat can be used to construct format argument lists dynamically.\n\n::: dynamic_format_arg_store\n\n<a id=\"printf-api\"></a>\n## Safe `printf`\n\nThe header `fmt/printf.h` provides `printf`-like formatting\nfunctionality. The following functions use [printf format string\nsyntax](https://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html)\nwith the POSIX extension for positional arguments. Unlike their standard\ncounterparts, the `fmt` functions are type-safe and throw an exception\nif an argument type doesn't match its format specification.\n\n::: printf(string_view, const T&...)\n\n::: fprintf(std::FILE*, string_view, const T&...)\n\n::: sprintf(string_view, const T&...)\n\n<a id=\"xchar-api\"></a>\n## Wide Strings\n\nThe optional header `fmt/xchar.h` provides support for `wchar_t` and\nexotic character types.\n\n::: wstring_view\n\n::: wformat_context\n\n::: to_wstring(const T&)\n\n## Compatibility with C++20 `std::format`\n\n{fmt} implements nearly all of the [C++20 formatting\nlibrary](https://en.cppreference.com/w/cpp/utility/format) with the\nfollowing differences:\n\n- Names are defined in the `fmt` namespace instead of `std` to avoid\n  collisions with standard library implementations.\n\n- Width calculation doesn't use grapheme clusterization. The latter has\n  been implemented in a separate branch but hasn't been integrated yet.\n\n- The default floating-point representation in {fmt} uses the smallest\n  precision that provides round-trip guarantees similarly to other languages\n  like Java and Python. `std::format` is currently specified in terms of\n  `std::to_chars` which tries to generate the smallest number of characters\n  (ignoring redundant digits and sign in exponent) and may produce more\n  decimal digits than necessary.\n\n## Configuration Options\n\n{fmt} provides configuration via CMake options and preprocessor macros to\nenable or disable features and to optimize for binary size. For example, you\ncan disable OS-specific APIs defined in `fmt/os.h` with `-DFMT_OS=OFF` when\nconfiguring CMake.\n\n### CMake Options\n\n- **`FMT_OS`**: When set to `OFF`, disables OS-specific APIs (`fmt/os.h`).\n- **`FMT_UNICODE`**: When set to `OFF`, disables Unicode support on\n  Windows/MSVC. Unicode support is always enabled on other platforms.\n\n### Macros\n\n- **`FMT_HEADER_ONLY`**: Enables the header-only mode when defined. It is an\n  alternative to using the `fmt::fmt-header-only` CMake target.\n  Default: not defined.\n\n- **`FMT_USE_EXCEPTIONS`**: Disables the use of exceptions when set to `0`.\n  Default: `1` (`0` if compiled with `-fno-exceptions`).\n\n- **`FMT_USE_LOCALE`**: When set to `0`, disables locale support.\n  Default: `1` (`0` when `FMT_OPTIMIZE_SIZE > 1`).\n\n- **`FMT_CUSTOM_ASSERT_FAIL`**: When set to `1`, allows users to provide a\n  custom `fmt::assert_fail` function which is called on assertion failures and,\n  if exceptions are disabled, on runtime errors. Default: `0`.\n\n- **`FMT_BUILTIN_TYPES`**: When set to `0`, disables built-in handling of\n  arithmetic and string types other than `int`. This reduces library size at\n  the cost of per-call overhead. Default: `1`.\n\n- **`FMT_OPTIMIZE_SIZE`**: Controls binary size optimizations:\n    - `0` - off (default)\n    - `1` - disables locale support and applies some optimizations\n    - `2` - disables some Unicode features, named arguments and applies more\n      aggressive optimizations\n\n### Binary Size Optimization\n\nTo minimize the binary footprint of {fmt} as much as possible at the cost of\nsome features, you can use the following configuration:\n\n- CMake options:\n    - `FMT_OS=OFF`\n- Macros:\n    - `FMT_BUILTIN_TYPES=0`\n    - `FMT_OPTIMIZE_SIZE=2`\n"
  },
  {
    "path": "doc/fmt.css",
    "content": ":root {\n  --md-primary-fg-color: #0050D0;\n}\n\n.md-grid {\n  max-width: 960px;\n}\n\n@media (min-width: 400px) {\n  .md-tabs {\n    display: block;\n  }\n}\n\n.docblock {\n  border-left: .05rem solid var(--md-primary-fg-color);\n}\n\n.docblock-desc {\n  margin-left: 1em;\n}\n\ncode,\npre > code.decl {\n  white-space: pre-wrap;\n}\n\n\ncode.decl > div {\n  text-indent: -2ch; /* Negative indent to counteract the indent on the first line */\n  padding-left: 2ch; /* Add padding to the left to create an indent */\n}\n\n.features-container {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 20px;\n  justify-content: center; /* Center the items horizontally */\n}\n\n.feature {\n  flex: 1 1 calc(50% - 20px); /* Two columns with space between */\n  max-width: 600px; /* Set the maximum width for the feature boxes */\n  box-sizing: border-box;\n  padding: 10px;\n  overflow: hidden; /* Hide overflow content */\n  text-overflow: ellipsis; /* Handle text overflow */\n  white-space: normal; /* Allow text wrapping */\n}\n\n.feature h2 {\n  margin-top: 0px;\n  font-weight: bold;\n}\n\n@media (max-width: 768px) {\n  .feature {\n      flex: 1 1 100%; /* Stack columns on smaller screens */\n      max-width: 100%; /* Allow full width on smaller screens */\n      white-space: normal; /* Allow text wrapping on smaller screens */\n  }\n}\n"
  },
  {
    "path": "doc/fmt.js",
    "content": "document$.subscribe(() => {\n  hljs.highlightAll(),\n  { language: 'c++' }\n})\n"
  },
  {
    "path": "doc/get-started.md",
    "content": "# Get Started\n\nCompile and run {fmt} examples online with [Compiler Explorer](\nhttps://godbolt.org/z/P7h6cd6o3).\n\n{fmt} is compatible with any build system. The next section describes its usage\nwith CMake, while the [Build Systems](#build-systems) section covers the rest.\n\n## CMake\n\n{fmt} provides three CMake targets: `fmt::fmt` for the standard compiled library,\n`fmt::fmt-module` for the C++ module library and `fmt::fmt-header-only` for the\nheader-only library. It is recommended to use the compiled library or the module \nlibrary for improved build times. \n\nThere are three primary ways to use {fmt} with CMake:\n\n* **FetchContent**: Starting from CMake 3.11, you can use [`FetchContent`](\n  https://cmake.org/cmake/help/v3.30/module/FetchContent.html) to automatically\n  download {fmt} as a dependency at configure time:\n\n        include(FetchContent)\n\n        FetchContent_Declare(\n          fmt\n          GIT_REPOSITORY https://github.com/fmtlib/fmt\n          GIT_TAG        e69e5f977d458f2650bb346dadf2ad30c5320281) # 10.2.1\n        FetchContent_MakeAvailable(fmt)\n\n        target_link_libraries(<your-target> fmt::fmt)\n\n* **Installed**: You can find and use an [installed](#installation) version of\n  {fmt} in your `CMakeLists.txt` file as follows:\n\n        find_package(fmt)\n        target_link_libraries(<your-target> fmt::fmt)\n\n* **Embedded**: You can add the {fmt} source tree to your project and include it\n  in your `CMakeLists.txt` file:\n\n        add_subdirectory(fmt)\n        target_link_libraries(<your-target> fmt::fmt)\n\n### Alternative Targets\n\nIn order to use the header-only target or the module target, simply substitute the\n`fmt::fmt` in the above steps with `fmt::fmt-header-only` or `fmt::fmt-module` \naccordingly.\n\n## Installation\n\n### Debian/Ubuntu\n\nTo install {fmt} on Debian, Ubuntu, or any other Debian-based Linux\ndistribution, use the following command:\n\n    apt install libfmt-dev\n\n### Homebrew\n\nInstall {fmt} on macOS using [Homebrew](https://brew.sh/):\n\n    brew install fmt\n\n### Conda\n\nInstall {fmt} on Linux, macOS, and Windows with [Conda](\nhttps://docs.conda.io/en/latest/), using its [conda-forge package](\nhttps://github.com/conda-forge/fmt-feedstock):\n\n    conda install -c conda-forge fmt\n\n### vcpkg\n\nDownload and install {fmt} using the vcpkg package manager:\n\n    git clone https://github.com/Microsoft/vcpkg.git\n    cd vcpkg\n    ./bootstrap-vcpkg.sh\n    ./vcpkg integrate install\n    ./vcpkg install fmt\n\n<!-- The fmt package in vcpkg is kept up to date by Microsoft team members and\ncommunity contributors. If the version is out of date, please [create an\nissue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg\nrepository. -->\n\n### Conan\n\nYou can download and install {fmt} using the [Conan](https://conan.io/) package manager:\n\n    conan install -r conancenter --requires=\"fmt/[*]\" --build=missing\n\n<!-- The {fmt} package in Conan Center is maintained by\n[ConanCenterIndex](https://github.com/conan-io/conan-center-index) community.\nIf the version is out of date or the package does not work,\nplease create an issue or pull request on the Conan Center Index repository. -->\n\n## Building from Source\n\nCMake works by generating native makefiles or project files that can be\nused in the compiler environment of your choice. The typical workflow\nstarts with:\n\n    mkdir build  # Create a directory to hold the build output.\n    cd build\n    cmake ..     # Generate native build scripts.\n\nrun in the `fmt` repository.\n\nIf you are on a Unix-like system, you should now see a Makefile in the\ncurrent directory. Now you can build the library by running `make`.\n\nOnce the library has been built you can invoke `make test` to run the tests.\n\nYou can control generation of the make `test` target with the `FMT_TEST`\nCMake option. This can be useful if you include fmt as a subdirectory in\nyour project but don't want to add fmt's tests to your `test` target.\n\nTo build a shared library set the `BUILD_SHARED_LIBS` CMake variable to `TRUE`:\n\n    cmake -DBUILD_SHARED_LIBS=TRUE ..\n\nTo build a static library with position-independent code (e.g. for\nlinking it into another shared library such as a Python extension), set the\n`CMAKE_POSITION_INDEPENDENT_CODE` CMake variable to `TRUE`:\n\n    cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ..\n\nAfter building the library you can install it on a Unix-like system by\nrunning `sudo make install`.\n\n### Building the Docs\n\nTo build the documentation you need the following software installed on\nyour system:\n\n- [Python](https://www.python.org/)\n- [Doxygen](http://www.stack.nl/~dimitri/doxygen/)\n- [MkDocs](https://www.mkdocs.org/) with `mkdocs-material`, `mkdocstrings`,\n  `pymdown-extensions` and `mike`\n\nFirst generate makefiles or project files using CMake as described in\nthe previous section. Then compile the `doc` target/project, for example:\n\n    make doc\n\nThis will generate the HTML documentation in `doc/html`.\n\n## Build Systems\n\n### build2\n\nYou can use [build2](https://build2.org), a dependency manager and a build\nsystem, to use {fmt}.\n\nCurrently this package is available in these package repositories:\n\n- <https://cppget.org/fmt/> for released and published versions.\n- <https://github.com/build2-packaging/fmt> for unreleased or custom versions.\n\n**Usage:**\n\n- `build2` package name: `fmt`\n- Library target name: `lib{fmt}`\n\nTo make your `build2` project depend on `fmt`:\n\n- Add one of the repositories to your configurations, or in your\n  `repositories.manifest`, if not already there:\n\n        :\n        role: prerequisite\n        location: https://pkg.cppget.org/1/stable\n\n- Add this package as a dependency to your `manifest` file (example\n  for version 10):\n\n        depends: fmt ~10.0.0\n\n- Import the target and use it as a prerequisite to your own target\n  using `fmt` in the appropriate `buildfile`:\n\n        import fmt = fmt%lib{fmt}\n        lib{mylib} : cxx{**} ... $fmt\n\nThen build your project as usual with `b` or `bdep update`.\n\n### Meson\n\n[Meson WrapDB](https://mesonbuild.com/Wrapdb-projects.html) includes an `fmt`\npackage.\n\n**Usage:**\n\n- Install the `fmt` subproject from the WrapDB by running:\n\n        meson wrap install fmt\n\n  from the root of your project.\n\n- In your project's `meson.build` file, add an entry for the new subproject:\n\n        fmt = subproject('fmt')\n        fmt_dep = fmt.get_variable('fmt_dep')\n\n- Include the new dependency object to link with fmt:\n\n        my_build_target = executable(\n          'name', 'src/main.cc', dependencies: [fmt_dep])\n\n**Options:**\n\nIf desired, {fmt} can be built as a static library, or as a header-only library.\n\nFor a static build, use the following subproject definition:\n\n    fmt = subproject('fmt', default_options: 'default_library=static')\n    fmt_dep = fmt.get_variable('fmt_dep')\n\nFor the header-only version, use:\n\n    fmt = subproject('fmt', default_options: ['header-only=true'])\n    fmt_dep = fmt.get_variable('fmt_header_only_dep')\n\n### Android NDK\n\n{fmt} provides [Android.mk file](\nhttps://github.com/fmtlib/fmt/blob/master/support/Android.mk) that can be used\nto build the library with [Android NDK](\nhttps://developer.android.com/tools/sdk/ndk/index.html).\n\n### Other\n\nTo use the {fmt} library with any other build system, add\n`include/fmt/base.h`, `include/fmt/format.h`, `include/fmt/format-inl.h`,\n`src/format.cc` and optionally other headers from a [release archive](\nhttps://github.com/fmtlib/fmt/releases) or the [git repository](\nhttps://github.com/fmtlib/fmt) to your project, add `include` to include\ndirectories and make sure `src/format.cc` is compiled and linked with your code.\n"
  },
  {
    "path": "doc/index.md",
    "content": "---\nhide:\n  - navigation\n  - toc\n---\n\n# A modern formatting library\n\n<div class=\"features-container\">\n\n<div class=\"feature\">\n<h2>Safety</h2>\n<p>\n  Inspired by Python's formatting facility, {fmt} provides a safe replacement\n  for the <code>printf</code> family of functions. Errors in format strings,\n  which are a common source of vulnerabilities in C, are <b>reported at\n  compile time</b>. For example:\n\n  <pre><code class=\"language-cpp\"\n  >fmt::format(\"{:d}\", \"I am not a number\");</code></pre>\n\n  will give a compile-time error because <code>d</code> is not a valid\n  format specifier for strings. APIs like <a href=\"api/#format\">\n  <code>fmt::format</code></a> <b>prevent buffer overflow errors</b> via\n  automatic memory management.\n</p>\n<a href=\"api#compile-time-checks\">→ Learn more</a>\n</div>\n\n<div class=\"feature\">\n<h2>Extensibility</h2>\n<p>\n  Formatting of most <b>standard types</b>, including all containers, dates,\n  and times is <b>supported out-of-the-box</b>. For example:\n  \n  <pre><code class=\"language-cpp\"\n  >fmt::print(\"{}\", std::vector{1, 2, 3});</code></pre>\n\n  prints the vector in a JSON-like format:\n\n  <pre><code>[1, 2, 3]</code></pre>\n\n  You can <b>make your own types formattable</b> and even make compile-time\n  checks work for them.\n</p>\n<a href=\"api#udt\">→ Learn more</a>\n</div>\n\n<div class=\"feature\">\n<h2>Performance</h2>\n<p>\n  {fmt} can be anywhere from <b>tens of percent to 20-30 times faster</b> than\n  iostreams and <code>sprintf</code>, especially for numeric formatting.\n\n<a href=\"https://github.com/fmtlib/fmt?tab=readme-ov-file#benchmarks\">\n<img src=\"perf.svg\">\n</a>\n\n  The library <b>minimizes dynamic memory allocations</b> and can optionally\n  <a href=\"api#compile-api\">compile format strings</a> to optimal code.\n</p>\n</div>\n\n<div class=\"feature\">\n<h2>Unicode support</h2>\n<p>\n  {fmt} provides <b>portable Unicode support</b> on major operating systems\n  with UTF-8 and <code>char</code> strings. For example:\n\n  <pre><code class=\"language-cpp\"\n  >fmt::print(\"Слава Україні!\");</code></pre>\n\n  will be printed correctly on Linux, macOS, and even Windows console,\n  irrespective of the codepages.\n</p>\n<p>\n  The default is <b>locale-independent</b>, but you can opt into localized\n  formatting and {fmt} makes it work with Unicode, addressing issues in the\n  standard library.\n</p>\n</div>\n\n<div class=\"feature\">\n<h2>Fast compilation</h2>\n<p>\n  The library makes extensive use of <b>type erasure</b> to achieve fast\n  compilation. <code>fmt/base.h</code> provides a subset of the API with\n  <b>minimal include dependencies</b> and enough functionality to replace\n  all uses of <code>*printf</code>.\n</p>\n<p>\n  Code using {fmt} is usually several times faster to compile than the\n  equivalent iostreams code, and while <code>printf</code> compiles faster\n  still, the gap is narrowing.\n</p>\n<a href=\n\"https://github.com/fmtlib/fmt?tab=readme-ov-file#compile-time-and-code-bloat\">\n→ Learn more</a>\n</div>\n\n<div class=\"feature\">\n<h2>Small binary footprint</h2>\n<p>\n  Type erasure is also used to prevent template bloat, resulting in <b>compact\n  per-call binary code</b>. For example, a call to <code>fmt::print</code> with\n  a single argument is just <a href=\"https://godbolt.org/g/TZU4KF\">a few\n  instructions</a>, comparable to <code>printf</code> despite adding\n  runtime safety, and much smaller than the equivalent iostreams code.\n</p>\n<p>\n  The library itself has small binary footprint and some components such as\n  floating-point formatting can be disabled to make it even smaller for\n  resource-constrained devices.\n</p>\n</div>\n\n<div class=\"feature\">\n<h2>Portability</h2>\n<p>\n  {fmt} has a <b>small self-contained codebase</b> with the core consisting of\n  just three headers and no external dependencies.\n</p>\n<p>\n  The library is highly portable and requires only a minimal <b>subset of\n  C++11</b> features which are available in GCC 4.9, Clang 3.6, MSVC 19.10\n  (2017) and later. Newer compiler and standard library features are used\n  if available, and enable additional functionality.\n</p>\n<p>\n  Where possible, the output of formatting functions is <b>consistent across\n  platforms</b>.\n</p>\n</p>\n</div>\n\n<div class=\"feature\">\n<h2>Open source</h2>\n<p>\n  {fmt} is in the top hundred open-source C++ libraries on GitHub and has\n  <a href=\"https://github.com/fmtlib/fmt/graphs/contributors\">hundreds of\n  all-time contributors</a>.\n</p>\n<p>\n  The library is distributed under a permissive MIT\n  <a href=\"https://github.com/fmtlib/fmt#license\">license</a> and is\n  <b>relied upon by many open-source projects</b>, including Blender, PyTorch,\n  Apple's FoundationDB, Windows Terminal, MongoDB, and others.\n</p>\n</div>\n\n</div>\n"
  },
  {
    "path": "doc/python-license.txt",
    "content": "A. HISTORY OF THE SOFTWARE\n==========================\n\nPython was created in the early 1990s by Guido van Rossum at Stichting\nMathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands\nas a successor of a language called ABC.  Guido remains Python's\nprincipal author, although it includes many contributions from others.\n\nIn 1995, Guido continued his work on Python at the Corporation for\nNational Research Initiatives (CNRI, see http://www.cnri.reston.va.us)\nin Reston, Virginia where he released several versions of the\nsoftware.\n\nIn May 2000, Guido and the Python core development team moved to\nBeOpen.com to form the BeOpen PythonLabs team.  In October of the same\nyear, the PythonLabs team moved to Digital Creations (now Zope\nCorporation, see http://www.zope.com).  In 2001, the Python Software\nFoundation (PSF, see http://www.python.org/psf/) was formed, a\nnon-profit organization created specifically to own Python-related\nIntellectual Property.  Zope Corporation is a sponsoring member of\nthe PSF.\n\nAll Python releases are Open Source (see http://www.opensource.org for\nthe Open Source Definition).  Historically, most, but not all, Python\nreleases have also been GPL-compatible; the table below summarizes\nthe various releases.\n\n    Release         Derived     Year        Owner       GPL-\n                    from                                compatible? (1)\n\n    0.9.0 thru 1.2              1991-1995   CWI         yes\n    1.3 thru 1.5.2  1.2         1995-1999   CNRI        yes\n    1.6             1.5.2       2000        CNRI        no\n    2.0             1.6         2000        BeOpen.com  no\n    1.6.1           1.6         2001        CNRI        yes (2)\n    2.1             2.0+1.6.1   2001        PSF         no\n    2.0.1           2.0+1.6.1   2001        PSF         yes\n    2.1.1           2.1+2.0.1   2001        PSF         yes\n    2.2             2.1.1       2001        PSF         yes\n    2.1.2           2.1.1       2002        PSF         yes\n    2.1.3           2.1.2       2002        PSF         yes\n    2.2.1           2.2         2002        PSF         yes\n    2.2.2           2.2.1       2002        PSF         yes\n    2.2.3           2.2.2       2003        PSF         yes\n    2.3             2.2.2       2002-2003   PSF         yes\n    2.3.1           2.3         2002-2003   PSF         yes\n    2.3.2           2.3.1       2002-2003   PSF         yes\n    2.3.3           2.3.2       2002-2003   PSF         yes\n    2.3.4           2.3.3       2004        PSF         yes\n    2.3.5           2.3.4       2005        PSF         yes\n    2.4             2.3         2004        PSF         yes\n    2.4.1           2.4         2005        PSF         yes\n    2.4.2           2.4.1       2005        PSF         yes\n    2.4.3           2.4.2       2006        PSF         yes\n    2.4.4           2.4.3       2006        PSF         yes\n    2.5             2.4         2006        PSF         yes\n    2.5.1           2.5         2007        PSF         yes\n    2.5.2           2.5.1       2008        PSF         yes\n    2.5.3           2.5.2       2008        PSF         yes\n    2.6             2.5         2008        PSF         yes\n    2.6.1           2.6         2008        PSF         yes\n    2.6.2           2.6.1       2009        PSF         yes\n    2.6.3           2.6.2       2009        PSF         yes\n    2.6.4           2.6.3       2009        PSF         yes\n    2.6.5           2.6.4       2010        PSF         yes\n    3.0             2.6         2008        PSF         yes\n    3.0.1           3.0         2009        PSF         yes\n    3.1             3.0.1       2009        PSF         yes\n    3.1.1           3.1         2009        PSF         yes\n    3.1.2           3.1.1       2010        PSF         yes\n    3.1.3           3.1.2       2010        PSF         yes\n    3.1.4           3.1.3       2011        PSF         yes\n    3.2             3.1         2011        PSF         yes\n    3.2.1           3.2         2011        PSF         yes\n    3.2.2           3.2.1       2011        PSF         yes\n    3.2.3           3.2.2       2012        PSF         yes\n    3.3.0           3.2         2012        PSF         yes\n\nFootnotes:\n\n(1) GPL-compatible doesn't mean that we're distributing Python under\n    the GPL.  All Python licenses, unlike the GPL, let you distribute\n    a modified version without making your changes open source.  The\n    GPL-compatible licenses make it possible to combine Python with\n    other software that is released under the GPL; the others don't.\n\n(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,\n    because its license has a choice of law clause.  According to\n    CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1\n    is \"not incompatible\" with the GPL.\n\nThanks to the many outside volunteers who have worked under Guido's\ndirection to make these releases possible.\n\n\nB. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON\n===============================================================\n\nPYTHON SOFTWARE FOUNDATION LICENSE VERSION 2\n--------------------------------------------\n\n1. This LICENSE AGREEMENT is between the Python Software Foundation\n(\"PSF\"), and the Individual or Organization (\"Licensee\") accessing and\notherwise using this software (\"Python\") in source or binary form and\nits associated documentation.\n\n2. Subject to the terms and conditions of this License Agreement, PSF hereby\ngrants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,\nanalyze, test, perform and/or display publicly, prepare derivative works,\ndistribute, and otherwise use Python alone or in any derivative version,\nprovided, however, that PSF's License Agreement and PSF's notice of copyright,\ni.e., \"Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,\n2011, 2012 Python Software Foundation; All Rights Reserved\" are retained in Python\nalone or in any derivative version prepared by Licensee.\n\n3. In the event Licensee prepares a derivative work that is based on\nor incorporates Python or any part thereof, and wants to make\nthe derivative work available to others as provided herein, then\nLicensee hereby agrees to include in any such work a brief summary of\nthe changes made to Python.\n\n4. PSF is making Python available to Licensee on an \"AS IS\"\nbasis.  PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\nFOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\nA RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,\nOR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n6. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n7. Nothing in this License Agreement shall be deemed to create any\nrelationship of agency, partnership, or joint venture between PSF and\nLicensee.  This License Agreement does not grant permission to use PSF\ntrademarks or trade name in a trademark sense to endorse or promote\nproducts or services of Licensee, or any third party.\n\n8. By copying, installing or otherwise using Python, Licensee\nagrees to be bound by the terms and conditions of this License\nAgreement.\n\n\nBEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0\n-------------------------------------------\n\nBEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1\n\n1. This LICENSE AGREEMENT is between BeOpen.com (\"BeOpen\"), having an\noffice at 160 Saratoga Avenue, Santa Clara, CA 95051, and the\nIndividual or Organization (\"Licensee\") accessing and otherwise using\nthis software in source or binary form and its associated\ndocumentation (\"the Software\").\n\n2. Subject to the terms and conditions of this BeOpen Python License\nAgreement, BeOpen hereby grants Licensee a non-exclusive,\nroyalty-free, world-wide license to reproduce, analyze, test, perform\nand/or display publicly, prepare derivative works, distribute, and\notherwise use the Software alone or in any derivative version,\nprovided, however, that the BeOpen Python License is retained in the\nSoftware, alone or in any derivative version prepared by Licensee.\n\n3. BeOpen is making the Software available to Licensee on an \"AS IS\"\nbasis.  BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE\nSOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS\nAS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY\nDERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n5. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n6. This License Agreement shall be governed by and interpreted in all\nrespects by the law of the State of California, excluding conflict of\nlaw provisions.  Nothing in this License Agreement shall be deemed to\ncreate any relationship of agency, partnership, or joint venture\nbetween BeOpen and Licensee.  This License Agreement does not grant\npermission to use BeOpen trademarks or trade names in a trademark\nsense to endorse or promote products or services of Licensee, or any\nthird party.  As an exception, the \"BeOpen Python\" logos available at\nhttp://www.pythonlabs.com/logos.html may be used according to the\npermissions granted on that web page.\n\n7. By copying, installing or otherwise using the software, Licensee\nagrees to be bound by the terms and conditions of this License\nAgreement.\n\n\nCNRI LICENSE AGREEMENT FOR PYTHON 1.6.1\n---------------------------------------\n\n1. This LICENSE AGREEMENT is between the Corporation for National\nResearch Initiatives, having an office at 1895 Preston White Drive,\nReston, VA 20191 (\"CNRI\"), and the Individual or Organization\n(\"Licensee\") accessing and otherwise using Python 1.6.1 software in\nsource or binary form and its associated documentation.\n\n2. Subject to the terms and conditions of this License Agreement, CNRI\nhereby grants Licensee a nonexclusive, royalty-free, world-wide\nlicense to reproduce, analyze, test, perform and/or display publicly,\nprepare derivative works, distribute, and otherwise use Python 1.6.1\nalone or in any derivative version, provided, however, that CNRI's\nLicense Agreement and CNRI's notice of copyright, i.e., \"Copyright (c)\n1995-2001 Corporation for National Research Initiatives; All Rights\nReserved\" are retained in Python 1.6.1 alone or in any derivative\nversion prepared by Licensee.  Alternately, in lieu of CNRI's License\nAgreement, Licensee may substitute the following text (omitting the\nquotes): \"Python 1.6.1 is made available subject to the terms and\nconditions in CNRI's License Agreement.  This Agreement together with\nPython 1.6.1 may be located on the Internet using the following\nunique, persistent identifier (known as a handle): 1895.22/1013.  This\nAgreement may also be obtained from a proxy server on the Internet\nusing the following URL: http://hdl.handle.net/1895.22/1013\".\n\n3. In the event Licensee prepares a derivative work that is based on\nor incorporates Python 1.6.1 or any part thereof, and wants to make\nthe derivative work available to others as provided herein, then\nLicensee hereby agrees to include in any such work a brief summary of\nthe changes made to Python 1.6.1.\n\n4. CNRI is making Python 1.6.1 available to Licensee on an \"AS IS\"\nbasis.  CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR\nIMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND\nDISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS\nFOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT\nINFRINGE ANY THIRD PARTY RIGHTS.\n\n5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON\n1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS\nA RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,\nOR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.\n\n6. This License Agreement will automatically terminate upon a material\nbreach of its terms and conditions.\n\n7. This License Agreement shall be governed by the federal\nintellectual property law of the United States, including without\nlimitation the federal copyright law, and, to the extent such\nU.S. federal law does not apply, by the law of the Commonwealth of\nVirginia, excluding Virginia's conflict of law provisions.\nNotwithstanding the foregoing, with regard to derivative works based\non Python 1.6.1 that incorporate non-separable material that was\npreviously distributed under the GNU General Public License (GPL), the\nlaw of the Commonwealth of Virginia shall govern this License\nAgreement only as to issues arising under or with respect to\nParagraphs 4, 5, and 7 of this License Agreement.  Nothing in this\nLicense Agreement shall be deemed to create any relationship of\nagency, partnership, or joint venture between CNRI and Licensee.  This\nLicense Agreement does not grant permission to use CNRI trademarks or\ntrade name in a trademark sense to endorse or promote products or\nservices of Licensee, or any third party.\n\n8. By clicking on the \"ACCEPT\" button where indicated, or by copying,\ninstalling or otherwise using Python 1.6.1, Licensee agrees to be\nbound by the terms and conditions of this License Agreement.\n\n        ACCEPT\n\n\nCWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2\n--------------------------------------------------\n\nCopyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,\nThe Netherlands.  All rights reserved.\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Stichting Mathematisch\nCentrum or CWI not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior\npermission.\n\nSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO\nTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE\nFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT\nOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n"
  },
  {
    "path": "doc/syntax.md",
    "content": "# Format String Syntax\n\nFormatting functions such as [`fmt::format`](api.md#format) and [`fmt::print`](\napi.md#print) use the same format string syntax described in this section.\n\nFormat strings contain \"replacement fields\" surrounded by curly braces `{}`.\nAnything that is not contained in braces is considered literal text, which is\ncopied unchanged to the output. If you need to include a brace character in\nthe literal text, it can be escaped by doubling: `{{` and `}}`.\n\nThe grammar for a replacement field is as follows:\n\n<a id=\"replacement-field\"></a>\n<pre><code class=\"language-json\"\n>replacement_field ::= \"{\" [arg_id] [\":\" (<a href=\"#format-spec\"\n  >format_spec</a> | <a href=\"#chrono-format-spec\">chrono_format_spec</a>)] \"}\"\narg_id            ::= integer | identifier\ninteger           ::= digit+\ndigit             ::= \"0\"...\"9\"\nidentifier        ::= id_start id_continue*\nid_start          ::= \"a\"...\"z\" | \"A\"...\"Z\" | \"_\"\nid_continue       ::= id_start | digit</code>\n</pre>\n\nIn less formal terms, the replacement field can start with an *arg_id* that\nspecifies the argument whose value is to be formatted and inserted into the\noutput instead of the replacement field. The *arg_id* is optionally followed\nby a *format_spec*, which is preceded by a colon `':'`. These specify a\nnon-default format for the replacement value.\n\nSee also the [Format Specification\nMini-Language](#format-specification-mini-language) section.\n\nIf the numerical arg_ids in a format string are 0, 1, 2, ... in sequence,\nthey can all be omitted (not just some) and the numbers 0, 1, 2, ... will be\nautomatically inserted in that order.\n\nNamed arguments can be referred to by their names or indices.\n\nSome simple format string examples:\n\n```c++\n\"First, thou shalt count to {0}\" // References the first argument\n\"Bring me a {}\"                  // Implicitly references the first argument\n\"From {} to {}\"                  // Same as \"From {0} to {1}\"\n```\n\nThe *format_spec* field contains a specification of how the value should\nbe presented, including such details as field width, alignment, padding,\ndecimal precision and so on. Each value type can define its own\n\"formatting mini-language\" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which is\ndescribed in the next section.\n\nA *format_spec* field can also include nested replacement fields in\ncertain positions within it. These nested replacement fields can contain\nonly an argument id; format specifications are not allowed. This allows\nthe formatting of a value to be dynamically specified.\n\nSee the [Format Examples](#format-examples) section for some examples.\n\n## Format Specification Mini-Language\n\n\"Format specifications\" are used within replacement fields contained within a\nformat string to define how individual values are presented. Each formattable\ntype may define how the format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nThe general form of a *standard format specifier* is:\n\n<a id=\"format-spec\"></a>\n<pre><code class=\"language-json\"\n>format_spec ::= [[fill]align][sign][\"#\"][\"0\"][width][\".\" precision][\"L\"][type]\nfill        ::= &lt;a character other than '{' or '}'>\nalign       ::= \"<\" | \">\" | \"^\"\nsign        ::= \"+\" | \"-\" | \" \"\nwidth       ::= <a href=\"#replacement-field\">integer</a> | \"{\" [<a\n  href=\"#replacement-field\">arg_id</a>] \"}\"\nprecision   ::= <a href=\"#replacement-field\">integer</a> | \"{\" [<a\n  href=\"#replacement-field\">arg_id</a>] \"}\"\ntype        ::= \"a\" | \"A\" | \"b\" | \"B\" | \"c\" | \"d\" | \"e\" | \"E\" | \"f\" | \"F\" |\n                \"g\" | \"G\" | \"o\" | \"p\" | \"s\" | \"x\" | \"X\" | \"?\"</code>\n</pre>\n\nThe *fill* character can be any Unicode code point other than `'{'` or `'}'`.\nThe presence of a fill character is signaled by the character following it,\nwhich must be one of the alignment options. If the second character of\n*format_spec* is not a valid alignment option, then it is assumed that both\nthe fill character and the alignment option are absent.\n\nThe meaning of the various alignment options is as follows:\n\n<table>\n<tr>\n  <th>Option</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'<'</code></td>\n  <td>\n    Forces the field to be left-aligned within the available space (this is the\n    default for most objects).\n  </td>\n</tr>\n<tr>\n  <td><code>'>'</code></td>\n  <td>\n    Forces the field to be right-aligned within the available space (this is\n    the default for numbers).\n  </td>\n</tr>\n<tr>\n  <td><code>'^'</code></td>\n  <td>Forces the field to be centered within the available space.</td>\n</tr>\n</table>\n\nNote that unless a minimum field width is defined, the field width will\nalways be the same size as the data to fill it, so that the alignment\noption has no meaning in this case.\n\nThe *sign* option is only valid for floating point and signed integer types,\nand can be one of the following:\n\n<table>\n<tr>\n  <th>Option</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'+'</code></td>\n  <td>\n    Indicates that a sign should be used for both nonnegative as well as\n    negative numbers.\n  </td>\n</tr>\n<tr>\n  <td><code>'-'</code></td>\n  <td>\n    Indicates that a sign should be used only for negative numbers (this is the\n    default behavior).\n  </td>\n</tr>\n<tr>\n  <td>space</td>\n  <td>\n    Indicates that a leading space should be used on nonnegative numbers, and a\n    minus sign on negative numbers.\n  </td>\n</tr>\n</table>\n\nThe `'#'` option causes the \"alternate form\" to be used for the\nconversion. The alternate form is defined differently for different\ntypes. This option is only valid for integer and floating-point types.\nFor integers, when binary, octal, or hexadecimal output is used, this\noption adds the prefix respective `\"0b\"` (`\"0B\"`), `\"0\"`, or `\"0x\"`\n(`\"0X\"`) to the output value. Whether the prefix is lower-case or\nupper-case is determined by the case of the type specifier, for example,\nthe prefix `\"0x\"` is used for the type `'x'` and `\"0X\"` is used for\n`'X'`. For floating-point numbers the alternate form causes the result\nof the conversion to always contain a decimal-point character, even if\nno digits follow it. Normally, a decimal-point character appears in the\nresult of these conversions only if a digit follows it. In addition, for\n`'g'` and `'G'` conversions, trailing zeros are not removed from the\nresult.\n\n*width* is a decimal integer defining the minimum field width. If not\nspecified, then the field width will be determined by the content.\n\nPreceding the *width* field by a zero (`'0'`) character enables\nsign-aware zero-padding for numeric types. It forces the padding to be\nplaced after the sign or base (if any) but before the digits. This is\nused for printing fields in the form \"+000000120\". This option is only\nvalid for numeric types and it has no effect on formatting of infinity\nand NaN. This option is ignored when any alignment specifier is present.\n\nThe *precision* is a decimal number indicating how many digits should be\ndisplayed after the decimal point for a floating-point value formatted\nwith `'f'` and `'F'`, or before and after the decimal point for a\nfloating-point value formatted with `'g'` or `'G'`. For non-number types\nthe field indicates the maximum field size - in other words, how many\ncharacters will be used from the field content. The *precision* is not\nallowed for integer, character, Boolean, and pointer values. Note that a\nC string must be null-terminated even if precision is specified.\n\nThe `'L'` option uses the current locale setting to insert the appropriate\nnumber separator characters. This option is only valid for numeric types.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n<table>\n<tr>\n  <th>Type</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'s'</code></td>\n  <td>\n    String format. This is the default type for strings and may be omitted.\n  </td>\n</tr>\n<tr>\n  <td><code>'?'</code></td>\n  <td>Debug format. The string is quoted and special characters escaped.</td>\n</tr>\n<tr>\n  <td>none</td>\n  <td>The same as <code>'s'</code>.</td>\n</tr>\n</table>\n\nThe available character presentation types are:\n\n<table>\n<tr>\n  <th>Type</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'c'</code></td>\n  <td>\n    Character format. This is the default type for characters and may be\n    omitted.\n  </td>\n</tr>\n<tr>\n  <td><code>'?'</code></td>\n  <td>Debug format. The character is quoted and special characters escaped.</td>\n</tr>\n<tr>\n  <td>none</td>\n  <td>The same as <code>'c'</code>.</td>\n</tr>\n</table>\n\nThe available integer presentation types are:\n\n<table>\n<tr>\n  <th>Type</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'b'</code></td>\n  <td>\n    Binary format. Outputs the number in base 2. Using the <code>'#'</code>\n    option with this type adds the prefix <code>\"0b\"</code> to the output value.\n  </td>\n</tr>\n<tr>\n  <td><code>'B'</code></td>\n  <td>\n    Binary format. Outputs the number in base 2. Using the <code>'#'</code>\n    option with this type adds the prefix <code>\"0B\"</code> to the output value.\n  </td>\n</tr>\n<tr>\n  <td><code>'c'</code></td>\n  <td>Character format. Outputs the number as a character.</td>\n</tr>\n<tr>\n  <td><code>'d'</code></td>\n  <td>Decimal integer. Outputs the number in base 10.</td>\n</tr>\n<tr>\n  <td><code>'o'</code></td>\n  <td>Octal format. Outputs the number in base 8.</td>\n</tr>\n<tr>\n  <td><code>'x'</code></td>\n  <td>\n    Hex format. Outputs the number in base 16, using lower-case letters for the\n    digits above 9. Using the <code>'#'</code> option with this type adds the\n    prefix <code>\"0x\"</code> to the output value.\n  </td>\n</tr>\n<tr>\n  <td><code>'X'</code></td>\n  <td>\n    Hex format. Outputs the number in base 16, using upper-case letters for the\n    digits above 9. Using the <code>'#'</code> option with this type adds the\n    prefix <code>\"0X\"</code> to the output value.\n  </td>\n</tr>\n<tr>\n  <td>none</td>\n  <td>The same as <code>'d'</code>.</td>\n</tr>\n</table>\n\nInteger presentation types can also be used with character and Boolean values\nwith the only exception that `'c'` cannot be used with `bool`. Boolean values\nare formatted using textual representation, either `true` or `false`, if the\npresentation type is not specified.\n\nThe available presentation types for floating-point values are:\n\n<table>\n<tr>\n  <th>Type</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'a'</code></td>\n  <td>\n    Hexadecimal floating point format. Prints the number in base 16 with\n    prefix <code>\"0x\"</code> and lower-case letters for digits above 9.\n    Uses <code>'p'</code> to indicate the exponent.\n  </td>\n</tr>\n<tr>\n  <td><code>'A'</code></td>\n  <td>\n    Same as <code>'a'</code> except it uses upper-case letters for the\n    prefix, digits above 9 and to indicate the exponent.\n  </td>\n</tr>\n<tr>\n  <td><code>'e'</code></td>\n  <td>\n    Exponent notation. Prints the number in scientific notation using\n    the letter 'e' to indicate the exponent.\n  </td>\n</tr>\n<tr>\n  <td><code>'E'</code></td>\n  <td>\n    Exponent notation. Same as <code>'e'</code> except it uses an\n    upper-case <code>'E'</code> as the separator character.\n  </td>\n</tr>\n<tr>\n  <td><code>'f'</code></td>\n  <td>Fixed point. Displays the number as a fixed-point number.</td>\n</tr>\n<tr>\n  <td><code>'F'</code></td>\n  <td>\n    Fixed point. Same as <code>'f'</code>, but converts <code>nan</code>\n    to <code>NAN</code> and <code>inf</code> to <code>INF</code>.\n  </td>\n</tr>\n<tr>\n  <td><code>'g'</code></td>\n  <td>\n    <p>General format. For a given precision <code>p &gt;= 1</code>,\n    this rounds the number to <code>p</code> significant digits and then\n    formats the result in either fixed-point format or in scientific\n    notation, depending on its magnitude.</p>\n    <p>A precision of <code>0</code> is treated as equivalent to a precision\n    of <code>1</code>.</p>\n  </td>\n</tr>\n<tr>\n  <td><code>'G'</code></td>\n  <td>\n    General format. Same as <code>'g'</code> except switches to\n    <code>'E'</code> if the number gets too large. The representations of\n    infinity and NaN are uppercased, too.\n  </td>\n</tr>\n<tr>\n  <td>none</td>\n  <td>\n    Similar to <code>'g'</code>, except that the default precision is as\n    high as needed to represent the particular value.\n  </td>\n</tr>\n</table>\n\nThe available presentation types for pointers are:\n\n<table>\n<tr>\n  <th>Type</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'p'</code></td>\n  <td>\n    Pointer format. This is the default type for pointers and may be omitted.\n  </td>\n</tr>\n<tr>\n  <td>none</td>\n  <td>The same as <code>'p'</code>.</td>\n</tr>\n</table>\n\n## Chrono Format Specifications\n\nFormat specifications for chrono duration and time point types as well as\n`std::tm` have the following syntax:\n\n<a id=\"chrono-format-spec\"></a>\n<pre><code class=\"language-json\"\n>chrono_format_spec ::= [[<a href=\"#format-spec\">fill</a>]<a href=\"#format-spec\"\n  >align</a>][<a href=\"#format-spec\">width</a>][\".\" <a href=\"#format-spec\"\n  >precision</a>][chrono_specs]\nchrono_specs       ::= conversion_spec |\n                       chrono_specs (conversion_spec | literal_char)\nconversion_spec    ::= \"%\" [padding_modifier] [locale_modifier] chrono_type\nliteral_char       ::= &lt;a character other than '{', '}' or '%'>\npadding_modifier   ::= \"-\" | \"_\"  | \"0\"\nlocale_modifier    ::= \"E\" | \"O\"\nchrono_type        ::= \"a\" | \"A\" | \"b\" | \"B\" | \"c\" | \"C\" | \"d\" | \"D\" | \"e\" |\n                       \"F\" | \"g\" | \"G\" | \"h\" | \"H\" | \"I\" | \"j\" | \"m\" | \"M\" |\n                       \"n\" | \"p\" | \"q\" | \"Q\" | \"r\" | \"R\" | \"S\" | \"t\" | \"T\" |\n                       \"u\" | \"U\" | \"V\" | \"w\" | \"W\" | \"x\" | \"X\" | \"y\" | \"Y\" |\n                       \"z\" | \"Z\" | \"%\"</code>\n</pre>\n\nLiteral chars are copied unchanged to the output. Precision is valid only\nfor `std::chrono::duration` types with a floating-point representation type.\n\nThe available presentation types (*chrono_type*) are:\n\n<table>\n<tr>\n  <th>Type</th>\n  <th>Meaning</th>\n</tr>\n<tr>\n  <td><code>'a'</code></td>\n  <td>\n    The abbreviated weekday name, e.g. \"Sat\". If the value does not contain a\n    valid weekday, an exception of type <code>format_error</code> is thrown.\n  </td>\n</tr>\n<tr>\n  <td><code>'A'</code></td>\n  <td>\n    The full weekday name, e.g. \"Saturday\". If the value does not contain a\n    valid weekday, an exception of type <code>format_error</code> is thrown.\n  </td>\n</tr>\n<tr>\n  <td><code>'b'</code></td>\n  <td>\n    The abbreviated month name, e.g. \"Nov\". If the value does not contain a\n    valid month, an exception of type <code>format_error</code> is thrown.\n  </td>\n</tr>\n<tr>\n  <td><code>'B'</code></td>\n  <td>\n    The full month name, e.g. \"November\". If the value does not contain a valid\n    month, an exception of type <code>format_error</code> is thrown.\n  </td>\n</tr>\n<tr>\n  <td><code>'c'</code></td>\n  <td>\n    The date and time representation, e.g. \"Sat Nov 12 22:04:00 1955\". The\n    modified command <code>%Ec</code> produces the locale's alternate date and\n    time representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'C'</code></td>\n  <td>\n    The year divided by 100 using floored division, e.g. \"19\". If the result\n    is a single decimal digit, it is prefixed with 0. The modified command\n    <code>%EC</code> produces the locale's alternative representation of the\n    century.\n  </td>\n</tr>\n<tr>\n  <td><code>'d'</code></td>\n  <td>\n    The day of month as a decimal number. If the result is a single decimal\n    digit, it is prefixed with 0. The modified command <code>%Od</code>\n    produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'D'</code></td>\n  <td>Equivalent to <code>%m/%d/%y</code>, e.g. \"11/12/55\".</td>\n</tr>\n<tr>\n  <td><code>'e'</code></td>\n  <td>\n    The day of month as a decimal number. If the result is a single decimal\n    digit, it is prefixed with a space. The modified command <code>%Oe</code>\n    produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'F'</code></td>\n  <td>Equivalent to <code>%Y-%m-%d</code>, e.g. \"1955-11-12\".</td>\n</tr>\n<tr>\n  <td><code>'g'</code></td>\n  <td>\n    The last two decimal digits of the ISO week-based year. If the result is a\n    single digit it is prefixed by 0.\n  </td>\n</tr>\n<tr>\n  <td><code>'G'</code></td>\n  <td>\n    The ISO week-based year as a decimal number. If the result is less than\n    four digits it is left-padded with 0 to four digits.\n  </td>\n</tr>\n<tr>\n  <td><code>'h'</code></td>\n  <td>Equivalent to <code>%b</code>, e.g. \"Nov\".</td>\n</tr>\n<tr>\n  <td><code>'H'</code></td>\n  <td>\n    The hour (24-hour clock) as a decimal number. If the result is a single\n    digit, it is prefixed with 0. The modified command <code>%OH</code>\n    produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'I'</code></td>\n  <td>\n    The hour (12-hour clock) as a decimal number. If the result is a single\n    digit, it is prefixed with 0. The modified command <code>%OI</code>\n    produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'j'</code></td>\n  <td>\n    If the type being formatted is a specialization of duration, the decimal\n    number of days without padding. Otherwise, the day of the year as a decimal\n    number. Jan 1 is 001. If the result is less than three digits, it is\n    left-padded with 0 to three digits.\n  </td>\n</tr>\n<tr>\n  <td><code>'m'</code></td>\n  <td>\n    The month as a decimal number. Jan is 01. If the result is a single digit,\n    it is prefixed with 0. The modified command <code>%Om</code> produces the\n    locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'M'</code></td>\n  <td>\n    The minute as a decimal number. If the result is a single digit, it\n    is prefixed with 0. The modified command <code>%OM</code> produces the\n    locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'n'</code></td>\n  <td>A new-line character.</td>\n</tr>\n<tr>\n  <td><code>'p'</code></td>\n  <td>The AM/PM designations associated with a 12-hour clock.</td>\n</tr>\n<tr>\n  <td><code>'q'</code></td>\n  <td>The duration's unit suffix.</td>\n</tr>\n<tr>\n  <td><code>'Q'</code></td>\n  <td>\n    The duration's numeric value (as if extracted via <code>.count()</code>).\n  </td>\n</tr>\n<tr>\n  <td><code>'r'</code></td>\n  <td>The 12-hour clock time, e.g. \"10:04:00 PM\".</td>\n</tr>\n<tr>\n  <td><code>'R'</code></td>\n  <td>Equivalent to <code>%H:%M</code>, e.g. \"22:04\".</td>\n</tr>\n<tr>\n  <td><code>'S'</code></td>\n  <td>\n    Seconds as a decimal number. If the number of seconds is less than 10, the\n    result is prefixed with 0. If the precision of the input cannot be exactly\n    represented with seconds, then the format is a decimal floating-point number\n    with a fixed format and a precision matching that of the precision of the\n    input (or to a microseconds precision if the conversion to floating-point\n    decimal seconds cannot be made within 18 fractional digits). The modified\n    command <code>%OS</code> produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'t'</code></td>\n  <td>A horizontal-tab character.</td>\n</tr>\n<tr>\n  <td><code>'T'</code></td>\n  <td>Equivalent to <code>%H:%M:%S</code>.</td>\n</tr>\n<tr>\n  <td><code>'u'</code></td>\n  <td>\n    The ISO weekday as a decimal number (1-7), where Monday is 1. The modified\n    command <code>%Ou</code> produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'U'</code></td>\n  <td>\n    The week number of the year as a decimal number. The first Sunday of the\n    year is the first day of week 01. Days of the same year prior to that are\n    in week 00. If the result is a single digit, it is prefixed with 0.\n    The modified command <code>%OU</code> produces the locale's alternative\n    representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'V'</code></td>\n  <td>\n    The ISO week-based week number as a decimal number. If the result is a\n    single digit, it is prefixed with 0. The modified command <code>%OV</code>\n    produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'w'</code></td>\n  <td>\n    The weekday as a decimal number (0-6), where Sunday is 0. The modified\n    command <code>%Ow</code> produces the locale's alternative representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'W'</code></td>\n  <td>\n    The week number of the year as a decimal number. The first Monday of the\n    year is the first day of week 01. Days of the same year prior to that are\n    in week 00. If the result is a single digit, it is prefixed with 0.\n    The modified command <code>%OW</code> produces the locale's alternative\n    representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'x'</code></td>\n  <td>\n    The date representation, e.g. \"11/12/55\". The modified command\n    <code>%Ex</code> produces the locale's alternate date representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'X'</code></td>\n  <td>\n    The time representation, e.g. \"10:04:00\". The modified command\n    <code>%EX</code> produces the locale's alternate time representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'y'</code></td>\n  <td>\n    The last two decimal digits of the year. If the result is a single digit\n    it is prefixed by 0. The modified command <code>%Oy</code> produces the\n    locale's alternative representation. The modified command <code>%Ey</code>\n    produces the locale's alternative representation of offset from\n    <code>%EC</code> (year only).\n  </td>\n</tr>\n<tr>\n  <td><code>'Y'</code></td>\n  <td>\n    The year as a decimal number. If the result is less than four digits it is\n    left-padded with 0 to four digits. The modified command <code>%EY</code>\n    produces the locale's alternative full year representation.\n  </td>\n</tr>\n<tr>\n  <td><code>'z'</code></td>\n  <td>\n    The offset from UTC in the ISO 8601:2004 format. For example -0430 refers\n    to 4 hours 30 minutes behind UTC. If the offset is zero, +0000 is used.\n    The modified commands <code>%Ez</code> and <code>%Oz</code> insert a\n    <code>:</code> between the hours and minutes: -04:30. If the offset\n    information is not available, an exception of type\n    <code>format_error</code> is thrown.\n  </td>\n</tr>\n<tr>\n  <td><code>'Z'</code></td>\n  <td>\n    The time zone abbreviation. If the time zone abbreviation is not available,\n    an exception of type <code>format_error</code> is thrown.\n  </td>\n</tr>\n<tr>\n  <td><code>'%'</code></td>\n  <td>A % character.</td>\n</tr>\n</table>\n\nSpecifiers that have a calendaric component such as `'d'` (the day of month)\nare valid only for `std::tm` and time points but not durations.\n\nThe available padding modifiers (*padding_modifier*) are:\n\n| Type  | Meaning                                 |\n|-------|-----------------------------------------|\n| `'_'` | Pad a numeric result with spaces.       |\n| `'-'` | Do not pad a numeric result string.     |\n| `'0'` | Pad a numeric result string with zeros. |\n\nThese modifiers are only supported for the `'H'`, `'I'`, `'M'`, `'S'`, `'U'`,\n`'V'`, `'W'`, `'Y'`, `'d'`, `'j'` and `'m'` presentation types.\n\n## Range Format Specifications\n\nFormat specifications for range types have the following syntax:\n\n<pre><code class=\"language-json\"\n>range_format_spec ::= [\"n\"][range_type][\":\" range_underlying_spec]</code>\n</pre>\n\nThe `'n'` option formats the range without the opening and closing brackets.\n\nThe available presentation types for `range_type` are:\n\n| Type   | Meaning                                                    |\n|--------|------------------------------------------------------------|\n| none   | Default format.                                            |\n| `'s'`  | String format. The range is formatted as a string.         |\n| `'?⁠s'` | Debug format. The range is formatted as an escaped string. |\n\nIf `range_type` is `'s'` or `'?s'`, the range element type must be a character\ntype. The `'n'` option and `range_underlying_spec` are mutually exclusive with\n`'s'` and `'?s'`.\n\nThe `range_underlying_spec` is parsed based on the formatter of the range's\nelement type.\n\nBy default, a range of characters or strings is printed escaped and quoted.\nBut if any `range_underlying_spec` is provided (even if it is empty), then the\ncharacters or strings are printed according to the provided specification.\n\nExamples:\n\n```c++\nfmt::print(\"{}\", std::vector{10, 20, 30});\n// Output: [10, 20, 30]\nfmt::print(\"{::#x}\", std::vector{10, 20, 30});\n// Output: [0xa, 0x14, 0x1e]\nfmt::print(\"{}\", std::vector{'h', 'e', 'l', 'l', 'o'});\n// Output: ['h', 'e', 'l', 'l', 'o']\nfmt::print(\"{:n}\", std::vector{'h', 'e', 'l', 'l', 'o'});\n// Output: 'h', 'e', 'l', 'l', 'o'\nfmt::print(\"{:s}\", std::vector{'h', 'e', 'l', 'l', 'o'});\n// Output: \"hello\"\nfmt::print(\"{:?s}\", std::vector{'h', 'e', 'l', 'l', 'o', '\\n'});\n// Output: \"hello\\n\"\nfmt::print(\"{::}\", std::vector{'h', 'e', 'l', 'l', 'o'});\n// Output: [h, e, l, l, o]\nfmt::print(\"{::d}\", std::vector{'h', 'e', 'l', 'l', 'o'});\n// Output: [104, 101, 108, 108, 111]\nfmt::print(\"{:n:f}\", std::array{std::numbers::pi, std::numbers::e});\n// Output: 3.141593, 2.718282\n```\n\n## Format Examples\n\nThis section contains examples of the format syntax and comparison with\nthe `printf` formatting.\n\nIn most of the cases the syntax is similar to the `printf` formatting,\nwith the addition of the `{}` and with `:` used instead of `%`. For\nexample, `\"%03.2f\"` can be translated to `\"{:03.2f}\"`.\n\nThe new format syntax also supports new and different options, shown in\nthe following examples.\n\nAccessing arguments by position:\n\n```c++\nfmt::format(\"{0}, {1}, {2}\", 'a', 'b', 'c');\n// Result: \"a, b, c\"\nfmt::format(\"{}, {}, {}\", 'a', 'b', 'c');\n// Result: \"a, b, c\"\nfmt::format(\"{2}, {1}, {0}\", 'a', 'b', 'c');\n// Result: \"c, b, a\"\nfmt::format(\"{0}{1}{0}\", \"abra\", \"cad\");  // arguments' indices can be repeated\n// Result: \"abracadabra\"\n```\n\nAligning the text and specifying a width:\n\n```c++\nfmt::format(\"{:<30}\", \"left aligned\");\n// Result: \"left aligned                  \"\nfmt::format(\"{:>30}\", \"right aligned\");\n// Result: \"                 right aligned\"\nfmt::format(\"{:^30}\", \"centered\");\n// Result: \"           centered           \"\nfmt::format(\"{:*^30}\", \"centered\");  // use '*' as a fill char\n// Result: \"***********centered***********\"\n```\n\nDynamic width:\n\n```c++\nfmt::format(\"{:<{}}\", \"left aligned\", 30);\n// Result: \"left aligned                  \"\n```\n\nDynamic precision:\n\n```c++\nfmt::format(\"{:.{}f}\", 3.14, 1);\n// Result: \"3.1\"\n```\n\nReplacing `%+f`, `%-f`, and `% f` and specifying a sign:\n\n```c++\nfmt::format(\"{:+f}; {:+f}\", 3.14, -3.14);  // show it always\n// Result: \"+3.140000; -3.140000\"\nfmt::format(\"{: f}; {: f}\", 3.14, -3.14);  // show a space for positive numbers\n// Result: \" 3.140000; -3.140000\"\nfmt::format(\"{:-f}; {:-f}\", 3.14, -3.14);  // show only the minus -- same as '{:f}; {:f}'\n// Result: \"3.140000; -3.140000\"\n```\n\nReplacing `%x` and `%o` and converting the value to different bases:\n\n```c++\nfmt::format(\"int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}\", 42);\n// Result: \"int: 42;  hex: 2a;  oct: 52; bin: 101010\"\n// with 0x or 0 or 0b as prefix:\nfmt::format(\"int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}\", 42);\n// Result: \"int: 42;  hex: 0x2a;  oct: 052;  bin: 0b101010\"\n```\n\nPadded hex byte with prefix and always prints both hex characters:\n\n```c++\nfmt::format(\"{:#04x}\", 0);\n// Result: \"0x00\"\n```\n\nBox drawing using Unicode fill:\n\n```c++\nfmt::print(\n    \"┌{0:─^{2}}┐\\n\"\n    \"│{1: ^{2}}│\\n\"\n    \"└{0:─^{2}}┘\\n\", \"\", \"Hello, world!\", 20);\n```\n\nprints:\n\n```\n┌────────────────────┐\n│   Hello, world!    │\n└────────────────────┘\n```\n\nUsing type-specific formatting:\n\n```c++\n#include <fmt/chrono.h>\n\nauto t = tm();\nt.tm_year = 2010 - 1900;\nt.tm_mon = 7;\nt.tm_mday = 4;\nt.tm_hour = 12;\nt.tm_min = 15;\nt.tm_sec = 58;\nfmt::print(\"{:%Y-%m-%d %H:%M:%S}\", t);\n// Prints: 2010-08-04 12:15:58\n```\n\nUsing the comma as a thousands separator:\n\n```c++\n#include <fmt/format.h>\n\nauto s = fmt::format(std::locale(\"en_US.UTF-8\"), \"{:L}\", 1234567890);\n// s == \"1,234,567,890\"\n```\n"
  },
  {
    "path": "include/fmt/args.h",
    "content": "// Formatting library for C++ - dynamic argument lists\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_ARGS_H_\n#define FMT_ARGS_H_\n\n#ifndef FMT_MODULE\n#  include <functional>  // std::reference_wrapper\n#  include <memory>      // std::unique_ptr\n#  include <vector>\n#endif\n\n#include \"format.h\"  // std_string_view\n\nFMT_BEGIN_NAMESPACE\nnamespace detail {\n\ntemplate <typename T> struct is_reference_wrapper : std::false_type {};\ntemplate <typename T>\nstruct is_reference_wrapper<std::reference_wrapper<T>> : std::true_type {};\n\ntemplate <typename T> auto unwrap(const T& v) -> const T& { return v; }\ntemplate <typename T>\nauto unwrap(const std::reference_wrapper<T>& v) -> const T& {\n  return static_cast<const T&>(v);\n}\n\n// node is defined outside dynamic_arg_list to workaround a C2504 bug in MSVC\n// 2022 (v17.10.0).\n//\n// Workaround for clang's -Wweak-vtables. Unlike for regular classes, for\n// templates it doesn't complain about inability to deduce single translation\n// unit for placing vtable. So node is made a fake template.\ntemplate <typename = void> struct node {\n  virtual ~node() = default;\n  std::unique_ptr<node<>> next;\n};\n\nclass dynamic_arg_list {\n  template <typename T> struct typed_node : node<> {\n    T value;\n\n    template <typename Arg>\n    FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {}\n\n    template <typename Char>\n    FMT_CONSTEXPR typed_node(const basic_string_view<Char>& arg)\n        : value(arg.data(), arg.size()) {}\n  };\n\n  std::unique_ptr<node<>> head_;\n\n public:\n  template <typename T, typename Arg> auto push(const Arg& arg) -> const T& {\n    auto new_node = std::unique_ptr<typed_node<T>>(new typed_node<T>(arg));\n    auto& value = new_node->value;\n    new_node->next = std::move(head_);\n    head_ = std::move(new_node);\n    return value;\n  }\n};\n}  // namespace detail\n\n/**\n * A dynamic list of formatting arguments with storage.\n *\n * It can be implicitly converted into `fmt::basic_format_args` for passing\n * into type-erased formatting functions such as `fmt::vformat`.\n */\nFMT_EXPORT template <typename Context> class dynamic_format_arg_store {\n private:\n  using char_type = typename Context::char_type;\n\n  template <typename T> struct need_copy {\n    static constexpr detail::type mapped_type =\n        detail::mapped_type_constant<T, char_type>::value;\n\n    enum {\n      value = !(detail::is_reference_wrapper<T>::value ||\n                std::is_same<T, basic_string_view<char_type>>::value ||\n                std::is_same<T, detail::std_string_view<char_type>>::value ||\n                (mapped_type != detail::type::cstring_type &&\n                 mapped_type != detail::type::string_type &&\n                 mapped_type != detail::type::custom_type))\n    };\n  };\n\n  template <typename T>\n  using stored_t = conditional_t<\n      std::is_convertible<T, std::basic_string<char_type>>::value &&\n          !detail::is_reference_wrapper<T>::value,\n      std::basic_string<char_type>, T>;\n\n  // Storage of basic_format_arg must be contiguous.\n  std::vector<basic_format_arg<Context>> data_;\n  std::vector<detail::named_arg_info<char_type>> named_info_;\n\n  // Storage of arguments not fitting into basic_format_arg must grow\n  // without relocation because items in data_ refer to it.\n  detail::dynamic_arg_list dynamic_args_;\n\n  friend class basic_format_args<Context>;\n\n  auto data() const -> const basic_format_arg<Context>* {\n    return named_info_.empty() ? data_.data() : data_.data() + 1;\n  }\n\n  template <typename T> void emplace_arg(const T& arg) {\n    data_.emplace_back(arg);\n  }\n\n  template <typename T> void emplace_arg(const named_arg<T, char_type>& arg) {\n    if (named_info_.empty())\n      data_.insert(data_.begin(), basic_format_arg<Context>(nullptr, 0));\n    data_.emplace_back(detail::unwrap(arg.value));\n    auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {\n      data->pop_back();\n    };\n    std::unique_ptr<std::vector<basic_format_arg<Context>>, decltype(pop_one)>\n        guard{&data_, pop_one};\n    named_info_.push_back({arg.name, static_cast<int>(data_.size() - 2u)});\n    data_[0] = {named_info_.data(), named_info_.size()};\n    guard.release();\n  }\n\n public:\n  constexpr dynamic_format_arg_store() = default;\n\n  operator basic_format_args<Context>() const {\n    return basic_format_args<Context>(data(), static_cast<int>(data_.size()),\n                                      !named_info_.empty());\n  }\n\n  /**\n   * Adds an argument into the dynamic store for later passing to a formatting\n   * function.\n   *\n   * Note that custom types and string types (but not string views) are copied\n   * into the store dynamically allocating memory if necessary.\n   *\n   * **Example**:\n   *\n   *     fmt::dynamic_format_arg_store<fmt::format_context> store;\n   *     store.push_back(42);\n   *     store.push_back(\"abc\");\n   *     store.push_back(1.5f);\n   *     std::string result = fmt::vformat(\"{} and {} and {}\", store);\n   */\n  template <typename T> void push_back(const T& arg) {\n    if FMT_CONSTEXPR20 (need_copy<T>::value)\n      emplace_arg(dynamic_args_.push<stored_t<T>>(arg));\n    else\n      emplace_arg(detail::unwrap(arg));\n  }\n\n  /**\n   * Adds a reference to the argument into the dynamic store for later passing\n   * to a formatting function.\n   *\n   * **Example**:\n   *\n   *     fmt::dynamic_format_arg_store<fmt::format_context> store;\n   *     char band[] = \"Rolling Stones\";\n   *     store.push_back(std::cref(band));\n   *     band[9] = 'c'; // Changing str affects the output.\n   *     std::string result = fmt::vformat(\"{}\", store);\n   *     // result == \"Rolling Scones\"\n   */\n  template <typename T> void push_back(std::reference_wrapper<T> arg) {\n    static_assert(\n        need_copy<T>::value,\n        \"objects of built-in types and string views are always copied\");\n    emplace_arg(arg.get());\n  }\n\n  /**\n   * Adds named argument into the dynamic store for later passing to a\n   * formatting function. `std::reference_wrapper` is supported to avoid\n   * copying of the argument. The name is always copied into the store.\n   */\n  template <typename T> void push_back(const named_arg<T, char_type>& arg) {\n    const char_type* arg_name =\n        dynamic_args_.push<std::basic_string<char_type>>(arg.name).c_str();\n    if FMT_CONSTEXPR20 (need_copy<T>::value) {\n      emplace_arg(\n          fmt::arg(arg_name, dynamic_args_.push<stored_t<T>>(arg.value)));\n    } else {\n      emplace_arg(fmt::arg(arg_name, arg.value));\n    }\n  }\n\n  /// Erase all elements from the store.\n  void clear() {\n    data_.clear();\n    named_info_.clear();\n    dynamic_args_ = {};\n  }\n\n  /// Reserves space to store at least `new_cap` arguments including\n  /// `new_cap_named` named arguments.\n  void reserve(size_t new_cap, size_t new_cap_named) {\n    FMT_ASSERT(new_cap >= new_cap_named,\n               \"set of arguments includes set of named arguments\");\n    data_.reserve(new_cap);\n    named_info_.reserve(new_cap_named);\n  }\n\n  /// Returns the number of elements in the store.\n  auto size() const noexcept -> size_t { return data_.size(); }\n};\n\nFMT_END_NAMESPACE\n\n#endif  // FMT_ARGS_H_\n"
  },
  {
    "path": "include/fmt/base.h",
    "content": "// Formatting library for C++ - the base API for char/UTF-8\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_BASE_H_\n#define FMT_BASE_H_\n\n#if defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)\n#  define FMT_MODULE\n#endif\n\n#ifndef FMT_MODULE\n#  include <limits.h>  // CHAR_BIT\n#  include <stdio.h>   // FILE\n#  include <string.h>  // memcmp\n\n#  include <type_traits>  // std::enable_if\n#endif\n\n// The fmt library version in the form major * 10000 + minor * 100 + patch.\n#define FMT_VERSION 120101\n\n// Detect compiler versions.\n#if defined(__clang__) && !defined(__ibmxl__)\n#  define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)\n#else\n#  define FMT_CLANG_VERSION 0\n#endif\n#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)\n#  define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)\n#else\n#  define FMT_GCC_VERSION 0\n#endif\n#if defined(__ICL)\n#  define FMT_ICC_VERSION __ICL\n#elif defined(__INTEL_COMPILER)\n#  define FMT_ICC_VERSION __INTEL_COMPILER\n#else\n#  define FMT_ICC_VERSION 0\n#endif\n#if defined(_MSC_VER)\n#  define FMT_MSC_VERSION _MSC_VER\n#else\n#  define FMT_MSC_VERSION 0\n#endif\n\n// Detect standard library versions.\n#ifdef _GLIBCXX_RELEASE\n#  define FMT_GLIBCXX_RELEASE _GLIBCXX_RELEASE\n#else\n#  define FMT_GLIBCXX_RELEASE 0\n#endif\n#ifdef _LIBCPP_VERSION\n#  define FMT_LIBCPP_VERSION _LIBCPP_VERSION\n#else\n#  define FMT_LIBCPP_VERSION 0\n#endif\n\n#ifdef _MSVC_LANG\n#  define FMT_CPLUSPLUS _MSVC_LANG\n#else\n#  define FMT_CPLUSPLUS __cplusplus\n#endif\n\n// Detect __has_*.\n#ifdef __has_feature\n#  define FMT_HAS_FEATURE(x) __has_feature(x)\n#else\n#  define FMT_HAS_FEATURE(x) 0\n#endif\n#ifdef __has_include\n#  define FMT_HAS_INCLUDE(x) __has_include(x)\n#else\n#  define FMT_HAS_INCLUDE(x) 0\n#endif\n#ifdef __has_builtin\n#  define FMT_HAS_BUILTIN(x) __has_builtin(x)\n#else\n#  define FMT_HAS_BUILTIN(x) 0\n#endif\n#ifdef __has_cpp_attribute\n#  define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)\n#else\n#  define FMT_HAS_CPP_ATTRIBUTE(x) 0\n#endif\n\n#define FMT_HAS_CPP14_ATTRIBUTE(attribute) \\\n  (FMT_CPLUSPLUS >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute))\n\n#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \\\n  (FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute))\n\n// Detect C++14 relaxed constexpr.\n#ifdef FMT_USE_CONSTEXPR\n// Use the provided definition.\n#elif FMT_GCC_VERSION >= 702 && FMT_CPLUSPLUS >= 201402L\n// GCC only allows constexpr member functions in non-literal types since 7.2:\n// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66297.\n#  define FMT_USE_CONSTEXPR 1\n#elif FMT_ICC_VERSION\n#  define FMT_USE_CONSTEXPR 0  // https://github.com/fmtlib/fmt/issues/1628\n#elif FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VERSION >= 1912\n#  define FMT_USE_CONSTEXPR 1\n#else\n#  define FMT_USE_CONSTEXPR 0\n#endif\n#if FMT_USE_CONSTEXPR\n#  define FMT_CONSTEXPR constexpr\n#else\n#  define FMT_CONSTEXPR\n#endif\n\n// Detect consteval, C++20 constexpr extensions and std::is_constant_evaluated.\n#ifdef FMT_USE_CONSTEVAL\n// Use the provided definition.\n#elif !defined(__cpp_lib_is_constant_evaluated)\n#  define FMT_USE_CONSTEVAL 0\n#elif FMT_CPLUSPLUS < 201709L\n#  define FMT_USE_CONSTEVAL 0\n#elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10\n#  define FMT_USE_CONSTEVAL 0\n#elif FMT_LIBCPP_VERSION && FMT_LIBCPP_VERSION < 10000\n#  define FMT_USE_CONSTEVAL 0\n#elif defined(__apple_build_version__) && __apple_build_version__ < 14000029L\n#  define FMT_USE_CONSTEVAL 0  // consteval is broken in Apple clang < 14.\n#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1940\n#  define FMT_USE_CONSTEVAL 0  // consteval is broken in some MSVC2022 versions.\n#elif defined(__cpp_consteval)\n#  define FMT_USE_CONSTEVAL 1\n#elif FMT_GCC_VERSION >= 1002 || FMT_CLANG_VERSION >= 1101\n#  define FMT_USE_CONSTEVAL 1\n#else\n#  define FMT_USE_CONSTEVAL 0\n#endif\n#if FMT_USE_CONSTEVAL\n#  define FMT_CONSTEVAL consteval\n#  define FMT_CONSTEXPR20 constexpr\n#else\n#  define FMT_CONSTEVAL\n#  define FMT_CONSTEXPR20\n#endif\n\n// Check if exceptions are disabled.\n#ifdef FMT_USE_EXCEPTIONS\n// Use the provided definition.\n#elif defined(__GNUC__) && !defined(__EXCEPTIONS)\n#  define FMT_USE_EXCEPTIONS 0\n#elif defined(__clang__) && !defined(__cpp_exceptions)\n#  define FMT_USE_EXCEPTIONS 0\n#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS\n#  define FMT_USE_EXCEPTIONS 0\n#else\n#  define FMT_USE_EXCEPTIONS 1\n#endif\n#if FMT_USE_EXCEPTIONS\n#  define FMT_TRY try\n#  define FMT_CATCH(x) catch (x)\n#else\n#  define FMT_TRY if (true)\n#  define FMT_CATCH(x) if (false)\n#endif\n\n#ifdef FMT_NO_UNIQUE_ADDRESS\n// Use the provided definition.\n#elif FMT_CPLUSPLUS < 202002L\n// Not supported.\n#elif FMT_HAS_CPP_ATTRIBUTE(no_unique_address)\n#  define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]\n// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485).\n#elif FMT_MSC_VERSION >= 1929 && !FMT_CLANG_VERSION\n#  define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]\n#endif\n#ifndef FMT_NO_UNIQUE_ADDRESS\n#  define FMT_NO_UNIQUE_ADDRESS\n#endif\n\n#if FMT_HAS_CPP17_ATTRIBUTE(fallthrough)\n#  define FMT_FALLTHROUGH [[fallthrough]]\n#elif defined(__clang__)\n#  define FMT_FALLTHROUGH [[clang::fallthrough]]\n#elif FMT_GCC_VERSION >= 700 && \\\n    (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 520)\n#  define FMT_FALLTHROUGH [[gnu::fallthrough]]\n#else\n#  define FMT_FALLTHROUGH\n#endif\n\n// Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings.\n#if FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && !defined(__NVCC__)\n#  define FMT_NORETURN [[noreturn]]\n#else\n#  define FMT_NORETURN\n#endif\n\n#ifdef FMT_NODISCARD\n// Use the provided definition.\n#elif FMT_HAS_CPP17_ATTRIBUTE(nodiscard)\n#  define FMT_NODISCARD [[nodiscard]]\n#else\n#  define FMT_NODISCARD\n#endif\n\n#if FMT_GCC_VERSION || FMT_CLANG_VERSION\n#  define FMT_VISIBILITY(value) __attribute__((visibility(value)))\n#else\n#  define FMT_VISIBILITY(value)\n#endif\n\n// Detect pragmas.\n#define FMT_PRAGMA_IMPL(x) _Pragma(#x)\n#if FMT_GCC_VERSION >= 504 && !defined(__NVCOMPILER)\n// Workaround a _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884\n// and an nvhpc warning: https://github.com/fmtlib/fmt/pull/2582.\n#  define FMT_PRAGMA_GCC(x) FMT_PRAGMA_IMPL(GCC x)\n#else\n#  define FMT_PRAGMA_GCC(x)\n#endif\n#if FMT_CLANG_VERSION\n#  define FMT_PRAGMA_CLANG(x) FMT_PRAGMA_IMPL(clang x)\n#else\n#  define FMT_PRAGMA_CLANG(x)\n#endif\n\n// Enable minimal optimizations for more compact code in debug mode.\nFMT_PRAGMA_GCC(push_options)\n#if !defined(__OPTIMIZE__) && !defined(__CUDACC__) && !defined(FMT_MODULE)\nFMT_PRAGMA_GCC(optimize(\"Og\"))\n#endif\n\n#ifdef FMT_DEPRECATED\n// Use the provided definition.\n#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)\n#  define FMT_DEPRECATED [[deprecated]]\n#else\n#  define FMT_DEPRECATED /* deprecated */\n#endif\n\n#ifdef FMT_ALWAYS_INLINE\n// Use the provided definition.\n#elif FMT_GCC_VERSION || FMT_CLANG_VERSION\n#  define FMT_ALWAYS_INLINE inline __attribute__((always_inline))\n#else\n#  define FMT_ALWAYS_INLINE inline\n#endif\n// A version of FMT_ALWAYS_INLINE to prevent code bloat in debug mode.\n#ifdef NDEBUG\n#  define FMT_INLINE FMT_ALWAYS_INLINE\n#else\n#  define FMT_INLINE inline\n#endif\n\n#ifndef FMT_BEGIN_NAMESPACE\n#  define FMT_BEGIN_NAMESPACE \\\n    namespace fmt {           \\\n    inline namespace v12 {\n#  define FMT_END_NAMESPACE \\\n    }                       \\\n    }\n#endif\n\n#ifndef FMT_EXPORT\n#  define FMT_EXPORT\n#  define FMT_BEGIN_EXPORT\n#  define FMT_END_EXPORT\n#endif\n\n#ifdef _WIN32\n#  define FMT_WIN32 1\n#else\n#  define FMT_WIN32 0\n#endif\n\n#if !defined(FMT_HEADER_ONLY) && FMT_WIN32\n#  if defined(FMT_LIB_EXPORT)\n#    define FMT_API __declspec(dllexport)\n#  elif defined(FMT_SHARED)\n#    define FMT_API __declspec(dllimport)\n#  endif\n#elif defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)\n#  define FMT_API FMT_VISIBILITY(\"default\")\n#endif\n#ifndef FMT_API\n#  define FMT_API\n#endif\n\n#ifndef FMT_OPTIMIZE_SIZE\n#  define FMT_OPTIMIZE_SIZE 0\n#endif\n\n// FMT_BUILTIN_TYPE=0 may result in smaller library size at the cost of higher\n// per-call binary size by passing built-in types through the extension API.\n#ifndef FMT_BUILTIN_TYPES\n#  define FMT_BUILTIN_TYPES 1\n#endif\n\n#define FMT_APPLY_VARIADIC(expr) \\\n  using unused = int[];          \\\n  (void)unused { 0, (expr, 0)... }\n\nFMT_BEGIN_NAMESPACE\n\n// Implementations of enable_if_t and other metafunctions for older systems.\ntemplate <bool B, typename T = void>\nusing enable_if_t = typename std::enable_if<B, T>::type;\ntemplate <bool B, typename T, typename F>\nusing conditional_t = typename std::conditional<B, T, F>::type;\ntemplate <bool B> using bool_constant = std::integral_constant<bool, B>;\ntemplate <typename T>\nusing remove_reference_t = typename std::remove_reference<T>::type;\ntemplate <typename T>\nusing remove_const_t = typename std::remove_const<T>::type;\ntemplate <typename T>\nusing remove_cvref_t = typename std::remove_cv<remove_reference_t<T>>::type;\ntemplate <typename T>\nusing make_unsigned_t = typename std::make_unsigned<T>::type;\ntemplate <typename T>\nusing underlying_t = typename std::underlying_type<T>::type;\ntemplate <typename T> using decay_t = typename std::decay<T>::type;\nusing nullptr_t = decltype(nullptr);\n\nusing ullong = unsigned long long;\n\n#if (FMT_GCC_VERSION && FMT_GCC_VERSION < 500) || FMT_MSC_VERSION\n// A workaround for gcc 4.9 & MSVC v141 to make void_t work in a SFINAE context.\ntemplate <typename...> struct void_t_impl {\n  using type = void;\n};\ntemplate <typename... T> using void_t = typename void_t_impl<T...>::type;\n#else\ntemplate <typename...> using void_t = void;\n#endif\n\nstruct monostate {\n  constexpr monostate() {}\n};\n\n// An enable_if helper to be used in template parameters which results in much\n// shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed\n// to workaround a bug in MSVC 2019 (see #1140 and #1186).\n#ifdef FMT_DOC\n#  define FMT_ENABLE_IF(...)\n#else\n#  define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0\n#endif\n\ntemplate <typename T> constexpr auto min_of(T a, T b) -> T {\n  return a < b ? a : b;\n}\ntemplate <typename T> constexpr auto max_of(T a, T b) -> T {\n  return a > b ? a : b;\n}\n\nFMT_NORETURN FMT_API void assert_fail(const char* file, int line,\n                                      const char* message);\n\nnamespace detail {\n// Suppresses \"unused variable\" warnings with the method described in\n// https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/.\n// (void)var does not work on many Intel compilers.\ntemplate <typename... T> FMT_CONSTEXPR void ignore_unused(const T&...) {}\n\nconstexpr auto is_constant_evaluated(bool default_value = false) noexcept\n    -> bool {\n// Workaround for incompatibility between clang 14 and libstdc++ consteval-based\n// std::is_constant_evaluated: https://github.com/fmtlib/fmt/issues/3247.\n#if FMT_CPLUSPLUS >= 202002L && FMT_GLIBCXX_RELEASE >= 12 && \\\n    (FMT_CLANG_VERSION >= 1400 && FMT_CLANG_VERSION < 1500)\n  ignore_unused(default_value);\n  return __builtin_is_constant_evaluated();\n#elif defined(__cpp_lib_is_constant_evaluated)\n  ignore_unused(default_value);\n  return std::is_constant_evaluated();\n#else\n  return default_value;\n#endif\n}\n\n#ifdef FMT_ASSERT\n// Use the provided definition.\n#elif defined(NDEBUG)\n// FMT_ASSERT is not empty to avoid -Wempty-body.\n#  define FMT_ASSERT(condition, message) \\\n    fmt::detail::ignore_unused((condition), (message))\n#else\n#  define FMT_ASSERT(condition, message)                                    \\\n    ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \\\n         ? (void)0                                                          \\\n         : ::fmt::assert_fail(__FILE__, __LINE__, (message)))\n#endif\n\n#ifdef FMT_USE_INT128\n// Use the provided definition.\n#elif defined(__SIZEOF_INT128__) && !defined(__NVCC__) && \\\n    !(FMT_CLANG_VERSION && FMT_MSC_VERSION)\n#  define FMT_USE_INT128 1\nusing native_int128 = __int128_t;\nusing native_uint128 = __uint128_t;\ninline auto map(native_int128 x) -> native_int128 { return x; }\ninline auto map(native_uint128 x) -> native_uint128 { return x; }\n#else\n#  define FMT_USE_INT128 0\n#endif\n#if !FMT_USE_INT128\n// Fallbacks to reduce conditional compilation and SFINAE.\nenum class native_int128 {};\nenum class native_uint128 {};\ninline auto map(native_int128) -> monostate { return {}; }\ninline auto map(native_uint128) -> monostate { return {}; }\n#endif\n\n// Casts a nonnegative integer to unsigned.\ntemplate <typename Int>\nFMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t<Int> {\n  FMT_ASSERT(std::is_unsigned<Int>::value || value >= 0, \"negative value\");\n  return static_cast<make_unsigned_t<Int>>(value);\n}\n\ntemplate <typename Char>\nusing unsigned_char = conditional_t<sizeof(Char) == 1, unsigned char, unsigned>;\n\n// A heuristic to detect std::string and std::[experimental::]string_view.\n// It is mainly used to avoid dependency on <[experimental/]string_view>.\ntemplate <typename T, typename Enable = void>\nstruct is_std_string_like : std::false_type {};\ntemplate <typename T>\nstruct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(\n                                 typename T::value_type(), 0))>>\n    : std::is_convertible<decltype(std::declval<T>().data()),\n                          const typename T::value_type*> {};\n\n// Check if the literal encoding is UTF-8.\nenum { is_utf8_enabled = \"\\u00A7\"[1] == '\\xA7' };\nenum { use_utf8 = !FMT_WIN32 || is_utf8_enabled };\n\n#ifndef FMT_UNICODE\n#  define FMT_UNICODE 1\n#endif\n\nstatic_assert(!FMT_UNICODE || use_utf8,\n              \"Unicode support requires compiling with /utf-8\");\n\ntemplate <typename T> constexpr auto narrow(T*) -> char* { return nullptr; }\nconstexpr FMT_ALWAYS_INLINE auto narrow(const char* s) -> const char* {\n  return s;\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, size_t n) -> int {\n  if (!is_constant_evaluated() && sizeof(Char) == 1) return memcmp(s1, s2, n);\n  for (; n != 0; ++s1, ++s2, --n) {\n    if (*s1 < *s2) return -1;\n    if (*s1 > *s2) return 1;\n  }\n  return 0;\n}\n\nnamespace adl {\nusing namespace std;\n\ntemplate <typename Container>\nauto invoke_back_inserter()\n    -> decltype(back_inserter(std::declval<Container&>()));\n}  // namespace adl\n\ntemplate <typename It, typename Enable = std::true_type>\nstruct is_back_insert_iterator : std::false_type {};\n\ntemplate <typename It>\nstruct is_back_insert_iterator<\n    It, bool_constant<std::is_same<\n            decltype(adl::invoke_back_inserter<typename It::container_type>()),\n            It>::value>> : std::true_type {};\n\n// Extracts a reference to the container from *insert_iterator.\ntemplate <typename OutputIt>\ninline FMT_CONSTEXPR auto get_container(OutputIt it) ->\n    typename OutputIt::container_type& {\n  struct accessor : OutputIt {\n    constexpr accessor(OutputIt base) : OutputIt(base) {}\n    using OutputIt::container;\n  };\n  return *accessor(it).container;\n}\n}  // namespace detail\n\n// Parsing-related public API and forward declarations.\nFMT_BEGIN_EXPORT\n\n/**\n * An implementation of `std::basic_string_view` for pre-C++17 providing a\n * subset of the API. `fmt::basic_string_view` is used in the public API even\n * if `std::basic_string_view` is available to prevent issues when a library is\n * compiled with a different `-std` option than the client code (which is not\n * recommended).\n */\ntemplate <typename Char> class basic_string_view {\n private:\n  const Char* data_;\n  size_t size_;\n\n public:\n  using value_type = Char;\n  using iterator = const Char*;\n\n  constexpr basic_string_view() noexcept : data_(nullptr), size_(0) {}\n  constexpr basic_string_view(const Char* s, size_t count) noexcept\n      : data_(s), size_(count) {}\n\n#if FMT_GCC_VERSION\n  FMT_ALWAYS_INLINE\n#endif\n  FMT_CONSTEXPR basic_string_view(const Char* s) : data_(s) {\n#if FMT_HAS_BUILTIN(__builtin_strlen) || FMT_GCC_VERSION || FMT_CLANG_VERSION\n    if (std::is_same<Char, char>::value && !detail::is_constant_evaluated()) {\n      size_ = __builtin_strlen(detail::narrow(s));  // strlen is not constexpr.\n      return;\n    }\n#endif\n    size_t len = 0;\n    while (*s++) ++len;\n    size_ = len;\n  }\n\n  template <\n      typename S,\n      FMT_ENABLE_IF(detail::is_std_string_like<S>::value&&  //\n                        std::is_same<typename S::value_type, Char>::value)>\n  constexpr basic_string_view(const S& s) noexcept\n      : data_(s.data()), size_(s.size()) {}\n\n  constexpr auto data() const noexcept -> const Char* { return data_; }\n  constexpr auto size() const noexcept -> size_t { return size_; }\n\n  constexpr auto begin() const noexcept -> iterator { return data_; }\n  constexpr auto end() const noexcept -> iterator { return data_ + size_; }\n\n  constexpr auto operator[](size_t pos) const noexcept -> const Char& {\n    return data_[pos];\n  }\n\n  FMT_CONSTEXPR void remove_prefix(size_t n) noexcept {\n    data_ += n;\n    size_ -= n;\n  }\n\n  FMT_CONSTEXPR auto starts_with(basic_string_view sv) const noexcept -> bool {\n    return size_ >= sv.size_ && detail::compare(data_, sv.data_, sv.size_) == 0;\n  }\n  FMT_CONSTEXPR auto starts_with(Char c) const noexcept -> bool {\n    return size_ >= 1 && *data_ == c;\n  }\n  FMT_CONSTEXPR auto starts_with(const Char* s) const -> bool {\n    return starts_with(basic_string_view(s));\n  }\n\n  FMT_CONSTEXPR auto compare(basic_string_view other) const -> int {\n    int cmp = detail::compare(data_, other.data_, min_of(size_, other.size_));\n    if (cmp != 0) return cmp;\n    return size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);\n  }\n\n  FMT_CONSTEXPR friend auto operator==(basic_string_view lhs,\n                                       basic_string_view rhs) -> bool {\n    return lhs.compare(rhs) == 0;\n  }\n  friend auto operator!=(basic_string_view lhs, basic_string_view rhs) -> bool {\n    return lhs.compare(rhs) != 0;\n  }\n  friend auto operator<(basic_string_view lhs, basic_string_view rhs) -> bool {\n    return lhs.compare(rhs) < 0;\n  }\n  friend auto operator<=(basic_string_view lhs, basic_string_view rhs) -> bool {\n    return lhs.compare(rhs) <= 0;\n  }\n  friend auto operator>(basic_string_view lhs, basic_string_view rhs) -> bool {\n    return lhs.compare(rhs) > 0;\n  }\n  friend auto operator>=(basic_string_view lhs, basic_string_view rhs) -> bool {\n    return lhs.compare(rhs) >= 0;\n  }\n};\nusing string_view = basic_string_view<char>;\n\ntemplate <typename T> class basic_appender;\nusing appender = basic_appender<char>;\n\n// Checks whether T is a container with contiguous storage.\ntemplate <typename T> struct is_contiguous : std::false_type {};\n\nclass context;\ntemplate <typename OutputIt, typename Char> class generic_context;\ntemplate <typename Char> class parse_context;\n\n// Longer aliases for C++20 compatibility.\ntemplate <typename Char> using basic_format_parse_context = parse_context<Char>;\nusing format_parse_context = parse_context<char>;\ntemplate <typename OutputIt, typename Char>\nusing basic_format_context =\n    conditional_t<std::is_same<OutputIt, appender>::value, context,\n                  generic_context<OutputIt, Char>>;\nusing format_context = context;\n\ntemplate <typename Char>\nusing buffered_context =\n    conditional_t<std::is_same<Char, char>::value, context,\n                  generic_context<basic_appender<Char>, Char>>;\n\ntemplate <typename Context> class basic_format_arg;\ntemplate <typename Context> class basic_format_args;\n\n// A separate type would result in shorter symbols but break ABI compatibility\n// between clang and gcc on ARM (#1919).\nusing format_args = basic_format_args<context>;\n\n// A formatter for objects of type T.\ntemplate <typename T, typename Char = char, typename Enable = void>\nstruct formatter {\n  // A deleted default constructor indicates a disabled formatter.\n  formatter() = delete;\n};\n\ntemplate <typename T, typename Enable = void>\nstruct locking : std::false_type {};\n\n/// Reports a format error at compile time or, via a `format_error` exception,\n/// at runtime.\n// This function is intentionally not constexpr to give a compile-time error.\nFMT_NORETURN FMT_API void report_error(const char* message);\n\nenum class presentation_type : unsigned char {\n  // Common specifiers:\n  none = 0,\n  debug = 1,   // '?'\n  string = 2,  // 's' (string, bool)\n\n  // Integral, bool and character specifiers:\n  dec = 3,  // 'd'\n  hex,      // 'x' or 'X'\n  oct,      // 'o'\n  bin,      // 'b' or 'B'\n  chr,      // 'c'\n\n  // String and pointer specifiers:\n  pointer = 3,  // 'p'\n\n  // Floating-point specifiers:\n  exp = 1,  // 'e' or 'E' (1 since there is no FP debug presentation)\n  fixed,    // 'f' or 'F'\n  general,  // 'g' or 'G'\n  hexfloat  // 'a' or 'A'\n};\n\nenum class align { none, left, right, center, numeric };\nenum class sign { none, minus, plus, space };\nenum class arg_id_kind { none, index, name };\n\n// Basic format specifiers for built-in and string types.\nclass basic_specs {\n private:\n  // Data is arranged as follows:\n  //\n  //  0                   1                   2                   3\n  //  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1\n  // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n  // |type |align| w | p | s |u|#|L|  f  |          unused           |\n  // +-----+-----+---+---+---+-+-+-+-----+---------------------------+\n  //\n  //   w - dynamic width info\n  //   p - dynamic precision info\n  //   s - sign\n  //   u - uppercase (e.g. 'X' for 'x')\n  //   # - alternate form ('#')\n  //   L - localized\n  //   f - fill size\n  //\n  // Bitfields are not used because of compiler bugs such as gcc bug 61414.\n  enum : unsigned {\n    type_mask = 0x00007,\n    align_mask = 0x00038,\n    width_mask = 0x000C0,\n    precision_mask = 0x00300,\n    sign_mask = 0x00C00,\n    uppercase_mask = 0x01000,\n    alternate_mask = 0x02000,\n    localized_mask = 0x04000,\n    fill_size_mask = 0x38000,\n\n    align_shift = 3,\n    width_shift = 6,\n    precision_shift = 8,\n    sign_shift = 10,\n    fill_size_shift = 15,\n\n    max_fill_size = 4\n  };\n\n  unsigned data_ = 1 << fill_size_shift;\n  static_assert(sizeof(basic_specs::data_) * CHAR_BIT >= 18, \"\");\n\n  // Character (code unit) type is erased to prevent template bloat.\n  char fill_data_[max_fill_size] = {' '};\n\n  FMT_CONSTEXPR void set_fill_size(size_t size) {\n    data_ = (data_ & ~fill_size_mask) | (unsigned(size) << fill_size_shift);\n  }\n\n public:\n  constexpr auto type() const -> presentation_type {\n    return static_cast<presentation_type>(data_ & type_mask);\n  }\n  FMT_CONSTEXPR void set_type(presentation_type t) {\n    data_ = (data_ & ~type_mask) | unsigned(t);\n  }\n\n  constexpr auto align() const -> align {\n    return static_cast<fmt::align>((data_ & align_mask) >> align_shift);\n  }\n  FMT_CONSTEXPR void set_align(fmt::align a) {\n    data_ = (data_ & ~align_mask) | (unsigned(a) << align_shift);\n  }\n\n  constexpr auto dynamic_width() const -> arg_id_kind {\n    return static_cast<arg_id_kind>((data_ & width_mask) >> width_shift);\n  }\n  FMT_CONSTEXPR void set_dynamic_width(arg_id_kind w) {\n    data_ = (data_ & ~width_mask) | (unsigned(w) << width_shift);\n  }\n\n  FMT_CONSTEXPR auto dynamic_precision() const -> arg_id_kind {\n    return static_cast<arg_id_kind>((data_ & precision_mask) >>\n                                    precision_shift);\n  }\n  FMT_CONSTEXPR void set_dynamic_precision(arg_id_kind p) {\n    data_ = (data_ & ~precision_mask) | (unsigned(p) << precision_shift);\n  }\n\n  constexpr auto dynamic() const -> bool {\n    return (data_ & (width_mask | precision_mask)) != 0;\n  }\n\n  constexpr auto sign() const -> sign {\n    return static_cast<fmt::sign>((data_ & sign_mask) >> sign_shift);\n  }\n  FMT_CONSTEXPR void set_sign(fmt::sign s) {\n    data_ = (data_ & ~sign_mask) | (unsigned(s) << sign_shift);\n  }\n\n  constexpr auto upper() const -> bool { return (data_ & uppercase_mask) != 0; }\n  FMT_CONSTEXPR void set_upper() { data_ |= uppercase_mask; }\n\n  constexpr auto alt() const -> bool { return (data_ & alternate_mask) != 0; }\n  FMT_CONSTEXPR void set_alt() { data_ |= alternate_mask; }\n  FMT_CONSTEXPR void clear_alt() { data_ &= ~alternate_mask; }\n\n  constexpr auto localized() const -> bool {\n    return (data_ & localized_mask) != 0;\n  }\n  FMT_CONSTEXPR void set_localized() { data_ |= localized_mask; }\n\n  constexpr auto fill_size() const -> size_t {\n    return (data_ & fill_size_mask) >> fill_size_shift;\n  }\n\n  template <typename Char, FMT_ENABLE_IF(std::is_same<Char, char>::value)>\n  constexpr auto fill() const -> const Char* {\n    return fill_data_;\n  }\n  template <typename Char, FMT_ENABLE_IF(!std::is_same<Char, char>::value)>\n  constexpr auto fill() const -> const Char* {\n    return nullptr;\n  }\n\n  template <typename Char> constexpr auto fill_unit() const -> Char {\n    using uchar = unsigned char;\n    return Char(uchar(fill_data_[0]) | uchar(fill_data_[1]) << 8 |\n                uchar(fill_data_[2]) << 16);\n  }\n\n  FMT_CONSTEXPR void set_fill(char c) {\n    fill_data_[0] = c;\n    set_fill_size(1);\n  }\n\n  template <typename Char>\n  FMT_CONSTEXPR void set_fill(basic_string_view<Char> s) {\n    auto size = s.size();\n    set_fill_size(size);\n    if (size == 1) {\n      unsigned uchar = static_cast<detail::unsigned_char<Char>>(s[0]);\n      fill_data_[0] = char(uchar);\n      fill_data_[1] = char(uchar >> 8);\n      fill_data_[2] = char(uchar >> 16);\n      return;\n    }\n    FMT_ASSERT(size <= max_fill_size, \"invalid fill\");\n    for (size_t i = 0; i < size; ++i) fill_data_[i & 3] = char(s[i]);\n  }\n\n  FMT_CONSTEXPR void copy_fill_from(const basic_specs& specs) {\n    set_fill_size(specs.fill_size());\n    for (size_t i = 0; i < max_fill_size; ++i)\n      fill_data_[i] = specs.fill_data_[i];\n  }\n};\n\n// Format specifiers for built-in and string types.\nstruct format_specs : basic_specs {\n  int width;\n  int precision;\n\n  constexpr format_specs() : width(0), precision(-1) {}\n};\n\n/**\n * Parsing context consisting of a format string range being parsed and an\n * argument counter for automatic indexing.\n */\ntemplate <typename Char = char> class parse_context {\n private:\n  basic_string_view<Char> fmt_;\n  int next_arg_id_;\n\n  enum { use_constexpr_cast = !FMT_GCC_VERSION || FMT_GCC_VERSION >= 1200 };\n\n  FMT_CONSTEXPR void do_check_arg_id(int arg_id);\n\n public:\n  using char_type = Char;\n  using iterator = const Char*;\n\n  constexpr explicit parse_context(basic_string_view<Char> fmt,\n                                   int next_arg_id = 0)\n      : fmt_(fmt), next_arg_id_(next_arg_id) {}\n\n  /// Returns an iterator to the beginning of the format string range being\n  /// parsed.\n  constexpr auto begin() const noexcept -> iterator { return fmt_.begin(); }\n\n  /// Returns an iterator past the end of the format string range being parsed.\n  constexpr auto end() const noexcept -> iterator { return fmt_.end(); }\n\n  /// Advances the begin iterator to `it`.\n  FMT_CONSTEXPR void advance_to(iterator it) {\n    fmt_.remove_prefix(detail::to_unsigned(it - begin()));\n  }\n\n  /// Reports an error if using the manual argument indexing; otherwise returns\n  /// the next argument index and switches to the automatic indexing.\n  FMT_CONSTEXPR auto next_arg_id() -> int {\n    if (next_arg_id_ < 0) {\n      report_error(\"cannot switch from manual to automatic argument indexing\");\n      return 0;\n    }\n    int id = next_arg_id_++;\n    do_check_arg_id(id);\n    return id;\n  }\n\n  /// Reports an error if using the automatic argument indexing; otherwise\n  /// switches to the manual indexing.\n  FMT_CONSTEXPR void check_arg_id(int id) {\n    if (next_arg_id_ > 0) {\n      report_error(\"cannot switch from automatic to manual argument indexing\");\n      return;\n    }\n    next_arg_id_ = -1;\n    do_check_arg_id(id);\n  }\n  FMT_CONSTEXPR void check_arg_id(basic_string_view<Char>) {\n    next_arg_id_ = -1;\n  }\n  FMT_CONSTEXPR void check_dynamic_spec(int arg_id);\n};\n\n#ifndef FMT_USE_LOCALE\n#  define FMT_USE_LOCALE (FMT_OPTIMIZE_SIZE <= 1)\n#endif\n\n// A type-erased reference to std::locale to avoid the heavy <locale> include.\nclass locale_ref {\n#if FMT_USE_LOCALE\n private:\n  const void* locale_;  // A type-erased pointer to std::locale.\n\n public:\n  constexpr locale_ref() : locale_(nullptr) {}\n\n  template <typename Locale, FMT_ENABLE_IF(sizeof(Locale::collate) != 0)>\n  locale_ref(const Locale& loc) : locale_(&loc) {\n    // Check if std::isalpha is found via ADL to reduce the chance of misuse.\n    detail::ignore_unused(sizeof(isalpha('x', loc)));\n  }\n\n  inline explicit operator bool() const noexcept { return locale_ != nullptr; }\n#else\n public:\n  inline explicit operator bool() const noexcept { return false; }\n#endif  // FMT_USE_LOCALE\n\n public:\n  template <typename Locale> auto get() const -> Locale;\n};\n\nFMT_END_EXPORT\n\nnamespace detail {\n\n// Specifies if `T` is a code unit type.\ntemplate <typename T> struct is_code_unit : std::false_type {};\ntemplate <> struct is_code_unit<char> : std::true_type {};\ntemplate <> struct is_code_unit<wchar_t> : std::true_type {};\ntemplate <> struct is_code_unit<char16_t> : std::true_type {};\ntemplate <> struct is_code_unit<char32_t> : std::true_type {};\n#ifdef __cpp_char8_t\ntemplate <> struct is_code_unit<char8_t> : bool_constant<is_utf8_enabled> {};\n#endif\n\n// Constructs fmt::basic_string_view<Char> from types implicitly convertible\n// to it, deducing Char. Explicitly convertible types such as the ones returned\n// from FMT_STRING are intentionally excluded.\ntemplate <typename Char, FMT_ENABLE_IF(is_code_unit<Char>::value)>\nconstexpr auto to_string_view(const Char* s) -> basic_string_view<Char> {\n  return s;\n}\ntemplate <typename T, FMT_ENABLE_IF(is_std_string_like<T>::value)>\nconstexpr auto to_string_view(const T& s)\n    -> basic_string_view<typename T::value_type> {\n  return s;\n}\ntemplate <typename Char>\nconstexpr auto to_string_view(basic_string_view<Char> s)\n    -> basic_string_view<Char> {\n  return s;\n}\n\ntemplate <typename T, typename Enable = void>\nstruct has_to_string_view : std::false_type {};\n// detail:: is intentional since to_string_view is not an extension point.\ntemplate <typename T>\nstruct has_to_string_view<\n    T, void_t<decltype(detail::to_string_view(std::declval<T>()))>>\n    : std::true_type {};\n\n/// String's character (code unit) type. detail:: is intentional to prevent ADL.\ntemplate <typename S,\n          typename V = decltype(detail::to_string_view(std::declval<S>()))>\nusing char_t = typename V::value_type;\n\nenum class type {\n  none_type,\n  // Integer types should go first,\n  int_type,\n  uint_type,\n  long_long_type,\n  ulong_long_type,\n  int128_type,\n  uint128_type,\n  bool_type,\n  char_type,\n  last_integer_type = char_type,\n  // followed by floating-point types.\n  float_type,\n  double_type,\n  long_double_type,\n  last_numeric_type = long_double_type,\n  cstring_type,\n  string_type,\n  pointer_type,\n  custom_type\n};\n\n// Maps core type T to the corresponding type enum constant.\ntemplate <typename T, typename Char>\nstruct type_constant : std::integral_constant<type, type::custom_type> {};\n\n#define FMT_TYPE_CONSTANT(Type, constant) \\\n  template <typename Char>                \\\n  struct type_constant<Type, Char>        \\\n      : std::integral_constant<type, type::constant> {}\n\nFMT_TYPE_CONSTANT(int, int_type);\nFMT_TYPE_CONSTANT(unsigned, uint_type);\nFMT_TYPE_CONSTANT(long long, long_long_type);\nFMT_TYPE_CONSTANT(ullong, ulong_long_type);\nFMT_TYPE_CONSTANT(native_int128, int128_type);\nFMT_TYPE_CONSTANT(native_uint128, uint128_type);\nFMT_TYPE_CONSTANT(bool, bool_type);\nFMT_TYPE_CONSTANT(Char, char_type);\nFMT_TYPE_CONSTANT(float, float_type);\nFMT_TYPE_CONSTANT(double, double_type);\nFMT_TYPE_CONSTANT(long double, long_double_type);\nFMT_TYPE_CONSTANT(const Char*, cstring_type);\nFMT_TYPE_CONSTANT(basic_string_view<Char>, string_type);\nFMT_TYPE_CONSTANT(const void*, pointer_type);\n\nconstexpr auto is_integral_type(type t) -> bool {\n  return t > type::none_type && t <= type::last_integer_type;\n}\nconstexpr auto is_arithmetic_type(type t) -> bool {\n  return t > type::none_type && t <= type::last_numeric_type;\n}\n\nconstexpr auto set(type rhs) -> int { return 1 << int(rhs); }\nconstexpr auto in(type t, int set) -> bool {\n  return ((set >> int(t)) & 1) != 0;\n}\n\n// Bitsets of types.\nenum {\n  sint_set =\n      set(type::int_type) | set(type::long_long_type) | set(type::int128_type),\n  uint_set = set(type::uint_type) | set(type::ulong_long_type) |\n             set(type::uint128_type),\n  bool_set = set(type::bool_type),\n  char_set = set(type::char_type),\n  float_set = set(type::float_type) | set(type::double_type) |\n              set(type::long_double_type),\n  string_set = set(type::string_type),\n  cstring_set = set(type::cstring_type),\n  pointer_set = set(type::pointer_type)\n};\n\nstruct view {};\n\ntemplate <typename T, typename Enable = std::true_type>\nstruct is_view : std::false_type {};\ntemplate <typename T>\nstruct is_view<T, bool_constant<sizeof(T) != 0>> : std::is_base_of<view, T> {};\n\n// DEPRECATED! named_arg will be moved to the fmt namespace.\ntemplate <typename T, typename Char> struct named_arg;\ntemplate <typename T> struct is_named_arg : std::false_type {};\ntemplate <typename T> struct is_static_named_arg : std::false_type {};\n\ntemplate <typename T, typename Char>\nstruct is_named_arg<named_arg<T, Char>> : std::true_type {};\n\ntemplate <typename T, typename Char = char> struct named_arg : view {\n  const Char* name;\n  const T& value;\n\n  named_arg(const Char* n, const T& v) : name(n), value(v) {}\n  static_assert(!is_named_arg<T>::value, \"nested named arguments\");\n};\n\ntemplate <bool B = false> constexpr auto count() -> int { return B ? 1 : 0; }\ntemplate <bool B1, bool B2, bool... Tail> constexpr auto count() -> int {\n  return (B1 ? 1 : 0) + count<B2, Tail...>();\n}\n\ntemplate <typename... T> constexpr auto count_named_args() -> int {\n  return count<is_named_arg<T>::value...>();\n}\ntemplate <typename... T> constexpr auto count_static_named_args() -> int {\n  return count<is_static_named_arg<T>::value...>();\n}\n\ntemplate <typename Char> struct named_arg_info {\n  const Char* name;\n  int id;\n};\n\n// named_args is non-const to suppress a bogus -Wmaybe-uninitialized in gcc 13.\ntemplate <typename Char>\nFMT_CONSTEXPR void check_for_duplicate(named_arg_info<Char>* named_args,\n                                       int named_arg_index,\n                                       basic_string_view<Char> arg_name) {\n  for (int i = 0; i < named_arg_index; ++i) {\n    if (named_args[i].name == arg_name) report_error(\"duplicate named arg\");\n  }\n}\n\ntemplate <typename Char, typename T, FMT_ENABLE_IF(!is_named_arg<T>::value)>\nvoid init_named_arg(named_arg_info<Char>*, int& arg_index, int&, const T&) {\n  ++arg_index;\n}\ntemplate <typename Char, typename T, FMT_ENABLE_IF(is_named_arg<T>::value)>\nvoid init_named_arg(named_arg_info<Char>* named_args, int& arg_index,\n                    int& named_arg_index, const T& arg) {\n  check_for_duplicate<Char>(named_args, named_arg_index, arg.name);\n  named_args[named_arg_index++] = {arg.name, arg_index++};\n}\n\ntemplate <typename T, typename Char,\n          FMT_ENABLE_IF(!is_static_named_arg<T>::value)>\nFMT_CONSTEXPR void init_static_named_arg(named_arg_info<Char>*, int& arg_index,\n                                         int&) {\n  ++arg_index;\n}\ntemplate <typename T, typename Char,\n          FMT_ENABLE_IF(is_static_named_arg<T>::value)>\nFMT_CONSTEXPR void init_static_named_arg(named_arg_info<Char>* named_args,\n                                         int& arg_index, int& named_arg_index) {\n  check_for_duplicate<Char>(named_args, named_arg_index, T::name);\n  named_args[named_arg_index++] = {T::name, arg_index++};\n}\n\n// To minimize the number of types we need to deal with, long is translated\n// either to int or to long long depending on its size.\nenum { long_short = sizeof(long) == sizeof(int) && FMT_BUILTIN_TYPES };\nusing long_type = conditional_t<long_short, int, long long>;\nusing ulong_type = conditional_t<long_short, unsigned, ullong>;\n\ntemplate <typename T>\nusing format_as_result =\n    remove_cvref_t<decltype(format_as(std::declval<const T&>()))>;\ntemplate <typename T>\nusing format_as_member_result =\n    remove_cvref_t<decltype(formatter<T>::format_as(std::declval<const T&>()))>;\n\ntemplate <typename T, typename Enable = std::true_type>\nstruct use_format_as : std::false_type {};\n// format_as member is only used to avoid injection into the std namespace.\ntemplate <typename T, typename Enable = std::true_type>\nstruct use_format_as_member : std::false_type {};\n\n// Only map owning types because mapping views can be unsafe.\ntemplate <typename T>\nstruct use_format_as<\n    T, bool_constant<std::is_arithmetic<format_as_result<T>>::value>>\n    : std::true_type {};\ntemplate <typename T>\nstruct use_format_as_member<\n    T, bool_constant<std::is_arithmetic<format_as_member_result<T>>::value>>\n    : std::true_type {};\n\ntemplate <typename T, typename U = remove_const_t<T>>\nusing use_formatter =\n    bool_constant<(std::is_class<T>::value || std::is_enum<T>::value ||\n                   std::is_union<T>::value || std::is_array<T>::value) &&\n                  !has_to_string_view<T>::value && !is_named_arg<T>::value &&\n                  !use_format_as<T>::value && !use_format_as_member<U>::value>;\n\ntemplate <typename Char, typename T, typename U = remove_const_t<T>>\nauto has_formatter_impl(T* p, buffered_context<Char>* ctx = nullptr)\n    -> decltype(formatter<U, Char>().format(*p, *ctx), std::true_type());\ntemplate <typename Char> auto has_formatter_impl(...) -> std::false_type;\n\n// T can be const-qualified to check if it is const-formattable.\ntemplate <typename T, typename Char> constexpr auto has_formatter() -> bool {\n  return decltype(has_formatter_impl<Char>(static_cast<T*>(nullptr)))::value;\n}\n\n// Maps formatting argument types to natively supported types or user-defined\n// types with formatters. Returns void on errors to be SFINAE-friendly.\ntemplate <typename Char> struct type_mapper {\n  static auto map(signed char) -> int;\n  static auto map(unsigned char) -> unsigned;\n  static auto map(short) -> int;\n  static auto map(unsigned short) -> unsigned;\n  static auto map(int) -> int;\n  static auto map(unsigned) -> unsigned;\n  static auto map(long) -> long_type;\n  static auto map(unsigned long) -> ulong_type;\n  static auto map(long long) -> long long;\n  static auto map(ullong) -> ullong;\n  static auto map(native_int128) -> native_int128;\n  static auto map(native_uint128) -> native_uint128;\n  static auto map(bool) -> bool;\n\n  template <typename T, FMT_ENABLE_IF(is_code_unit<T>::value)>\n  static auto map(T) -> conditional_t<\n      std::is_same<T, char>::value || std::is_same<T, Char>::value, Char, void>;\n\n  static auto map(float) -> float;\n  static auto map(double) -> double;\n  static auto map(long double) -> long double;\n\n  static auto map(Char*) -> const Char*;\n  static auto map(const Char*) -> const Char*;\n  template <typename T, typename C = char_t<T>,\n            FMT_ENABLE_IF(!std::is_pointer<T>::value)>\n  static auto map(const T&) -> conditional_t<std::is_same<C, Char>::value,\n                                             basic_string_view<C>, void>;\n\n  static auto map(void*) -> const void*;\n  static auto map(const void*) -> const void*;\n  static auto map(volatile void*) -> const void*;\n  static auto map(const volatile void*) -> const void*;\n  static auto map(nullptr_t) -> const void*;\n  template <typename T, FMT_ENABLE_IF(std::is_pointer<T>::value ||\n                                      std::is_member_pointer<T>::value)>\n  static auto map(const T&) -> void;\n\n  template <typename T, FMT_ENABLE_IF(use_format_as<T>::value)>\n  static auto map(const T& x) -> decltype(map(format_as(x)));\n  template <typename T, FMT_ENABLE_IF(use_format_as_member<T>::value)>\n  static auto map(const T& x) -> decltype(map(formatter<T>::format_as(x)));\n\n  template <typename T, FMT_ENABLE_IF(use_formatter<T>::value)>\n  static auto map(T&) -> conditional_t<has_formatter<T, Char>(), T&, void>;\n\n  template <typename T, FMT_ENABLE_IF(is_named_arg<T>::value)>\n  static auto map(const T& named_arg) -> decltype(map(named_arg.value));\n};\n\n// detail:: is used to workaround a bug in MSVC 2017.\ntemplate <typename T, typename Char>\nusing mapped_t = decltype(detail::type_mapper<Char>::map(std::declval<T&>()));\n\n// A type constant after applying type_mapper.\ntemplate <typename T, typename Char = char>\nusing mapped_type_constant = type_constant<mapped_t<T, Char>, Char>;\n\ntemplate <typename T, typename Context,\n          type TYPE =\n              mapped_type_constant<T, typename Context::char_type>::value>\nusing stored_type_constant = std::integral_constant<\n    type, Context::builtin_types || TYPE == type::int_type ? TYPE\n                                                           : type::custom_type>;\n// A parse context with extra data used only in compile-time checks.\ntemplate <typename Char>\nclass compile_parse_context : public parse_context<Char> {\n private:\n  int num_args_;\n  const type* types_;\n  using base = parse_context<Char>;\n\n public:\n  constexpr explicit compile_parse_context(basic_string_view<Char> fmt,\n                                           int num_args, const type* types,\n                                           int next_arg_id = 0)\n      : base(fmt, next_arg_id), num_args_(num_args), types_(types) {}\n\n  constexpr auto num_args() const -> int { return num_args_; }\n  constexpr auto arg_type(int id) const -> type { return types_[id]; }\n\n  FMT_CONSTEXPR auto next_arg_id() -> int {\n    int id = base::next_arg_id();\n    if (id >= num_args_) report_error(\"argument not found\");\n    return id;\n  }\n\n  FMT_CONSTEXPR void check_arg_id(int id) {\n    base::check_arg_id(id);\n    if (id >= num_args_) report_error(\"argument not found\");\n  }\n  using base::check_arg_id;\n\n  FMT_CONSTEXPR void check_dynamic_spec(int arg_id) {\n    if (arg_id < num_args_ && types_ && !is_integral_type(types_[arg_id]))\n      report_error(\"width/precision is not integer\");\n  }\n};\n\n// An argument reference.\ntemplate <typename Char> union arg_ref {\n  FMT_CONSTEXPR arg_ref(int idx = 0) : index(idx) {}\n  FMT_CONSTEXPR arg_ref(basic_string_view<Char> n) : name(n) {}\n\n  int index;\n  basic_string_view<Char> name;\n};\n\n// Format specifiers with width and precision resolved at formatting rather\n// than parsing time to allow reusing the same parsed specifiers with\n// different sets of arguments (precompilation of format strings).\ntemplate <typename Char = char> struct dynamic_format_specs : format_specs {\n  arg_ref<Char> width_ref;\n  arg_ref<Char> precision_ref;\n};\n\n// Converts a character to ASCII. Returns '\\0' on conversion failure.\ntemplate <typename Char, FMT_ENABLE_IF(std::is_integral<Char>::value)>\nconstexpr auto to_ascii(Char c) -> char {\n  return c <= 0xff ? char(c) : '\\0';\n}\n\n// Returns the number of code units in a code point or 1 on error.\ntemplate <typename Char>\nFMT_CONSTEXPR auto code_point_length(const Char* begin) -> int {\n  if FMT_CONSTEXPR20 (sizeof(Char) != 1) return 1;\n  auto c = static_cast<unsigned char>(*begin);\n  return static_cast<int>((0x3a55000000000000ull >> (2 * (c >> 3))) & 3) + 1;\n}\n\n// Parses the range [begin, end) as an unsigned integer. This function assumes\n// that the range is non-empty and the first character is a digit.\ntemplate <typename Char>\nFMT_CONSTEXPR auto parse_nonnegative_int(const Char*& begin, const Char* end,\n                                         int error_value) noexcept -> int {\n  FMT_ASSERT(begin != end && '0' <= *begin && *begin <= '9', \"\");\n  unsigned value = 0, prev = 0;\n  auto p = begin;\n  do {\n    prev = value;\n    value = value * 10 + unsigned(*p - '0');\n    ++p;\n  } while (p != end && '0' <= *p && *p <= '9');\n  auto num_digits = p - begin;\n  begin = p;\n  int digits10 = int(sizeof(int) * CHAR_BIT * 3 / 10);\n  if (num_digits <= digits10) return int(value);\n  // Check for overflow.\n  unsigned max = INT_MAX;\n  return num_digits == digits10 + 1 &&\n                 prev * 10ull + unsigned(p[-1] - '0') <= max\n             ? int(value)\n             : error_value;\n}\n\nFMT_CONSTEXPR inline auto parse_align(char c) -> align {\n  switch (c) {\n  case '<': return align::left;\n  case '>': return align::right;\n  case '^': return align::center;\n  }\n  return align::none;\n}\n\ntemplate <typename Char> constexpr auto is_name_start(Char c) -> bool {\n  return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '_';\n}\n\ntemplate <typename Char, typename Handler>\nFMT_CONSTEXPR auto parse_arg_id(const Char* begin, const Char* end,\n                                Handler&& handler) -> const Char* {\n  Char c = *begin;\n  if (c >= '0' && c <= '9') {\n    int index = 0;\n    if (c != '0')\n      index = parse_nonnegative_int(begin, end, INT_MAX);\n    else\n      ++begin;\n    if (begin == end || (*begin != '}' && *begin != ':'))\n      report_error(\"invalid format string\");\n    else\n      handler.on_index(index);\n    return begin;\n  }\n  if (FMT_OPTIMIZE_SIZE > 1 || !is_name_start(c)) {\n    report_error(\"invalid format string\");\n    return begin;\n  }\n  auto it = begin;\n  do {\n    ++it;\n  } while (it != end && (is_name_start(*it) || ('0' <= *it && *it <= '9')));\n  handler.on_name({begin, to_unsigned(it - begin)});\n  return it;\n}\n\ntemplate <typename Char> struct dynamic_spec_handler {\n  parse_context<Char>& ctx;\n  arg_ref<Char>& ref;\n  arg_id_kind& kind;\n\n  FMT_CONSTEXPR void on_index(int id) {\n    ref = id;\n    kind = arg_id_kind::index;\n    ctx.check_arg_id(id);\n    ctx.check_dynamic_spec(id);\n  }\n  FMT_CONSTEXPR void on_name(basic_string_view<Char> id) {\n    ref = id;\n    kind = arg_id_kind::name;\n    ctx.check_arg_id(id);\n  }\n};\n\ntemplate <typename Char> struct parse_dynamic_spec_result {\n  const Char* end;\n  arg_id_kind kind;\n};\n\n// Parses integer | \"{\" [arg_id] \"}\".\ntemplate <typename Char>\nFMT_CONSTEXPR auto parse_dynamic_spec(const Char* begin, const Char* end,\n                                      int& value, arg_ref<Char>& ref,\n                                      parse_context<Char>& ctx)\n    -> parse_dynamic_spec_result<Char> {\n  FMT_ASSERT(begin != end, \"\");\n  auto kind = arg_id_kind::none;\n  if ('0' <= *begin && *begin <= '9') {\n    int val = parse_nonnegative_int(begin, end, -1);\n    if (val == -1) report_error(\"number is too big\");\n    value = val;\n  } else {\n    if (*begin == '{') {\n      ++begin;\n      if (begin != end) {\n        Char c = *begin;\n        if (c == '}' || c == ':') {\n          int id = ctx.next_arg_id();\n          ref = id;\n          kind = arg_id_kind::index;\n          ctx.check_dynamic_spec(id);\n        } else {\n          begin = parse_arg_id(begin, end,\n                               dynamic_spec_handler<Char>{ctx, ref, kind});\n        }\n      }\n      if (begin != end && *begin == '}') return {++begin, kind};\n    }\n    report_error(\"invalid format string\");\n  }\n  return {begin, kind};\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto parse_width(const Char* begin, const Char* end,\n                               format_specs& specs, arg_ref<Char>& width_ref,\n                               parse_context<Char>& ctx) -> const Char* {\n  auto result = parse_dynamic_spec(begin, end, specs.width, width_ref, ctx);\n  specs.set_dynamic_width(result.kind);\n  return result.end;\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto parse_precision(const Char* begin, const Char* end,\n                                   format_specs& specs,\n                                   arg_ref<Char>& precision_ref,\n                                   parse_context<Char>& ctx) -> const Char* {\n  ++begin;\n  if (begin == end) {\n    report_error(\"invalid precision\");\n    return begin;\n  }\n  auto result =\n      parse_dynamic_spec(begin, end, specs.precision, precision_ref, ctx);\n  specs.set_dynamic_precision(result.kind);\n  return result.end;\n}\n\nenum class state { start, align, sign, hash, zero, width, precision, locale };\n\n// Parses standard format specifiers.\ntemplate <typename Char>\nFMT_CONSTEXPR auto parse_format_specs(const Char* begin, const Char* end,\n                                      dynamic_format_specs<Char>& specs,\n                                      parse_context<Char>& ctx, type arg_type)\n    -> const Char* {\n  auto c = '\\0';\n  if (end - begin > 1) {\n    auto next = to_ascii(begin[1]);\n    c = parse_align(next) == align::none ? to_ascii(*begin) : '\\0';\n  } else {\n    if (begin == end) return begin;\n    c = to_ascii(*begin);\n  }\n\n  struct {\n    state current_state = state::start;\n    FMT_CONSTEXPR void operator()(state s, bool valid = true) {\n      if (current_state >= s || !valid)\n        report_error(\"invalid format specifier\");\n      current_state = s;\n    }\n  } enter_state;\n\n  using pres = presentation_type;\n  constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;\n  struct {\n    const Char*& begin;\n    format_specs& specs;\n    type arg_type;\n\n    FMT_CONSTEXPR auto operator()(pres pres_type, int set) -> const Char* {\n      if (!in(arg_type, set)) report_error(\"invalid format specifier\");\n      specs.set_type(pres_type);\n      return begin + 1;\n    }\n  } parse_presentation_type{begin, specs, arg_type};\n\n  for (;;) {\n    switch (c) {\n    case '<':\n    case '>':\n    case '^':\n      enter_state(state::align);\n      specs.set_align(parse_align(c));\n      ++begin;\n      break;\n    case '+':\n    case ' ':\n      specs.set_sign(c == ' ' ? sign::space : sign::plus);\n      FMT_FALLTHROUGH;\n    case '-':\n      enter_state(state::sign, in(arg_type, sint_set | float_set));\n      ++begin;\n      break;\n    case '#':\n      enter_state(state::hash, is_arithmetic_type(arg_type));\n      specs.set_alt();\n      ++begin;\n      break;\n    case '0':\n      enter_state(state::zero);\n      if (!is_arithmetic_type(arg_type))\n        report_error(\"format specifier requires numeric argument\");\n      if (specs.align() == align::none) {\n        // Ignore 0 if align is specified for compatibility with std::format.\n        specs.set_align(align::numeric);\n        specs.set_fill('0');\n      }\n      ++begin;\n      break;\n      // clang-format off\n    case '1': case '2': case '3': case '4': case '5':\n    case '6': case '7': case '8': case '9': case '{':\n      // clang-format on\n      enter_state(state::width);\n      begin = parse_width(begin, end, specs, specs.width_ref, ctx);\n      break;\n    case '.':\n      enter_state(state::precision,\n                  in(arg_type, float_set | string_set | cstring_set));\n      begin = parse_precision(begin, end, specs, specs.precision_ref, ctx);\n      break;\n    case 'L':\n      enter_state(state::locale, is_arithmetic_type(arg_type));\n      specs.set_localized();\n      ++begin;\n      break;\n    case 'd': return parse_presentation_type(pres::dec, integral_set);\n    case 'X': specs.set_upper(); FMT_FALLTHROUGH;\n    case 'x': return parse_presentation_type(pres::hex, integral_set);\n    case 'o': return parse_presentation_type(pres::oct, integral_set);\n    case 'B': specs.set_upper(); FMT_FALLTHROUGH;\n    case 'b': return parse_presentation_type(pres::bin, integral_set);\n    case 'E': specs.set_upper(); FMT_FALLTHROUGH;\n    case 'e': return parse_presentation_type(pres::exp, float_set);\n    case 'F': specs.set_upper(); FMT_FALLTHROUGH;\n    case 'f': return parse_presentation_type(pres::fixed, float_set);\n    case 'G': specs.set_upper(); FMT_FALLTHROUGH;\n    case 'g': return parse_presentation_type(pres::general, float_set);\n    case 'A': specs.set_upper(); FMT_FALLTHROUGH;\n    case 'a': return parse_presentation_type(pres::hexfloat, float_set);\n    case 'c':\n      if (arg_type == type::bool_type) report_error(\"invalid format specifier\");\n      return parse_presentation_type(pres::chr, integral_set);\n    case 's':\n      return parse_presentation_type(pres::string,\n                                     bool_set | string_set | cstring_set);\n    case 'p':\n      return parse_presentation_type(pres::pointer, pointer_set | cstring_set);\n    case '?':\n      return parse_presentation_type(pres::debug,\n                                     char_set | string_set | cstring_set);\n    case '}': return begin;\n    default:  {\n      if (*begin == '}') return begin;\n      // Parse fill and alignment.\n      auto fill_end = begin + code_point_length(begin);\n      if (end - fill_end <= 0) {\n        report_error(\"invalid format specifier\");\n        return begin;\n      }\n      if (*begin == '{') {\n        report_error(\"invalid fill character '{'\");\n        return begin;\n      }\n      auto alignment = parse_align(to_ascii(*fill_end));\n      enter_state(state::align, alignment != align::none);\n      specs.set_fill(\n          basic_string_view<Char>(begin, to_unsigned(fill_end - begin)));\n      specs.set_align(alignment);\n      begin = fill_end + 1;\n    }\n    }\n    if (begin == end) return begin;\n    c = to_ascii(*begin);\n  }\n}\n\ntemplate <typename Char, typename Handler>\nFMT_CONSTEXPR FMT_INLINE auto parse_replacement_field(const Char* begin,\n                                                      const Char* end,\n                                                      Handler&& handler)\n    -> const Char* {\n  ++begin;\n  if (begin == end) {\n    handler.on_error(\"invalid format string\");\n    return end;\n  }\n  int arg_id = 0;\n  switch (*begin) {\n  case '}':\n    handler.on_replacement_field(handler.on_arg_id(), begin);\n    return begin + 1;\n  case '{': handler.on_text(begin, begin + 1); return begin + 1;\n  case ':': arg_id = handler.on_arg_id(); break;\n  default:  {\n    struct id_adapter {\n      Handler& handler;\n      int arg_id;\n\n      FMT_CONSTEXPR void on_index(int id) { arg_id = handler.on_arg_id(id); }\n      FMT_CONSTEXPR void on_name(basic_string_view<Char> id) {\n        arg_id = handler.on_arg_id(id);\n      }\n    } adapter = {handler, 0};\n    begin = parse_arg_id(begin, end, adapter);\n    arg_id = adapter.arg_id;\n    Char c = begin != end ? *begin : Char();\n    if (c == '}') {\n      handler.on_replacement_field(arg_id, begin);\n      return begin + 1;\n    }\n    if (c != ':') {\n      handler.on_error(\"missing '}' in format string\");\n      return end;\n    }\n    break;\n  }\n  }\n  begin = handler.on_format_specs(arg_id, begin + 1, end);\n  if (begin == end || *begin != '}')\n    return handler.on_error(\"unknown format specifier\"), end;\n  return begin + 1;\n}\n\ntemplate <typename Char, typename Handler>\nFMT_CONSTEXPR void parse_format_string(basic_string_view<Char> fmt,\n                                       Handler&& handler) {\n  auto begin = fmt.data(), end = begin + fmt.size();\n  auto p = begin;\n  while (p != end) {\n    auto c = *p++;\n    if (c == '{') {\n      handler.on_text(begin, p - 1);\n      begin = p = parse_replacement_field(p - 1, end, handler);\n    } else if (c == '}') {\n      if (p == end || *p != '}')\n        return handler.on_error(\"unmatched '}' in format string\");\n      handler.on_text(begin, p);\n      begin = ++p;\n    }\n  }\n  handler.on_text(begin, end);\n}\n\n// Checks char specs and returns true iff the presentation type is char-like.\nFMT_CONSTEXPR inline auto check_char_specs(const format_specs& specs) -> bool {\n  auto type = specs.type();\n  if (type != presentation_type::none && type != presentation_type::chr &&\n      type != presentation_type::debug) {\n    return false;\n  }\n  if (specs.align() == align::numeric || specs.sign() != sign::none ||\n      specs.alt()) {\n    report_error(\"invalid format specifier for char\");\n  }\n  return true;\n}\n\n// A base class for compile-time strings.\nstruct compile_string {};\n\ntemplate <typename T, typename Char>\nFMT_VISIBILITY(\"hidden\")  // Suppress an ld warning on macOS (#3769).\nFMT_CONSTEXPR auto invoke_parse(parse_context<Char>& ctx) -> const Char* {\n  using mapped_type = remove_cvref_t<mapped_t<T, Char>>;\n  constexpr bool formattable =\n      std::is_constructible<formatter<mapped_type, Char>>::value;\n  if (!formattable) return ctx.begin();  // Error is reported in the value ctor.\n  using formatted_type = conditional_t<formattable, mapped_type, int>;\n  return formatter<formatted_type, Char>().parse(ctx);\n}\n\ntemplate <typename... T> struct arg_pack {};\n\ntemplate <typename Char, int NUM_ARGS, int NUM_NAMED_ARGS, bool DYNAMIC_NAMES>\nclass format_string_checker {\n private:\n  type types_[max_of<size_t>(1, NUM_ARGS)];\n  named_arg_info<Char> named_args_[max_of<size_t>(1, NUM_NAMED_ARGS)];\n  compile_parse_context<Char> context_;\n\n  using parse_func = auto (*)(parse_context<Char>&) -> const Char*;\n  parse_func parse_funcs_[max_of<size_t>(1, NUM_ARGS)];\n\n public:\n  template <typename... T>\n  FMT_CONSTEXPR explicit format_string_checker(basic_string_view<Char> fmt,\n                                               arg_pack<T...>)\n      : types_{mapped_type_constant<T, Char>::value...},\n        named_args_{},\n        context_(fmt, NUM_ARGS, types_),\n        parse_funcs_{&invoke_parse<T, Char>...} {\n    int arg_index = 0, named_arg_index = 0;\n    FMT_APPLY_VARIADIC(\n        init_static_named_arg<T>(named_args_, arg_index, named_arg_index));\n    ignore_unused(arg_index, named_arg_index);\n  }\n\n  FMT_CONSTEXPR void on_text(const Char*, const Char*) {}\n\n  FMT_CONSTEXPR auto on_arg_id() -> int { return context_.next_arg_id(); }\n  FMT_CONSTEXPR auto on_arg_id(int id) -> int {\n    context_.check_arg_id(id);\n    return id;\n  }\n  FMT_CONSTEXPR auto on_arg_id(basic_string_view<Char> id) -> int {\n    for (int i = 0; i < NUM_NAMED_ARGS; ++i) {\n      if (named_args_[i].name == id) return named_args_[i].id;\n    }\n    if (!DYNAMIC_NAMES) on_error(\"argument not found\");\n    return -1;\n  }\n\n  FMT_CONSTEXPR void on_replacement_field(int id, const Char* begin) {\n    on_format_specs(id, begin, begin);  // Call parse() on empty specs.\n  }\n\n  FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char* end)\n      -> const Char* {\n    context_.advance_to(begin);\n    if (id >= 0 && id < NUM_ARGS) return parse_funcs_[id](context_);\n\n    // If id is out of range, it means we do not know the type and cannot parse\n    // the format at compile time. Instead, skip over content until we finish\n    // the format spec, accounting for any nested replacements.\n    for (int bracket_count = 0;\n         begin != end && (bracket_count > 0 || *begin != '}'); ++begin) {\n      if (*begin == '{')\n        ++bracket_count;\n      else if (*begin == '}')\n        --bracket_count;\n    }\n    return begin;\n  }\n\n  FMT_NORETURN FMT_CONSTEXPR void on_error(const char* message) {\n    report_error(message);\n  }\n};\n\n/// A contiguous memory buffer with an optional growing ability. It is an\n/// internal class and shouldn't be used directly, only via `memory_buffer`.\ntemplate <typename T> class buffer {\n private:\n  T* ptr_;\n  size_t size_;\n  size_t capacity_;\n\n  using grow_fun = void (*)(buffer& buf, size_t capacity);\n  grow_fun grow_;\n\n protected:\n  // Don't initialize ptr_ since it is not accessed to save a few cycles.\n  FMT_CONSTEXPR buffer(grow_fun grow, size_t sz) noexcept\n      : size_(sz), capacity_(sz), grow_(grow) {\n    if (FMT_MSC_VERSION != 0) ptr_ = nullptr;  // Suppress warning 26495.\n  }\n\n  constexpr buffer(grow_fun grow, T* p = nullptr, size_t sz = 0,\n                   size_t cap = 0) noexcept\n      : ptr_(p), size_(sz), capacity_(cap), grow_(grow) {}\n\n  FMT_CONSTEXPR20 ~buffer() = default;\n  buffer(buffer&&) = default;\n\n  /// Sets the buffer data and capacity.\n  FMT_CONSTEXPR void set(T* buf_data, size_t buf_capacity) noexcept {\n    ptr_ = buf_data;\n    capacity_ = buf_capacity;\n  }\n\n public:\n  using value_type = T;\n  using const_reference = const T&;\n\n  buffer(const buffer&) = delete;\n  void operator=(const buffer&) = delete;\n\n  auto begin() noexcept -> T* { return ptr_; }\n  auto end() noexcept -> T* { return ptr_ + size_; }\n\n  auto begin() const noexcept -> const T* { return ptr_; }\n  auto end() const noexcept -> const T* { return ptr_ + size_; }\n\n  /// Returns the size of this buffer.\n  constexpr auto size() const noexcept -> size_t { return size_; }\n\n  /// Returns the capacity of this buffer.\n  constexpr auto capacity() const noexcept -> size_t { return capacity_; }\n\n  /// Returns a pointer to the buffer data (not null-terminated).\n  FMT_CONSTEXPR auto data() noexcept -> T* { return ptr_; }\n  FMT_CONSTEXPR auto data() const noexcept -> const T* { return ptr_; }\n\n  /// Clears this buffer.\n  FMT_CONSTEXPR void clear() { size_ = 0; }\n\n  // Tries resizing the buffer to contain `count` elements. If T is a POD type\n  // the new elements may not be initialized.\n  FMT_CONSTEXPR void try_resize(size_t count) {\n    try_reserve(count);\n    size_ = min_of(count, capacity_);\n  }\n\n  // Tries increasing the buffer capacity to `new_capacity`. It can increase the\n  // capacity by a smaller amount than requested but guarantees there is space\n  // for at least one additional element either by increasing the capacity or by\n  // flushing the buffer if it is full.\n  FMT_CONSTEXPR void try_reserve(size_t new_capacity) {\n    if (new_capacity > capacity_) grow_(*this, new_capacity);\n  }\n\n  FMT_CONSTEXPR void push_back(const T& value) {\n    try_reserve(size_ + 1);\n    ptr_[size_++] = value;\n  }\n\n  /// Appends data to the end of the buffer.\n  template <typename U>\n  FMT_CONSTEXPR20 void append(const U* begin, const U* end) {\n    static_assert(std::is_same<T, U>() || std::is_same<U, char>(), \"\");\n    while (begin != end) {\n      auto size = size_;\n      auto free_cap = capacity_ - size;\n      auto count = to_unsigned(end - begin);\n      if (free_cap < count) {\n        grow_(*this, size + count);\n        size = size_;\n        free_cap = capacity_ - size;\n        count = count < free_cap ? count : free_cap;\n      }\n      // A loop is faster than memcpy on small sizes.\n      T* out = ptr_ + size;\n      for (size_t i = 0; i < count; ++i) out[i] = static_cast<T>(begin[i]);\n      size_ += count;\n      begin += count;\n    }\n  }\n\n  template <typename Idx> FMT_CONSTEXPR auto operator[](Idx index) -> T& {\n    return ptr_[index];\n  }\n  template <typename Idx>\n  constexpr auto operator[](Idx index) const -> const T& {\n    return ptr_[index];\n  }\n};\n\nstruct buffer_traits {\n  constexpr explicit buffer_traits(size_t) {}\n  constexpr auto count() const -> size_t { return 0; }\n  constexpr auto limit(size_t size) const -> size_t { return size; }\n};\n\nclass fixed_buffer_traits {\n private:\n  size_t count_ = 0;\n  size_t limit_;\n\n public:\n  constexpr explicit fixed_buffer_traits(size_t limit) : limit_(limit) {}\n  constexpr auto count() const -> size_t { return count_; }\n  FMT_CONSTEXPR auto limit(size_t size) -> size_t {\n    size_t n = limit_ > count_ ? limit_ - count_ : 0;\n    count_ += size;\n    return min_of(size, n);\n  }\n};\n\n// A buffer that writes to an output iterator when flushed.\ntemplate <typename OutputIt, typename T, typename Traits = buffer_traits>\nclass iterator_buffer : public Traits, public buffer<T> {\n private:\n  OutputIt out_;\n  enum { buffer_size = 256 };\n  T data_[buffer_size];\n\n  static FMT_CONSTEXPR void grow(buffer<T>& buf, size_t) {\n    if (buf.size() == buffer_size) static_cast<iterator_buffer&>(buf).flush();\n  }\n\n  void flush() {\n    auto size = this->size();\n    this->clear();\n    const T* begin = data_;\n    const T* end = begin + this->limit(size);\n    while (begin != end) *out_++ = *begin++;\n  }\n\n public:\n  explicit iterator_buffer(OutputIt out, size_t n = buffer_size)\n      : Traits(n), buffer<T>(grow, data_, 0, buffer_size), out_(out) {}\n  iterator_buffer(iterator_buffer&& other) noexcept\n      : Traits(other),\n        buffer<T>(grow, data_, 0, buffer_size),\n        out_(other.out_) {}\n  ~iterator_buffer() {\n    // Don't crash if flush fails during unwinding.\n    FMT_TRY { flush(); }\n    FMT_CATCH(...) {}\n  }\n\n  auto out() -> OutputIt {\n    flush();\n    return out_;\n  }\n  auto count() const -> size_t { return Traits::count() + this->size(); }\n};\n\ntemplate <typename T>\nclass iterator_buffer<T*, T, fixed_buffer_traits> : public fixed_buffer_traits,\n                                                    public buffer<T> {\n private:\n  T* out_;\n  enum { buffer_size = 256 };\n  T data_[buffer_size];\n\n  static FMT_CONSTEXPR void grow(buffer<T>& buf, size_t) {\n    if (buf.size() == buf.capacity())\n      static_cast<iterator_buffer&>(buf).flush();\n  }\n\n  void flush() {\n    size_t n = this->limit(this->size());\n    if (this->data() == out_) {\n      out_ += n;\n      this->set(data_, buffer_size);\n    }\n    this->clear();\n  }\n\n public:\n  explicit iterator_buffer(T* out, size_t n = buffer_size)\n      : fixed_buffer_traits(n), buffer<T>(grow, out, 0, n), out_(out) {}\n  iterator_buffer(iterator_buffer&& other) noexcept\n      : fixed_buffer_traits(other),\n        buffer<T>(static_cast<iterator_buffer&&>(other)),\n        out_(other.out_) {\n    if (this->data() != out_) {\n      this->set(data_, buffer_size);\n      this->clear();\n    }\n  }\n  ~iterator_buffer() { flush(); }\n\n  auto out() -> T* {\n    flush();\n    return out_;\n  }\n  auto count() const -> size_t {\n    return fixed_buffer_traits::count() + this->size();\n  }\n};\n\ntemplate <typename T> class iterator_buffer<T*, T> : public buffer<T> {\n public:\n  explicit iterator_buffer(T* out, size_t = 0)\n      : buffer<T>([](buffer<T>&, size_t) {}, out, 0, ~size_t()) {}\n\n  auto out() -> T* { return &*this->end(); }\n};\n\ntemplate <typename Container>\nclass container_buffer : public buffer<typename Container::value_type> {\n private:\n  using value_type = typename Container::value_type;\n\n  static FMT_CONSTEXPR void grow(buffer<value_type>& buf, size_t capacity) {\n    auto& self = static_cast<container_buffer&>(buf);\n    self.container.resize(capacity);\n    self.set(&self.container[0], capacity);\n  }\n\n public:\n  Container& container;\n\n  explicit container_buffer(Container& c)\n      : buffer<value_type>(grow, c.size()), container(c) {}\n};\n\n// A buffer that writes to a container with the contiguous storage.\ntemplate <typename OutputIt>\nclass iterator_buffer<\n    OutputIt,\n    enable_if_t<is_back_insert_iterator<OutputIt>::value &&\n                    is_contiguous<typename OutputIt::container_type>::value,\n                typename OutputIt::container_type::value_type>>\n    : public container_buffer<typename OutputIt::container_type> {\n private:\n  using base = container_buffer<typename OutputIt::container_type>;\n\n public:\n  explicit iterator_buffer(typename OutputIt::container_type& c) : base(c) {}\n  explicit iterator_buffer(OutputIt out, size_t = 0)\n      : base(get_container(out)) {}\n\n  auto out() -> OutputIt { return OutputIt(this->container); }\n};\n\n// A buffer that counts the number of code units written discarding the output.\ntemplate <typename T = char> class counting_buffer : public buffer<T> {\n private:\n  enum { buffer_size = 256 };\n  T data_[buffer_size];\n  size_t count_ = 0;\n\n  static FMT_CONSTEXPR void grow(buffer<T>& buf, size_t) {\n    if (buf.size() != buffer_size) return;\n    static_cast<counting_buffer&>(buf).count_ += buf.size();\n    buf.clear();\n  }\n\n public:\n  constexpr counting_buffer() : buffer<T>(grow, data_, 0, buffer_size) {}\n\n  constexpr auto count() const noexcept -> size_t {\n    return count_ + this->size();\n  }\n};\n\ntemplate <typename T>\nstruct is_back_insert_iterator<basic_appender<T>> : std::true_type {};\n\ntemplate <typename It, typename Enable = std::true_type>\nstruct is_buffer_appender : std::false_type {};\ntemplate <typename It>\nstruct is_buffer_appender<\n    It, bool_constant<\n            is_back_insert_iterator<It>::value &&\n            std::is_base_of<buffer<typename It::container_type::value_type>,\n                            typename It::container_type>::value>>\n    : std::true_type {};\n\n// Maps an output iterator to a buffer.\ntemplate <typename T, typename OutputIt,\n          FMT_ENABLE_IF(!is_buffer_appender<OutputIt>::value)>\nauto get_buffer(OutputIt out) -> iterator_buffer<OutputIt, T> {\n  return iterator_buffer<OutputIt, T>(out);\n}\ntemplate <typename T, typename OutputIt,\n          FMT_ENABLE_IF(is_buffer_appender<OutputIt>::value)>\nauto get_buffer(OutputIt out) -> buffer<T>& {\n  return get_container(out);\n}\n\ntemplate <typename Buf, typename OutputIt>\nauto get_iterator(Buf& buf, OutputIt) -> decltype(buf.out()) {\n  return buf.out();\n}\ntemplate <typename T, typename OutputIt>\nauto get_iterator(buffer<T>&, OutputIt out) -> OutputIt {\n  return out;\n}\n\n// This type is intentionally undefined, only used for errors.\ntemplate <typename T, typename Char> struct type_is_unformattable_for;\n\ntemplate <typename Char> struct string_value {\n  const Char* data;\n  size_t size;\n  auto str() const -> basic_string_view<Char> { return {data, size}; }\n};\n\ntemplate <typename Context> struct custom_value {\n  using char_type = typename Context::char_type;\n  void* value;\n  void (*format)(void* arg, parse_context<char_type>& parse_ctx, Context& ctx);\n};\n\ntemplate <typename Char> struct named_arg_value {\n  const named_arg_info<Char>* data;\n  size_t size;\n};\n\nstruct custom_tag {};\n\n#if !FMT_BUILTIN_TYPES\n#  define FMT_BUILTIN , monostate\n#else\n#  define FMT_BUILTIN\n#endif\n\n// A formatting argument value.\ntemplate <typename Context> class value {\n public:\n  using char_type = typename Context::char_type;\n\n  union {\n    monostate no_value;\n    int int_value;\n    unsigned uint_value;\n    long long long_long_value;\n    ullong ulong_long_value;\n    native_int128 int128_value;\n    native_uint128 uint128_value;\n    bool bool_value;\n    char_type char_value;\n    float float_value;\n    double double_value;\n    long double long_double_value;\n    const void* pointer;\n    string_value<char_type> string;\n    custom_value<Context> custom;\n    named_arg_value<char_type> named_args;\n  };\n\n  constexpr FMT_INLINE value() : no_value() {}\n  constexpr FMT_INLINE value(signed char x) : int_value(x) {}\n  constexpr FMT_INLINE value(unsigned char x FMT_BUILTIN) : uint_value(x) {}\n  constexpr FMT_INLINE value(signed short x) : int_value(x) {}\n  constexpr FMT_INLINE value(unsigned short x FMT_BUILTIN) : uint_value(x) {}\n  constexpr FMT_INLINE value(int x) : int_value(x) {}\n  constexpr FMT_INLINE value(unsigned x FMT_BUILTIN) : uint_value(x) {}\n  constexpr FMT_INLINE value(long x FMT_BUILTIN) : value(long_type(x)) {}\n  constexpr FMT_INLINE value(unsigned long x FMT_BUILTIN)\n      : value(ulong_type(x)) {}\n  constexpr FMT_INLINE value(long long x FMT_BUILTIN) : long_long_value(x) {}\n  constexpr FMT_INLINE value(ullong x FMT_BUILTIN) : ulong_long_value(x) {}\n  FMT_INLINE value(native_int128 x FMT_BUILTIN) : int128_value(x) {}\n  FMT_INLINE value(native_uint128 x FMT_BUILTIN) : uint128_value(x) {}\n  constexpr FMT_INLINE value(bool x FMT_BUILTIN) : bool_value(x) {}\n\n  template <typename T, FMT_ENABLE_IF(is_code_unit<T>::value)>\n  constexpr FMT_INLINE value(T x FMT_BUILTIN) : char_value(x) {\n    static_assert(\n        std::is_same<T, char>::value || std::is_same<T, char_type>::value,\n        \"mixing character types is disallowed\");\n  }\n\n  constexpr FMT_INLINE value(float x FMT_BUILTIN) : float_value(x) {}\n  constexpr FMT_INLINE value(double x FMT_BUILTIN) : double_value(x) {}\n  FMT_INLINE value(long double x FMT_BUILTIN) : long_double_value(x) {}\n\n  FMT_CONSTEXPR FMT_INLINE value(char_type* x FMT_BUILTIN) {\n    string.data = x;\n    if (is_constant_evaluated()) string.size = 0;\n  }\n  FMT_CONSTEXPR FMT_INLINE value(const char_type* x FMT_BUILTIN) {\n    string.data = x;\n    if (is_constant_evaluated()) string.size = 0;\n  }\n  template <typename T, typename C = char_t<T>,\n            FMT_ENABLE_IF(!std::is_pointer<T>::value)>\n  FMT_CONSTEXPR value(const T& x FMT_BUILTIN) {\n    static_assert(std::is_same<C, char_type>::value,\n                  \"mixing character types is disallowed\");\n    auto sv = to_string_view(x);\n    string.data = sv.data();\n    string.size = sv.size();\n  }\n  constexpr FMT_INLINE value(void* x FMT_BUILTIN) : pointer(x) {}\n  constexpr FMT_INLINE value(const void* x FMT_BUILTIN) : pointer(x) {}\n  constexpr FMT_INLINE value(volatile void* x FMT_BUILTIN)\n      : pointer(const_cast<const void*>(x)) {}\n  constexpr FMT_INLINE value(const volatile void* x FMT_BUILTIN)\n      : pointer(const_cast<const void*>(x)) {}\n  constexpr FMT_INLINE value(nullptr_t) : pointer(nullptr) {}\n\n  template <typename T,\n            FMT_ENABLE_IF(\n                (std::is_pointer<T>::value ||\n                 std::is_member_pointer<T>::value) &&\n                !std::is_void<typename std::remove_pointer<T>::type>::value)>\n  constexpr value(const T&) {\n    // Formatting of arbitrary pointers is disallowed. If you want to format a\n    // pointer cast it to `void*` or `const void*`. In particular, this forbids\n    // formatting of `[const] volatile char*` printed as bool by iostreams.\n    static_assert(sizeof(T) == 0,\n                  \"formatting of non-void pointers is disallowed\");\n  }\n\n  template <typename T, FMT_ENABLE_IF(use_format_as<T>::value)>\n  constexpr value(const T& x) : value(format_as(x)) {}\n  template <typename T, FMT_ENABLE_IF(use_format_as_member<T>::value)>\n  constexpr value(const T& x) : value(formatter<T>::format_as(x)) {}\n\n  template <typename T, FMT_ENABLE_IF(is_named_arg<T>::value)>\n  constexpr value(const T& named_arg) : value(named_arg.value) {}\n\n  template <typename T,\n            FMT_ENABLE_IF(use_formatter<T>::value || !FMT_BUILTIN_TYPES)>\n  FMT_CONSTEXPR FMT_INLINE value(T& x) : value(x, custom_tag()) {}\n\n  FMT_ALWAYS_INLINE value(const named_arg_info<char_type>* args, size_t size)\n      : named_args{args, size} {}\n\n private:\n  template <typename T, FMT_ENABLE_IF(has_formatter<T, char_type>())>\n  FMT_CONSTEXPR value(T& x, custom_tag) {\n    using value_type = remove_const_t<T>;\n    // T may overload operator& e.g. std::vector<bool>::reference in libc++.\n    if (!is_constant_evaluated()) {\n      custom.value =\n          const_cast<char*>(&reinterpret_cast<const volatile char&>(x));\n    } else {\n      custom.value = nullptr;\n#if defined(__cpp_if_constexpr)\n      if constexpr (std::is_same<decltype(&x), remove_reference_t<T>*>::value)\n        custom.value = const_cast<value_type*>(&x);\n#endif\n    }\n    custom.format = format_custom<value_type>;\n  }\n\n  template <typename T, FMT_ENABLE_IF(!has_formatter<T, char_type>())>\n  FMT_CONSTEXPR value(const T&, custom_tag) {\n    // Cannot format an argument; to make type T formattable provide a\n    // formatter<T> specialization: https://fmt.dev/latest/api#udt.\n    type_is_unformattable_for<T, char_type> _;\n  }\n\n  // Formats an argument of a custom type, such as a user-defined class.\n  template <typename T>\n  static void format_custom(void* arg, parse_context<char_type>& parse_ctx,\n                            Context& ctx) {\n    auto f = formatter<T, char_type>();\n    parse_ctx.advance_to(f.parse(parse_ctx));\n    using qualified_type =\n        conditional_t<has_formatter<const T, char_type>(), const T, T>;\n    // format must be const for compatibility with std::format and compilation.\n    const auto& cf = f;\n    ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));\n  }\n};\n\nenum { packed_arg_bits = 4 };\n// Maximum number of arguments with packed types.\nenum { max_packed_args = 62 / packed_arg_bits };\nenum : ullong { is_unpacked_bit = 1ULL << 63 };\nenum : ullong { has_named_args_bit = 1ULL << 62 };\n\ntemplate <typename It, typename T, typename Enable = void>\nstruct is_output_iterator : std::false_type {};\n\ntemplate <> struct is_output_iterator<appender, char> : std::true_type {};\n\ntemplate <typename It, typename T>\nstruct is_output_iterator<\n    It, T,\n    enable_if_t<std::is_assignable<decltype(*std::declval<decay_t<It>&>()++),\n                                   T>::value>> : std::true_type {};\n\ntemplate <typename> constexpr auto encode_types() -> ullong { return 0; }\n\ntemplate <typename Context, typename First, typename... T>\nconstexpr auto encode_types() -> ullong {\n  return unsigned(stored_type_constant<First, Context>::value) |\n         (encode_types<Context, T...>() << packed_arg_bits);\n}\n\ntemplate <typename Context, typename... T, size_t NUM_ARGS = sizeof...(T)>\nconstexpr auto make_descriptor() -> ullong {\n  return NUM_ARGS <= max_packed_args ? encode_types<Context, T...>()\n                                     : is_unpacked_bit | NUM_ARGS;\n}\n\ntemplate <typename Context, int NUM_ARGS>\nusing arg_t = conditional_t<NUM_ARGS <= max_packed_args, value<Context>,\n                            basic_format_arg<Context>>;\n\ntemplate <typename Context, int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC>\nstruct named_arg_store {\n  // args_[0].named_args points to named_args to avoid bloating format_args.\n  arg_t<Context, NUM_ARGS> args[NUM_ARGS + 1u];\n  named_arg_info<typename Context::char_type> named_args[NUM_NAMED_ARGS + 0u];\n\n  template <typename... T>\n  FMT_CONSTEXPR FMT_ALWAYS_INLINE named_arg_store(T&... values)\n      : args{{named_args, NUM_NAMED_ARGS}, values...} {\n    int arg_index = 0, named_arg_index = 0;\n    FMT_APPLY_VARIADIC(\n        init_named_arg(named_args, arg_index, named_arg_index, values));\n  }\n\n  named_arg_store(named_arg_store&& rhs) {\n    args[0] = {named_args, NUM_NAMED_ARGS};\n    for (size_t i = 1; i < sizeof(args) / sizeof(*args); ++i)\n      args[i] = rhs.args[i];\n    for (size_t i = 0; i < NUM_NAMED_ARGS; ++i)\n      named_args[i] = rhs.named_args[i];\n  }\n\n  named_arg_store(const named_arg_store& rhs) = delete;\n  auto operator=(const named_arg_store& rhs) -> named_arg_store& = delete;\n  auto operator=(named_arg_store&& rhs) -> named_arg_store& = delete;\n  operator const arg_t<Context, NUM_ARGS>*() const { return args + 1; }\n};\n\n// An array of references to arguments. It can be implicitly converted to\n// `basic_format_args` for passing into type-erased formatting functions\n// such as `vformat`. It is a plain struct to reduce binary size in debug mode.\ntemplate <typename Context, int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC>\nstruct format_arg_store {\n  // +1 to workaround a bug in gcc 7.5 that causes duplicated-branches warning.\n  using type =\n      conditional_t<NUM_NAMED_ARGS == 0,\n                    arg_t<Context, NUM_ARGS>[max_of<size_t>(1, NUM_ARGS)],\n                    named_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>>;\n  type args;\n};\n\n// TYPE can be different from type_constant<T>, e.g. for __float128.\ntemplate <typename T, typename Char, type TYPE> struct native_formatter {\n private:\n  dynamic_format_specs<Char> specs_;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    if (ctx.begin() == ctx.end() || *ctx.begin() == '}') return ctx.begin();\n    auto end = parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx, TYPE);\n    if FMT_CONSTEXPR20 (TYPE == type::char_type) check_char_specs(specs_);\n    return end;\n  }\n\n  template <type U = TYPE,\n            FMT_ENABLE_IF(U == type::string_type || U == type::cstring_type ||\n                          U == type::char_type)>\n  FMT_CONSTEXPR void set_debug_format(bool set = true) {\n    specs_.set_type(set ? presentation_type::debug : presentation_type::none);\n  }\n\n  template <typename FormatContext>\n  FMT_CONSTEXPR auto format(const T& val, FormatContext& ctx) const\n      -> decltype(ctx.out());\n};\n\ntemplate <bool B> constexpr bool enforce_compile_checks() {\n#ifdef FMT_ENFORCE_COMPILE_STRING\n  static_assert(\n      FMT_USE_CONSTEVAL && B,\n      \"FMT_ENFORCE_COMPILE_STRING requires format strings to use FMT_STRING\");\n#endif\n  return true;\n}\n\ntemplate <typename T = int> constexpr auto is_locking() -> bool {\n  return locking<remove_cvref_t<T>>::value;\n}\ntemplate <typename T1, typename T2, typename... Tail>\nconstexpr auto is_locking() -> bool {\n  return locking<remove_cvref_t<T1>>::value || is_locking<T2, Tail...>();\n}\n\nFMT_API void vformat_to(buffer<char>& buf, string_view fmt, format_args args,\n                        locale_ref loc = {});\n\n#if FMT_WIN32\nFMT_API void vprint_mojibake(FILE*, string_view, format_args, bool);\n#else  // format_args is passed by reference since it is defined later.\ninline void vprint_mojibake(FILE*, string_view, const format_args&, bool) {}\n#endif\n}  // namespace detail\n\n// The main public API.\n\ntemplate <typename T, typename Char = char>\nusing named_arg = detail::named_arg<T, Char>;\n\ntemplate <typename Char>\nFMT_CONSTEXPR void parse_context<Char>::do_check_arg_id(int arg_id) {\n  // Argument id is only checked at compile time during parsing because\n  // formatting has its own validation.\n  if (detail::is_constant_evaluated() && use_constexpr_cast) {\n    auto ctx = static_cast<detail::compile_parse_context<Char>*>(this);\n    if (arg_id >= ctx->num_args()) report_error(\"argument not found\");\n  }\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR void parse_context<Char>::check_dynamic_spec(int arg_id) {\n  using detail::compile_parse_context;\n  if (detail::is_constant_evaluated() && use_constexpr_cast)\n    static_cast<compile_parse_context<Char>*>(this)->check_dynamic_spec(arg_id);\n}\n\nFMT_BEGIN_EXPORT\n\n// An output iterator that appends to a buffer. It is used instead of\n// back_insert_iterator to reduce symbol sizes and avoid <iterator> dependency.\ntemplate <typename T> class basic_appender {\n protected:\n  detail::buffer<T>* container;\n\n public:\n  using container_type = detail::buffer<T>;\n\n  constexpr basic_appender(detail::buffer<T>& buf) : container(&buf) {}\n\n  FMT_CONSTEXPR auto operator=(T c) -> basic_appender& {\n    container->push_back(c);\n    return *this;\n  }\n  FMT_CONSTEXPR auto operator*() -> basic_appender& { return *this; }\n  FMT_CONSTEXPR auto operator++() -> basic_appender& { return *this; }\n  FMT_CONSTEXPR auto operator++(int) -> basic_appender { return *this; }\n};\n\n// A formatting argument. Context is a template parameter for the compiled API\n// where output can be unbuffered.\ntemplate <typename Context> class basic_format_arg {\n private:\n  detail::value<Context> value_;\n  detail::type type_;\n\n  friend class basic_format_args<Context>;\n\n  using char_type = typename Context::char_type;\n\n public:\n  class handle {\n   private:\n    detail::custom_value<Context> custom_;\n\n   public:\n    explicit handle(detail::custom_value<Context> custom) : custom_(custom) {}\n\n    void format(parse_context<char_type>& parse_ctx, Context& ctx) const {\n      custom_.format(custom_.value, parse_ctx, ctx);\n    }\n  };\n\n  constexpr basic_format_arg() : type_(detail::type::none_type) {}\n  basic_format_arg(const detail::named_arg_info<char_type>* args, size_t size)\n      : value_(args, size) {}\n  template <typename T>\n  basic_format_arg(T&& val)\n      : value_(val), type_(detail::stored_type_constant<T, Context>::value) {}\n\n  constexpr explicit operator bool() const noexcept {\n    return type_ != detail::type::none_type;\n  }\n  auto type() const -> detail::type { return type_; }\n\n  /**\n   * Visits an argument dispatching to the appropriate visit method based on\n   * the argument type. For example, if the argument type is `double` then\n   * `vis(value)` will be called with the value of type `double`.\n   */\n  template <typename Visitor>\n  FMT_CONSTEXPR FMT_INLINE auto visit(Visitor&& vis) const -> decltype(vis(0)) {\n    using detail::map;\n    switch (type_) {\n    case detail::type::none_type:        break;\n    case detail::type::int_type:         return vis(value_.int_value);\n    case detail::type::uint_type:        return vis(value_.uint_value);\n    case detail::type::long_long_type:   return vis(value_.long_long_value);\n    case detail::type::ulong_long_type:  return vis(value_.ulong_long_value);\n    case detail::type::int128_type:      return vis(map(value_.int128_value));\n    case detail::type::uint128_type:     return vis(map(value_.uint128_value));\n    case detail::type::bool_type:        return vis(value_.bool_value);\n    case detail::type::char_type:        return vis(value_.char_value);\n    case detail::type::float_type:       return vis(value_.float_value);\n    case detail::type::double_type:      return vis(value_.double_value);\n    case detail::type::long_double_type: return vis(value_.long_double_value);\n    case detail::type::cstring_type:     return vis(value_.string.data);\n    case detail::type::string_type:      return vis(value_.string.str());\n    case detail::type::pointer_type:     return vis(value_.pointer);\n    case detail::type::custom_type:      return vis(handle(value_.custom));\n    }\n    return vis(monostate());\n  }\n\n  auto format_custom(const char_type* parse_begin,\n                     parse_context<char_type>& parse_ctx, Context& ctx)\n      -> bool {\n    if (type_ != detail::type::custom_type) return false;\n    parse_ctx.advance_to(parse_begin);\n    value_.custom.format(value_.custom.value, parse_ctx, ctx);\n    return true;\n  }\n};\n\n/**\n * A view of a collection of formatting arguments. To avoid lifetime issues it\n * should only be used as a parameter type in type-erased functions such as\n * `vformat`:\n *\n *     void vlog(fmt::string_view fmt, fmt::format_args args);  // OK\n *     fmt::format_args args = fmt::make_format_args();  // Dangling reference\n */\ntemplate <typename Context> class basic_format_args {\n private:\n  // A descriptor that contains information about formatting arguments.\n  // If the number of arguments is less or equal to max_packed_args then\n  // argument types are passed in the descriptor. This reduces binary code size\n  // per formatting function call.\n  ullong desc_;\n  union {\n    // If is_packed() returns true then argument values are stored in values_;\n    // otherwise they are stored in args_. This is done to improve cache\n    // locality and reduce compiled code size since storing larger objects\n    // may require more code (at least on x86-64) even if the same amount of\n    // data is actually copied to stack. It saves ~10% on the bloat test.\n    const detail::value<Context>* values_;\n    const basic_format_arg<Context>* args_;\n  };\n\n  constexpr auto is_packed() const -> bool {\n    return (desc_ & detail::is_unpacked_bit) == 0;\n  }\n  constexpr auto has_named_args() const -> bool {\n    return (desc_ & detail::has_named_args_bit) != 0;\n  }\n\n  FMT_CONSTEXPR auto type(int index) const -> detail::type {\n    int shift = index * detail::packed_arg_bits;\n    unsigned mask = (1 << detail::packed_arg_bits) - 1;\n    return static_cast<detail::type>((desc_ >> shift) & mask);\n  }\n\n  template <int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC>\n  using store =\n      detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC>;\n\n public:\n  using format_arg = basic_format_arg<Context>;\n\n  constexpr basic_format_args() : desc_(0), args_(nullptr) {}\n\n  /// Constructs a `basic_format_args` object from `format_arg_store`.\n  template <int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC,\n            FMT_ENABLE_IF(NUM_ARGS <= detail::max_packed_args)>\n  constexpr FMT_ALWAYS_INLINE basic_format_args(\n      const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)\n      : desc_(DESC | (NUM_NAMED_ARGS != 0 ? +detail::has_named_args_bit : 0)),\n        values_(s.args) {}\n\n  template <int NUM_ARGS, int NUM_NAMED_ARGS, ullong DESC,\n            FMT_ENABLE_IF(NUM_ARGS > detail::max_packed_args)>\n  constexpr basic_format_args(const store<NUM_ARGS, NUM_NAMED_ARGS, DESC>& s)\n      : desc_(DESC | (NUM_NAMED_ARGS != 0 ? +detail::has_named_args_bit : 0)),\n        args_(s.args) {}\n\n  /// Constructs a `basic_format_args` object from a dynamic list of arguments.\n  constexpr basic_format_args(const format_arg* args, int count,\n                              bool has_named = false)\n      : desc_(detail::is_unpacked_bit | detail::to_unsigned(count) |\n              (has_named ? +detail::has_named_args_bit : 0)),\n        args_(args) {}\n\n  /// Returns the argument with the specified id.\n  FMT_CONSTEXPR auto get(int id) const -> format_arg {\n    auto arg = format_arg();\n    if (!is_packed()) {\n      if (id < max_size()) arg = args_[id];\n      return arg;\n    }\n    if (unsigned(id) >= detail::max_packed_args) return arg;\n    arg.type_ = type(id);\n    if (arg.type_ != detail::type::none_type) arg.value_ = values_[id];\n    return arg;\n  }\n\n  template <typename Char>\n  auto get(basic_string_view<Char> name) const -> format_arg {\n    int id = get_id(name);\n    return id >= 0 ? get(id) : format_arg();\n  }\n\n  template <typename Char>\n  FMT_CONSTEXPR auto get_id(basic_string_view<Char> name) const -> int {\n    if (!has_named_args()) return -1;\n    const auto& named_args =\n        (is_packed() ? values_[-1] : args_[-1].value_).named_args;\n    for (size_t i = 0; i < named_args.size; ++i) {\n      if (named_args.data[i].name == name) return named_args.data[i].id;\n    }\n    return -1;\n  }\n\n  auto max_size() const -> int {\n    return int(is_packed() ? ullong(detail::max_packed_args)\n                           : desc_ & ~detail::is_unpacked_bit);\n  }\n};\n\n// A formatting context.\nclass context {\n private:\n  appender out_;\n  format_args args_;\n  FMT_NO_UNIQUE_ADDRESS locale_ref loc_;\n\n public:\n  using char_type = char;  ///< The character type for the output.\n  using iterator = appender;\n  using format_arg = basic_format_arg<context>;\n  enum { builtin_types = FMT_BUILTIN_TYPES };\n\n  /// Constructs a `context` object. References to the arguments are stored\n  /// in the object so make sure they have appropriate lifetimes.\n  constexpr context(iterator out, format_args args, locale_ref loc = {})\n      : out_(out), args_(args), loc_(loc) {}\n  context(context&&) = default;\n  context(const context&) = delete;\n  void operator=(const context&) = delete;\n\n  FMT_CONSTEXPR auto arg(int id) const -> format_arg { return args_.get(id); }\n  inline auto arg(string_view name) const -> format_arg {\n    return args_.get(name);\n  }\n  FMT_CONSTEXPR auto arg_id(string_view name) const -> int {\n    return args_.get_id(name);\n  }\n  auto args() const -> const format_args& { return args_; }\n\n  // Returns an iterator to the beginning of the output range.\n  constexpr auto out() const -> iterator { return out_; }\n\n  // Advances the begin iterator to `it`.\n  FMT_CONSTEXPR void advance_to(iterator) {}\n\n  constexpr auto locale() const -> locale_ref { return loc_; }\n};\n\ntemplate <typename Char = char> struct runtime_format_string {\n  basic_string_view<Char> str;\n};\n\n/**\n * Creates a runtime format string.\n *\n * **Example**:\n *\n *     // Check format string at runtime instead of compile-time.\n *     fmt::print(fmt::runtime(\"{:d}\"), \"I am not a number\");\n */\ninline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; }\n\n/// A compile-time format string. Use `format_string` in the public API to\n/// prevent type deduction.\ntemplate <typename... T> struct fstring {\n private:\n  static constexpr int num_static_named_args =\n      detail::count_static_named_args<T...>();\n\n  using checker = detail::format_string_checker<\n      char, int(sizeof...(T)), num_static_named_args,\n      num_static_named_args != detail::count_named_args<T...>()>;\n\n  using arg_pack = detail::arg_pack<T...>;\n\n public:\n  string_view str;\n  using t = fstring;\n\n  // Reports a compile-time error if S is not a valid format string for T.\n  template <size_t N>\n  FMT_CONSTEVAL FMT_ALWAYS_INLINE fstring(const char (&s)[N]) : str(s, N - 1) {\n    using namespace detail;\n    static_assert(count<(is_view<remove_cvref_t<T>>::value &&\n                         std::is_reference<T>::value)...>() == 0,\n                  \"passing views as lvalues is disallowed\");\n    if (FMT_USE_CONSTEVAL) parse_format_string<char>(s, checker(s, arg_pack()));\n    constexpr bool unused = detail::enforce_compile_checks<sizeof(s) != 0>();\n    (void)unused;\n  }\n  template <typename S,\n            FMT_ENABLE_IF(std::is_convertible<const S&, string_view>::value)>\n  FMT_CONSTEVAL FMT_ALWAYS_INLINE fstring(const S& s) : str(s) {\n    auto sv = string_view(str);\n    if (FMT_USE_CONSTEVAL)\n      detail::parse_format_string<char>(sv, checker(sv, arg_pack()));\n    constexpr bool unused = detail::enforce_compile_checks<sizeof(s) != 0>();\n    (void)unused;\n  }\n  template <typename S,\n            FMT_ENABLE_IF(std::is_base_of<detail::compile_string, S>::value&&\n                              std::is_same<typename S::char_type, char>::value)>\n  FMT_ALWAYS_INLINE fstring(const S&) : str(S()) {\n    FMT_CONSTEXPR auto sv = string_view(S());\n    FMT_CONSTEXPR int x = (parse_format_string(sv, checker(sv, arg_pack())), 0);\n    detail::ignore_unused(x);\n  }\n  fstring(runtime_format_string<> fmt) : str(fmt.str) {}\n\n  FMT_DEPRECATED operator const string_view&() const { return str; }\n  auto get() const -> string_view { return str; }\n};\n\ntemplate <typename... T> using format_string = typename fstring<T...>::t;\n\ntemplate <typename T, typename Char = char>\nusing is_formattable = bool_constant<!std::is_same<\n    detail::mapped_t<conditional_t<std::is_void<T>::value, int*, T>, Char>,\n    void>::value>;\n#if defined(__cpp_concepts) && __cpp_concepts >= 201907L\ntemplate <typename T, typename Char = char>\nconcept formattable = is_formattable<remove_reference_t<T>, Char>::value;\n#endif\n\n// A formatter specialization for natively supported types.\ntemplate <typename T, typename Char>\nstruct formatter<T, Char,\n                 enable_if_t<detail::type_constant<T, Char>::value !=\n                             detail::type::custom_type>>\n    : detail::native_formatter<T, Char, detail::type_constant<T, Char>::value> {\n};\n\n/**\n * Constructs an object that stores references to arguments and can be\n * implicitly converted to `format_args`. `Context` can be omitted in which case\n * it defaults to `context`. See `arg` for lifetime considerations.\n */\n// Take arguments by lvalue references to avoid some lifetime issues, e.g.\n//   auto args = make_format_args(std::string());\ntemplate <typename Context = context, typename... T,\n          int NUM_ARGS = int(sizeof...(T)),\n          int NUM_NAMED_ARGS = detail::count_named_args<T...>(),\n          ullong DESC = detail::make_descriptor<Context, T...>()>\nconstexpr FMT_ALWAYS_INLINE auto make_format_args(T&... args)\n    -> detail::format_arg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC> {\n  return {{args...}};\n}\n\ntemplate <typename... T>\nusing vargs =\n    detail::format_arg_store<context, int(sizeof...(T)),\n                             detail::count_named_args<T...>(),\n                             detail::make_descriptor<context, T...>()>;\n\n/**\n * Returns a named argument to be used in a formatting function.\n * It should only be used in a call to a formatting function.\n *\n * **Example**:\n *\n *     fmt::print(\"The answer is {answer}.\", fmt::arg(\"answer\", 42));\n *\n * Named arguments passed with `fmt::arg` are not supported\n * in compile-time checks, but `\"answer\"_a=42` are compile-time checked in\n * sufficiently new compilers. See `operator\"\"_a()`.\n */\ntemplate <typename T>\ninline auto arg(const char* name, const T& arg) -> named_arg<T> {\n  return {name, arg};\n}\n\n/// Formats a string and writes the output to `out`.\ntemplate <typename OutputIt,\n          FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,\n                                                   char>::value)>\n// DEPRECATED! Passing out as a forwarding reference.\nauto vformat_to(OutputIt&& out, string_view fmt, format_args args)\n    -> remove_cvref_t<OutputIt> {\n  auto&& buf = detail::get_buffer<char>(out);\n  detail::vformat_to(buf, fmt, args, {});\n  return detail::get_iterator(buf, out);\n}\n\n/**\n * Formats `args` according to specifications in `fmt`, writes the result to\n * the output iterator `out` and returns the iterator past the end of the output\n * range. `format_to` does not append a terminating null character.\n *\n * **Example**:\n *\n *     auto out = std::vector<char>();\n *     fmt::format_to(std::back_inserter(out), \"{}\", 42);\n */\ntemplate <typename OutputIt, typename... T,\n          FMT_ENABLE_IF(detail::is_output_iterator<remove_cvref_t<OutputIt>,\n                                                   char>::value)>\nFMT_INLINE auto format_to(OutputIt&& out, format_string<T...> fmt, T&&... args)\n    -> remove_cvref_t<OutputIt> {\n  return vformat_to(out, fmt.str, vargs<T...>{{args...}});\n}\n\ntemplate <typename OutputIt> struct format_to_n_result {\n  OutputIt out;  ///< Iterator past the end of the output range.\n  size_t size;   ///< Total (not truncated) output size.\n};\n\ntemplate <typename OutputIt, typename... T,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>\nauto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args)\n    -> format_to_n_result<OutputIt> {\n  using traits = detail::fixed_buffer_traits;\n  auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);\n  detail::vformat_to(buf, fmt, args, {});\n  return {buf.out(), buf.count()};\n}\n\n/**\n * Formats `args` according to specifications in `fmt`, writes up to `n`\n * characters of the result to the output iterator `out` and returns the total\n * (not truncated) output size and the iterator past the end of the output\n * range. `format_to_n` does not append a terminating null character.\n */\ntemplate <typename OutputIt, typename... T,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>\nFMT_INLINE auto format_to_n(OutputIt out, size_t n, format_string<T...> fmt,\n                            T&&... args) -> format_to_n_result<OutputIt> {\n  return vformat_to_n(out, n, fmt.str, vargs<T...>{{args...}});\n}\n\nstruct format_to_result {\n  char* out;       ///< Pointer to just after the last successful write.\n  bool truncated;  ///< Specifies if the output was truncated.\n\n  FMT_CONSTEXPR operator char*() const {\n    // Report truncation to prevent silent data loss.\n    if (truncated) report_error(\"output is truncated\");\n    return out;\n  }\n};\n\ntemplate <size_t N>\nFMT_DEPRECATED auto vformat_to(char (&out)[N], string_view fmt,\n                               format_args args) -> format_to_result {\n  auto result = vformat_to_n(out, N, fmt, args);\n  return {result.out, result.size > N};\n}\n\ntemplate <size_t N, typename... T>\nFMT_INLINE auto format_to(char (&out)[N], format_string<T...> fmt, T&&... args)\n    -> format_to_result {\n  auto result = vformat_to_n(out, N, fmt.str, vargs<T...>{{args...}});\n  return {result.out, result.size > N};\n}\n\n/// Returns the number of chars in the output of `format(fmt, args...)`.\ntemplate <typename... T>\nFMT_NODISCARD FMT_INLINE auto formatted_size(format_string<T...> fmt,\n                                             T&&... args) -> size_t {\n  auto buf = detail::counting_buffer<>();\n  detail::vformat_to(buf, fmt.str, vargs<T...>{{args...}}, {});\n  return buf.count();\n}\n\nFMT_API void vprint(string_view fmt, format_args args);\nFMT_API void vprint(FILE* f, string_view fmt, format_args args);\nFMT_API void vprintln(FILE* f, string_view fmt, format_args args);\nFMT_API void vprint_buffered(FILE* f, string_view fmt, format_args args);\n\n/**\n * Formats `args` according to specifications in `fmt` and writes the output\n * to `stdout`.\n *\n * **Example**:\n *\n *     fmt::print(\"The answer is {}.\", 42);\n */\ntemplate <typename... T>\nFMT_INLINE void print(format_string<T...> fmt, T&&... args) {\n  vargs<T...> va = {{args...}};\n  if FMT_CONSTEXPR20 (!detail::use_utf8)\n    return detail::vprint_mojibake(stdout, fmt.str, va, false);\n  detail::is_locking<T...>() ? vprint_buffered(stdout, fmt.str, va)\n                             : vprint(fmt.str, va);\n}\n\n/**\n * Formats `args` according to specifications in `fmt` and writes the\n * output to the file `f`.\n *\n * **Example**:\n *\n *     fmt::print(stderr, \"Don't {}!\", \"panic\");\n */\ntemplate <typename... T>\nFMT_INLINE void print(FILE* f, format_string<T...> fmt, T&&... args) {\n  vargs<T...> va = {{args...}};\n  if FMT_CONSTEXPR20 (!detail::use_utf8)\n    return detail::vprint_mojibake(f, fmt.str, va, false);\n  detail::is_locking<T...>() ? vprint_buffered(f, fmt.str, va)\n                             : vprint(f, fmt.str, va);\n}\n\n/// Formats `args` according to specifications in `fmt` and writes the output\n/// to the file `f` followed by a newline.\ntemplate <typename... T>\nFMT_INLINE void println(FILE* f, format_string<T...> fmt, T&&... args) {\n  vargs<T...> va = {{args...}};\n  if FMT_CONSTEXPR20 (detail::use_utf8) return vprintln(f, fmt.str, va);\n  detail::vprint_mojibake(f, fmt.str, va, true);\n}\n\n/// Formats `args` according to specifications in `fmt` and writes the output\n/// to `stdout` followed by a newline.\ntemplate <typename... T>\nFMT_INLINE void println(format_string<T...> fmt, T&&... args) {\n  fmt::println(stdout, fmt, static_cast<T&&>(args)...);\n}\n\nFMT_PRAGMA_GCC(pop_options)\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#ifdef FMT_HEADER_ONLY\n#  include \"format.h\"\n#endif\n#endif  // FMT_BASE_H_\n"
  },
  {
    "path": "include/fmt/chrono.h",
    "content": "// Formatting library for C++ - chrono support\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_CHRONO_H_\n#define FMT_CHRONO_H_\n\n#ifndef FMT_MODULE\n#  include <algorithm>\n#  include <chrono>\n#  include <cmath>    // std::isfinite\n#  include <cstring>  // std::memcpy\n#  include <ctime>\n#  include <iterator>\n#  include <locale>\n#  include <ostream>\n#  include <type_traits>\n#endif\n\n#include \"format.h\"\n\nFMT_BEGIN_NAMESPACE\n\n// Enable safe chrono durations, unless explicitly disabled.\n#ifndef FMT_SAFE_DURATION_CAST\n#  define FMT_SAFE_DURATION_CAST 1\n#endif\n#if FMT_SAFE_DURATION_CAST\n\n// For conversion between std::chrono::durations without undefined\n// behaviour or erroneous results.\n// This is a stripped down version of duration_cast, for inclusion in fmt.\n// See https://github.com/pauldreik/safe_duration_cast\n//\n// Copyright Paul Dreik 2019\nnamespace safe_duration_cast {\n\n// DEPRECATED!\ntemplate <typename To, typename From,\n          FMT_ENABLE_IF(!std::is_same<From, To>::value &&\n                        std::numeric_limits<From>::is_signed ==\n                            std::numeric_limits<To>::is_signed)>\nFMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)\n    -> To {\n  ec = 0;\n  using F = std::numeric_limits<From>;\n  using T = std::numeric_limits<To>;\n  static_assert(F::is_integer, \"From must be integral\");\n  static_assert(T::is_integer, \"To must be integral\");\n\n  // A and B are both signed, or both unsigned.\n  if FMT_CONSTEXPR20 (F::digits <= T::digits) {\n    // From fits in To without any problem.\n  } else {\n    // From does not always fit in To, resort to a dynamic check.\n    if (from < (T::min)() || from > (T::max)()) {\n      // outside range.\n      ec = 1;\n      return {};\n    }\n  }\n  return static_cast<To>(from);\n}\n\n/// Converts From to To, without loss. If the dynamic value of from\n/// can't be converted to To without loss, ec is set.\ntemplate <typename To, typename From,\n          FMT_ENABLE_IF(!std::is_same<From, To>::value &&\n                        std::numeric_limits<From>::is_signed !=\n                            std::numeric_limits<To>::is_signed)>\nFMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)\n    -> To {\n  ec = 0;\n  using F = std::numeric_limits<From>;\n  using T = std::numeric_limits<To>;\n  static_assert(F::is_integer, \"From must be integral\");\n  static_assert(T::is_integer, \"To must be integral\");\n\n  if FMT_CONSTEXPR20 (F::is_signed && !T::is_signed) {\n    // From may be negative, not allowed!\n    if (fmt::detail::is_negative(from)) {\n      ec = 1;\n      return {};\n    }\n    // From is positive. Can it always fit in To?\n    if (F::digits > T::digits &&\n        from > static_cast<From>(detail::max_value<To>())) {\n      ec = 1;\n      return {};\n    }\n  }\n\n  if (!F::is_signed && T::is_signed && F::digits >= T::digits &&\n      from > static_cast<From>(detail::max_value<To>())) {\n    ec = 1;\n    return {};\n  }\n  return static_cast<To>(from);  // Lossless conversion.\n}\n\ntemplate <typename To, typename From,\n          FMT_ENABLE_IF(std::is_same<From, To>::value)>\nFMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)\n    -> To {\n  ec = 0;\n  return from;\n}  // function\n\n// clang-format off\n/**\n * converts From to To if possible, otherwise ec is set.\n *\n * input                            |    output\n * ---------------------------------|---------------\n * NaN                              | NaN\n * Inf                              | Inf\n * normal, fits in output           | converted (possibly lossy)\n * normal, does not fit in output   | ec is set\n * subnormal                        | best effort\n * -Inf                             | -Inf\n */\n// clang-format on\ntemplate <typename To, typename From,\n          FMT_ENABLE_IF(!std::is_same<From, To>::value)>\nFMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {\n  ec = 0;\n  using T = std::numeric_limits<To>;\n  static_assert(std::is_floating_point<From>::value, \"From must be floating\");\n  static_assert(std::is_floating_point<To>::value, \"To must be floating\");\n\n  // catch the only happy case\n  if (std::isfinite(from)) {\n    if (from >= T::lowest() && from <= (T::max)()) {\n      return static_cast<To>(from);\n    }\n    // not within range.\n    ec = 1;\n    return {};\n  }\n\n  // nan and inf will be preserved\n  return static_cast<To>(from);\n}  // function\n\ntemplate <typename To, typename From,\n          FMT_ENABLE_IF(std::is_same<From, To>::value)>\nFMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {\n  ec = 0;\n  static_assert(std::is_floating_point<From>::value, \"From must be floating\");\n  return from;\n}\n\n/// Safe duration_cast between floating point durations\ntemplate <typename To, typename FromRep, typename FromPeriod,\n          FMT_ENABLE_IF(std::is_floating_point<FromRep>::value),\n          FMT_ENABLE_IF(std::is_floating_point<typename To::rep>::value)>\nauto safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,\n                        int& ec) -> To {\n  using From = std::chrono::duration<FromRep, FromPeriod>;\n  ec = 0;\n\n  // the basic idea is that we need to convert from count() in the from type\n  // to count() in the To type, by multiplying it with this:\n  struct Factor\n      : std::ratio_divide<typename From::period, typename To::period> {};\n\n  static_assert(Factor::num > 0, \"num must be positive\");\n  static_assert(Factor::den > 0, \"den must be positive\");\n\n  // the conversion is like this: multiply from.count() with Factor::num\n  // /Factor::den and convert it to To::rep, all this without\n  // overflow/underflow. let's start by finding a suitable type that can hold\n  // both To, From and Factor::num\n  using IntermediateRep =\n      typename std::common_type<typename From::rep, typename To::rep,\n                                decltype(Factor::num)>::type;\n\n  // force conversion of From::rep -> IntermediateRep to be safe,\n  // even if it will never happen be narrowing in this context.\n  IntermediateRep count =\n      safe_float_conversion<IntermediateRep>(from.count(), ec);\n  if (ec) {\n    return {};\n  }\n\n  // multiply with Factor::num without overflow or underflow\n  if FMT_CONSTEXPR20 (Factor::num != 1) {\n    constexpr auto max1 = detail::max_value<IntermediateRep>() /\n                          static_cast<IntermediateRep>(Factor::num);\n    if (count > max1) {\n      ec = 1;\n      return {};\n    }\n    constexpr auto min1 = std::numeric_limits<IntermediateRep>::lowest() /\n                          static_cast<IntermediateRep>(Factor::num);\n    if (count < min1) {\n      ec = 1;\n      return {};\n    }\n    count *= static_cast<IntermediateRep>(Factor::num);\n  }\n\n  // this can't go wrong, right? den>0 is checked earlier.\n  if FMT_CONSTEXPR20 (Factor::den != 1) {\n    using common_t = typename std::common_type<IntermediateRep, intmax_t>::type;\n    count /= static_cast<common_t>(Factor::den);\n  }\n\n  // convert to the to type, safely\n  using ToRep = typename To::rep;\n\n  const ToRep tocount = safe_float_conversion<ToRep>(count, ec);\n  if (ec) {\n    return {};\n  }\n  return To{tocount};\n}\n}  // namespace safe_duration_cast\n#endif\n\nnamespace detail {\n\n// Check if std::chrono::utc_time is available.\n#ifdef FMT_USE_UTC_TIME\n// Use the provided definition.\n#elif defined(__cpp_lib_chrono)\n#  define FMT_USE_UTC_TIME (__cpp_lib_chrono >= 201907L)\n#else\n#  define FMT_USE_UTC_TIME 0\n#endif\n#if FMT_USE_UTC_TIME\nusing utc_clock = std::chrono::utc_clock;\n#else\nstruct utc_clock {\n  template <typename T> void to_sys(T);\n};\n#endif\n\n// Check if std::chrono::local_time is available.\n#ifdef FMT_USE_LOCAL_TIME\n// Use the provided definition.\n#elif defined(__cpp_lib_chrono)\n#  define FMT_USE_LOCAL_TIME (__cpp_lib_chrono >= 201907L)\n#else\n#  define FMT_USE_LOCAL_TIME 0\n#endif\n#if FMT_USE_LOCAL_TIME\nusing local_t = std::chrono::local_t;\n#else\nstruct local_t {};\n#endif\n\n}  // namespace detail\n\ntemplate <typename Duration>\nusing sys_time = std::chrono::time_point<std::chrono::system_clock, Duration>;\n\ntemplate <typename Duration>\nusing utc_time = std::chrono::time_point<detail::utc_clock, Duration>;\n\ntemplate <class Duration>\nusing local_time = std::chrono::time_point<detail::local_t, Duration>;\n\nnamespace detail {\n\n// Prevents expansion of a preceding token as a function-style macro.\n// Usage: f FMT_NOMACRO()\n#define FMT_NOMACRO\n\ntemplate <typename T = void> struct null {};\ninline auto gmtime_r(...) -> null<> { return null<>(); }\ninline auto gmtime_s(...) -> null<> { return null<>(); }\n\n// It is defined here and not in ostream.h because the latter has expensive\n// includes.\ntemplate <typename StreamBuf> class formatbuf : public StreamBuf {\n private:\n  using char_type = typename StreamBuf::char_type;\n  using streamsize = decltype(std::declval<StreamBuf>().sputn(nullptr, 0));\n  using int_type = typename StreamBuf::int_type;\n  using traits_type = typename StreamBuf::traits_type;\n\n  buffer<char_type>& buffer_;\n\n public:\n  explicit formatbuf(buffer<char_type>& buf) : buffer_(buf) {}\n\n protected:\n  // The put area is always empty. This makes the implementation simpler and has\n  // the advantage that the streambuf and the buffer are always in sync and\n  // sputc never writes into uninitialized memory. A disadvantage is that each\n  // call to sputc always results in a (virtual) call to overflow. There is no\n  // disadvantage here for sputn since this always results in a call to xsputn.\n\n  auto overflow(int_type ch) -> int_type override {\n    if (!traits_type::eq_int_type(ch, traits_type::eof()))\n      buffer_.push_back(static_cast<char_type>(ch));\n    return ch;\n  }\n\n  auto xsputn(const char_type* s, streamsize count) -> streamsize override {\n    buffer_.append(s, s + count);\n    return count;\n  }\n};\n\ninline auto get_classic_locale() -> const std::locale& {\n  static const auto& locale = std::locale::classic();\n  return locale;\n}\n\ntemplate <typename CodeUnit> struct codecvt_result {\n  static constexpr size_t max_size = 32;\n  CodeUnit buf[max_size];\n  CodeUnit* end;\n};\n\ntemplate <typename CodeUnit>\nvoid write_codecvt(codecvt_result<CodeUnit>& out, string_view in,\n                   const std::locale& loc) {\n  FMT_PRAGMA_CLANG(diagnostic push)\n  FMT_PRAGMA_CLANG(diagnostic ignored \"-Wdeprecated\")\n  auto& f = std::use_facet<std::codecvt<CodeUnit, char, std::mbstate_t>>(loc);\n  FMT_PRAGMA_CLANG(diagnostic pop)\n  auto mb = std::mbstate_t();\n  const char* from_next = nullptr;\n  auto result = f.in(mb, in.begin(), in.end(), from_next, std::begin(out.buf),\n                     std::end(out.buf), out.end);\n  if (result != std::codecvt_base::ok)\n    FMT_THROW(format_error(\"failed to format time\"));\n}\n\ntemplate <typename OutputIt>\nauto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)\n    -> OutputIt {\n  if (detail::use_utf8 && loc != get_classic_locale()) {\n    // char16_t and char32_t codecvts are broken in MSVC (linkage errors) and\n    // gcc-4.\n#if FMT_MSC_VERSION != 0 ||  \\\n    (defined(__GLIBCXX__) && \\\n     (!defined(_GLIBCXX_USE_DUAL_ABI) || _GLIBCXX_USE_DUAL_ABI == 0))\n    // The _GLIBCXX_USE_DUAL_ABI macro is always defined in libstdc++ from gcc-5\n    // and newer.\n    using code_unit = wchar_t;\n#else\n    using code_unit = char32_t;\n#endif\n\n    using unit_t = codecvt_result<code_unit>;\n    unit_t unit;\n    write_codecvt(unit, in, loc);\n    // In UTF-8 is used one to four one-byte code units.\n    auto u =\n        to_utf8<code_unit, basic_memory_buffer<char, unit_t::max_size * 4>>();\n    if (!u.convert({unit.buf, to_unsigned(unit.end - unit.buf)}))\n      FMT_THROW(format_error(\"failed to format time\"));\n    return copy<char>(u.c_str(), u.c_str() + u.size(), out);\n  }\n  return copy<char>(in.data(), in.data() + in.size(), out);\n}\n\ntemplate <typename Char, typename OutputIt,\n          FMT_ENABLE_IF(!std::is_same<Char, char>::value)>\nauto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)\n    -> OutputIt {\n  codecvt_result<Char> unit;\n  write_codecvt(unit, sv, loc);\n  return copy<Char>(unit.buf, unit.end, out);\n}\n\ntemplate <typename Char, typename OutputIt,\n          FMT_ENABLE_IF(std::is_same<Char, char>::value)>\nauto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)\n    -> OutputIt {\n  return write_encoded_tm_str(out, sv, loc);\n}\n\ntemplate <typename Char>\ninline void do_write(buffer<Char>& buf, const std::tm& time,\n                     const std::locale& loc, char format, char modifier) {\n  auto&& format_buf = formatbuf<std::basic_streambuf<Char>>(buf);\n  auto&& os = std::basic_ostream<Char>(&format_buf);\n  os.imbue(loc);\n  const auto& facet = std::use_facet<std::time_put<Char>>(loc);\n  auto end = facet.put(os, os, Char(' '), &time, format, modifier);\n  if (end.failed()) FMT_THROW(format_error(\"failed to format time\"));\n}\n\ntemplate <typename Char, typename OutputIt,\n          FMT_ENABLE_IF(!std::is_same<Char, char>::value)>\nauto write(OutputIt out, const std::tm& time, const std::locale& loc,\n           char format, char modifier = 0) -> OutputIt {\n  auto&& buf = get_buffer<Char>(out);\n  do_write<Char>(buf, time, loc, format, modifier);\n  return get_iterator(buf, out);\n}\n\ntemplate <typename Char, typename OutputIt,\n          FMT_ENABLE_IF(std::is_same<Char, char>::value)>\nauto write(OutputIt out, const std::tm& time, const std::locale& loc,\n           char format, char modifier = 0) -> OutputIt {\n  auto&& buf = basic_memory_buffer<Char>();\n  do_write<char>(buf, time, loc, format, modifier);\n  return write_encoded_tm_str(out, string_view(buf.data(), buf.size()), loc);\n}\n\ntemplate <typename T, typename U>\nusing is_similar_arithmetic_type =\n    bool_constant<(std::is_integral<T>::value && std::is_integral<U>::value) ||\n                  (std::is_floating_point<T>::value &&\n                   std::is_floating_point<U>::value)>;\n\nFMT_NORETURN inline void throw_duration_error() {\n  FMT_THROW(format_error(\"cannot format duration\"));\n}\n\n// Cast one integral duration to another with an overflow check.\ntemplate <typename To, typename FromRep, typename FromPeriod,\n          FMT_ENABLE_IF(std::is_integral<FromRep>::value&&\n                            std::is_integral<typename To::rep>::value)>\nauto duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {\n#if !FMT_SAFE_DURATION_CAST\n  return std::chrono::duration_cast<To>(from);\n#else\n  // The conversion factor: to.count() == factor * from.count().\n  using factor = std::ratio_divide<FromPeriod, typename To::period>;\n\n  using common_rep = typename std::common_type<FromRep, typename To::rep,\n                                               decltype(factor::num)>::type;\n  common_rep count = from.count();  // This conversion is lossless.\n\n  // Multiply from.count() by factor and check for overflow.\n  if FMT_CONSTEXPR20 (factor::num != 1) {\n    if (count > max_value<common_rep>() / factor::num) throw_duration_error();\n    const auto min = (std::numeric_limits<common_rep>::min)() / factor::num;\n    if (!std::is_unsigned<common_rep>::value && count < min)\n      throw_duration_error();\n    count *= factor::num;\n  }\n  if FMT_CONSTEXPR20 (factor::den != 1) count /= factor::den;\n  int ec = 0;\n  auto to =\n      To(safe_duration_cast::lossless_integral_conversion<typename To::rep>(\n          count, ec));\n  if (ec) throw_duration_error();\n  return to;\n#endif\n}\n\ntemplate <typename To, typename FromRep, typename FromPeriod,\n          FMT_ENABLE_IF(std::is_floating_point<FromRep>::value&&\n                            std::is_floating_point<typename To::rep>::value)>\nauto duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {\n#if FMT_SAFE_DURATION_CAST\n  // Preserve infinity and NaN.\n  if (!isfinite(from.count())) return static_cast<To>(from.count());\n  // Throwing version of safe_duration_cast is only available for\n  // integer to integer or float to float casts.\n  int ec;\n  To to = safe_duration_cast::safe_duration_cast<To>(from, ec);\n  if (ec) throw_duration_error();\n  return to;\n#else\n  // Standard duration cast, may overflow.\n  return std::chrono::duration_cast<To>(from);\n#endif\n}\n\ntemplate <typename To, typename FromRep, typename FromPeriod,\n          FMT_ENABLE_IF(\n              !is_similar_arithmetic_type<FromRep, typename To::rep>::value)>\nauto duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {\n  // Mixed integer <-> float cast is not supported by safe duration_cast.\n  return std::chrono::duration_cast<To>(from);\n}\n\ntemplate <typename Duration>\nauto to_time_t(sys_time<Duration> time_point) -> std::time_t {\n  // Cannot use std::chrono::system_clock::to_time_t since this would first\n  // require a cast to std::chrono::system_clock::time_point, which could\n  // overflow.\n  return detail::duration_cast<std::chrono::duration<std::time_t>>(\n             time_point.time_since_epoch())\n      .count();\n}\n\n}  // namespace detail\n\nFMT_BEGIN_EXPORT\n\n/**\n * Converts given time since epoch as `std::time_t` value into calendar time,\n * expressed in Coordinated Universal Time (UTC). Unlike `std::gmtime`, this\n * function is thread-safe on most platforms.\n */\ninline auto gmtime(std::time_t time) -> std::tm {\n  struct dispatcher {\n    std::time_t time_;\n    std::tm tm_;\n\n    inline dispatcher(std::time_t t) : time_(t) {}\n\n    inline auto run() -> bool {\n      using namespace fmt::detail;\n      return handle(gmtime_r(&time_, &tm_));\n    }\n\n    inline auto handle(std::tm* tm) -> bool { return tm != nullptr; }\n\n    inline auto handle(detail::null<>) -> bool {\n      using namespace fmt::detail;\n      return fallback(gmtime_s(&tm_, &time_));\n    }\n\n    inline auto fallback(int res) -> bool { return res == 0; }\n\n#if !FMT_MSC_VERSION\n    inline auto fallback(detail::null<>) -> bool {\n      std::tm* tm = std::gmtime(&time_);\n      if (tm) tm_ = *tm;\n      return tm != nullptr;\n    }\n#endif\n  };\n  auto gt = dispatcher(time);\n  // Too big time values may be unsupported.\n  if (!gt.run()) FMT_THROW(format_error(\"time_t value out of range\"));\n  return gt.tm_;\n}\n\ntemplate <typename Duration>\ninline auto gmtime(sys_time<Duration> time_point) -> std::tm {\n  return gmtime(detail::to_time_t(time_point));\n}\n\nnamespace detail {\n\n// Writes two-digit numbers a, b and c separated by sep to buf.\n// The method by Pavel Novikov based on\n// https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/.\ninline void write_digit2_separated(char* buf, unsigned a, unsigned b,\n                                   unsigned c, char sep) {\n  ullong digits = a | (b << 24) | (static_cast<ullong>(c) << 48);\n  // Convert each value to BCD.\n  // We have x = a * 10 + b and we want to convert it to BCD y = a * 16 + b.\n  // The difference is\n  //   y - x = a * 6\n  // a can be found from x:\n  //   a = floor(x / 10)\n  // then\n  //   y = x + a * 6 = x + floor(x / 10) * 6\n  // floor(x / 10) is (x * 205) >> 11 (needs 16 bits).\n  digits += (((digits * 205) >> 11) & 0x000f00000f00000f) * 6;\n  // Put low nibbles to high bytes and high nibbles to low bytes.\n  digits = ((digits & 0x00f00000f00000f0) >> 4) |\n           ((digits & 0x000f00000f00000f) << 8);\n  auto usep = static_cast<ullong>(sep);\n  // Add ASCII '0' to each digit byte and insert separators.\n  digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);\n\n  constexpr size_t len = 8;\n  if (is_big_endian()) {\n    char tmp[len];\n    std::memcpy(tmp, &digits, len);\n    std::reverse_copy(tmp, tmp + len, buf);\n  } else {\n    std::memcpy(buf, &digits, len);\n  }\n}\n\ntemplate <typename Period>\nFMT_CONSTEXPR inline auto get_units() -> const char* {\n  if (std::is_same<Period, std::atto>::value) return \"as\";\n  if (std::is_same<Period, std::femto>::value) return \"fs\";\n  if (std::is_same<Period, std::pico>::value) return \"ps\";\n  if (std::is_same<Period, std::nano>::value) return \"ns\";\n  if (std::is_same<Period, std::micro>::value)\n    return detail::use_utf8 ? \"µs\" : \"us\";\n  if (std::is_same<Period, std::milli>::value) return \"ms\";\n  if (std::is_same<Period, std::centi>::value) return \"cs\";\n  if (std::is_same<Period, std::deci>::value) return \"ds\";\n  if (std::is_same<Period, std::ratio<1>>::value) return \"s\";\n  if (std::is_same<Period, std::deca>::value) return \"das\";\n  if (std::is_same<Period, std::hecto>::value) return \"hs\";\n  if (std::is_same<Period, std::kilo>::value) return \"ks\";\n  if (std::is_same<Period, std::mega>::value) return \"Ms\";\n  if (std::is_same<Period, std::giga>::value) return \"Gs\";\n  if (std::is_same<Period, std::tera>::value) return \"Ts\";\n  if (std::is_same<Period, std::peta>::value) return \"Ps\";\n  if (std::is_same<Period, std::exa>::value) return \"Es\";\n  if (std::is_same<Period, std::ratio<60>>::value) return \"min\";\n  if (std::is_same<Period, std::ratio<3600>>::value) return \"h\";\n  if (std::is_same<Period, std::ratio<86400>>::value) return \"d\";\n  return nullptr;\n}\n\nenum class numeric_system {\n  standard,\n  // Alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale.\n  alternative\n};\n\n// Glibc extensions for formatting numeric values.\nenum class pad_type {\n  // Pad a numeric result string with zeros (the default).\n  zero,\n  // Do not pad a numeric result string.\n  none,\n  // Pad a numeric result string with spaces.\n  space,\n};\n\ntemplate <typename OutputIt>\nauto write_padding(OutputIt out, pad_type pad, int width) -> OutputIt {\n  if (pad == pad_type::none) return out;\n  return detail::fill_n(out, width, pad == pad_type::space ? ' ' : '0');\n}\n\ntemplate <typename OutputIt>\nauto write_padding(OutputIt out, pad_type pad) -> OutputIt {\n  if (pad != pad_type::none) *out++ = pad == pad_type::space ? ' ' : '0';\n  return out;\n}\n\n// Parses a put_time-like format string and invokes handler actions.\ntemplate <typename Char, typename Handler>\nFMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end,\n                                       Handler&& handler) -> const Char* {\n  if (begin == end || *begin == '}') return begin;\n  if (*begin != '%') FMT_THROW(format_error(\"invalid format\"));\n  auto ptr = begin;\n  while (ptr != end) {\n    pad_type pad = pad_type::zero;\n    auto c = *ptr;\n    if (c == '}') break;\n    if (c != '%') {\n      ++ptr;\n      continue;\n    }\n    if (begin != ptr) handler.on_text(begin, ptr);\n    ++ptr;  // consume '%'\n    if (ptr == end) FMT_THROW(format_error(\"invalid format\"));\n    c = *ptr;\n    switch (c) {\n    case '_':\n      pad = pad_type::space;\n      ++ptr;\n      break;\n    case '-':\n      pad = pad_type::none;\n      ++ptr;\n      break;\n    }\n    if (ptr == end) FMT_THROW(format_error(\"invalid format\"));\n    c = *ptr++;\n    switch (c) {\n    case '%': handler.on_text(ptr - 1, ptr); break;\n    case 'n': {\n      const Char newline[] = {'\\n'};\n      handler.on_text(newline, newline + 1);\n      break;\n    }\n    case 't': {\n      const Char tab[] = {'\\t'};\n      handler.on_text(tab, tab + 1);\n      break;\n    }\n    // Year:\n    case 'Y': handler.on_year(numeric_system::standard, pad); break;\n    case 'y': handler.on_short_year(numeric_system::standard); break;\n    case 'C': handler.on_century(numeric_system::standard); break;\n    case 'G': handler.on_iso_week_based_year(); break;\n    case 'g': handler.on_iso_week_based_short_year(); break;\n    // Day of the week:\n    case 'a': handler.on_abbr_weekday(); break;\n    case 'A': handler.on_full_weekday(); break;\n    case 'w': handler.on_dec0_weekday(numeric_system::standard); break;\n    case 'u': handler.on_dec1_weekday(numeric_system::standard); break;\n    // Month:\n    case 'b':\n    case 'h': handler.on_abbr_month(); break;\n    case 'B': handler.on_full_month(); break;\n    case 'm': handler.on_dec_month(numeric_system::standard, pad); break;\n    // Day of the year/month:\n    case 'U':\n      handler.on_dec0_week_of_year(numeric_system::standard, pad);\n      break;\n    case 'W':\n      handler.on_dec1_week_of_year(numeric_system::standard, pad);\n      break;\n    case 'V': handler.on_iso_week_of_year(numeric_system::standard, pad); break;\n    case 'j': handler.on_day_of_year(pad); break;\n    case 'd': handler.on_day_of_month(numeric_system::standard, pad); break;\n    case 'e':\n      handler.on_day_of_month(numeric_system::standard, pad_type::space);\n      break;\n    // Hour, minute, second:\n    case 'H': handler.on_24_hour(numeric_system::standard, pad); break;\n    case 'I': handler.on_12_hour(numeric_system::standard, pad); break;\n    case 'M': handler.on_minute(numeric_system::standard, pad); break;\n    case 'S': handler.on_second(numeric_system::standard, pad); break;\n    // Other:\n    case 'c': handler.on_datetime(numeric_system::standard); break;\n    case 'x': handler.on_loc_date(numeric_system::standard); break;\n    case 'X': handler.on_loc_time(numeric_system::standard); break;\n    case 'D': handler.on_us_date(); break;\n    case 'F': handler.on_iso_date(); break;\n    case 'r': handler.on_12_hour_time(); break;\n    case 'R': handler.on_24_hour_time(); break;\n    case 'T': handler.on_iso_time(); break;\n    case 'p': handler.on_am_pm(); break;\n    case 'Q': handler.on_duration_value(); break;\n    case 'q': handler.on_duration_unit(); break;\n    case 'z': handler.on_utc_offset(numeric_system::standard); break;\n    case 'Z': handler.on_tz_name(); break;\n    // Alternative representation:\n    case 'E': {\n      if (ptr == end) FMT_THROW(format_error(\"invalid format\"));\n      c = *ptr++;\n      switch (c) {\n      case 'Y': handler.on_year(numeric_system::alternative, pad); break;\n      case 'y': handler.on_offset_year(); break;\n      case 'C': handler.on_century(numeric_system::alternative); break;\n      case 'c': handler.on_datetime(numeric_system::alternative); break;\n      case 'x': handler.on_loc_date(numeric_system::alternative); break;\n      case 'X': handler.on_loc_time(numeric_system::alternative); break;\n      case 'z': handler.on_utc_offset(numeric_system::alternative); break;\n      default:  FMT_THROW(format_error(\"invalid format\"));\n      }\n      break;\n    }\n    case 'O':\n      if (ptr == end) FMT_THROW(format_error(\"invalid format\"));\n      c = *ptr++;\n      switch (c) {\n      case 'y': handler.on_short_year(numeric_system::alternative); break;\n      case 'm': handler.on_dec_month(numeric_system::alternative, pad); break;\n      case 'U':\n        handler.on_dec0_week_of_year(numeric_system::alternative, pad);\n        break;\n      case 'W':\n        handler.on_dec1_week_of_year(numeric_system::alternative, pad);\n        break;\n      case 'V':\n        handler.on_iso_week_of_year(numeric_system::alternative, pad);\n        break;\n      case 'd':\n        handler.on_day_of_month(numeric_system::alternative, pad);\n        break;\n      case 'e':\n        handler.on_day_of_month(numeric_system::alternative, pad_type::space);\n        break;\n      case 'w': handler.on_dec0_weekday(numeric_system::alternative); break;\n      case 'u': handler.on_dec1_weekday(numeric_system::alternative); break;\n      case 'H': handler.on_24_hour(numeric_system::alternative, pad); break;\n      case 'I': handler.on_12_hour(numeric_system::alternative, pad); break;\n      case 'M': handler.on_minute(numeric_system::alternative, pad); break;\n      case 'S': handler.on_second(numeric_system::alternative, pad); break;\n      case 'z': handler.on_utc_offset(numeric_system::alternative); break;\n      default:  FMT_THROW(format_error(\"invalid format\"));\n      }\n      break;\n    default: FMT_THROW(format_error(\"invalid format\"));\n    }\n    begin = ptr;\n  }\n  if (begin != ptr) handler.on_text(begin, ptr);\n  return ptr;\n}\n\ntemplate <typename Derived> struct null_chrono_spec_handler {\n  FMT_CONSTEXPR void unsupported() {\n    static_cast<Derived*>(this)->unsupported();\n  }\n  FMT_CONSTEXPR void on_year(numeric_system, pad_type) { unsupported(); }\n  FMT_CONSTEXPR void on_short_year(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_offset_year() { unsupported(); }\n  FMT_CONSTEXPR void on_century(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_iso_week_based_year() { unsupported(); }\n  FMT_CONSTEXPR void on_iso_week_based_short_year() { unsupported(); }\n  FMT_CONSTEXPR void on_abbr_weekday() { unsupported(); }\n  FMT_CONSTEXPR void on_full_weekday() { unsupported(); }\n  FMT_CONSTEXPR void on_dec0_weekday(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_dec1_weekday(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_abbr_month() { unsupported(); }\n  FMT_CONSTEXPR void on_full_month() { unsupported(); }\n  FMT_CONSTEXPR void on_dec_month(numeric_system, pad_type) { unsupported(); }\n  FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system, pad_type) {\n    unsupported();\n  }\n  FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system, pad_type) {\n    unsupported();\n  }\n  FMT_CONSTEXPR void on_iso_week_of_year(numeric_system, pad_type) {\n    unsupported();\n  }\n  FMT_CONSTEXPR void on_day_of_year(pad_type) { unsupported(); }\n  FMT_CONSTEXPR void on_day_of_month(numeric_system, pad_type) {\n    unsupported();\n  }\n  FMT_CONSTEXPR void on_24_hour(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_12_hour(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_minute(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_second(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_datetime(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_loc_date(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_loc_time(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_us_date() { unsupported(); }\n  FMT_CONSTEXPR void on_iso_date() { unsupported(); }\n  FMT_CONSTEXPR void on_12_hour_time() { unsupported(); }\n  FMT_CONSTEXPR void on_24_hour_time() { unsupported(); }\n  FMT_CONSTEXPR void on_iso_time() { unsupported(); }\n  FMT_CONSTEXPR void on_am_pm() { unsupported(); }\n  FMT_CONSTEXPR void on_duration_value() { unsupported(); }\n  FMT_CONSTEXPR void on_duration_unit() { unsupported(); }\n  FMT_CONSTEXPR void on_utc_offset(numeric_system) { unsupported(); }\n  FMT_CONSTEXPR void on_tz_name() { unsupported(); }\n};\n\nclass tm_format_checker : public null_chrono_spec_handler<tm_format_checker> {\n private:\n  bool has_timezone_ = false;\n\n public:\n  constexpr explicit tm_format_checker(bool has_timezone)\n      : has_timezone_(has_timezone) {}\n\n  FMT_NORETURN inline void unsupported() {\n    FMT_THROW(format_error(\"no format\"));\n  }\n\n  template <typename Char>\n  FMT_CONSTEXPR void on_text(const Char*, const Char*) {}\n  FMT_CONSTEXPR void on_year(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_short_year(numeric_system) {}\n  FMT_CONSTEXPR void on_offset_year() {}\n  FMT_CONSTEXPR void on_century(numeric_system) {}\n  FMT_CONSTEXPR void on_iso_week_based_year() {}\n  FMT_CONSTEXPR void on_iso_week_based_short_year() {}\n  FMT_CONSTEXPR void on_abbr_weekday() {}\n  FMT_CONSTEXPR void on_full_weekday() {}\n  FMT_CONSTEXPR void on_dec0_weekday(numeric_system) {}\n  FMT_CONSTEXPR void on_dec1_weekday(numeric_system) {}\n  FMT_CONSTEXPR void on_abbr_month() {}\n  FMT_CONSTEXPR void on_full_month() {}\n  FMT_CONSTEXPR void on_dec_month(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_iso_week_of_year(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_day_of_year(pad_type) {}\n  FMT_CONSTEXPR void on_day_of_month(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_second(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_datetime(numeric_system) {}\n  FMT_CONSTEXPR void on_loc_date(numeric_system) {}\n  FMT_CONSTEXPR void on_loc_time(numeric_system) {}\n  FMT_CONSTEXPR void on_us_date() {}\n  FMT_CONSTEXPR void on_iso_date() {}\n  FMT_CONSTEXPR void on_12_hour_time() {}\n  FMT_CONSTEXPR void on_24_hour_time() {}\n  FMT_CONSTEXPR void on_iso_time() {}\n  FMT_CONSTEXPR void on_am_pm() {}\n  FMT_CONSTEXPR void on_utc_offset(numeric_system) {\n    if (!has_timezone_) FMT_THROW(format_error(\"no timezone\"));\n  }\n  FMT_CONSTEXPR void on_tz_name() {\n    if (!has_timezone_) FMT_THROW(format_error(\"no timezone\"));\n  }\n};\n\ninline auto tm_wday_full_name(int wday) -> const char* {\n  static constexpr const char* full_name_list[] = {\n      \"Sunday\",   \"Monday\", \"Tuesday\", \"Wednesday\",\n      \"Thursday\", \"Friday\", \"Saturday\"};\n  return wday >= 0 && wday <= 6 ? full_name_list[wday] : \"?\";\n}\ninline auto tm_wday_short_name(int wday) -> const char* {\n  static constexpr const char* short_name_list[] = {\"Sun\", \"Mon\", \"Tue\", \"Wed\",\n                                                    \"Thu\", \"Fri\", \"Sat\"};\n  return wday >= 0 && wday <= 6 ? short_name_list[wday] : \"???\";\n}\n\ninline auto tm_mon_full_name(int mon) -> const char* {\n  static constexpr const char* full_name_list[] = {\n      \"January\", \"February\", \"March\",     \"April\",   \"May\",      \"June\",\n      \"July\",    \"August\",   \"September\", \"October\", \"November\", \"December\"};\n  return mon >= 0 && mon <= 11 ? full_name_list[mon] : \"?\";\n}\ninline auto tm_mon_short_name(int mon) -> const char* {\n  static constexpr const char* short_name_list[] = {\n      \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n      \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\",\n  };\n  return mon >= 0 && mon <= 11 ? short_name_list[mon] : \"???\";\n}\n\ntemplate <typename T, typename = void>\nstruct has_tm_gmtoff : std::false_type {};\ntemplate <typename T>\nstruct has_tm_gmtoff<T, void_t<decltype(T::tm_gmtoff)>> : std::true_type {};\n\ntemplate <typename T, typename = void> struct has_tm_zone : std::false_type {};\ntemplate <typename T>\nstruct has_tm_zone<T, void_t<decltype(T::tm_zone)>> : std::true_type {};\n\ntemplate <typename T, FMT_ENABLE_IF(has_tm_zone<T>::value)>\nauto set_tm_zone(T& time, char* tz) -> bool {\n  time.tm_zone = tz;\n  return true;\n}\ntemplate <typename T, FMT_ENABLE_IF(!has_tm_zone<T>::value)>\nauto set_tm_zone(T&, char*) -> bool {\n  return false;\n}\n\ninline auto utc() -> char* {\n  static char tz[] = \"UTC\";\n  return tz;\n}\n\n// Converts value to Int and checks that it's in the range [0, upper).\ntemplate <typename T, typename Int, FMT_ENABLE_IF(std::is_integral<T>::value)>\ninline auto to_nonnegative_int(T value, Int upper) -> Int {\n  if (!std::is_unsigned<Int>::value &&\n      (value < 0 || to_unsigned(value) > to_unsigned(upper))) {\n    FMT_THROW(format_error(\"chrono value is out of range\"));\n  }\n  return static_cast<Int>(value);\n}\ntemplate <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>\ninline auto to_nonnegative_int(T value, Int upper) -> Int {\n  auto int_value = static_cast<Int>(value);\n  if (int_value < 0 || value > static_cast<T>(upper))\n    FMT_THROW(format_error(\"invalid value\"));\n  return int_value;\n}\n\nconstexpr auto pow10(std::uint32_t n) -> long long {\n  return n == 0 ? 1 : 10 * pow10(n - 1);\n}\n\n// Counts the number of fractional digits in the range [0, 18] according to the\n// C++20 spec. If more than 18 fractional digits are required then returns 6 for\n// microseconds precision.\ntemplate <long long Num, long long Den, int N = 0,\n          bool Enabled = (N < 19) && (Num <= max_value<long long>() / 10)>\nstruct count_fractional_digits {\n  static constexpr int value =\n      Num % Den == 0 ? N : count_fractional_digits<Num * 10, Den, N + 1>::value;\n};\n\n// Base case that doesn't instantiate any more templates\n// in order to avoid overflow.\ntemplate <long long Num, long long Den, int N>\nstruct count_fractional_digits<Num, Den, N, false> {\n  static constexpr int value = (Num % Den == 0) ? N : 6;\n};\n\n// Format subseconds which are given as an integer type with an appropriate\n// number of digits.\ntemplate <typename Char, typename OutputIt, typename Duration>\nvoid write_fractional_seconds(OutputIt& out, Duration d, int precision = -1) {\n  constexpr auto num_fractional_digits =\n      count_fractional_digits<Duration::period::num,\n                              Duration::period::den>::value;\n\n  using subsecond_precision = std::chrono::duration<\n      typename std::common_type<typename Duration::rep,\n                                std::chrono::seconds::rep>::type,\n      std::ratio<1, pow10(num_fractional_digits)>>;\n\n  const auto fractional = d - detail::duration_cast<std::chrono::seconds>(d);\n  const auto subseconds =\n      std::chrono::treat_as_floating_point<\n          typename subsecond_precision::rep>::value\n          ? fractional.count()\n          : detail::duration_cast<subsecond_precision>(fractional).count();\n  auto n = static_cast<uint32_or_64_or_128_t<long long>>(subseconds);\n  const int num_digits = count_digits(n);\n\n  int leading_zeroes = (std::max)(0, num_fractional_digits - num_digits);\n  if (precision < 0) {\n    FMT_ASSERT(!std::is_floating_point<typename Duration::rep>::value, \"\");\n    if (std::ratio_less<typename subsecond_precision::period,\n                        std::chrono::seconds::period>::value) {\n      *out++ = '.';\n      out = detail::fill_n(out, leading_zeroes, '0');\n      out = format_decimal<Char>(out, n, num_digits);\n    }\n  } else if (precision > 0) {\n    *out++ = '.';\n    leading_zeroes = min_of(leading_zeroes, precision);\n    int remaining = precision - leading_zeroes;\n    out = detail::fill_n(out, leading_zeroes, '0');\n    if (remaining < num_digits) {\n      int num_truncated_digits = num_digits - remaining;\n      n /= to_unsigned(pow10(to_unsigned(num_truncated_digits)));\n      if (n != 0) out = format_decimal<Char>(out, n, remaining);\n      return;\n    }\n    if (n != 0) {\n      out = format_decimal<Char>(out, n, num_digits);\n      remaining -= num_digits;\n    }\n    out = detail::fill_n(out, remaining, '0');\n  }\n}\n\n// Format subseconds which are given as a floating point type with an\n// appropriate number of digits. We cannot pass the Duration here, as we\n// explicitly need to pass the Rep value in the duration_formatter.\ntemplate <typename Duration>\nvoid write_floating_seconds(memory_buffer& buf, Duration duration,\n                            int num_fractional_digits = -1) {\n  using rep = typename Duration::rep;\n  FMT_ASSERT(std::is_floating_point<rep>::value, \"\");\n\n  auto val = duration.count();\n\n  if (num_fractional_digits < 0) {\n    // For `std::round` with fallback to `round`:\n    // On some toolchains `std::round` is not available (e.g. GCC 6).\n    using namespace std;\n    num_fractional_digits =\n        count_fractional_digits<Duration::period::num,\n                                Duration::period::den>::value;\n    if (num_fractional_digits < 6 && static_cast<rep>(round(val)) != val)\n      num_fractional_digits = 6;\n  }\n\n  fmt::format_to(std::back_inserter(buf), FMT_STRING(\"{:.{}f}\"),\n                 std::fmod(val * static_cast<rep>(Duration::period::num) /\n                               static_cast<rep>(Duration::period::den),\n                           static_cast<rep>(60)),\n                 num_fractional_digits);\n}\n\ntemplate <typename OutputIt, typename Char,\n          typename Duration = std::chrono::seconds>\nclass tm_writer {\n private:\n  static constexpr int days_per_week = 7;\n\n  const std::locale& loc_;\n  bool is_classic_;\n  OutputIt out_;\n  const Duration* subsecs_;\n  const std::tm& tm_;\n\n  auto tm_sec() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61, \"\");\n    return tm_.tm_sec;\n  }\n  auto tm_min() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_min >= 0 && tm_.tm_min <= 59, \"\");\n    return tm_.tm_min;\n  }\n  auto tm_hour() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_hour >= 0 && tm_.tm_hour <= 23, \"\");\n    return tm_.tm_hour;\n  }\n  auto tm_mday() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_mday >= 1 && tm_.tm_mday <= 31, \"\");\n    return tm_.tm_mday;\n  }\n  auto tm_mon() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_mon >= 0 && tm_.tm_mon <= 11, \"\");\n    return tm_.tm_mon;\n  }\n  auto tm_year() const noexcept -> long long { return 1900ll + tm_.tm_year; }\n  auto tm_wday() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_wday >= 0 && tm_.tm_wday <= 6, \"\");\n    return tm_.tm_wday;\n  }\n  auto tm_yday() const noexcept -> int {\n    FMT_ASSERT(tm_.tm_yday >= 0 && tm_.tm_yday <= 365, \"\");\n    return tm_.tm_yday;\n  }\n\n  auto tm_hour12() const noexcept -> int {\n    auto h = tm_hour();\n    auto z = h < 12 ? h : h - 12;\n    return z == 0 ? 12 : z;\n  }\n\n  // POSIX and the C Standard are unclear or inconsistent about what %C and %y\n  // do if the year is negative or exceeds 9999. Use the convention that %C\n  // concatenated with %y yields the same output as %Y, and that %Y contains at\n  // least 4 characters, with more only if necessary.\n  auto split_year_lower(long long year) const noexcept -> int {\n    auto l = year % 100;\n    if (l < 0) l = -l;  // l in [0, 99]\n    return static_cast<int>(l);\n  }\n\n  // Algorithm: https://en.wikipedia.org/wiki/ISO_week_date.\n  auto iso_year_weeks(long long curr_year) const noexcept -> int {\n    auto prev_year = curr_year - 1;\n    auto curr_p =\n        (curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %\n        days_per_week;\n    auto prev_p =\n        (prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %\n        days_per_week;\n    return 52 + ((curr_p == 4 || prev_p == 3) ? 1 : 0);\n  }\n  auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int {\n    return (tm_yday + 11 - (tm_wday == 0 ? days_per_week : tm_wday)) /\n           days_per_week;\n  }\n  auto tm_iso_week_year() const noexcept -> long long {\n    auto year = tm_year();\n    auto w = iso_week_num(tm_yday(), tm_wday());\n    if (w < 1) return year - 1;\n    if (w > iso_year_weeks(year)) return year + 1;\n    return year;\n  }\n  auto tm_iso_week_of_year() const noexcept -> int {\n    auto year = tm_year();\n    auto w = iso_week_num(tm_yday(), tm_wday());\n    if (w < 1) return iso_year_weeks(year - 1);\n    if (w > iso_year_weeks(year)) return 1;\n    return w;\n  }\n\n  void write1(int value) {\n    *out_++ = static_cast<char>('0' + to_unsigned(value) % 10);\n  }\n  void write2(int value) {\n    const char* d = digits2(to_unsigned(value) % 100);\n    *out_++ = *d++;\n    *out_++ = *d;\n  }\n  void write2(int value, pad_type pad) {\n    unsigned int v = to_unsigned(value) % 100;\n    if (v >= 10) {\n      const char* d = digits2(v);\n      *out_++ = *d++;\n      *out_++ = *d;\n    } else {\n      out_ = detail::write_padding(out_, pad);\n      *out_++ = static_cast<char>('0' + v);\n    }\n  }\n\n  void write_year_extended(long long year, pad_type pad) {\n    // At least 4 characters.\n    int width = 4;\n    bool negative = year < 0;\n    if (negative) {\n      year = 0 - year;\n      --width;\n    }\n    uint32_or_64_or_128_t<long long> n = to_unsigned(year);\n    const int num_digits = count_digits(n);\n    if (negative && pad == pad_type::zero) *out_++ = '-';\n    if (width > num_digits)\n      out_ = detail::write_padding(out_, pad, width - num_digits);\n    if (negative && pad != pad_type::zero) *out_++ = '-';\n    out_ = format_decimal<Char>(out_, n, num_digits);\n  }\n  void write_year(long long year, pad_type pad) {\n    write_year_extended(year, pad);\n  }\n\n  void write_utc_offset(long long offset, numeric_system ns) {\n    if (offset < 0) {\n      *out_++ = '-';\n      offset = -offset;\n    } else {\n      *out_++ = '+';\n    }\n    offset /= 60;\n    write2(static_cast<int>(offset / 60));\n    if (ns != numeric_system::standard) *out_++ = ':';\n    write2(static_cast<int>(offset % 60));\n  }\n\n  template <typename T, FMT_ENABLE_IF(has_tm_gmtoff<T>::value)>\n  void format_utc_offset(const T& tm, numeric_system ns) {\n    write_utc_offset(tm.tm_gmtoff, ns);\n  }\n  template <typename T, FMT_ENABLE_IF(!has_tm_gmtoff<T>::value)>\n  void format_utc_offset(const T&, numeric_system ns) {\n    write_utc_offset(0, ns);\n  }\n\n  template <typename T, FMT_ENABLE_IF(has_tm_zone<T>::value)>\n  void format_tz_name(const T& tm) {\n    out_ = write_tm_str<Char>(out_, tm.tm_zone, loc_);\n  }\n  template <typename T, FMT_ENABLE_IF(!has_tm_zone<T>::value)>\n  void format_tz_name(const T&) {\n    out_ = std::copy_n(utc(), 3, out_);\n  }\n\n  void format_localized(char format, char modifier = 0) {\n    out_ = write<Char>(out_, tm_, loc_, format, modifier);\n  }\n\n public:\n  tm_writer(const std::locale& loc, OutputIt out, const std::tm& tm,\n            const Duration* subsecs = nullptr)\n      : loc_(loc),\n        is_classic_(loc_ == get_classic_locale()),\n        out_(out),\n        subsecs_(subsecs),\n        tm_(tm) {}\n\n  auto out() const -> OutputIt { return out_; }\n\n  FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {\n    out_ = copy<Char>(begin, end, out_);\n  }\n\n  void on_abbr_weekday() {\n    if (is_classic_)\n      out_ = write(out_, tm_wday_short_name(tm_wday()));\n    else\n      format_localized('a');\n  }\n  void on_full_weekday() {\n    if (is_classic_)\n      out_ = write(out_, tm_wday_full_name(tm_wday()));\n    else\n      format_localized('A');\n  }\n  void on_dec0_weekday(numeric_system ns) {\n    if (is_classic_ || ns == numeric_system::standard) return write1(tm_wday());\n    format_localized('w', 'O');\n  }\n  void on_dec1_weekday(numeric_system ns) {\n    if (is_classic_ || ns == numeric_system::standard) {\n      auto wday = tm_wday();\n      write1(wday == 0 ? days_per_week : wday);\n    } else {\n      format_localized('u', 'O');\n    }\n  }\n\n  void on_abbr_month() {\n    if (is_classic_)\n      out_ = write(out_, tm_mon_short_name(tm_mon()));\n    else\n      format_localized('b');\n  }\n  void on_full_month() {\n    if (is_classic_)\n      out_ = write(out_, tm_mon_full_name(tm_mon()));\n    else\n      format_localized('B');\n  }\n\n  void on_datetime(numeric_system ns) {\n    if (is_classic_) {\n      on_abbr_weekday();\n      *out_++ = ' ';\n      on_abbr_month();\n      *out_++ = ' ';\n      on_day_of_month(numeric_system::standard, pad_type::space);\n      *out_++ = ' ';\n      on_iso_time();\n      *out_++ = ' ';\n      on_year(numeric_system::standard, pad_type::space);\n    } else {\n      format_localized('c', ns == numeric_system::standard ? '\\0' : 'E');\n    }\n  }\n  void on_loc_date(numeric_system ns) {\n    if (is_classic_)\n      on_us_date();\n    else\n      format_localized('x', ns == numeric_system::standard ? '\\0' : 'E');\n  }\n  void on_loc_time(numeric_system ns) {\n    if (is_classic_)\n      on_iso_time();\n    else\n      format_localized('X', ns == numeric_system::standard ? '\\0' : 'E');\n  }\n  void on_us_date() {\n    char buf[8];\n    write_digit2_separated(buf, to_unsigned(tm_mon() + 1),\n                           to_unsigned(tm_mday()),\n                           to_unsigned(split_year_lower(tm_year())), '/');\n    out_ = copy<Char>(std::begin(buf), std::end(buf), out_);\n  }\n  void on_iso_date() {\n    auto year = tm_year();\n    char buf[10];\n    size_t offset = 0;\n    if (year >= 0 && year < 10000) {\n      write2digits(buf, static_cast<size_t>(year / 100));\n    } else {\n      offset = 4;\n      write_year_extended(year, pad_type::zero);\n      year = 0;\n    }\n    write_digit2_separated(buf + 2, static_cast<unsigned>(year % 100),\n                           to_unsigned(tm_mon() + 1), to_unsigned(tm_mday()),\n                           '-');\n    out_ = copy<Char>(std::begin(buf) + offset, std::end(buf), out_);\n  }\n\n  void on_utc_offset(numeric_system ns) { format_utc_offset(tm_, ns); }\n  void on_tz_name() { format_tz_name(tm_); }\n\n  void on_year(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write_year(tm_year(), pad);\n    format_localized('Y', 'E');\n  }\n  void on_short_year(numeric_system ns) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(split_year_lower(tm_year()));\n    format_localized('y', 'O');\n  }\n  void on_offset_year() {\n    if (is_classic_) return write2(split_year_lower(tm_year()));\n    format_localized('y', 'E');\n  }\n\n  void on_century(numeric_system ns) {\n    if (is_classic_ || ns == numeric_system::standard) {\n      auto year = tm_year();\n      auto upper = year / 100;\n      if (year >= -99 && year < 0) {\n        // Zero upper on negative year.\n        *out_++ = '-';\n        *out_++ = '0';\n      } else if (upper >= 0 && upper < 100) {\n        write2(static_cast<int>(upper));\n      } else {\n        out_ = write<Char>(out_, upper);\n      }\n    } else {\n      format_localized('C', 'E');\n    }\n  }\n\n  void on_dec_month(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(tm_mon() + 1, pad);\n    format_localized('m', 'O');\n  }\n\n  void on_dec0_week_of_year(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2((tm_yday() + days_per_week - tm_wday()) / days_per_week,\n                    pad);\n    format_localized('U', 'O');\n  }\n  void on_dec1_week_of_year(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard) {\n      auto wday = tm_wday();\n      write2((tm_yday() + days_per_week -\n              (wday == 0 ? (days_per_week - 1) : (wday - 1))) /\n                 days_per_week,\n             pad);\n    } else {\n      format_localized('W', 'O');\n    }\n  }\n  void on_iso_week_of_year(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(tm_iso_week_of_year(), pad);\n    format_localized('V', 'O');\n  }\n\n  void on_iso_week_based_year() {\n    write_year(tm_iso_week_year(), pad_type::zero);\n  }\n  void on_iso_week_based_short_year() {\n    write2(split_year_lower(tm_iso_week_year()));\n  }\n\n  void on_day_of_year(pad_type pad) {\n    auto yday = tm_yday() + 1;\n    auto digit1 = yday / 100;\n    if (digit1 != 0)\n      write1(digit1);\n    else\n      out_ = detail::write_padding(out_, pad);\n    write2(yday % 100, pad);\n  }\n\n  void on_day_of_month(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(tm_mday(), pad);\n    format_localized('d', 'O');\n  }\n\n  void on_24_hour(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(tm_hour(), pad);\n    format_localized('H', 'O');\n  }\n  void on_12_hour(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(tm_hour12(), pad);\n    format_localized('I', 'O');\n  }\n  void on_minute(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard)\n      return write2(tm_min(), pad);\n    format_localized('M', 'O');\n  }\n\n  void on_second(numeric_system ns, pad_type pad) {\n    if (is_classic_ || ns == numeric_system::standard) {\n      write2(tm_sec(), pad);\n      if (subsecs_) {\n        if (std::is_floating_point<typename Duration::rep>::value) {\n          auto buf = memory_buffer();\n          write_floating_seconds(buf, *subsecs_);\n          if (buf.size() > 1) {\n            // Remove the leading \"0\", write something like \".123\".\n            out_ = copy<Char>(buf.begin() + 1, buf.end(), out_);\n          }\n        } else {\n          write_fractional_seconds<Char>(out_, *subsecs_);\n        }\n      }\n    } else {\n      // Currently no formatting of subseconds when a locale is set.\n      format_localized('S', 'O');\n    }\n  }\n\n  void on_12_hour_time() {\n    if (is_classic_) {\n      char buf[8];\n      write_digit2_separated(buf, to_unsigned(tm_hour12()),\n                             to_unsigned(tm_min()), to_unsigned(tm_sec()), ':');\n      out_ = copy<Char>(std::begin(buf), std::end(buf), out_);\n      *out_++ = ' ';\n      on_am_pm();\n    } else {\n      format_localized('r');\n    }\n  }\n  void on_24_hour_time() {\n    write2(tm_hour());\n    *out_++ = ':';\n    write2(tm_min());\n  }\n  void on_iso_time() {\n    on_24_hour_time();\n    *out_++ = ':';\n    on_second(numeric_system::standard, pad_type::zero);\n  }\n\n  void on_am_pm() {\n    if (is_classic_) {\n      *out_++ = tm_hour() < 12 ? 'A' : 'P';\n      *out_++ = 'M';\n    } else {\n      format_localized('p');\n    }\n  }\n\n  // These apply to chrono durations but not tm.\n  void on_duration_value() {}\n  void on_duration_unit() {}\n};\n\nstruct chrono_format_checker : null_chrono_spec_handler<chrono_format_checker> {\n  bool has_precision_integral = false;\n\n  FMT_NORETURN inline void unsupported() { FMT_THROW(format_error(\"no date\")); }\n\n  template <typename Char>\n  FMT_CONSTEXPR void on_text(const Char*, const Char*) {}\n  FMT_CONSTEXPR void on_day_of_year(pad_type) {}\n  FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_second(numeric_system, pad_type) {}\n  FMT_CONSTEXPR void on_12_hour_time() {}\n  FMT_CONSTEXPR void on_24_hour_time() {}\n  FMT_CONSTEXPR void on_iso_time() {}\n  FMT_CONSTEXPR void on_am_pm() {}\n  FMT_CONSTEXPR void on_duration_value() const {\n    if (has_precision_integral)\n      FMT_THROW(format_error(\"precision not allowed for this argument type\"));\n  }\n  FMT_CONSTEXPR void on_duration_unit() {}\n};\n\ntemplate <typename T,\n          FMT_ENABLE_IF(std::is_integral<T>::value&& has_isfinite<T>::value)>\ninline auto isfinite(T) -> bool {\n  return true;\n}\n\ntemplate <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\ninline auto mod(T x, int y) -> T {\n  return x % static_cast<T>(y);\n}\ntemplate <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>\ninline auto mod(T x, int y) -> T {\n  return std::fmod(x, static_cast<T>(y));\n}\n\n// If T is an integral type, maps T to its unsigned counterpart, otherwise\n// leaves it unchanged (unlike std::make_unsigned).\ntemplate <typename T, bool INTEGRAL = std::is_integral<T>::value>\nstruct make_unsigned_or_unchanged {\n  using type = T;\n};\n\ntemplate <typename T> struct make_unsigned_or_unchanged<T, true> {\n  using type = typename std::make_unsigned<T>::type;\n};\n\ntemplate <typename Rep, typename Period,\n          FMT_ENABLE_IF(std::is_integral<Rep>::value)>\ninline auto get_milliseconds(std::chrono::duration<Rep, Period> d)\n    -> std::chrono::duration<Rep, std::milli> {\n  // This may overflow and/or the result may not fit in the target type.\n#if FMT_SAFE_DURATION_CAST\n  using common_seconds_type =\n      typename std::common_type<decltype(d), std::chrono::seconds>::type;\n  auto d_as_common = detail::duration_cast<common_seconds_type>(d);\n  auto d_as_whole_seconds =\n      detail::duration_cast<std::chrono::seconds>(d_as_common);\n  // This conversion should be nonproblematic.\n  auto diff = d_as_common - d_as_whole_seconds;\n  auto ms = detail::duration_cast<std::chrono::duration<Rep, std::milli>>(diff);\n  return ms;\n#else\n  auto s = detail::duration_cast<std::chrono::seconds>(d);\n  return detail::duration_cast<std::chrono::milliseconds>(d - s);\n#endif\n}\n\ntemplate <typename Char, typename Rep, typename OutputIt,\n          FMT_ENABLE_IF(std::is_integral<Rep>::value)>\nauto format_duration_value(OutputIt out, Rep val, int) -> OutputIt {\n  return write<Char>(out, val);\n}\n\ntemplate <typename Char, typename Rep, typename OutputIt,\n          FMT_ENABLE_IF(std::is_floating_point<Rep>::value)>\nauto format_duration_value(OutputIt out, Rep val, int precision) -> OutputIt {\n  auto specs = format_specs();\n  specs.precision = precision;\n  specs.set_type(precision >= 0 ? presentation_type::fixed\n                                : presentation_type::general);\n  return write<Char>(out, val, specs);\n}\n\ntemplate <typename Char, typename OutputIt>\nauto copy_unit(string_view unit, OutputIt out, Char) -> OutputIt {\n  return copy<Char>(unit.begin(), unit.end(), out);\n}\n\ntemplate <typename OutputIt>\nauto copy_unit(string_view unit, OutputIt out, wchar_t) -> OutputIt {\n  // This works when wchar_t is UTF-32 because units only contain characters\n  // that have the same representation in UTF-16 and UTF-32.\n  utf8_to_utf16 u(unit);\n  return copy<wchar_t>(u.c_str(), u.c_str() + u.size(), out);\n}\n\ntemplate <typename Char, typename Period, typename OutputIt>\nauto format_duration_unit(OutputIt out) -> OutputIt {\n  if (const char* unit = get_units<Period>())\n    return copy_unit(string_view(unit), out, Char());\n  *out++ = '[';\n  out = write<Char>(out, Period::num);\n  if FMT_CONSTEXPR20 (Period::den != 1) {\n    *out++ = '/';\n    out = write<Char>(out, Period::den);\n  }\n  *out++ = ']';\n  *out++ = 's';\n  return out;\n}\n\nclass get_locale {\n private:\n  union {\n    std::locale locale_;\n  };\n  bool has_locale_ = false;\n\n public:\n  inline get_locale(bool localized, locale_ref loc) : has_locale_(localized) {\n    if (!localized) return;\n    ignore_unused(loc);\n    ::new (&locale_) std::locale(\n#if FMT_USE_LOCALE\n        loc.template get<std::locale>()\n#endif\n    );\n  }\n  inline ~get_locale() {\n    if (has_locale_) locale_.~locale();\n  }\n  inline operator const std::locale&() const {\n    return has_locale_ ? locale_ : get_classic_locale();\n  }\n};\n\ntemplate <typename Char, typename Rep, typename Period>\nstruct duration_formatter {\n  using iterator = basic_appender<Char>;\n  iterator out;\n  // rep is unsigned to avoid overflow.\n  using rep =\n      conditional_t<std::is_integral<Rep>::value && sizeof(Rep) < sizeof(int),\n                    unsigned, typename make_unsigned_or_unchanged<Rep>::type>;\n  rep val;\n  int precision;\n  locale_ref locale;\n  bool localized = false;\n  using seconds = std::chrono::duration<rep>;\n  seconds s;\n  using milliseconds = std::chrono::duration<rep, std::milli>;\n  bool negative;\n\n  using tm_writer_type = tm_writer<iterator, Char>;\n\n  duration_formatter(iterator o, std::chrono::duration<Rep, Period> d,\n                     locale_ref loc)\n      : out(o), val(static_cast<rep>(d.count())), locale(loc), negative(false) {\n    if (d.count() < 0) {\n      val = 0 - val;\n      negative = true;\n    }\n\n    // this may overflow and/or the result may not fit in the\n    // target type.\n    // might need checked conversion (rep!=Rep)\n    s = detail::duration_cast<seconds>(std::chrono::duration<rep, Period>(val));\n  }\n\n  // returns true if nan or inf, writes to out.\n  auto handle_nan_inf() -> bool {\n    if (isfinite(val)) return false;\n    if (isnan(val)) {\n      write_nan();\n      return true;\n    }\n    // must be +-inf\n    if (val > 0)\n      std::copy_n(\"inf\", 3, out);\n    else\n      std::copy_n(\"-inf\", 4, out);\n    return true;\n  }\n\n  auto days() const -> Rep { return static_cast<Rep>(s.count() / 86400); }\n  auto hour() const -> Rep {\n    return static_cast<Rep>(mod((s.count() / 3600), 24));\n  }\n\n  auto hour12() const -> Rep {\n    Rep hour = static_cast<Rep>(mod((s.count() / 3600), 12));\n    return hour <= 0 ? 12 : hour;\n  }\n\n  auto minute() const -> Rep {\n    return static_cast<Rep>(mod((s.count() / 60), 60));\n  }\n  auto second() const -> Rep { return static_cast<Rep>(mod(s.count(), 60)); }\n\n  auto time() const -> std::tm {\n    auto time = std::tm();\n    time.tm_hour = to_nonnegative_int(hour(), 24);\n    time.tm_min = to_nonnegative_int(minute(), 60);\n    time.tm_sec = to_nonnegative_int(second(), 60);\n    return time;\n  }\n\n  void write_sign() {\n    if (!negative) return;\n    *out++ = '-';\n    negative = false;\n  }\n\n  void write(Rep value, int width, pad_type pad = pad_type::zero) {\n    write_sign();\n    if (isnan(value)) return write_nan();\n    uint32_or_64_or_128_t<int> n =\n        to_unsigned(to_nonnegative_int(value, max_value<int>()));\n    int num_digits = detail::count_digits(n);\n    if (width > num_digits) {\n      out = detail::write_padding(out, pad, width - num_digits);\n    }\n    out = format_decimal<Char>(out, n, num_digits);\n  }\n\n  void write_nan() { std::copy_n(\"nan\", 3, out); }\n\n  template <typename Callback, typename... Args>\n  void format_tm(const tm& time, Callback cb, Args... args) {\n    if (isnan(val)) return write_nan();\n    get_locale loc(localized, locale);\n    auto w = tm_writer_type(loc, out, time);\n    (w.*cb)(args...);\n    out = w.out();\n  }\n\n  void on_text(const Char* begin, const Char* end) {\n    copy<Char>(begin, end, out);\n  }\n\n  // These are not implemented because durations don't have date information.\n  void on_abbr_weekday() {}\n  void on_full_weekday() {}\n  void on_dec0_weekday(numeric_system) {}\n  void on_dec1_weekday(numeric_system) {}\n  void on_abbr_month() {}\n  void on_full_month() {}\n  void on_datetime(numeric_system) {}\n  void on_loc_date(numeric_system) {}\n  void on_loc_time(numeric_system) {}\n  void on_us_date() {}\n  void on_iso_date() {}\n  void on_utc_offset(numeric_system) {}\n  void on_tz_name() {}\n  void on_year(numeric_system, pad_type) {}\n  void on_short_year(numeric_system) {}\n  void on_offset_year() {}\n  void on_century(numeric_system) {}\n  void on_iso_week_based_year() {}\n  void on_iso_week_based_short_year() {}\n  void on_dec_month(numeric_system, pad_type) {}\n  void on_dec0_week_of_year(numeric_system, pad_type) {}\n  void on_dec1_week_of_year(numeric_system, pad_type) {}\n  void on_iso_week_of_year(numeric_system, pad_type) {}\n  void on_day_of_month(numeric_system, pad_type) {}\n\n  void on_day_of_year(pad_type) {\n    if (handle_nan_inf()) return;\n    write(days(), 0);\n  }\n\n  void on_24_hour(numeric_system ns, pad_type pad) {\n    if (handle_nan_inf()) return;\n\n    if (ns == numeric_system::standard) return write(hour(), 2, pad);\n    auto time = tm();\n    time.tm_hour = to_nonnegative_int(hour(), 24);\n    format_tm(time, &tm_writer_type::on_24_hour, ns, pad);\n  }\n\n  void on_12_hour(numeric_system ns, pad_type pad) {\n    if (handle_nan_inf()) return;\n\n    if (ns == numeric_system::standard) return write(hour12(), 2, pad);\n    auto time = tm();\n    time.tm_hour = to_nonnegative_int(hour12(), 12);\n    format_tm(time, &tm_writer_type::on_12_hour, ns, pad);\n  }\n\n  void on_minute(numeric_system ns, pad_type pad) {\n    if (handle_nan_inf()) return;\n\n    if (ns == numeric_system::standard) return write(minute(), 2, pad);\n    auto time = tm();\n    time.tm_min = to_nonnegative_int(minute(), 60);\n    format_tm(time, &tm_writer_type::on_minute, ns, pad);\n  }\n\n  void on_second(numeric_system ns, pad_type pad) {\n    if (handle_nan_inf()) return;\n\n    if (ns == numeric_system::standard) {\n      if (std::is_floating_point<rep>::value) {\n        auto buf = memory_buffer();\n        write_floating_seconds(buf, std::chrono::duration<rep, Period>(val),\n                               precision);\n        if (negative) *out++ = '-';\n        if (buf.size() < 2 || buf[1] == '.')\n          out = detail::write_padding(out, pad);\n        out = copy<Char>(buf.begin(), buf.end(), out);\n      } else {\n        write(second(), 2, pad);\n        write_fractional_seconds<Char>(\n            out, std::chrono::duration<rep, Period>(val), precision);\n      }\n      return;\n    }\n    auto time = tm();\n    time.tm_sec = to_nonnegative_int(second(), 60);\n    format_tm(time, &tm_writer_type::on_second, ns, pad);\n  }\n\n  void on_12_hour_time() {\n    if (handle_nan_inf()) return;\n    format_tm(time(), &tm_writer_type::on_12_hour_time);\n  }\n\n  void on_24_hour_time() {\n    if (handle_nan_inf()) {\n      *out++ = ':';\n      handle_nan_inf();\n      return;\n    }\n\n    write(hour(), 2);\n    *out++ = ':';\n    write(minute(), 2);\n  }\n\n  void on_iso_time() {\n    on_24_hour_time();\n    *out++ = ':';\n    if (handle_nan_inf()) return;\n    on_second(numeric_system::standard, pad_type::zero);\n  }\n\n  void on_am_pm() {\n    if (handle_nan_inf()) return;\n    format_tm(time(), &tm_writer_type::on_am_pm);\n  }\n\n  void on_duration_value() {\n    if (handle_nan_inf()) return;\n    write_sign();\n    out = format_duration_value<Char>(out, val, precision);\n  }\n\n  void on_duration_unit() { out = format_duration_unit<Char, Period>(out); }\n};\n\n}  // namespace detail\n\n#if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907\nusing weekday = std::chrono::weekday;\nusing day = std::chrono::day;\nusing month = std::chrono::month;\nusing year = std::chrono::year;\nusing year_month_day = std::chrono::year_month_day;\n#else\n// A fallback version of weekday.\nclass weekday {\n private:\n  unsigned char value_;\n\n public:\n  weekday() = default;\n  constexpr explicit weekday(unsigned wd) noexcept\n      : value_(static_cast<unsigned char>(wd != 7 ? wd : 0)) {}\n  constexpr auto c_encoding() const noexcept -> unsigned { return value_; }\n};\n\nclass day {\n private:\n  unsigned char value_;\n\n public:\n  day() = default;\n  constexpr explicit day(unsigned d) noexcept\n      : value_(static_cast<unsigned char>(d)) {}\n  constexpr explicit operator unsigned() const noexcept { return value_; }\n};\n\nclass month {\n private:\n  unsigned char value_;\n\n public:\n  month() = default;\n  constexpr explicit month(unsigned m) noexcept\n      : value_(static_cast<unsigned char>(m)) {}\n  constexpr explicit operator unsigned() const noexcept { return value_; }\n};\n\nclass year {\n private:\n  int value_;\n\n public:\n  year() = default;\n  constexpr explicit year(int y) noexcept : value_(y) {}\n  constexpr explicit operator int() const noexcept { return value_; }\n};\n\nclass year_month_day {\n private:\n  fmt::year year_;\n  fmt::month month_;\n  fmt::day day_;\n\n public:\n  year_month_day() = default;\n  constexpr year_month_day(const year& y, const month& m, const day& d) noexcept\n      : year_(y), month_(m), day_(d) {}\n  constexpr auto year() const noexcept -> fmt::year { return year_; }\n  constexpr auto month() const noexcept -> fmt::month { return month_; }\n  constexpr auto day() const noexcept -> fmt::day { return day_; }\n};\n#endif  // __cpp_lib_chrono >= 201907\n\ntemplate <typename Char>\nstruct formatter<weekday, Char> : private formatter<std::tm, Char> {\n private:\n  bool use_tm_formatter_ = false;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it != end && *it == 'L') {\n      ++it;\n      this->set_localized();\n    }\n    use_tm_formatter_ = it != end && *it != '}';\n    return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;\n  }\n\n  template <typename FormatContext>\n  auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto time = std::tm();\n    time.tm_wday = static_cast<int>(wd.c_encoding());\n    if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);\n    detail::get_locale loc(this->localized(), ctx.locale());\n    auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);\n    w.on_abbr_weekday();\n    return w.out();\n  }\n};\n\ntemplate <typename Char>\nstruct formatter<day, Char> : private formatter<std::tm, Char> {\n private:\n  bool use_tm_formatter_ = false;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    use_tm_formatter_ = it != end && *it != '}';\n    return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;\n  }\n\n  template <typename FormatContext>\n  auto format(day d, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto time = std::tm();\n    time.tm_mday = static_cast<int>(static_cast<unsigned>(d));\n    if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);\n    detail::get_locale loc(false, ctx.locale());\n    auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);\n    w.on_day_of_month(detail::numeric_system::standard, detail::pad_type::zero);\n    return w.out();\n  }\n};\n\ntemplate <typename Char>\nstruct formatter<month, Char> : private formatter<std::tm, Char> {\n private:\n  bool use_tm_formatter_ = false;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it != end && *it == 'L') {\n      ++it;\n      this->set_localized();\n    }\n    use_tm_formatter_ = it != end && *it != '}';\n    return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;\n  }\n\n  template <typename FormatContext>\n  auto format(month m, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto time = std::tm();\n    time.tm_mon = static_cast<int>(static_cast<unsigned>(m)) - 1;\n    if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);\n    detail::get_locale loc(this->localized(), ctx.locale());\n    auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);\n    w.on_abbr_month();\n    return w.out();\n  }\n};\n\ntemplate <typename Char>\nstruct formatter<year, Char> : private formatter<std::tm, Char> {\n private:\n  bool use_tm_formatter_ = false;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    use_tm_formatter_ = it != end && *it != '}';\n    return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;\n  }\n\n  template <typename FormatContext>\n  auto format(year y, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto time = std::tm();\n    time.tm_year = static_cast<int>(y) - 1900;\n    if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);\n    detail::get_locale loc(false, ctx.locale());\n    auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);\n    w.on_year(detail::numeric_system::standard, detail::pad_type::zero);\n    return w.out();\n  }\n};\n\ntemplate <typename Char>\nstruct formatter<year_month_day, Char> : private formatter<std::tm, Char> {\n private:\n  bool use_tm_formatter_ = false;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    use_tm_formatter_ = it != end && *it != '}';\n    return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;\n  }\n\n  template <typename FormatContext>\n  auto format(year_month_day val, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto time = std::tm();\n    time.tm_year = static_cast<int>(val.year()) - 1900;\n    time.tm_mon = static_cast<int>(static_cast<unsigned>(val.month())) - 1;\n    time.tm_mday = static_cast<int>(static_cast<unsigned>(val.day()));\n    if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);\n    detail::get_locale loc(true, ctx.locale());\n    auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);\n    w.on_iso_date();\n    return w.out();\n  }\n};\n\ntemplate <typename Rep, typename Period, typename Char>\nstruct formatter<std::chrono::duration<Rep, Period>, Char> {\n private:\n  format_specs specs_;\n  detail::arg_ref<Char> width_ref_;\n  detail::arg_ref<Char> precision_ref_;\n  basic_string_view<Char> fmt_;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it == end || *it == '}') return it;\n\n    it = detail::parse_align(it, end, specs_);\n    if (it == end) return it;\n\n    Char c = *it;\n    if ((c >= '0' && c <= '9') || c == '{') {\n      it = detail::parse_width(it, end, specs_, width_ref_, ctx);\n      if (it == end) return it;\n    }\n\n    auto checker = detail::chrono_format_checker();\n    if (*it == '.') {\n      checker.has_precision_integral = !std::is_floating_point<Rep>::value;\n      it = detail::parse_precision(it, end, specs_, precision_ref_, ctx);\n    }\n    if (it != end && *it == 'L') {\n      specs_.set_localized();\n      ++it;\n    }\n    end = detail::parse_chrono_format(it, end, checker);\n    fmt_ = {it, detail::to_unsigned(end - it)};\n    return end;\n  }\n\n  template <typename FormatContext>\n  auto format(std::chrono::duration<Rep, Period> d, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto specs = specs_;\n    auto precision = specs.precision;\n    specs.precision = -1;\n    auto begin = fmt_.begin(), end = fmt_.end();\n    // As a possible future optimization, we could avoid extra copying if width\n    // is not specified.\n    auto buf = basic_memory_buffer<Char>();\n    auto out = basic_appender<Char>(buf);\n    detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,\n                                ctx);\n    detail::handle_dynamic_spec(specs.dynamic_precision(), precision,\n                                precision_ref_, ctx);\n    if (begin == end || *begin == '}') {\n      out = detail::format_duration_value<Char>(out, d.count(), precision);\n      detail::format_duration_unit<Char, Period>(out);\n    } else {\n      auto f =\n          detail::duration_formatter<Char, Rep, Period>(out, d, ctx.locale());\n      f.precision = precision;\n      f.localized = specs_.localized();\n      detail::parse_chrono_format(begin, end, f);\n    }\n    return detail::write(\n        ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);\n  }\n};\n\ntemplate <typename Char> struct formatter<std::tm, Char> {\n private:\n  format_specs specs_;\n  detail::arg_ref<Char> width_ref_;\n  basic_string_view<Char> fmt_ =\n      detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>();\n\n protected:\n  auto localized() const -> bool { return specs_.localized(); }\n  FMT_CONSTEXPR void set_localized() { specs_.set_localized(); }\n\n  FMT_CONSTEXPR auto do_parse(parse_context<Char>& ctx, bool has_timezone)\n      -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it == end || *it == '}') return it;\n\n    it = detail::parse_align(it, end, specs_);\n    if (it == end) return it;\n\n    Char c = *it;\n    if ((c >= '0' && c <= '9') || c == '{') {\n      it = detail::parse_width(it, end, specs_, width_ref_, ctx);\n      if (it == end) return it;\n    }\n\n    if (*it == 'L') {\n      specs_.set_localized();\n      ++it;\n    }\n\n    end = detail::parse_chrono_format(it, end,\n                                      detail::tm_format_checker(has_timezone));\n    // Replace the default format string only if the new spec is not empty.\n    if (end != it) fmt_ = {it, detail::to_unsigned(end - it)};\n    return end;\n  }\n\n  template <typename Duration, typename FormatContext>\n  auto do_format(const std::tm& tm, FormatContext& ctx,\n                 const Duration* subsecs) const -> decltype(ctx.out()) {\n    auto specs = specs_;\n    auto buf = basic_memory_buffer<Char>();\n    auto out = basic_appender<Char>(buf);\n    detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,\n                                ctx);\n\n    auto loc_ref = specs.localized() ? ctx.locale() : locale_ref();\n    detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);\n    auto w = detail::tm_writer<basic_appender<Char>, Char, Duration>(\n        loc, out, tm, subsecs);\n    detail::parse_chrono_format(fmt_.begin(), fmt_.end(), w);\n    return detail::write(\n        ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);\n  }\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return do_parse(ctx, detail::has_tm_gmtoff<std::tm>::value);\n  }\n\n  template <typename FormatContext>\n  auto format(const std::tm& tm, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return do_format<std::chrono::seconds>(tm, ctx, nullptr);\n  }\n};\n\n// DEPRECATED! Reversed order of template parameters.\ntemplate <typename Char, typename Duration>\nstruct formatter<sys_time<Duration>, Char> : private formatter<std::tm, Char> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return this->do_parse(ctx, true);\n  }\n\n  template <typename FormatContext>\n  auto format(sys_time<Duration> val, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    std::tm tm = gmtime(val);\n    using period = typename Duration::period;\n    if FMT_CONSTEXPR20 (period::num == 1 && period::den == 1 &&\n                        !std::is_floating_point<\n                            typename Duration::rep>::value) {\n      detail::set_tm_zone(tm, detail::utc());\n      return formatter<std::tm, Char>::format(tm, ctx);\n    }\n    Duration epoch = val.time_since_epoch();\n    Duration subsecs = detail::duration_cast<Duration>(\n        epoch - detail::duration_cast<std::chrono::seconds>(epoch));\n    if (subsecs.count() < 0) {\n      auto second = detail::duration_cast<Duration>(std::chrono::seconds(1));\n      if (tm.tm_sec != 0) {\n        --tm.tm_sec;\n      } else {\n        tm = gmtime(val - second);\n        detail::set_tm_zone(tm, detail::utc());\n      }\n      subsecs += second;\n    }\n    return formatter<std::tm, Char>::do_format(tm, ctx, &subsecs);\n  }\n};\n\ntemplate <typename Duration, typename Char>\nstruct formatter<utc_time<Duration>, Char>\n    : formatter<sys_time<Duration>, Char> {\n  template <typename FormatContext>\n  auto format(utc_time<Duration> val, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<sys_time<Duration>, Char>::format(\n        detail::utc_clock::to_sys(val), ctx);\n  }\n};\n\ntemplate <typename Duration, typename Char>\nstruct formatter<local_time<Duration>, Char>\n    : private formatter<std::tm, Char> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return this->do_parse(ctx, false);\n  }\n\n  template <typename FormatContext>\n  auto format(local_time<Duration> val, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto time_since_epoch = val.time_since_epoch();\n    auto seconds_since_epoch =\n        detail::duration_cast<std::chrono::seconds>(time_since_epoch);\n    // Use gmtime to prevent time zone conversion since local_time has an\n    // unspecified time zone.\n    std::tm t = gmtime(seconds_since_epoch.count());\n    using period = typename Duration::period;\n    if (period::num == 1 && period::den == 1 &&\n        !std::is_floating_point<typename Duration::rep>::value) {\n      return formatter<std::tm, Char>::format(t, ctx);\n    }\n    auto subsecs =\n        detail::duration_cast<Duration>(time_since_epoch - seconds_since_epoch);\n    return formatter<std::tm, Char>::do_format(t, ctx, &subsecs);\n  }\n};\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_CHRONO_H_\n"
  },
  {
    "path": "include/fmt/color.h",
    "content": "// Formatting library for C++ - color support\n//\n// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_COLOR_H_\n#define FMT_COLOR_H_\n\n#include \"format.h\"\n\nFMT_BEGIN_NAMESPACE\nFMT_BEGIN_EXPORT\n\nenum class color : uint32_t {\n  alice_blue = 0xF0F8FF,               // rgb(240,248,255)\n  antique_white = 0xFAEBD7,            // rgb(250,235,215)\n  aqua = 0x00FFFF,                     // rgb(0,255,255)\n  aquamarine = 0x7FFFD4,               // rgb(127,255,212)\n  azure = 0xF0FFFF,                    // rgb(240,255,255)\n  beige = 0xF5F5DC,                    // rgb(245,245,220)\n  bisque = 0xFFE4C4,                   // rgb(255,228,196)\n  black = 0x000000,                    // rgb(0,0,0)\n  blanched_almond = 0xFFEBCD,          // rgb(255,235,205)\n  blue = 0x0000FF,                     // rgb(0,0,255)\n  blue_violet = 0x8A2BE2,              // rgb(138,43,226)\n  brown = 0xA52A2A,                    // rgb(165,42,42)\n  burly_wood = 0xDEB887,               // rgb(222,184,135)\n  cadet_blue = 0x5F9EA0,               // rgb(95,158,160)\n  chartreuse = 0x7FFF00,               // rgb(127,255,0)\n  chocolate = 0xD2691E,                // rgb(210,105,30)\n  coral = 0xFF7F50,                    // rgb(255,127,80)\n  cornflower_blue = 0x6495ED,          // rgb(100,149,237)\n  cornsilk = 0xFFF8DC,                 // rgb(255,248,220)\n  crimson = 0xDC143C,                  // rgb(220,20,60)\n  cyan = 0x00FFFF,                     // rgb(0,255,255)\n  dark_blue = 0x00008B,                // rgb(0,0,139)\n  dark_cyan = 0x008B8B,                // rgb(0,139,139)\n  dark_golden_rod = 0xB8860B,          // rgb(184,134,11)\n  dark_gray = 0xA9A9A9,                // rgb(169,169,169)\n  dark_green = 0x006400,               // rgb(0,100,0)\n  dark_khaki = 0xBDB76B,               // rgb(189,183,107)\n  dark_magenta = 0x8B008B,             // rgb(139,0,139)\n  dark_olive_green = 0x556B2F,         // rgb(85,107,47)\n  dark_orange = 0xFF8C00,              // rgb(255,140,0)\n  dark_orchid = 0x9932CC,              // rgb(153,50,204)\n  dark_red = 0x8B0000,                 // rgb(139,0,0)\n  dark_salmon = 0xE9967A,              // rgb(233,150,122)\n  dark_sea_green = 0x8FBC8F,           // rgb(143,188,143)\n  dark_slate_blue = 0x483D8B,          // rgb(72,61,139)\n  dark_slate_gray = 0x2F4F4F,          // rgb(47,79,79)\n  dark_turquoise = 0x00CED1,           // rgb(0,206,209)\n  dark_violet = 0x9400D3,              // rgb(148,0,211)\n  deep_pink = 0xFF1493,                // rgb(255,20,147)\n  deep_sky_blue = 0x00BFFF,            // rgb(0,191,255)\n  dim_gray = 0x696969,                 // rgb(105,105,105)\n  dodger_blue = 0x1E90FF,              // rgb(30,144,255)\n  fire_brick = 0xB22222,               // rgb(178,34,34)\n  floral_white = 0xFFFAF0,             // rgb(255,250,240)\n  forest_green = 0x228B22,             // rgb(34,139,34)\n  fuchsia = 0xFF00FF,                  // rgb(255,0,255)\n  gainsboro = 0xDCDCDC,                // rgb(220,220,220)\n  ghost_white = 0xF8F8FF,              // rgb(248,248,255)\n  gold = 0xFFD700,                     // rgb(255,215,0)\n  golden_rod = 0xDAA520,               // rgb(218,165,32)\n  gray = 0x808080,                     // rgb(128,128,128)\n  green = 0x008000,                    // rgb(0,128,0)\n  green_yellow = 0xADFF2F,             // rgb(173,255,47)\n  honey_dew = 0xF0FFF0,                // rgb(240,255,240)\n  hot_pink = 0xFF69B4,                 // rgb(255,105,180)\n  indian_red = 0xCD5C5C,               // rgb(205,92,92)\n  indigo = 0x4B0082,                   // rgb(75,0,130)\n  ivory = 0xFFFFF0,                    // rgb(255,255,240)\n  khaki = 0xF0E68C,                    // rgb(240,230,140)\n  lavender = 0xE6E6FA,                 // rgb(230,230,250)\n  lavender_blush = 0xFFF0F5,           // rgb(255,240,245)\n  lawn_green = 0x7CFC00,               // rgb(124,252,0)\n  lemon_chiffon = 0xFFFACD,            // rgb(255,250,205)\n  light_blue = 0xADD8E6,               // rgb(173,216,230)\n  light_coral = 0xF08080,              // rgb(240,128,128)\n  light_cyan = 0xE0FFFF,               // rgb(224,255,255)\n  light_golden_rod_yellow = 0xFAFAD2,  // rgb(250,250,210)\n  light_gray = 0xD3D3D3,               // rgb(211,211,211)\n  light_green = 0x90EE90,              // rgb(144,238,144)\n  light_pink = 0xFFB6C1,               // rgb(255,182,193)\n  light_salmon = 0xFFA07A,             // rgb(255,160,122)\n  light_sea_green = 0x20B2AA,          // rgb(32,178,170)\n  light_sky_blue = 0x87CEFA,           // rgb(135,206,250)\n  light_slate_gray = 0x778899,         // rgb(119,136,153)\n  light_steel_blue = 0xB0C4DE,         // rgb(176,196,222)\n  light_yellow = 0xFFFFE0,             // rgb(255,255,224)\n  lime = 0x00FF00,                     // rgb(0,255,0)\n  lime_green = 0x32CD32,               // rgb(50,205,50)\n  linen = 0xFAF0E6,                    // rgb(250,240,230)\n  magenta = 0xFF00FF,                  // rgb(255,0,255)\n  maroon = 0x800000,                   // rgb(128,0,0)\n  medium_aquamarine = 0x66CDAA,        // rgb(102,205,170)\n  medium_blue = 0x0000CD,              // rgb(0,0,205)\n  medium_orchid = 0xBA55D3,            // rgb(186,85,211)\n  medium_purple = 0x9370DB,            // rgb(147,112,219)\n  medium_sea_green = 0x3CB371,         // rgb(60,179,113)\n  medium_slate_blue = 0x7B68EE,        // rgb(123,104,238)\n  medium_spring_green = 0x00FA9A,      // rgb(0,250,154)\n  medium_turquoise = 0x48D1CC,         // rgb(72,209,204)\n  medium_violet_red = 0xC71585,        // rgb(199,21,133)\n  midnight_blue = 0x191970,            // rgb(25,25,112)\n  mint_cream = 0xF5FFFA,               // rgb(245,255,250)\n  misty_rose = 0xFFE4E1,               // rgb(255,228,225)\n  moccasin = 0xFFE4B5,                 // rgb(255,228,181)\n  navajo_white = 0xFFDEAD,             // rgb(255,222,173)\n  navy = 0x000080,                     // rgb(0,0,128)\n  old_lace = 0xFDF5E6,                 // rgb(253,245,230)\n  olive = 0x808000,                    // rgb(128,128,0)\n  olive_drab = 0x6B8E23,               // rgb(107,142,35)\n  orange = 0xFFA500,                   // rgb(255,165,0)\n  orange_red = 0xFF4500,               // rgb(255,69,0)\n  orchid = 0xDA70D6,                   // rgb(218,112,214)\n  pale_golden_rod = 0xEEE8AA,          // rgb(238,232,170)\n  pale_green = 0x98FB98,               // rgb(152,251,152)\n  pale_turquoise = 0xAFEEEE,           // rgb(175,238,238)\n  pale_violet_red = 0xDB7093,          // rgb(219,112,147)\n  papaya_whip = 0xFFEFD5,              // rgb(255,239,213)\n  peach_puff = 0xFFDAB9,               // rgb(255,218,185)\n  peru = 0xCD853F,                     // rgb(205,133,63)\n  pink = 0xFFC0CB,                     // rgb(255,192,203)\n  plum = 0xDDA0DD,                     // rgb(221,160,221)\n  powder_blue = 0xB0E0E6,              // rgb(176,224,230)\n  purple = 0x800080,                   // rgb(128,0,128)\n  rebecca_purple = 0x663399,           // rgb(102,51,153)\n  red = 0xFF0000,                      // rgb(255,0,0)\n  rosy_brown = 0xBC8F8F,               // rgb(188,143,143)\n  royal_blue = 0x4169E1,               // rgb(65,105,225)\n  saddle_brown = 0x8B4513,             // rgb(139,69,19)\n  salmon = 0xFA8072,                   // rgb(250,128,114)\n  sandy_brown = 0xF4A460,              // rgb(244,164,96)\n  sea_green = 0x2E8B57,                // rgb(46,139,87)\n  sea_shell = 0xFFF5EE,                // rgb(255,245,238)\n  sienna = 0xA0522D,                   // rgb(160,82,45)\n  silver = 0xC0C0C0,                   // rgb(192,192,192)\n  sky_blue = 0x87CEEB,                 // rgb(135,206,235)\n  slate_blue = 0x6A5ACD,               // rgb(106,90,205)\n  slate_gray = 0x708090,               // rgb(112,128,144)\n  snow = 0xFFFAFA,                     // rgb(255,250,250)\n  spring_green = 0x00FF7F,             // rgb(0,255,127)\n  steel_blue = 0x4682B4,               // rgb(70,130,180)\n  tan = 0xD2B48C,                      // rgb(210,180,140)\n  teal = 0x008080,                     // rgb(0,128,128)\n  thistle = 0xD8BFD8,                  // rgb(216,191,216)\n  tomato = 0xFF6347,                   // rgb(255,99,71)\n  turquoise = 0x40E0D0,                // rgb(64,224,208)\n  violet = 0xEE82EE,                   // rgb(238,130,238)\n  wheat = 0xF5DEB3,                    // rgb(245,222,179)\n  white = 0xFFFFFF,                    // rgb(255,255,255)\n  white_smoke = 0xF5F5F5,              // rgb(245,245,245)\n  yellow = 0xFFFF00,                   // rgb(255,255,0)\n  yellow_green = 0x9ACD32              // rgb(154,205,50)\n};  // enum class color\n\nenum class terminal_color : uint8_t {\n  black = 30,\n  red,\n  green,\n  yellow,\n  blue,\n  magenta,\n  cyan,\n  white,\n  bright_black = 90,\n  bright_red,\n  bright_green,\n  bright_yellow,\n  bright_blue,\n  bright_magenta,\n  bright_cyan,\n  bright_white\n};\n\nenum class emphasis : uint8_t {\n  bold = 1,\n  faint = 1 << 1,\n  italic = 1 << 2,\n  underline = 1 << 3,\n  blink = 1 << 4,\n  reverse = 1 << 5,\n  conceal = 1 << 6,\n  strikethrough = 1 << 7,\n};\n\n// rgb is a struct for red, green and blue colors.\n// Using the name \"rgb\" makes some editors show the color in a tooltip.\nstruct rgb {\n  constexpr rgb() : r(0), g(0), b(0) {}\n  constexpr rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {}\n  constexpr rgb(uint32_t hex)\n      : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {}\n  constexpr rgb(color hex)\n      : r((uint32_t(hex) >> 16) & 0xFF),\n        g((uint32_t(hex) >> 8) & 0xFF),\n        b(uint32_t(hex) & 0xFF) {}\n  uint8_t r;\n  uint8_t g;\n  uint8_t b;\n};\n\nnamespace detail {\n\n// A bit-packed variant of an RGB color, a terminal color, or unset color.\n// see text_style for the bit-packing scheme.\nstruct color_type {\n  constexpr color_type() noexcept = default;\n  constexpr color_type(color rgb_color) noexcept\n      : value_(static_cast<uint32_t>(rgb_color) | (1 << 24)) {}\n  constexpr color_type(rgb rgb_color) noexcept\n      : color_type(static_cast<color>(\n            (static_cast<uint32_t>(rgb_color.r) << 16) |\n            (static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b)) {}\n  constexpr color_type(terminal_color term_color) noexcept\n      : value_(static_cast<uint32_t>(term_color) | (3 << 24)) {}\n\n  constexpr auto is_terminal_color() const noexcept -> bool {\n    return (value_ & (1 << 25)) != 0;\n  }\n\n  constexpr auto value() const noexcept -> uint32_t {\n    return value_ & 0xFFFFFF;\n  }\n\n  constexpr color_type(uint32_t value) noexcept : value_(value) {}\n\n  uint32_t value_ = 0;\n};\n}  // namespace detail\n\n/// A text style consisting of foreground and background colors and emphasis.\nclass text_style {\n  // The information is packed as follows:\n  // ┌──┐\n  // │ 0│─┐\n  // │..│ ├── foreground color value\n  // │23│─┘\n  // ├──┤\n  // │24│─┬── discriminator for the above value. 00 if unset, 01 if it's\n  // │25│─┘   an RGB color, or 11 if it's a terminal color (10 is unused)\n  // ├──┤\n  // │26│──── overflow bit, always zero (see below)\n  // ├──┤\n  // │27│─┐\n  // │..│ │\n  // │50│ │\n  // ├──┤ │\n  // │51│ ├── background color (same format as the foreground color)\n  // │52│ │\n  // ├──┤ │\n  // │53│─┘\n  // ├──┤\n  // │54│─┐\n  // │..│ ├── emphases\n  // │61│─┘\n  // ├──┤\n  // │62│─┬── unused\n  // │63│─┘\n  // └──┘\n  // The overflow bits are there to make operator|= efficient.\n  // When ORing, we must throw if, for either the foreground or background,\n  // one style specifies a terminal color and the other specifies any color\n  // (terminal or RGB); in other words, if one discriminator is 11 and the\n  // other is 11 or 01.\n  //\n  // We do that check by adding the styles. Consider what adding does to each\n  // possible pair of discriminators:\n  //    00 + 00 = 000\n  //    01 + 00 = 001\n  //    11 + 00 = 011\n  //    01 + 01 = 010\n  //    11 + 01 = 100 (!!)\n  //    11 + 11 = 110 (!!)\n  // In the last two cases, the ones we want to catch, the third bit——the\n  // overflow bit——is set. Bingo.\n  //\n  // We must take into account the possible carry bit from the bits\n  // before the discriminator. The only potentially problematic case is\n  // 11 + 00 = 011 (a carry bit would make it 100, not good!), but a carry\n  // bit is impossible in that case, because 00 (unset color) means the\n  // 24 bits that precede the discriminator are all zero.\n  //\n  // This test can be applied to both colors simultaneously.\n\n public:\n  FMT_CONSTEXPR text_style(emphasis em = emphasis()) noexcept\n      : style_(static_cast<uint64_t>(em) << 54) {}\n\n  FMT_CONSTEXPR auto operator|=(text_style rhs) -> text_style& {\n    if (((style_ + rhs.style_) & ((1ULL << 26) | (1ULL << 53))) != 0)\n      report_error(\"can't OR a terminal color\");\n    style_ |= rhs.style_;\n    return *this;\n  }\n\n  friend FMT_CONSTEXPR auto operator|(text_style lhs, text_style rhs)\n      -> text_style {\n    return lhs |= rhs;\n  }\n\n  FMT_CONSTEXPR auto operator==(text_style rhs) const noexcept -> bool {\n    return style_ == rhs.style_;\n  }\n\n  FMT_CONSTEXPR auto operator!=(text_style rhs) const noexcept -> bool {\n    return !(*this == rhs);\n  }\n\n  FMT_CONSTEXPR auto has_foreground() const noexcept -> bool {\n    return (style_ & (1 << 24)) != 0;\n  }\n  FMT_CONSTEXPR auto has_background() const noexcept -> bool {\n    return (style_ & (1ULL << 51)) != 0;\n  }\n  FMT_CONSTEXPR auto has_emphasis() const noexcept -> bool {\n    return (style_ >> 54) != 0;\n  }\n  FMT_CONSTEXPR auto get_foreground() const noexcept -> detail::color_type {\n    FMT_ASSERT(has_foreground(), \"no foreground specified for this style\");\n    return style_ & 0x3FFFFFF;\n  }\n  FMT_CONSTEXPR auto get_background() const noexcept -> detail::color_type {\n    FMT_ASSERT(has_background(), \"no background specified for this style\");\n    return (style_ >> 27) & 0x3FFFFFF;\n  }\n  FMT_CONSTEXPR auto get_emphasis() const noexcept -> emphasis {\n    FMT_ASSERT(has_emphasis(), \"no emphasis specified for this style\");\n    return static_cast<emphasis>(style_ >> 54);\n  }\n\n private:\n  FMT_CONSTEXPR text_style(uint64_t style) noexcept : style_(style) {}\n\n  friend FMT_CONSTEXPR auto fg(detail::color_type foreground) noexcept\n      -> text_style;\n\n  friend FMT_CONSTEXPR auto bg(detail::color_type background) noexcept\n      -> text_style;\n\n  uint64_t style_ = 0;\n};\n\n/// Creates a text style from the foreground (text) color.\nFMT_CONSTEXPR inline auto fg(detail::color_type foreground) noexcept\n    -> text_style {\n  return foreground.value_;\n}\n\n/// Creates a text style from the background color.\nFMT_CONSTEXPR inline auto bg(detail::color_type background) noexcept\n    -> text_style {\n  return static_cast<uint64_t>(background.value_) << 27;\n}\n\nFMT_CONSTEXPR inline auto operator|(emphasis lhs, emphasis rhs) noexcept\n    -> text_style {\n  return text_style(lhs) | rhs;\n}\n\nnamespace detail {\n\ntemplate <typename Char> struct ansi_color_escape {\n  FMT_CONSTEXPR ansi_color_escape(color_type text_color,\n                                  const char* esc) noexcept {\n    // If we have a terminal color, we need to output another escape code\n    // sequence.\n    if (text_color.is_terminal_color()) {\n      bool is_background = esc == string_view(\"\\x1b[48;2;\");\n      uint32_t value = text_color.value();\n      // Background ASCII codes are the same as the foreground ones but with\n      // 10 more.\n      if (is_background) value += 10u;\n\n      buffer[size++] = static_cast<Char>('\\x1b');\n      buffer[size++] = static_cast<Char>('[');\n\n      if (value >= 100u) {\n        buffer[size++] = static_cast<Char>('1');\n        value %= 100u;\n      }\n      buffer[size++] = static_cast<Char>('0' + value / 10u);\n      buffer[size++] = static_cast<Char>('0' + value % 10u);\n\n      buffer[size++] = static_cast<Char>('m');\n      return;\n    }\n\n    for (int i = 0; i < 7; i++) {\n      buffer[i] = static_cast<Char>(esc[i]);\n    }\n    rgb color(text_color.value());\n    to_esc(color.r, buffer + 7, ';');\n    to_esc(color.g, buffer + 11, ';');\n    to_esc(color.b, buffer + 15, 'm');\n    size = 19;\n  }\n  FMT_CONSTEXPR ansi_color_escape(emphasis em) noexcept {\n    uint8_t em_codes[num_emphases] = {};\n    if (has_emphasis(em, emphasis::bold)) em_codes[0] = 1;\n    if (has_emphasis(em, emphasis::faint)) em_codes[1] = 2;\n    if (has_emphasis(em, emphasis::italic)) em_codes[2] = 3;\n    if (has_emphasis(em, emphasis::underline)) em_codes[3] = 4;\n    if (has_emphasis(em, emphasis::blink)) em_codes[4] = 5;\n    if (has_emphasis(em, emphasis::reverse)) em_codes[5] = 7;\n    if (has_emphasis(em, emphasis::conceal)) em_codes[6] = 8;\n    if (has_emphasis(em, emphasis::strikethrough)) em_codes[7] = 9;\n\n    buffer[size++] = static_cast<Char>('\\x1b');\n    buffer[size++] = static_cast<Char>('[');\n\n    for (size_t i = 0; i < num_emphases; ++i) {\n      if (!em_codes[i]) continue;\n      buffer[size++] = static_cast<Char>('0' + em_codes[i]);\n      buffer[size++] = static_cast<Char>(';');\n    }\n\n    buffer[size - 1] = static_cast<Char>('m');\n  }\n  FMT_CONSTEXPR operator const Char*() const noexcept { return buffer; }\n\n  FMT_CONSTEXPR auto begin() const noexcept -> const Char* { return buffer; }\n  FMT_CONSTEXPR auto end() const noexcept -> const Char* {\n    return buffer + size;\n  }\n\n private:\n  static constexpr size_t num_emphases = 8;\n  Char buffer[7u + 4u * num_emphases] = {};\n  size_t size = 0;\n\n  static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out,\n                                   char delimiter) noexcept {\n    out[0] = static_cast<Char>('0' + c / 100);\n    out[1] = static_cast<Char>('0' + c / 10 % 10);\n    out[2] = static_cast<Char>('0' + c % 10);\n    out[3] = static_cast<Char>(delimiter);\n  }\n  static FMT_CONSTEXPR auto has_emphasis(emphasis em, emphasis mask) noexcept\n      -> bool {\n    return static_cast<uint8_t>(em) & static_cast<uint8_t>(mask);\n  }\n};\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto make_foreground_color(color_type foreground) noexcept\n    -> ansi_color_escape<Char> {\n  return ansi_color_escape<Char>(foreground, \"\\x1b[38;2;\");\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto make_background_color(color_type background) noexcept\n    -> ansi_color_escape<Char> {\n  return ansi_color_escape<Char>(background, \"\\x1b[48;2;\");\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto make_emphasis(emphasis em) noexcept\n    -> ansi_color_escape<Char> {\n  return ansi_color_escape<Char>(em);\n}\n\ntemplate <typename Char> inline void reset_color(buffer<Char>& buffer) {\n  auto reset_color = string_view(\"\\x1b[0m\");\n  buffer.append(reset_color.begin(), reset_color.end());\n}\n\ntemplate <typename T> struct styled_arg : view {\n  const T& value;\n  text_style style;\n  styled_arg(const T& v, text_style s) : value(v), style(s) {}\n};\n\ntemplate <typename Char>\nvoid vformat_to(buffer<Char>& buf, text_style ts, basic_string_view<Char> fmt,\n                basic_format_args<buffered_context<Char>> args) {\n  if (ts.has_emphasis()) {\n    auto emphasis = make_emphasis<Char>(ts.get_emphasis());\n    buf.append(emphasis.begin(), emphasis.end());\n  }\n  if (ts.has_foreground()) {\n    auto foreground = make_foreground_color<Char>(ts.get_foreground());\n    buf.append(foreground.begin(), foreground.end());\n  }\n  if (ts.has_background()) {\n    auto background = make_background_color<Char>(ts.get_background());\n    buf.append(background.begin(), background.end());\n  }\n  vformat_to(buf, fmt, args);\n  if (ts != text_style()) reset_color<Char>(buf);\n}\n}  // namespace detail\n\ninline void vprint(FILE* f, text_style ts, string_view fmt, format_args args) {\n  auto buf = memory_buffer();\n  detail::vformat_to(buf, ts, fmt, args);\n  print(f, FMT_STRING(\"{}\"), string_view(buf.begin(), buf.size()));\n}\n\n/**\n * Formats a string and prints it to the specified file stream using ANSI\n * escape sequences to specify text formatting.\n *\n * **Example**:\n *\n *     fmt::print(fmt::emphasis::bold | fg(fmt::color::red),\n *                \"Elapsed time: {0:.2f} seconds\", 1.23);\n */\ntemplate <typename... T>\nvoid print(FILE* f, text_style ts, format_string<T...> fmt, T&&... args) {\n  vprint(f, ts, fmt.str, vargs<T...>{{args...}});\n}\n\n/**\n * Formats a string and prints it to stdout using ANSI escape sequences to\n * specify text formatting.\n *\n * **Example**:\n *\n *     fmt::print(fmt::emphasis::bold | fg(fmt::color::red),\n *                \"Elapsed time: {0:.2f} seconds\", 1.23);\n */\ntemplate <typename... T>\nvoid print(text_style ts, format_string<T...> fmt, T&&... args) {\n  return print(stdout, ts, fmt, std::forward<T>(args)...);\n}\n\ninline auto vformat(text_style ts, string_view fmt, format_args args)\n    -> std::string {\n  auto buf = memory_buffer();\n  detail::vformat_to(buf, ts, fmt, args);\n  return fmt::to_string(buf);\n}\n\n/**\n * Formats arguments and returns the result as a string using ANSI escape\n * sequences to specify text formatting.\n *\n * **Example**:\n *\n * ```\n * #include <fmt/color.h>\n * std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),\n *                                   \"The answer is {}\", 42);\n * ```\n */\ntemplate <typename... T>\ninline auto format(text_style ts, format_string<T...> fmt, T&&... args)\n    -> std::string {\n  return fmt::vformat(ts, fmt.str, vargs<T...>{{args...}});\n}\n\n/// Formats a string with the given text_style and writes the output to `out`.\ntemplate <typename OutputIt,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>\nauto vformat_to(OutputIt out, text_style ts, string_view fmt, format_args args)\n    -> OutputIt {\n  auto&& buf = detail::get_buffer<char>(out);\n  detail::vformat_to(buf, ts, fmt, args);\n  return detail::get_iterator(buf, out);\n}\n\n/**\n * Formats arguments with the given text style, writes the result to the output\n * iterator `out` and returns the iterator past the end of the output range.\n *\n * **Example**:\n *\n *     std::vector<char> out;\n *     fmt::format_to(std::back_inserter(out),\n *                    fmt::emphasis::bold | fg(fmt::color::red), \"{}\", 42);\n */\ntemplate <typename OutputIt, typename... T,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>\ninline auto format_to(OutputIt out, text_style ts, format_string<T...> fmt,\n                      T&&... args) -> OutputIt {\n  return vformat_to(out, ts, fmt.str, vargs<T...>{{args...}});\n}\n\ntemplate <typename T, typename Char>\nstruct formatter<detail::styled_arg<T>, Char> : formatter<T, Char> {\n  template <typename FormatContext>\n  auto format(const detail::styled_arg<T>& arg, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    const auto& ts = arg.style;\n    auto out = ctx.out();\n\n    bool has_style = false;\n    if (ts.has_emphasis()) {\n      has_style = true;\n      auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());\n      out = detail::copy<Char>(emphasis.begin(), emphasis.end(), out);\n    }\n    if (ts.has_foreground()) {\n      has_style = true;\n      auto foreground =\n          detail::make_foreground_color<Char>(ts.get_foreground());\n      out = detail::copy<Char>(foreground.begin(), foreground.end(), out);\n    }\n    if (ts.has_background()) {\n      has_style = true;\n      auto background =\n          detail::make_background_color<Char>(ts.get_background());\n      out = detail::copy<Char>(background.begin(), background.end(), out);\n    }\n    out = formatter<T, Char>::format(arg.value, ctx);\n    if (has_style) {\n      auto reset_color = string_view(\"\\x1b[0m\");\n      out = detail::copy<Char>(reset_color.begin(), reset_color.end(), out);\n    }\n    return out;\n  }\n};\n\n/**\n * Returns an argument that will be formatted using ANSI escape sequences,\n * to be used in a formatting function.\n *\n * **Example**:\n *\n *     fmt::print(\"Elapsed time: {0:.2f} seconds\",\n *                fmt::styled(1.23, fmt::fg(fmt::color::green) |\n *                                  fmt::bg(fmt::color::blue)));\n */\ntemplate <typename T>\nFMT_CONSTEXPR auto styled(const T& value, text_style ts)\n    -> detail::styled_arg<remove_cvref_t<T>> {\n  return detail::styled_arg<remove_cvref_t<T>>{value, ts};\n}\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_COLOR_H_\n"
  },
  {
    "path": "include/fmt/compile.h",
    "content": "// Formatting library for C++ - experimental format string compilation\n//\n// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_COMPILE_H_\n#define FMT_COMPILE_H_\n\n#ifndef FMT_MODULE\n#  include <iterator>  // std::back_inserter\n#endif\n\n#include \"format.h\"\n\nFMT_BEGIN_NAMESPACE\nFMT_BEGIN_EXPORT\n\n// A compile-time string which is compiled into fast formatting code.\nclass compiled_string {};\n\ntemplate <typename S>\nstruct is_compiled_string : std::is_base_of<compiled_string, S> {};\n\n/**\n * Converts a string literal `s` into a format string that will be parsed at\n * compile time and converted into efficient formatting code. Requires C++17\n * `constexpr if` compiler support.\n *\n * **Example**:\n *\n *     // Converts 42 into std::string using the most efficient method and no\n *     // runtime format string processing.\n *     std::string s = fmt::format(FMT_COMPILE(\"{}\"), 42);\n */\n#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)\n#  define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::compiled_string)\n#else\n#  define FMT_COMPILE(s) FMT_STRING(s)\n#endif\n\n/**\n * Converts a string literal into a format string that will be parsed at\n * compile time and converted into efficient formatting code. Requires support\n * for class types in constant template parameters (a C++20 feature).\n *\n *  **Example**:\n *\n *     // Converts 42 into std::string using the most efficient method and no\n *     // runtime format string processing.\n *     using namespace fmt::literals;\n *     std::string s = fmt::format(\"{}\"_cf, 42);\n */\n#if FMT_USE_NONTYPE_TEMPLATE_ARGS\ninline namespace literals {\ntemplate <detail::fixed_string Str> constexpr auto operator\"\"_cf() {\n  return FMT_COMPILE(Str.data);\n}\n}  // namespace literals\n#endif\n\nFMT_END_EXPORT\n\nnamespace detail {\n\ntemplate <typename T, typename... Tail>\nconstexpr auto first(const T& value, const Tail&...) -> const T& {\n  return value;\n}\n\n#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)\ntemplate <typename... T> struct type_list {};\n\n// Returns a reference to the argument at index N from [first, rest...].\ntemplate <int N, typename T, typename... Args>\nconstexpr auto get([[maybe_unused]] const T& first,\n                   [[maybe_unused]] const Args&... rest) -> const auto& {\n  static_assert(N < 1 + sizeof...(Args), \"index is out of bounds\");\n  if constexpr (N == 0)\n    return first;\n  else\n    return detail::get<N - 1>(rest...);\n}\n\n#  if FMT_USE_NONTYPE_TEMPLATE_ARGS\ntemplate <int N, typename T, typename... Args, typename Char>\nconstexpr auto get_arg_index_by_name(basic_string_view<Char> name) -> int {\n  if constexpr (is_static_named_arg<T>()) {\n    if (name == T::name) return N;\n  }\n  if constexpr (sizeof...(Args) > 0)\n    return get_arg_index_by_name<N + 1, Args...>(name);\n  (void)name;  // Workaround an MSVC bug about \"unused\" parameter.\n  return -1;\n}\n#  endif\n\ntemplate <typename... Args, typename Char>\nFMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view<Char> name) -> int {\n#  if FMT_USE_NONTYPE_TEMPLATE_ARGS\n  if constexpr (sizeof...(Args) > 0)\n    return get_arg_index_by_name<0, Args...>(name);\n#  endif\n  (void)name;\n  return -1;\n}\n\ntemplate <typename Char, typename... Args>\nconstexpr auto get_arg_index_by_name(basic_string_view<Char> name,\n                                     type_list<Args...>) -> int {\n  return get_arg_index_by_name<Args...>(name);\n}\n\ntemplate <int N, typename> struct get_type_impl;\n\ntemplate <int N, typename... Args> struct get_type_impl<N, type_list<Args...>> {\n  using type =\n      remove_cvref_t<decltype(detail::get<N>(std::declval<Args>()...))>;\n};\n\ntemplate <int N, typename T>\nusing get_type = typename get_type_impl<N, T>::type;\n\ntemplate <typename T> struct is_compiled_format : std::false_type {};\n\ntemplate <typename Char> struct text {\n  basic_string_view<Char> data;\n  using char_type = Char;\n\n  template <typename OutputIt, typename... T>\n  constexpr auto format(OutputIt out, const T&...) const -> OutputIt {\n    return write<Char>(out, data);\n  }\n};\n\ntemplate <typename Char>\nstruct is_compiled_format<text<Char>> : std::true_type {};\n\ntemplate <typename Char>\nconstexpr auto make_text(basic_string_view<Char> s, size_t pos, size_t size)\n    -> text<Char> {\n  return {{&s[pos], size}};\n}\n\ntemplate <typename Char> struct code_unit {\n  Char value;\n  using char_type = Char;\n\n  template <typename OutputIt, typename... T>\n  constexpr auto format(OutputIt out, const T&...) const -> OutputIt {\n    *out++ = value;\n    return out;\n  }\n};\n\n// This ensures that the argument type is convertible to `const T&`.\ntemplate <typename T, int N, typename... Args>\nconstexpr auto get_arg_checked(const Args&... args) -> const T& {\n  const auto& arg = detail::get<N>(args...);\n  if constexpr (detail::is_named_arg<remove_cvref_t<decltype(arg)>>()) {\n    return arg.value;\n  } else {\n    return arg;\n  }\n}\n\ntemplate <typename Char>\nstruct is_compiled_format<code_unit<Char>> : std::true_type {};\n\n// A replacement field that refers to argument N.\ntemplate <typename Char, typename V, int N> struct field {\n  using char_type = Char;\n\n  template <typename OutputIt, typename... T>\n  constexpr auto format(OutputIt out, const T&... args) const -> OutputIt {\n    const V& arg = get_arg_checked<V, N>(args...);\n    if constexpr (std::is_convertible<V, basic_string_view<Char>>::value) {\n      auto s = basic_string_view<Char>(arg);\n      return copy<Char>(s.begin(), s.end(), out);\n    } else {\n      return write<Char>(out, arg);\n    }\n  }\n};\n\ntemplate <typename Char, typename T, int N>\nstruct is_compiled_format<field<Char, T, N>> : std::true_type {};\n\n// A replacement field that refers to argument with name.\ntemplate <typename Char> struct runtime_named_field {\n  using char_type = Char;\n  basic_string_view<Char> name;\n\n  template <typename OutputIt, typename T>\n  constexpr static auto try_format_argument(\n      OutputIt& out,\n      // [[maybe_unused]] due to unused-but-set-parameter warning in GCC 7,8,9\n      [[maybe_unused]] basic_string_view<Char> arg_name, const T& arg) -> bool {\n    if constexpr (is_named_arg<typename std::remove_cv<T>::type>::value) {\n      if (arg_name == arg.name) {\n        out = write<Char>(out, arg.value);\n        return true;\n      }\n    }\n    return false;\n  }\n\n  template <typename OutputIt, typename... T>\n  constexpr auto format(OutputIt out, const T&... args) const -> OutputIt {\n    bool found = (try_format_argument(out, name, args) || ...);\n    if (!found) {\n      FMT_THROW(format_error(\"argument with specified name is not found\"));\n    }\n    return out;\n  }\n};\n\ntemplate <typename Char>\nstruct is_compiled_format<runtime_named_field<Char>> : std::true_type {};\n\n// A replacement field that refers to argument N and has format specifiers.\ntemplate <typename Char, typename V, int N> struct spec_field {\n  using char_type = Char;\n  formatter<V, Char> fmt;\n\n  template <typename OutputIt, typename... T>\n  constexpr FMT_INLINE auto format(OutputIt out, const T&... args) const\n      -> OutputIt {\n    const auto& vargs =\n        fmt::make_format_args<basic_format_context<OutputIt, Char>>(args...);\n    basic_format_context<OutputIt, Char> ctx(out, vargs);\n    return fmt.format(get_arg_checked<V, N>(args...), ctx);\n  }\n};\n\ntemplate <typename Char, typename T, int N>\nstruct is_compiled_format<spec_field<Char, T, N>> : std::true_type {};\n\ntemplate <typename L, typename R> struct concat {\n  L lhs;\n  R rhs;\n  using char_type = typename L::char_type;\n\n  template <typename OutputIt, typename... T>\n  constexpr auto format(OutputIt out, const T&... args) const -> OutputIt {\n    out = lhs.format(out, args...);\n    return rhs.format(out, args...);\n  }\n};\n\ntemplate <typename L, typename R>\nstruct is_compiled_format<concat<L, R>> : std::true_type {};\n\ntemplate <typename L, typename R>\nconstexpr auto make_concat(L lhs, R rhs) -> concat<L, R> {\n  return {lhs, rhs};\n}\n\nstruct unknown_format {};\n\ntemplate <typename Char>\nconstexpr auto parse_text(basic_string_view<Char> str, size_t pos) -> size_t {\n  for (size_t size = str.size(); pos != size; ++pos) {\n    if (str[pos] == '{' || str[pos] == '}') break;\n  }\n  return pos;\n}\n\ntemplate <typename Args, size_t POS, int ID, bool DYNAMIC_NAMES, typename S>\nconstexpr auto compile_format_string(S fmt);\n\ntemplate <typename Args, size_t POS, int ID, bool DYNAMIC_NAMES, typename T,\n          typename S>\nconstexpr auto parse_tail(T head, S fmt) {\n  if constexpr (POS != basic_string_view<typename S::char_type>(fmt).size()) {\n    constexpr auto tail =\n        compile_format_string<Args, POS, ID, DYNAMIC_NAMES>(fmt);\n    if constexpr (std::is_same<remove_cvref_t<decltype(tail)>,\n                               unknown_format>())\n      return tail;\n    else\n      return make_concat(head, tail);\n  } else {\n    return head;\n  }\n}\n\ntemplate <typename T, typename Char> struct parse_specs_result {\n  formatter<T, Char> fmt;\n  size_t end;\n  int next_arg_id;\n};\n\nenum { manual_indexing_id = -1 };\n\ntemplate <typename T, typename Char>\nconstexpr auto parse_specs(basic_string_view<Char> str, size_t pos,\n                           int next_arg_id) -> parse_specs_result<T, Char> {\n  str.remove_prefix(pos);\n  auto ctx =\n      compile_parse_context<Char>(str, max_value<int>(), nullptr, next_arg_id);\n  auto f = formatter<T, Char>();\n  auto end = f.parse(ctx);\n  return {f, pos + fmt::detail::to_unsigned(end - str.data()),\n          next_arg_id == 0 ? manual_indexing_id : ctx.next_arg_id()};\n}\n\ntemplate <typename Char> struct arg_id_handler {\n  arg_id_kind kind;\n  arg_ref<Char> arg_id;\n\n  constexpr auto on_auto() -> int {\n    FMT_ASSERT(false, \"handler cannot be used with automatic indexing\");\n    return 0;\n  }\n  constexpr auto on_index(int id) -> int {\n    kind = arg_id_kind::index;\n    arg_id = arg_ref<Char>(id);\n    return 0;\n  }\n  constexpr auto on_name(basic_string_view<Char> id) -> int {\n    kind = arg_id_kind::name;\n    arg_id = arg_ref<Char>(id);\n    return 0;\n  }\n};\n\ntemplate <typename Char> struct parse_arg_id_result {\n  arg_id_kind kind;\n  arg_ref<Char> arg_id;\n  const Char* arg_id_end;\n};\n\ntemplate <int ID, typename Char>\nconstexpr auto parse_arg_id(const Char* begin, const Char* end) {\n  auto handler = arg_id_handler<Char>{arg_id_kind::none, arg_ref<Char>{}};\n  auto arg_id_end = parse_arg_id(begin, end, handler);\n  return parse_arg_id_result<Char>{handler.kind, handler.arg_id, arg_id_end};\n}\n\ntemplate <typename T, typename Enable = void> struct field_type {\n  using type = remove_cvref_t<T>;\n};\n\ntemplate <typename T>\nstruct field_type<T, enable_if_t<detail::is_named_arg<T>::value>> {\n  using type = remove_cvref_t<decltype(T::value)>;\n};\n\ntemplate <typename T, typename Args, size_t END_POS, int ARG_INDEX, int NEXT_ID,\n          bool DYNAMIC_NAMES, typename S>\nconstexpr auto parse_replacement_field_then_tail(S fmt) {\n  using char_type = typename S::char_type;\n  constexpr auto str = basic_string_view<char_type>(fmt);\n  constexpr char_type c = END_POS != str.size() ? str[END_POS] : char_type();\n  if constexpr (c == '}') {\n    return parse_tail<Args, END_POS + 1, NEXT_ID, DYNAMIC_NAMES>(\n        field<char_type, typename field_type<T>::type, ARG_INDEX>(), fmt);\n  } else if constexpr (c != ':') {\n    FMT_THROW(format_error(\"expected ':'\"));\n  } else {\n    constexpr auto result = parse_specs<typename field_type<T>::type>(\n        str, END_POS + 1, NEXT_ID == manual_indexing_id ? 0 : NEXT_ID);\n    if constexpr (result.end >= str.size() || str[result.end] != '}') {\n      FMT_THROW(format_error(\"expected '}'\"));\n      return 0;\n    } else {\n      return parse_tail<Args, result.end + 1, result.next_arg_id,\n                        DYNAMIC_NAMES>(\n          spec_field<char_type, typename field_type<T>::type, ARG_INDEX>{\n              result.fmt},\n          fmt);\n    }\n  }\n}\n\n// Compiles a non-empty format string and returns the compiled representation\n// or unknown_format() on unrecognized input.\ntemplate <typename Args, size_t POS, int ID, bool DYNAMIC_NAMES, typename S>\nconstexpr auto compile_format_string(S fmt) {\n  using char_type = typename S::char_type;\n  constexpr auto str = basic_string_view<char_type>(fmt);\n  if constexpr (str[POS] == '{') {\n    if constexpr (POS + 1 == str.size())\n      FMT_THROW(format_error(\"unmatched '{' in format string\"));\n    if constexpr (str[POS + 1] == '{') {\n      return parse_tail<Args, POS + 2, ID, DYNAMIC_NAMES>(\n          make_text(str, POS, 1), fmt);\n    } else if constexpr (str[POS + 1] == '}' || str[POS + 1] == ':') {\n      static_assert(ID != manual_indexing_id,\n                    \"cannot switch from manual to automatic argument indexing\");\n      constexpr auto next_id =\n          ID != manual_indexing_id ? ID + 1 : manual_indexing_id;\n      return parse_replacement_field_then_tail<\n          get_type<ID, Args>, Args, POS + 1, ID, next_id, DYNAMIC_NAMES>(fmt);\n    } else {\n      constexpr auto arg_id_result =\n          parse_arg_id<ID>(str.data() + POS + 1, str.data() + str.size());\n      constexpr auto arg_id_end_pos = arg_id_result.arg_id_end - str.data();\n      constexpr char_type c =\n          arg_id_end_pos != str.size() ? str[arg_id_end_pos] : char_type();\n      static_assert(c == '}' || c == ':', \"missing '}' in format string\");\n      if constexpr (arg_id_result.kind == arg_id_kind::index) {\n        static_assert(\n            ID == manual_indexing_id || ID == 0,\n            \"cannot switch from automatic to manual argument indexing\");\n        constexpr auto arg_index = arg_id_result.arg_id.index;\n        return parse_replacement_field_then_tail<\n            get_type<arg_index, Args>, Args, arg_id_end_pos, arg_index,\n            manual_indexing_id, DYNAMIC_NAMES>(fmt);\n      } else if constexpr (arg_id_result.kind == arg_id_kind::name) {\n        constexpr auto arg_index =\n            get_arg_index_by_name(arg_id_result.arg_id.name, Args{});\n\n        static_assert(arg_index >= 0 || DYNAMIC_NAMES,\n                      \"named argument not found\");\n\n        if constexpr (arg_index >= 0) {\n          constexpr auto next_id =\n              ID != manual_indexing_id ? ID + 1 : manual_indexing_id;\n          return parse_replacement_field_then_tail<\n              decltype(get_type<arg_index, Args>::value), Args, arg_id_end_pos,\n              arg_index, next_id, DYNAMIC_NAMES>(fmt);\n        } else if constexpr (c == '}') {\n          return parse_tail<Args, arg_id_end_pos + 1, ID, DYNAMIC_NAMES>(\n              runtime_named_field<char_type>{arg_id_result.arg_id.name}, fmt);\n        } else if constexpr (c == ':') {\n          return unknown_format();  // no type info for specs parsing\n        }\n      }\n    }\n  } else if constexpr (str[POS] == '}') {\n    if constexpr (POS + 1 == str.size())\n      FMT_THROW(format_error(\"unmatched '}' in format string\"));\n    return parse_tail<Args, POS + 2, ID, DYNAMIC_NAMES>(make_text(str, POS, 1),\n                                                        fmt);\n  } else {\n    constexpr auto end = parse_text(str, POS + 1);\n    if constexpr (end - POS > 1) {\n      return parse_tail<Args, end, ID, DYNAMIC_NAMES>(\n          make_text(str, POS, end - POS), fmt);\n    } else {\n      return parse_tail<Args, end, ID, DYNAMIC_NAMES>(\n          code_unit<char_type>{str[POS]}, fmt);\n    }\n  }\n}\n\ntemplate <typename... Args, typename S,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nconstexpr auto compile(S fmt) {\n  constexpr auto str = basic_string_view<typename S::char_type>(fmt);\n  if constexpr (str.size() == 0) {\n    return detail::make_text(str, 0, 0);\n  } else {\n    constexpr int num_static_named_args =\n        detail::count_static_named_args<Args...>();\n    constexpr auto result = detail::compile_format_string<\n        detail::type_list<Args...>, 0, 0,\n        num_static_named_args != detail::count_named_args<Args...>()>(fmt);\n    return result;\n  }\n}\n#endif  // defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)\n}  // namespace detail\n\nFMT_BEGIN_EXPORT\n\n#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)\n\ntemplate <typename CompiledFormat, typename... T,\n          typename Char = typename CompiledFormat::char_type,\n          FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>\nFMT_INLINE FMT_CONSTEXPR_STRING auto format(const CompiledFormat& cf,\n                                            const T&... args)\n    -> std::basic_string<Char> {\n  auto s = std::basic_string<Char>();\n  cf.format(std::back_inserter(s), args...);\n  return s;\n}\n\ntemplate <typename OutputIt, typename CompiledFormat, typename... T,\n          FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>\nconstexpr FMT_INLINE auto format_to(OutputIt out, const CompiledFormat& cf,\n                                    const T&... args) -> OutputIt {\n  return cf.format(out, args...);\n}\n\ntemplate <typename S, typename... T,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nFMT_INLINE FMT_CONSTEXPR_STRING auto format(const S&, T&&... args)\n    -> std::basic_string<typename S::char_type> {\n  if constexpr (std::is_same<typename S::char_type, char>::value) {\n    constexpr auto str = basic_string_view<typename S::char_type>(S());\n    if constexpr (str.size() == 2 && str[0] == '{' && str[1] == '}') {\n      const auto& first = detail::first(args...);\n      if constexpr (detail::is_named_arg<\n                        remove_cvref_t<decltype(first)>>::value) {\n        return fmt::to_string(first.value);\n      } else {\n        return fmt::to_string(first);\n      }\n    }\n  }\n  constexpr auto compiled = detail::compile<T...>(S());\n  if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,\n                             detail::unknown_format>()) {\n    return fmt::format(\n        static_cast<basic_string_view<typename S::char_type>>(S()),\n        std::forward<T>(args)...);\n  } else {\n    return fmt::format(compiled, std::forward<T>(args)...);\n  }\n}\n\ntemplate <typename OutputIt, typename S, typename... T,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nFMT_CONSTEXPR auto format_to(OutputIt out, const S&, T&&... args) -> OutputIt {\n  constexpr auto compiled = detail::compile<T...>(S());\n  if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,\n                             detail::unknown_format>()) {\n    return fmt::format_to(\n        out, static_cast<basic_string_view<typename S::char_type>>(S()),\n        std::forward<T>(args)...);\n  } else {\n    return fmt::format_to(out, compiled, std::forward<T>(args)...);\n  }\n}\n#endif\n\ntemplate <typename OutputIt, typename S, typename... T,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nauto format_to_n(OutputIt out, size_t n, const S& fmt, T&&... args)\n    -> format_to_n_result<OutputIt> {\n  using traits = detail::fixed_buffer_traits;\n  auto buf = detail::iterator_buffer<OutputIt, char, traits>(out, n);\n  fmt::format_to(appender(buf), fmt, std::forward<T>(args)...);\n  return {buf.out(), buf.count()};\n}\n\ntemplate <typename S, typename... T,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nFMT_CONSTEXPR20 auto formatted_size(const S& fmt, T&&... args) -> size_t {\n  auto buf = detail::counting_buffer<>();\n  fmt::format_to(appender(buf), fmt, std::forward<T>(args)...);\n  return buf.count();\n}\n\ntemplate <typename S, typename... T,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nvoid print(std::FILE* f, const S& fmt, T&&... args) {\n  auto buf = memory_buffer();\n  fmt::format_to(appender(buf), fmt, std::forward<T>(args)...);\n  detail::print(f, {buf.data(), buf.size()});\n}\n\ntemplate <typename S, typename... T,\n          FMT_ENABLE_IF(is_compiled_string<S>::value)>\nvoid print(const S& fmt, T&&... args) {\n  print(stdout, fmt, std::forward<T>(args)...);\n}\n\ntemplate <size_t N> class static_format_result {\n private:\n  char data[N];\n\n public:\n  template <typename S, typename... T,\n            FMT_ENABLE_IF(is_compiled_string<S>::value)>\n  explicit FMT_CONSTEXPR static_format_result(const S& fmt, T&&... args) {\n    *fmt::format_to(data, fmt, std::forward<T>(args)...) = '\\0';\n  }\n\n  FMT_CONSTEXPR auto str() const -> fmt::string_view { return {data, N - 1}; }\n  FMT_CONSTEXPR auto c_str() const -> const char* { return data; }\n};\n\n/**\n * Formats arguments according to the format string `fmt_str` and produces\n * a string of the exact required size at compile time. Both the format string\n * and the arguments must be compile-time expressions.\n *\n * The resulting string can be accessed as a C string via `c_str()` or as\n * a `fmt::string_view` via `str()`.\n *\n * **Example**:\n *\n *     // Produces the static string \"42\" at compile time.\n *     static constexpr auto result = FMT_STATIC_FORMAT(\"{}\", 42);\n *     const char* s = result.c_str();\n */\n#define FMT_STATIC_FORMAT(fmt_str, ...)                            \\\n  fmt::static_format_result<                                       \\\n      fmt::formatted_size(FMT_COMPILE(fmt_str), __VA_ARGS__) + 1>( \\\n      FMT_COMPILE(fmt_str), __VA_ARGS__)\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_COMPILE_H_\n"
  },
  {
    "path": "include/fmt/core.h",
    "content": "#include \"base.h\"\n\n// Using fmt::format via fmt/core.h has been deprecated since version 11\n// and now requires an explicit opt in.\n#ifdef FMT_DEPRECATED_HEAVY_CORE\n#  include \"format.h\"\n#endif\n"
  },
  {
    "path": "include/fmt/fmt-c.h",
    "content": "// Formatting library for C++ - the C API\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_C_H_\n#define FMT_C_H_\n\n#include <stdbool.h>  // bool\n#include <stddef.h>   // size_t\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n  fmt_int = 1,\n  fmt_uint,\n  fmt_bool = 7,\n  fmt_char,\n  fmt_float,\n  fmt_double,\n  fmt_long_double,\n  fmt_cstring,\n  fmt_pointer = 14\n} fmt_type;\n\ntypedef struct {\n  fmt_type type;\n  union {\n    long long int_value;\n    unsigned long long uint_value;  // Used for FMT_PTR and custom data\n    bool bool_value;\n    char char_value;\n    float float_value;\n    double double_value;\n    long double long_double_value;\n    const char* cstring;\n    const void* pointer;\n  } value;\n} fmt_arg;\n\nenum { fmt_error = -1, fmt_error_invalid_arg = -2 };\n\nint fmt_vformat(char* buffer, size_t size, const char* fmt, const fmt_arg* args,\n                size_t num_args);\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifndef __cplusplus\n\nstatic inline fmt_arg fmt_from_int(long long x) {\n  return (fmt_arg){.type = fmt_int, .value.int_value = x};\n}\n\nstatic inline fmt_arg fmt_from_uint(unsigned long long x) {\n  return (fmt_arg){.type = fmt_uint, .value.uint_value = x};\n}\n\nstatic inline fmt_arg fmt_from_bool(bool x) {\n  return (fmt_arg){.type = fmt_bool, .value.bool_value = x};\n}\n\nstatic inline fmt_arg fmt_from_char(char x) {\n  return (fmt_arg){.type = fmt_char, .value.char_value = x};\n}\n\nstatic inline fmt_arg fmt_from_float(float x) {\n  return (fmt_arg){.type = fmt_float, .value.float_value = x};\n}\n\nstatic inline fmt_arg fmt_from_double(double x) {\n  return (fmt_arg){.type = fmt_double, .value.double_value = x};\n}\n\nstatic inline fmt_arg fmt_from_long_double(long double x) {\n  return (fmt_arg){.type = fmt_long_double, .value.long_double_value = x};\n}\n\nstatic inline fmt_arg fmt_from_str(const char* x) {\n  return (fmt_arg){.type = fmt_cstring, .value.cstring = x};\n}\n\nstatic inline fmt_arg fmt_from_ptr(const void* x) {\n  return (fmt_arg){.type = fmt_pointer, .value.pointer = x};\n}\n\nvoid fmt_unsupported_type(void);\n\n#  if !defined(_MSC_VER) || defined(__clang__)\ntypedef signed char fmt_signed_char;\n#  else\ntypedef enum {} fmt_signed_char;\n#  endif\n\n// Require modern MSVC with conformant preprocessor.\n#  if defined(_MSC_VER) && !defined(__clang__) && \\\n      (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL)\n#    error \"C API requires MSVC 2019+ with /Zc:preprocessor flag.\"\n#  endif\n\n#  define FMT_MAKE_ARG(x)                  \\\n    _Generic((x),                          \\\n        fmt_signed_char: fmt_from_int,     \\\n        unsigned char: fmt_from_uint,      \\\n        short: fmt_from_int,               \\\n        unsigned short: fmt_from_uint,     \\\n        int: fmt_from_int,                 \\\n        unsigned int: fmt_from_uint,       \\\n        long: fmt_from_int,                \\\n        unsigned long: fmt_from_uint,      \\\n        long long: fmt_from_int,           \\\n        unsigned long long: fmt_from_uint, \\\n        bool: fmt_from_bool,               \\\n        char: fmt_from_char,               \\\n        float: fmt_from_float,             \\\n        double: fmt_from_double,           \\\n        long double: fmt_from_long_double, \\\n        char*: fmt_from_str,               \\\n        const char*: fmt_from_str,         \\\n        void*: fmt_from_ptr,               \\\n        const void*: fmt_from_ptr,         \\\n        default: fmt_unsupported_type)(x)\n\n#  define FMT_CAT(a, b) FMT_CAT_(a, b)\n#  define FMT_CAT_(a, b) a##b\n\n#  define FMT_NARG_(_unused, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, \\\n                    _12, _13, _14, _15, _16, N, ...)                       \\\n    N\n#  define FMT_NARG(_unused, ...)                                             \\\n    FMT_NARG_(, ##__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, \\\n              3, 2, 1, 0)\n\n#  define FMT_MAP_0(...)\n#  define FMT_MAP_1(f, a) f(a)\n#  define FMT_MAP_2(f, a, b) f(a), f(b)\n#  define FMT_MAP_3(f, a, b, c) f(a), f(b), f(c)\n#  define FMT_MAP_4(f, a, b, c, d) f(a), f(b), f(c), f(d)\n#  define FMT_MAP_5(f, a, b, c, d, e) f(a), f(b), f(c), f(d), f(e)\n#  define FMT_MAP_6(f, a, b, c, d, e, g) f(a), f(b), f(c), f(d), f(e), f(g)\n#  define FMT_MAP_7(f, a, b, c, d, e, g, h) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h)\n#  define FMT_MAP_8(f, a, b, c, d, e, g, h, i) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i)\n#  define FMT_MAP_9(f, a, b, c, d, e, g, h, i, j) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j)\n#  define FMT_MAP_10(f, a, b, c, d, e, g, h, i, j, k) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k)\n#  define FMT_MAP_11(f, a, b, c, d, e, g, h, i, j, k, l) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k), f(l)\n#  define FMT_MAP_12(f, a, b, c, d, e, g, h, i, j, k, l, m) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k), f(l), f(m)\n#  define FMT_MAP_13(f, a, b, c, d, e, g, h, i, j, k, l, m, n) \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k), f(l), f(m), f(n)\n#  define FMT_MAP_14(f, a, b, c, d, e, g, h, i, j, k, l, m, n, o)           \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k), f(l), f(m), \\\n        f(n), f(o)\n#  define FMT_MAP_15(f, a, b, c, d, e, g, h, i, j, k, l, m, n, o, p)        \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k), f(l), f(m), \\\n        f(n), f(o), f(p)\n#  define FMT_MAP_16(f, a, b, c, d, e, g, h, i, j, k, l, m, n, o, p, q)     \\\n    f(a), f(b), f(c), f(d), f(e), f(g), f(h), f(i), f(j), f(k), f(l), f(m), \\\n        f(n), f(o), f(p), f(q)\n\n#  define FMT_MAP(f, ...) \\\n    FMT_CAT(FMT_MAP_, FMT_NARG(, ##__VA_ARGS__))(f, ##__VA_ARGS__)\n\n// select between two expressions depending on whether __VA_ARGS__ is empty\n// expands to e if __VA_ARGS__ is empty and n otherwise\n#  define FMT_VA_SELECT(e, n, ...)                                             \\\n    FMT_NARG_(, ##__VA_ARGS__, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, \\\n              e)\n\n#  define FMT_MAKE_NULL(...) NULL\n#  define FMT_MAKE_ARGLIST(...) \\\n    (fmt_arg[]) { FMT_MAP(FMT_MAKE_ARG, ##__VA_ARGS__) }\n#  define FMT_EXPAND(v) v\n\n#  define fmt_format(buffer, size, fmt, ...)                              \\\n    fmt_vformat((buffer), (size), (fmt),                                  \\\n                FMT_EXPAND(FMT_VA_SELECT(FMT_MAKE_NULL, FMT_MAKE_ARGLIST, \\\n                                         ##__VA_ARGS__)(__VA_ARGS__)),    \\\n                FMT_NARG(, ##__VA_ARGS__))\n\n#endif  // __cplusplus\n\n#endif  // FMT_C_H_\n"
  },
  {
    "path": "include/fmt/format-inl.h",
    "content": "// Formatting library for C++ - implementation\n//\n// Copyright (c) 2012 - 2016, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_FORMAT_INL_H_\n#define FMT_FORMAT_INL_H_\n\n#ifndef FMT_MODULE\n#  include <stddef.h>  // ptrdiff_t\n\n#  include <algorithm>\n#  include <cerrno>  // errno\n#  include <climits>\n#  include <cmath>\n#  include <exception>\n#  include <new>  // std::bad_alloc\n#endif\n\n#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)\n#  include <io.h>  // _isatty\n#endif\n\n#include \"format.h\"\n\n#if FMT_USE_LOCALE && !defined(FMT_MODULE)\n#  include <locale>\n#endif\n\n#ifndef FMT_FUNC\n#  define FMT_FUNC\n#endif\n\n#if defined(FMT_USE_FULL_CACHE_DRAGONBOX)\n// Use the provided definition.\n#elif defined(__OPTIMIZE_SIZE__)\n#  define FMT_USE_FULL_CACHE_DRAGONBOX 0\n#else\n#  define FMT_USE_FULL_CACHE_DRAGONBOX 1\n#endif\n\nFMT_BEGIN_NAMESPACE\n\n#ifndef FMT_CUSTOM_ASSERT_FAIL\nFMT_FUNC void assert_fail(const char* file, int line, const char* message) {\n  // Use unchecked std::fprintf to avoid triggering another assertion when\n  // writing to stderr fails.\n  std::fprintf(stderr, \"%s:%d: assertion failed: %s\", file, line, message);\n  abort();\n}\n#endif\n\n#if FMT_USE_LOCALE\nnamespace detail {\nusing std::locale;\nusing std::numpunct;\nusing std::use_facet;\n}  // namespace detail\n#else\nnamespace detail {\nstruct locale {};\ntemplate <typename Char> struct numpunct {\n  auto grouping() const -> std::string { return \"\\03\"; }\n  auto thousands_sep() const -> Char { return ','; }\n  auto decimal_point() const -> Char { return '.'; }\n};\ntemplate <typename Facet> Facet use_facet(locale) { return {}; }\n}  // namespace detail\n#endif  // FMT_USE_LOCALE\n\ntemplate <typename Locale> auto locale_ref::get() const -> Locale {\n  using namespace detail;\n  static_assert(std::is_same<Locale, locale>::value, \"\");\n#if FMT_USE_LOCALE\n  if (locale_) return *static_cast<const locale*>(locale_);\n#endif\n  return locale();\n}\n\nnamespace detail {\n\nFMT_FUNC auto allocate(size_t size) -> void* {\n  void* p = malloc(size);\n  if (!p) FMT_THROW(std::bad_alloc());\n  return p;\n}\n\nFMT_FUNC void format_error_code(detail::buffer<char>& out, int error_code,\n                                string_view message) noexcept {\n  // Report error code making sure that the output fits into inline_buffer_size\n  // to avoid dynamic memory allocation and potential bad_alloc.\n  out.try_resize(0);\n  static constexpr char SEP[] = \": \";\n  static constexpr char ERROR_STR[] = \"error \";\n  // Subtract 2 to account for terminating null characters in SEP and ERROR_STR.\n  size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2;\n  auto abs_value = static_cast<uint32_or_64_or_128_t<int>>(error_code);\n  if (detail::is_negative(error_code)) {\n    abs_value = 0 - abs_value;\n    ++error_code_size;\n  }\n  error_code_size += detail::to_unsigned(detail::count_digits(abs_value));\n  auto it = appender(out);\n  if (message.size() <= inline_buffer_size - error_code_size)\n    fmt::format_to(it, FMT_STRING(\"{}{}\"), message, SEP);\n  fmt::format_to(it, FMT_STRING(\"{}{}\"), ERROR_STR, error_code);\n  FMT_ASSERT(out.size() <= inline_buffer_size, \"\");\n}\n\nFMT_FUNC void do_report_error(format_func func, int error_code,\n                              const char* message) noexcept {\n  memory_buffer full_message;\n  func(full_message, error_code, message);\n  // Don't use fwrite_all because the latter may throw.\n  if (std::fwrite(full_message.data(), full_message.size(), 1, stderr) > 0)\n    std::fputc('\\n', stderr);\n}\n\n// A wrapper around fwrite that throws on error.\ninline void fwrite_all(const void* ptr, size_t count, FILE* stream) {\n  size_t written = std::fwrite(ptr, 1, count, stream);\n  if (written < count)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot write to file\")));\n}\n\ntemplate <typename Char>\nFMT_FUNC auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result<Char> {\n  auto&& facet = use_facet<numpunct<Char>>(loc.get<locale>());\n  auto grouping = facet.grouping();\n  auto thousands_sep = grouping.empty() ? Char() : facet.thousands_sep();\n  return {std::move(grouping), thousands_sep};\n}\ntemplate <typename Char>\nFMT_FUNC auto decimal_point_impl(locale_ref loc) -> Char {\n  return use_facet<numpunct<Char>>(loc.get<locale>()).decimal_point();\n}\n\n#if FMT_USE_LOCALE\nFMT_FUNC auto write_loc(appender out, loc_value value,\n                        const format_specs& specs, locale_ref loc) -> bool {\n  auto locale = loc.get<std::locale>();\n  // We cannot use the num_put<char> facet because it may produce output in\n  // a wrong encoding.\n  using facet = format_facet<std::locale>;\n  if (std::has_facet<facet>(locale))\n    return use_facet<facet>(locale).put(out, value, specs);\n  return facet(locale).put(out, value, specs);\n}\n#endif\n}  // namespace detail\n\nFMT_FUNC void report_error(const char* message) {\n#if FMT_MSC_VERSION || defined(__NVCC__)\n  // Silence unreachable code warnings in MSVC and NVCC because these\n  // are nearly impossible to fix in a generic code.\n  volatile bool b = true;\n  if (!b) return;\n#endif\n  FMT_THROW(format_error(message));\n}\n\ntemplate <typename Locale> typename Locale::id format_facet<Locale>::id;\n\ntemplate <typename Locale> format_facet<Locale>::format_facet(Locale& loc) {\n  auto& np = detail::use_facet<detail::numpunct<char>>(loc);\n  grouping_ = np.grouping();\n  if (!grouping_.empty()) separator_ = std::string(1, np.thousands_sep());\n}\n\n#if FMT_USE_LOCALE\ntemplate <>\nFMT_API FMT_FUNC auto format_facet<std::locale>::do_put(\n    appender out, loc_value val, const format_specs& specs) const -> bool {\n  return val.visit(\n      detail::loc_writer<>{out, specs, separator_, grouping_, decimal_point_});\n}\n#endif\n\nFMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args)\n    -> std::system_error {\n  auto ec = std::error_code(error_code, std::generic_category());\n  return std::system_error(ec, vformat(fmt, args));\n}\n\nnamespace detail {\n\ntemplate <typename F>\ninline auto operator==(basic_fp<F> x, basic_fp<F> y) -> bool {\n  return x.f == y.f && x.e == y.e;\n}\n\n// Compilers should be able to optimize this into the ror instruction.\nFMT_INLINE auto rotr(uint32_t n, uint32_t r) noexcept -> uint32_t {\n  r &= 31;\n  return (n >> r) | (n << (32 - r));\n}\nFMT_INLINE auto rotr(uint64_t n, uint32_t r) noexcept -> uint64_t {\n  r &= 63;\n  return (n >> r) | (n << (64 - r));\n}\n\n// Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox.\nnamespace dragonbox {\n// Computes upper 64 bits of multiplication of a 32-bit unsigned integer and a\n// 64-bit unsigned integer.\ninline auto umul96_upper64(uint32_t x, uint64_t y) noexcept -> uint64_t {\n  return umul128_upper64(static_cast<uint64_t>(x) << 32, y);\n}\n\n// Computes lower 128 bits of multiplication of a 64-bit unsigned integer and a\n// 128-bit unsigned integer.\ninline auto umul192_lower128(uint64_t x, uint128 y) noexcept -> uint128 {\n  uint64_t high = x * y.high();\n  uint128 high_low = umul128(x, y.low());\n  return {high + high_low.high(), high_low.low()};\n}\n\n// Computes lower 64 bits of multiplication of a 32-bit unsigned integer and a\n// 64-bit unsigned integer.\ninline auto umul96_lower64(uint32_t x, uint64_t y) noexcept -> uint64_t {\n  return x * y;\n}\n\n// Various fast log computations.\ninline auto floor_log10_pow2_minus_log10_4_over_3(int e) noexcept -> int {\n  FMT_ASSERT(e <= 2936 && e >= -2985, \"too large exponent\");\n  return (e * 631305 - 261663) >> 21;\n}\n\nFMT_INLINE_VARIABLE constexpr struct div_small_pow10_infos_struct {\n  uint32_t divisor;\n  int shift_amount;\n} div_small_pow10_infos[] = {{10, 16}, {100, 16}};\n\n// Replaces n by floor(n / pow(10, N)) returning true if and only if n is\n// divisible by pow(10, N).\n// Precondition: n <= pow(10, N + 1).\ntemplate <int N>\nauto check_divisibility_and_divide_by_pow10(uint32_t& n) noexcept -> bool {\n  // The numbers below are chosen such that:\n  //   1. floor(n/d) = floor(nm / 2^k) where d=10 or d=100,\n  //   2. nm mod 2^k < m if and only if n is divisible by d,\n  // where m is magic_number, k is shift_amount\n  // and d is divisor.\n  //\n  // Item 1 is a common technique of replacing division by a constant with\n  // multiplication, see e.g. \"Division by Invariant Integers Using\n  // Multiplication\" by Granlund and Montgomery (1994). magic_number (m) is set\n  // to ceil(2^k/d) for large enough k.\n  // The idea for item 2 originates from Schubfach.\n  constexpr auto info = div_small_pow10_infos[N - 1];\n  FMT_ASSERT(n <= info.divisor * 10, \"n is too large\");\n  constexpr uint32_t magic_number =\n      (1u << info.shift_amount) / info.divisor + 1;\n  n *= magic_number;\n  const uint32_t comparison_mask = (1u << info.shift_amount) - 1;\n  bool result = (n & comparison_mask) < magic_number;\n  n >>= info.shift_amount;\n  return result;\n}\n\n// Computes floor(n / pow(10, N)) for small n and N.\n// Precondition: n <= pow(10, N + 1).\ntemplate <int N> auto small_division_by_pow10(uint32_t n) noexcept -> uint32_t {\n  constexpr auto info = div_small_pow10_infos[N - 1];\n  FMT_ASSERT(n <= info.divisor * 10, \"n is too large\");\n  constexpr uint32_t magic_number =\n      (1u << info.shift_amount) / info.divisor + 1;\n  return (n * magic_number) >> info.shift_amount;\n}\n\n// Computes floor(n / 10^(kappa + 1)) (float)\ninline auto divide_by_10_to_kappa_plus_1(uint32_t n) noexcept -> uint32_t {\n  // 1374389535 = ceil(2^37/100)\n  return static_cast<uint32_t>((static_cast<uint64_t>(n) * 1374389535) >> 37);\n}\n// Computes floor(n / 10^(kappa + 1)) (double)\ninline auto divide_by_10_to_kappa_plus_1(uint64_t n) noexcept -> uint64_t {\n  // 2361183241434822607 = ceil(2^(64+7)/1000)\n  return umul128_upper64(n, 2361183241434822607ull) >> 7;\n}\n\n// Various subroutines using pow10 cache\ntemplate <typename T> struct cache_accessor;\n\ntemplate <> struct cache_accessor<float> {\n  using carrier_uint = float_info<float>::carrier_uint;\n  using cache_entry_type = uint64_t;\n\n  static auto get_cached_power(int k) noexcept -> uint64_t {\n    FMT_ASSERT(k >= float_info<float>::min_k && k <= float_info<float>::max_k,\n               \"k is out of range\");\n    static constexpr uint64_t pow10_significands[] = {\n        0x81ceb32c4b43fcf5, 0xa2425ff75e14fc32, 0xcad2f7f5359a3b3f,\n        0xfd87b5f28300ca0e, 0x9e74d1b791e07e49, 0xc612062576589ddb,\n        0xf79687aed3eec552, 0x9abe14cd44753b53, 0xc16d9a0095928a28,\n        0xf1c90080baf72cb2, 0x971da05074da7bef, 0xbce5086492111aeb,\n        0xec1e4a7db69561a6, 0x9392ee8e921d5d08, 0xb877aa3236a4b44a,\n        0xe69594bec44de15c, 0x901d7cf73ab0acda, 0xb424dc35095cd810,\n        0xe12e13424bb40e14, 0x8cbccc096f5088cc, 0xafebff0bcb24aaff,\n        0xdbe6fecebdedd5bf, 0x89705f4136b4a598, 0xabcc77118461cefd,\n        0xd6bf94d5e57a42bd, 0x8637bd05af6c69b6, 0xa7c5ac471b478424,\n        0xd1b71758e219652c, 0x83126e978d4fdf3c, 0xa3d70a3d70a3d70b,\n        0xcccccccccccccccd, 0x8000000000000000, 0xa000000000000000,\n        0xc800000000000000, 0xfa00000000000000, 0x9c40000000000000,\n        0xc350000000000000, 0xf424000000000000, 0x9896800000000000,\n        0xbebc200000000000, 0xee6b280000000000, 0x9502f90000000000,\n        0xba43b74000000000, 0xe8d4a51000000000, 0x9184e72a00000000,\n        0xb5e620f480000000, 0xe35fa931a0000000, 0x8e1bc9bf04000000,\n        0xb1a2bc2ec5000000, 0xde0b6b3a76400000, 0x8ac7230489e80000,\n        0xad78ebc5ac620000, 0xd8d726b7177a8000, 0x878678326eac9000,\n        0xa968163f0a57b400, 0xd3c21bcecceda100, 0x84595161401484a0,\n        0xa56fa5b99019a5c8, 0xcecb8f27f4200f3a, 0x813f3978f8940985,\n        0xa18f07d736b90be6, 0xc9f2c9cd04674edf, 0xfc6f7c4045812297,\n        0x9dc5ada82b70b59e, 0xc5371912364ce306, 0xf684df56c3e01bc7,\n        0x9a130b963a6c115d, 0xc097ce7bc90715b4, 0xf0bdc21abb48db21,\n        0x96769950b50d88f5, 0xbc143fa4e250eb32, 0xeb194f8e1ae525fe,\n        0x92efd1b8d0cf37bf, 0xb7abc627050305ae, 0xe596b7b0c643c71a,\n        0x8f7e32ce7bea5c70, 0xb35dbf821ae4f38c, 0xe0352f62a19e306f};\n    return pow10_significands[k - float_info<float>::min_k];\n  }\n\n  struct compute_mul_result {\n    carrier_uint result;\n    bool is_integer;\n  };\n  struct compute_mul_parity_result {\n    bool parity;\n    bool is_integer;\n  };\n\n  static auto compute_mul(carrier_uint u,\n                          const cache_entry_type& cache) noexcept\n      -> compute_mul_result {\n    auto r = umul96_upper64(u, cache);\n    return {static_cast<carrier_uint>(r >> 32),\n            static_cast<carrier_uint>(r) == 0};\n  }\n\n  static auto compute_delta(const cache_entry_type& cache, int beta) noexcept\n      -> uint32_t {\n    return static_cast<uint32_t>(cache >> (64 - 1 - beta));\n  }\n\n  static auto compute_mul_parity(carrier_uint two_f,\n                                 const cache_entry_type& cache,\n                                 int beta) noexcept\n      -> compute_mul_parity_result {\n    FMT_ASSERT(beta >= 1, \"\");\n    FMT_ASSERT(beta < 64, \"\");\n\n    auto r = umul96_lower64(two_f, cache);\n    return {((r >> (64 - beta)) & 1) != 0,\n            static_cast<uint32_t>(r >> (32 - beta)) == 0};\n  }\n\n  static auto compute_left_endpoint_for_shorter_interval_case(\n      const cache_entry_type& cache, int beta) noexcept -> carrier_uint {\n    return static_cast<carrier_uint>(\n        (cache - (cache >> (num_significand_bits<float>() + 2))) >>\n        (64 - num_significand_bits<float>() - 1 - beta));\n  }\n\n  static auto compute_right_endpoint_for_shorter_interval_case(\n      const cache_entry_type& cache, int beta) noexcept -> carrier_uint {\n    return static_cast<carrier_uint>(\n        (cache + (cache >> (num_significand_bits<float>() + 1))) >>\n        (64 - num_significand_bits<float>() - 1 - beta));\n  }\n\n  static auto compute_round_up_for_shorter_interval_case(\n      const cache_entry_type& cache, int beta) noexcept -> carrier_uint {\n    return (static_cast<carrier_uint>(\n                cache >> (64 - num_significand_bits<float>() - 2 - beta)) +\n            1) /\n           2;\n  }\n};\n\ntemplate <> struct cache_accessor<double> {\n  using carrier_uint = float_info<double>::carrier_uint;\n  using cache_entry_type = uint128;\n\n  static auto get_cached_power(int k) noexcept -> uint128 {\n    FMT_ASSERT(k >= float_info<double>::min_k && k <= float_info<double>::max_k,\n               \"k is out of range\");\n\n    static constexpr uint128 pow10_significands[] = {\n#if FMT_USE_FULL_CACHE_DRAGONBOX\n        {0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7b},\n        {0x9faacf3df73609b1, 0x77b191618c54e9ad},\n        {0xc795830d75038c1d, 0xd59df5b9ef6a2418},\n        {0xf97ae3d0d2446f25, 0x4b0573286b44ad1e},\n        {0x9becce62836ac577, 0x4ee367f9430aec33},\n        {0xc2e801fb244576d5, 0x229c41f793cda740},\n        {0xf3a20279ed56d48a, 0x6b43527578c11110},\n        {0x9845418c345644d6, 0x830a13896b78aaaa},\n        {0xbe5691ef416bd60c, 0x23cc986bc656d554},\n        {0xedec366b11c6cb8f, 0x2cbfbe86b7ec8aa9},\n        {0x94b3a202eb1c3f39, 0x7bf7d71432f3d6aa},\n        {0xb9e08a83a5e34f07, 0xdaf5ccd93fb0cc54},\n        {0xe858ad248f5c22c9, 0xd1b3400f8f9cff69},\n        {0x91376c36d99995be, 0x23100809b9c21fa2},\n        {0xb58547448ffffb2d, 0xabd40a0c2832a78b},\n        {0xe2e69915b3fff9f9, 0x16c90c8f323f516d},\n        {0x8dd01fad907ffc3b, 0xae3da7d97f6792e4},\n        {0xb1442798f49ffb4a, 0x99cd11cfdf41779d},\n        {0xdd95317f31c7fa1d, 0x40405643d711d584},\n        {0x8a7d3eef7f1cfc52, 0x482835ea666b2573},\n        {0xad1c8eab5ee43b66, 0xda3243650005eed0},\n        {0xd863b256369d4a40, 0x90bed43e40076a83},\n        {0x873e4f75e2224e68, 0x5a7744a6e804a292},\n        {0xa90de3535aaae202, 0x711515d0a205cb37},\n        {0xd3515c2831559a83, 0x0d5a5b44ca873e04},\n        {0x8412d9991ed58091, 0xe858790afe9486c3},\n        {0xa5178fff668ae0b6, 0x626e974dbe39a873},\n        {0xce5d73ff402d98e3, 0xfb0a3d212dc81290},\n        {0x80fa687f881c7f8e, 0x7ce66634bc9d0b9a},\n        {0xa139029f6a239f72, 0x1c1fffc1ebc44e81},\n        {0xc987434744ac874e, 0xa327ffb266b56221},\n        {0xfbe9141915d7a922, 0x4bf1ff9f0062baa9},\n        {0x9d71ac8fada6c9b5, 0x6f773fc3603db4aa},\n        {0xc4ce17b399107c22, 0xcb550fb4384d21d4},\n        {0xf6019da07f549b2b, 0x7e2a53a146606a49},\n        {0x99c102844f94e0fb, 0x2eda7444cbfc426e},\n        {0xc0314325637a1939, 0xfa911155fefb5309},\n        {0xf03d93eebc589f88, 0x793555ab7eba27cb},\n        {0x96267c7535b763b5, 0x4bc1558b2f3458df},\n        {0xbbb01b9283253ca2, 0x9eb1aaedfb016f17},\n        {0xea9c227723ee8bcb, 0x465e15a979c1cadd},\n        {0x92a1958a7675175f, 0x0bfacd89ec191eca},\n        {0xb749faed14125d36, 0xcef980ec671f667c},\n        {0xe51c79a85916f484, 0x82b7e12780e7401b},\n        {0x8f31cc0937ae58d2, 0xd1b2ecb8b0908811},\n        {0xb2fe3f0b8599ef07, 0x861fa7e6dcb4aa16},\n        {0xdfbdcece67006ac9, 0x67a791e093e1d49b},\n        {0x8bd6a141006042bd, 0xe0c8bb2c5c6d24e1},\n        {0xaecc49914078536d, 0x58fae9f773886e19},\n        {0xda7f5bf590966848, 0xaf39a475506a899f},\n        {0x888f99797a5e012d, 0x6d8406c952429604},\n        {0xaab37fd7d8f58178, 0xc8e5087ba6d33b84},\n        {0xd5605fcdcf32e1d6, 0xfb1e4a9a90880a65},\n        {0x855c3be0a17fcd26, 0x5cf2eea09a550680},\n        {0xa6b34ad8c9dfc06f, 0xf42faa48c0ea481f},\n        {0xd0601d8efc57b08b, 0xf13b94daf124da27},\n        {0x823c12795db6ce57, 0x76c53d08d6b70859},\n        {0xa2cb1717b52481ed, 0x54768c4b0c64ca6f},\n        {0xcb7ddcdda26da268, 0xa9942f5dcf7dfd0a},\n        {0xfe5d54150b090b02, 0xd3f93b35435d7c4d},\n        {0x9efa548d26e5a6e1, 0xc47bc5014a1a6db0},\n        {0xc6b8e9b0709f109a, 0x359ab6419ca1091c},\n        {0xf867241c8cc6d4c0, 0xc30163d203c94b63},\n        {0x9b407691d7fc44f8, 0x79e0de63425dcf1e},\n        {0xc21094364dfb5636, 0x985915fc12f542e5},\n        {0xf294b943e17a2bc4, 0x3e6f5b7b17b2939e},\n        {0x979cf3ca6cec5b5a, 0xa705992ceecf9c43},\n        {0xbd8430bd08277231, 0x50c6ff782a838354},\n        {0xece53cec4a314ebd, 0xa4f8bf5635246429},\n        {0x940f4613ae5ed136, 0x871b7795e136be9a},\n        {0xb913179899f68584, 0x28e2557b59846e40},\n        {0xe757dd7ec07426e5, 0x331aeada2fe589d0},\n        {0x9096ea6f3848984f, 0x3ff0d2c85def7622},\n        {0xb4bca50b065abe63, 0x0fed077a756b53aa},\n        {0xe1ebce4dc7f16dfb, 0xd3e8495912c62895},\n        {0x8d3360f09cf6e4bd, 0x64712dd7abbbd95d},\n        {0xb080392cc4349dec, 0xbd8d794d96aacfb4},\n        {0xdca04777f541c567, 0xecf0d7a0fc5583a1},\n        {0x89e42caaf9491b60, 0xf41686c49db57245},\n        {0xac5d37d5b79b6239, 0x311c2875c522ced6},\n        {0xd77485cb25823ac7, 0x7d633293366b828c},\n        {0x86a8d39ef77164bc, 0xae5dff9c02033198},\n        {0xa8530886b54dbdeb, 0xd9f57f830283fdfd},\n        {0xd267caa862a12d66, 0xd072df63c324fd7c},\n        {0x8380dea93da4bc60, 0x4247cb9e59f71e6e},\n        {0xa46116538d0deb78, 0x52d9be85f074e609},\n        {0xcd795be870516656, 0x67902e276c921f8c},\n        {0x806bd9714632dff6, 0x00ba1cd8a3db53b7},\n        {0xa086cfcd97bf97f3, 0x80e8a40eccd228a5},\n        {0xc8a883c0fdaf7df0, 0x6122cd128006b2ce},\n        {0xfad2a4b13d1b5d6c, 0x796b805720085f82},\n        {0x9cc3a6eec6311a63, 0xcbe3303674053bb1},\n        {0xc3f490aa77bd60fc, 0xbedbfc4411068a9d},\n        {0xf4f1b4d515acb93b, 0xee92fb5515482d45},\n        {0x991711052d8bf3c5, 0x751bdd152d4d1c4b},\n        {0xbf5cd54678eef0b6, 0xd262d45a78a0635e},\n        {0xef340a98172aace4, 0x86fb897116c87c35},\n        {0x9580869f0e7aac0e, 0xd45d35e6ae3d4da1},\n        {0xbae0a846d2195712, 0x8974836059cca10a},\n        {0xe998d258869facd7, 0x2bd1a438703fc94c},\n        {0x91ff83775423cc06, 0x7b6306a34627ddd0},\n        {0xb67f6455292cbf08, 0x1a3bc84c17b1d543},\n        {0xe41f3d6a7377eeca, 0x20caba5f1d9e4a94},\n        {0x8e938662882af53e, 0x547eb47b7282ee9d},\n        {0xb23867fb2a35b28d, 0xe99e619a4f23aa44},\n        {0xdec681f9f4c31f31, 0x6405fa00e2ec94d5},\n        {0x8b3c113c38f9f37e, 0xde83bc408dd3dd05},\n        {0xae0b158b4738705e, 0x9624ab50b148d446},\n        {0xd98ddaee19068c76, 0x3badd624dd9b0958},\n        {0x87f8a8d4cfa417c9, 0xe54ca5d70a80e5d7},\n        {0xa9f6d30a038d1dbc, 0x5e9fcf4ccd211f4d},\n        {0xd47487cc8470652b, 0x7647c32000696720},\n        {0x84c8d4dfd2c63f3b, 0x29ecd9f40041e074},\n        {0xa5fb0a17c777cf09, 0xf468107100525891},\n        {0xcf79cc9db955c2cc, 0x7182148d4066eeb5},\n        {0x81ac1fe293d599bf, 0xc6f14cd848405531},\n        {0xa21727db38cb002f, 0xb8ada00e5a506a7d},\n        {0xca9cf1d206fdc03b, 0xa6d90811f0e4851d},\n        {0xfd442e4688bd304a, 0x908f4a166d1da664},\n        {0x9e4a9cec15763e2e, 0x9a598e4e043287ff},\n        {0xc5dd44271ad3cdba, 0x40eff1e1853f29fe},\n        {0xf7549530e188c128, 0xd12bee59e68ef47d},\n        {0x9a94dd3e8cf578b9, 0x82bb74f8301958cf},\n        {0xc13a148e3032d6e7, 0xe36a52363c1faf02},\n        {0xf18899b1bc3f8ca1, 0xdc44e6c3cb279ac2},\n        {0x96f5600f15a7b7e5, 0x29ab103a5ef8c0ba},\n        {0xbcb2b812db11a5de, 0x7415d448f6b6f0e8},\n        {0xebdf661791d60f56, 0x111b495b3464ad22},\n        {0x936b9fcebb25c995, 0xcab10dd900beec35},\n        {0xb84687c269ef3bfb, 0x3d5d514f40eea743},\n        {0xe65829b3046b0afa, 0x0cb4a5a3112a5113},\n        {0x8ff71a0fe2c2e6dc, 0x47f0e785eaba72ac},\n        {0xb3f4e093db73a093, 0x59ed216765690f57},\n        {0xe0f218b8d25088b8, 0x306869c13ec3532d},\n        {0x8c974f7383725573, 0x1e414218c73a13fc},\n        {0xafbd2350644eeacf, 0xe5d1929ef90898fb},\n        {0xdbac6c247d62a583, 0xdf45f746b74abf3a},\n        {0x894bc396ce5da772, 0x6b8bba8c328eb784},\n        {0xab9eb47c81f5114f, 0x066ea92f3f326565},\n        {0xd686619ba27255a2, 0xc80a537b0efefebe},\n        {0x8613fd0145877585, 0xbd06742ce95f5f37},\n        {0xa798fc4196e952e7, 0x2c48113823b73705},\n        {0xd17f3b51fca3a7a0, 0xf75a15862ca504c6},\n        {0x82ef85133de648c4, 0x9a984d73dbe722fc},\n        {0xa3ab66580d5fdaf5, 0xc13e60d0d2e0ebbb},\n        {0xcc963fee10b7d1b3, 0x318df905079926a9},\n        {0xffbbcfe994e5c61f, 0xfdf17746497f7053},\n        {0x9fd561f1fd0f9bd3, 0xfeb6ea8bedefa634},\n        {0xc7caba6e7c5382c8, 0xfe64a52ee96b8fc1},\n        {0xf9bd690a1b68637b, 0x3dfdce7aa3c673b1},\n        {0x9c1661a651213e2d, 0x06bea10ca65c084f},\n        {0xc31bfa0fe5698db8, 0x486e494fcff30a63},\n        {0xf3e2f893dec3f126, 0x5a89dba3c3efccfb},\n        {0x986ddb5c6b3a76b7, 0xf89629465a75e01d},\n        {0xbe89523386091465, 0xf6bbb397f1135824},\n        {0xee2ba6c0678b597f, 0x746aa07ded582e2d},\n        {0x94db483840b717ef, 0xa8c2a44eb4571cdd},\n        {0xba121a4650e4ddeb, 0x92f34d62616ce414},\n        {0xe896a0d7e51e1566, 0x77b020baf9c81d18},\n        {0x915e2486ef32cd60, 0x0ace1474dc1d122f},\n        {0xb5b5ada8aaff80b8, 0x0d819992132456bb},\n        {0xe3231912d5bf60e6, 0x10e1fff697ed6c6a},\n        {0x8df5efabc5979c8f, 0xca8d3ffa1ef463c2},\n        {0xb1736b96b6fd83b3, 0xbd308ff8a6b17cb3},\n        {0xddd0467c64bce4a0, 0xac7cb3f6d05ddbdf},\n        {0x8aa22c0dbef60ee4, 0x6bcdf07a423aa96c},\n        {0xad4ab7112eb3929d, 0x86c16c98d2c953c7},\n        {0xd89d64d57a607744, 0xe871c7bf077ba8b8},\n        {0x87625f056c7c4a8b, 0x11471cd764ad4973},\n        {0xa93af6c6c79b5d2d, 0xd598e40d3dd89bd0},\n        {0xd389b47879823479, 0x4aff1d108d4ec2c4},\n        {0x843610cb4bf160cb, 0xcedf722a585139bb},\n        {0xa54394fe1eedb8fe, 0xc2974eb4ee658829},\n        {0xce947a3da6a9273e, 0x733d226229feea33},\n        {0x811ccc668829b887, 0x0806357d5a3f5260},\n        {0xa163ff802a3426a8, 0xca07c2dcb0cf26f8},\n        {0xc9bcff6034c13052, 0xfc89b393dd02f0b6},\n        {0xfc2c3f3841f17c67, 0xbbac2078d443ace3},\n        {0x9d9ba7832936edc0, 0xd54b944b84aa4c0e},\n        {0xc5029163f384a931, 0x0a9e795e65d4df12},\n        {0xf64335bcf065d37d, 0x4d4617b5ff4a16d6},\n        {0x99ea0196163fa42e, 0x504bced1bf8e4e46},\n        {0xc06481fb9bcf8d39, 0xe45ec2862f71e1d7},\n        {0xf07da27a82c37088, 0x5d767327bb4e5a4d},\n        {0x964e858c91ba2655, 0x3a6a07f8d510f870},\n        {0xbbe226efb628afea, 0x890489f70a55368c},\n        {0xeadab0aba3b2dbe5, 0x2b45ac74ccea842f},\n        {0x92c8ae6b464fc96f, 0x3b0b8bc90012929e},\n        {0xb77ada0617e3bbcb, 0x09ce6ebb40173745},\n        {0xe55990879ddcaabd, 0xcc420a6a101d0516},\n        {0x8f57fa54c2a9eab6, 0x9fa946824a12232e},\n        {0xb32df8e9f3546564, 0x47939822dc96abfa},\n        {0xdff9772470297ebd, 0x59787e2b93bc56f8},\n        {0x8bfbea76c619ef36, 0x57eb4edb3c55b65b},\n        {0xaefae51477a06b03, 0xede622920b6b23f2},\n        {0xdab99e59958885c4, 0xe95fab368e45ecee},\n        {0x88b402f7fd75539b, 0x11dbcb0218ebb415},\n        {0xaae103b5fcd2a881, 0xd652bdc29f26a11a},\n        {0xd59944a37c0752a2, 0x4be76d3346f04960},\n        {0x857fcae62d8493a5, 0x6f70a4400c562ddc},\n        {0xa6dfbd9fb8e5b88e, 0xcb4ccd500f6bb953},\n        {0xd097ad07a71f26b2, 0x7e2000a41346a7a8},\n        {0x825ecc24c873782f, 0x8ed400668c0c28c9},\n        {0xa2f67f2dfa90563b, 0x728900802f0f32fb},\n        {0xcbb41ef979346bca, 0x4f2b40a03ad2ffba},\n        {0xfea126b7d78186bc, 0xe2f610c84987bfa9},\n        {0x9f24b832e6b0f436, 0x0dd9ca7d2df4d7ca},\n        {0xc6ede63fa05d3143, 0x91503d1c79720dbc},\n        {0xf8a95fcf88747d94, 0x75a44c6397ce912b},\n        {0x9b69dbe1b548ce7c, 0xc986afbe3ee11abb},\n        {0xc24452da229b021b, 0xfbe85badce996169},\n        {0xf2d56790ab41c2a2, 0xfae27299423fb9c4},\n        {0x97c560ba6b0919a5, 0xdccd879fc967d41b},\n        {0xbdb6b8e905cb600f, 0x5400e987bbc1c921},\n        {0xed246723473e3813, 0x290123e9aab23b69},\n        {0x9436c0760c86e30b, 0xf9a0b6720aaf6522},\n        {0xb94470938fa89bce, 0xf808e40e8d5b3e6a},\n        {0xe7958cb87392c2c2, 0xb60b1d1230b20e05},\n        {0x90bd77f3483bb9b9, 0xb1c6f22b5e6f48c3},\n        {0xb4ecd5f01a4aa828, 0x1e38aeb6360b1af4},\n        {0xe2280b6c20dd5232, 0x25c6da63c38de1b1},\n        {0x8d590723948a535f, 0x579c487e5a38ad0f},\n        {0xb0af48ec79ace837, 0x2d835a9df0c6d852},\n        {0xdcdb1b2798182244, 0xf8e431456cf88e66},\n        {0x8a08f0f8bf0f156b, 0x1b8e9ecb641b5900},\n        {0xac8b2d36eed2dac5, 0xe272467e3d222f40},\n        {0xd7adf884aa879177, 0x5b0ed81dcc6abb10},\n        {0x86ccbb52ea94baea, 0x98e947129fc2b4ea},\n        {0xa87fea27a539e9a5, 0x3f2398d747b36225},\n        {0xd29fe4b18e88640e, 0x8eec7f0d19a03aae},\n        {0x83a3eeeef9153e89, 0x1953cf68300424ad},\n        {0xa48ceaaab75a8e2b, 0x5fa8c3423c052dd8},\n        {0xcdb02555653131b6, 0x3792f412cb06794e},\n        {0x808e17555f3ebf11, 0xe2bbd88bbee40bd1},\n        {0xa0b19d2ab70e6ed6, 0x5b6aceaeae9d0ec5},\n        {0xc8de047564d20a8b, 0xf245825a5a445276},\n        {0xfb158592be068d2e, 0xeed6e2f0f0d56713},\n        {0x9ced737bb6c4183d, 0x55464dd69685606c},\n        {0xc428d05aa4751e4c, 0xaa97e14c3c26b887},\n        {0xf53304714d9265df, 0xd53dd99f4b3066a9},\n        {0x993fe2c6d07b7fab, 0xe546a8038efe402a},\n        {0xbf8fdb78849a5f96, 0xde98520472bdd034},\n        {0xef73d256a5c0f77c, 0x963e66858f6d4441},\n        {0x95a8637627989aad, 0xdde7001379a44aa9},\n        {0xbb127c53b17ec159, 0x5560c018580d5d53},\n        {0xe9d71b689dde71af, 0xaab8f01e6e10b4a7},\n        {0x9226712162ab070d, 0xcab3961304ca70e9},\n        {0xb6b00d69bb55c8d1, 0x3d607b97c5fd0d23},\n        {0xe45c10c42a2b3b05, 0x8cb89a7db77c506b},\n        {0x8eb98a7a9a5b04e3, 0x77f3608e92adb243},\n        {0xb267ed1940f1c61c, 0x55f038b237591ed4},\n        {0xdf01e85f912e37a3, 0x6b6c46dec52f6689},\n        {0x8b61313bbabce2c6, 0x2323ac4b3b3da016},\n        {0xae397d8aa96c1b77, 0xabec975e0a0d081b},\n        {0xd9c7dced53c72255, 0x96e7bd358c904a22},\n        {0x881cea14545c7575, 0x7e50d64177da2e55},\n        {0xaa242499697392d2, 0xdde50bd1d5d0b9ea},\n        {0xd4ad2dbfc3d07787, 0x955e4ec64b44e865},\n        {0x84ec3c97da624ab4, 0xbd5af13bef0b113f},\n        {0xa6274bbdd0fadd61, 0xecb1ad8aeacdd58f},\n        {0xcfb11ead453994ba, 0x67de18eda5814af3},\n        {0x81ceb32c4b43fcf4, 0x80eacf948770ced8},\n        {0xa2425ff75e14fc31, 0xa1258379a94d028e},\n        {0xcad2f7f5359a3b3e, 0x096ee45813a04331},\n        {0xfd87b5f28300ca0d, 0x8bca9d6e188853fd},\n        {0x9e74d1b791e07e48, 0x775ea264cf55347e},\n        {0xc612062576589dda, 0x95364afe032a819e},\n        {0xf79687aed3eec551, 0x3a83ddbd83f52205},\n        {0x9abe14cd44753b52, 0xc4926a9672793543},\n        {0xc16d9a0095928a27, 0x75b7053c0f178294},\n        {0xf1c90080baf72cb1, 0x5324c68b12dd6339},\n        {0x971da05074da7bee, 0xd3f6fc16ebca5e04},\n        {0xbce5086492111aea, 0x88f4bb1ca6bcf585},\n        {0xec1e4a7db69561a5, 0x2b31e9e3d06c32e6},\n        {0x9392ee8e921d5d07, 0x3aff322e62439fd0},\n        {0xb877aa3236a4b449, 0x09befeb9fad487c3},\n        {0xe69594bec44de15b, 0x4c2ebe687989a9b4},\n        {0x901d7cf73ab0acd9, 0x0f9d37014bf60a11},\n        {0xb424dc35095cd80f, 0x538484c19ef38c95},\n        {0xe12e13424bb40e13, 0x2865a5f206b06fba},\n        {0x8cbccc096f5088cb, 0xf93f87b7442e45d4},\n        {0xafebff0bcb24aafe, 0xf78f69a51539d749},\n        {0xdbe6fecebdedd5be, 0xb573440e5a884d1c},\n        {0x89705f4136b4a597, 0x31680a88f8953031},\n        {0xabcc77118461cefc, 0xfdc20d2b36ba7c3e},\n        {0xd6bf94d5e57a42bc, 0x3d32907604691b4d},\n        {0x8637bd05af6c69b5, 0xa63f9a49c2c1b110},\n        {0xa7c5ac471b478423, 0x0fcf80dc33721d54},\n        {0xd1b71758e219652b, 0xd3c36113404ea4a9},\n        {0x83126e978d4fdf3b, 0x645a1cac083126ea},\n        {0xa3d70a3d70a3d70a, 0x3d70a3d70a3d70a4},\n        {0xcccccccccccccccc, 0xcccccccccccccccd},\n        {0x8000000000000000, 0x0000000000000000},\n        {0xa000000000000000, 0x0000000000000000},\n        {0xc800000000000000, 0x0000000000000000},\n        {0xfa00000000000000, 0x0000000000000000},\n        {0x9c40000000000000, 0x0000000000000000},\n        {0xc350000000000000, 0x0000000000000000},\n        {0xf424000000000000, 0x0000000000000000},\n        {0x9896800000000000, 0x0000000000000000},\n        {0xbebc200000000000, 0x0000000000000000},\n        {0xee6b280000000000, 0x0000000000000000},\n        {0x9502f90000000000, 0x0000000000000000},\n        {0xba43b74000000000, 0x0000000000000000},\n        {0xe8d4a51000000000, 0x0000000000000000},\n        {0x9184e72a00000000, 0x0000000000000000},\n        {0xb5e620f480000000, 0x0000000000000000},\n        {0xe35fa931a0000000, 0x0000000000000000},\n        {0x8e1bc9bf04000000, 0x0000000000000000},\n        {0xb1a2bc2ec5000000, 0x0000000000000000},\n        {0xde0b6b3a76400000, 0x0000000000000000},\n        {0x8ac7230489e80000, 0x0000000000000000},\n        {0xad78ebc5ac620000, 0x0000000000000000},\n        {0xd8d726b7177a8000, 0x0000000000000000},\n        {0x878678326eac9000, 0x0000000000000000},\n        {0xa968163f0a57b400, 0x0000000000000000},\n        {0xd3c21bcecceda100, 0x0000000000000000},\n        {0x84595161401484a0, 0x0000000000000000},\n        {0xa56fa5b99019a5c8, 0x0000000000000000},\n        {0xcecb8f27f4200f3a, 0x0000000000000000},\n        {0x813f3978f8940984, 0x4000000000000000},\n        {0xa18f07d736b90be5, 0x5000000000000000},\n        {0xc9f2c9cd04674ede, 0xa400000000000000},\n        {0xfc6f7c4045812296, 0x4d00000000000000},\n        {0x9dc5ada82b70b59d, 0xf020000000000000},\n        {0xc5371912364ce305, 0x6c28000000000000},\n        {0xf684df56c3e01bc6, 0xc732000000000000},\n        {0x9a130b963a6c115c, 0x3c7f400000000000},\n        {0xc097ce7bc90715b3, 0x4b9f100000000000},\n        {0xf0bdc21abb48db20, 0x1e86d40000000000},\n        {0x96769950b50d88f4, 0x1314448000000000},\n        {0xbc143fa4e250eb31, 0x17d955a000000000},\n        {0xeb194f8e1ae525fd, 0x5dcfab0800000000},\n        {0x92efd1b8d0cf37be, 0x5aa1cae500000000},\n        {0xb7abc627050305ad, 0xf14a3d9e40000000},\n        {0xe596b7b0c643c719, 0x6d9ccd05d0000000},\n        {0x8f7e32ce7bea5c6f, 0xe4820023a2000000},\n        {0xb35dbf821ae4f38b, 0xdda2802c8a800000},\n        {0xe0352f62a19e306e, 0xd50b2037ad200000},\n        {0x8c213d9da502de45, 0x4526f422cc340000},\n        {0xaf298d050e4395d6, 0x9670b12b7f410000},\n        {0xdaf3f04651d47b4c, 0x3c0cdd765f114000},\n        {0x88d8762bf324cd0f, 0xa5880a69fb6ac800},\n        {0xab0e93b6efee0053, 0x8eea0d047a457a00},\n        {0xd5d238a4abe98068, 0x72a4904598d6d880},\n        {0x85a36366eb71f041, 0x47a6da2b7f864750},\n        {0xa70c3c40a64e6c51, 0x999090b65f67d924},\n        {0xd0cf4b50cfe20765, 0xfff4b4e3f741cf6d},\n        {0x82818f1281ed449f, 0xbff8f10e7a8921a5},\n        {0xa321f2d7226895c7, 0xaff72d52192b6a0e},\n        {0xcbea6f8ceb02bb39, 0x9bf4f8a69f764491},\n        {0xfee50b7025c36a08, 0x02f236d04753d5b5},\n        {0x9f4f2726179a2245, 0x01d762422c946591},\n        {0xc722f0ef9d80aad6, 0x424d3ad2b7b97ef6},\n        {0xf8ebad2b84e0d58b, 0xd2e0898765a7deb3},\n        {0x9b934c3b330c8577, 0x63cc55f49f88eb30},\n        {0xc2781f49ffcfa6d5, 0x3cbf6b71c76b25fc},\n        {0xf316271c7fc3908a, 0x8bef464e3945ef7b},\n        {0x97edd871cfda3a56, 0x97758bf0e3cbb5ad},\n        {0xbde94e8e43d0c8ec, 0x3d52eeed1cbea318},\n        {0xed63a231d4c4fb27, 0x4ca7aaa863ee4bde},\n        {0x945e455f24fb1cf8, 0x8fe8caa93e74ef6b},\n        {0xb975d6b6ee39e436, 0xb3e2fd538e122b45},\n        {0xe7d34c64a9c85d44, 0x60dbbca87196b617},\n        {0x90e40fbeea1d3a4a, 0xbc8955e946fe31ce},\n        {0xb51d13aea4a488dd, 0x6babab6398bdbe42},\n        {0xe264589a4dcdab14, 0xc696963c7eed2dd2},\n        {0x8d7eb76070a08aec, 0xfc1e1de5cf543ca3},\n        {0xb0de65388cc8ada8, 0x3b25a55f43294bcc},\n        {0xdd15fe86affad912, 0x49ef0eb713f39ebf},\n        {0x8a2dbf142dfcc7ab, 0x6e3569326c784338},\n        {0xacb92ed9397bf996, 0x49c2c37f07965405},\n        {0xd7e77a8f87daf7fb, 0xdc33745ec97be907},\n        {0x86f0ac99b4e8dafd, 0x69a028bb3ded71a4},\n        {0xa8acd7c0222311bc, 0xc40832ea0d68ce0d},\n        {0xd2d80db02aabd62b, 0xf50a3fa490c30191},\n        {0x83c7088e1aab65db, 0x792667c6da79e0fb},\n        {0xa4b8cab1a1563f52, 0x577001b891185939},\n        {0xcde6fd5e09abcf26, 0xed4c0226b55e6f87},\n        {0x80b05e5ac60b6178, 0x544f8158315b05b5},\n        {0xa0dc75f1778e39d6, 0x696361ae3db1c722},\n        {0xc913936dd571c84c, 0x03bc3a19cd1e38ea},\n        {0xfb5878494ace3a5f, 0x04ab48a04065c724},\n        {0x9d174b2dcec0e47b, 0x62eb0d64283f9c77},\n        {0xc45d1df942711d9a, 0x3ba5d0bd324f8395},\n        {0xf5746577930d6500, 0xca8f44ec7ee3647a},\n        {0x9968bf6abbe85f20, 0x7e998b13cf4e1ecc},\n        {0xbfc2ef456ae276e8, 0x9e3fedd8c321a67f},\n        {0xefb3ab16c59b14a2, 0xc5cfe94ef3ea101f},\n        {0x95d04aee3b80ece5, 0xbba1f1d158724a13},\n        {0xbb445da9ca61281f, 0x2a8a6e45ae8edc98},\n        {0xea1575143cf97226, 0xf52d09d71a3293be},\n        {0x924d692ca61be758, 0x593c2626705f9c57},\n        {0xb6e0c377cfa2e12e, 0x6f8b2fb00c77836d},\n        {0xe498f455c38b997a, 0x0b6dfb9c0f956448},\n        {0x8edf98b59a373fec, 0x4724bd4189bd5ead},\n        {0xb2977ee300c50fe7, 0x58edec91ec2cb658},\n        {0xdf3d5e9bc0f653e1, 0x2f2967b66737e3ee},\n        {0x8b865b215899f46c, 0xbd79e0d20082ee75},\n        {0xae67f1e9aec07187, 0xecd8590680a3aa12},\n        {0xda01ee641a708de9, 0xe80e6f4820cc9496},\n        {0x884134fe908658b2, 0x3109058d147fdcde},\n        {0xaa51823e34a7eede, 0xbd4b46f0599fd416},\n        {0xd4e5e2cdc1d1ea96, 0x6c9e18ac7007c91b},\n        {0x850fadc09923329e, 0x03e2cf6bc604ddb1},\n        {0xa6539930bf6bff45, 0x84db8346b786151d},\n        {0xcfe87f7cef46ff16, 0xe612641865679a64},\n        {0x81f14fae158c5f6e, 0x4fcb7e8f3f60c07f},\n        {0xa26da3999aef7749, 0xe3be5e330f38f09e},\n        {0xcb090c8001ab551c, 0x5cadf5bfd3072cc6},\n        {0xfdcb4fa002162a63, 0x73d9732fc7c8f7f7},\n        {0x9e9f11c4014dda7e, 0x2867e7fddcdd9afb},\n        {0xc646d63501a1511d, 0xb281e1fd541501b9},\n        {0xf7d88bc24209a565, 0x1f225a7ca91a4227},\n        {0x9ae757596946075f, 0x3375788de9b06959},\n        {0xc1a12d2fc3978937, 0x0052d6b1641c83af},\n        {0xf209787bb47d6b84, 0xc0678c5dbd23a49b},\n        {0x9745eb4d50ce6332, 0xf840b7ba963646e1},\n        {0xbd176620a501fbff, 0xb650e5a93bc3d899},\n        {0xec5d3fa8ce427aff, 0xa3e51f138ab4cebf},\n        {0x93ba47c980e98cdf, 0xc66f336c36b10138},\n        {0xb8a8d9bbe123f017, 0xb80b0047445d4185},\n        {0xe6d3102ad96cec1d, 0xa60dc059157491e6},\n        {0x9043ea1ac7e41392, 0x87c89837ad68db30},\n        {0xb454e4a179dd1877, 0x29babe4598c311fc},\n        {0xe16a1dc9d8545e94, 0xf4296dd6fef3d67b},\n        {0x8ce2529e2734bb1d, 0x1899e4a65f58660d},\n        {0xb01ae745b101e9e4, 0x5ec05dcff72e7f90},\n        {0xdc21a1171d42645d, 0x76707543f4fa1f74},\n        {0x899504ae72497eba, 0x6a06494a791c53a9},\n        {0xabfa45da0edbde69, 0x0487db9d17636893},\n        {0xd6f8d7509292d603, 0x45a9d2845d3c42b7},\n        {0x865b86925b9bc5c2, 0x0b8a2392ba45a9b3},\n        {0xa7f26836f282b732, 0x8e6cac7768d7141f},\n        {0xd1ef0244af2364ff, 0x3207d795430cd927},\n        {0x8335616aed761f1f, 0x7f44e6bd49e807b9},\n        {0xa402b9c5a8d3a6e7, 0x5f16206c9c6209a7},\n        {0xcd036837130890a1, 0x36dba887c37a8c10},\n        {0x802221226be55a64, 0xc2494954da2c978a},\n        {0xa02aa96b06deb0fd, 0xf2db9baa10b7bd6d},\n        {0xc83553c5c8965d3d, 0x6f92829494e5acc8},\n        {0xfa42a8b73abbf48c, 0xcb772339ba1f17fa},\n        {0x9c69a97284b578d7, 0xff2a760414536efc},\n        {0xc38413cf25e2d70d, 0xfef5138519684abb},\n        {0xf46518c2ef5b8cd1, 0x7eb258665fc25d6a},\n        {0x98bf2f79d5993802, 0xef2f773ffbd97a62},\n        {0xbeeefb584aff8603, 0xaafb550ffacfd8fb},\n        {0xeeaaba2e5dbf6784, 0x95ba2a53f983cf39},\n        {0x952ab45cfa97a0b2, 0xdd945a747bf26184},\n        {0xba756174393d88df, 0x94f971119aeef9e5},\n        {0xe912b9d1478ceb17, 0x7a37cd5601aab85e},\n        {0x91abb422ccb812ee, 0xac62e055c10ab33b},\n        {0xb616a12b7fe617aa, 0x577b986b314d600a},\n        {0xe39c49765fdf9d94, 0xed5a7e85fda0b80c},\n        {0x8e41ade9fbebc27d, 0x14588f13be847308},\n        {0xb1d219647ae6b31c, 0x596eb2d8ae258fc9},\n        {0xde469fbd99a05fe3, 0x6fca5f8ed9aef3bc},\n        {0x8aec23d680043bee, 0x25de7bb9480d5855},\n        {0xada72ccc20054ae9, 0xaf561aa79a10ae6b},\n        {0xd910f7ff28069da4, 0x1b2ba1518094da05},\n        {0x87aa9aff79042286, 0x90fb44d2f05d0843},\n        {0xa99541bf57452b28, 0x353a1607ac744a54},\n        {0xd3fa922f2d1675f2, 0x42889b8997915ce9},\n        {0x847c9b5d7c2e09b7, 0x69956135febada12},\n        {0xa59bc234db398c25, 0x43fab9837e699096},\n        {0xcf02b2c21207ef2e, 0x94f967e45e03f4bc},\n        {0x8161afb94b44f57d, 0x1d1be0eebac278f6},\n        {0xa1ba1ba79e1632dc, 0x6462d92a69731733},\n        {0xca28a291859bbf93, 0x7d7b8f7503cfdcff},\n        {0xfcb2cb35e702af78, 0x5cda735244c3d43f},\n        {0x9defbf01b061adab, 0x3a0888136afa64a8},\n        {0xc56baec21c7a1916, 0x088aaa1845b8fdd1},\n        {0xf6c69a72a3989f5b, 0x8aad549e57273d46},\n        {0x9a3c2087a63f6399, 0x36ac54e2f678864c},\n        {0xc0cb28a98fcf3c7f, 0x84576a1bb416a7de},\n        {0xf0fdf2d3f3c30b9f, 0x656d44a2a11c51d6},\n        {0x969eb7c47859e743, 0x9f644ae5a4b1b326},\n        {0xbc4665b596706114, 0x873d5d9f0dde1fef},\n        {0xeb57ff22fc0c7959, 0xa90cb506d155a7eb},\n        {0x9316ff75dd87cbd8, 0x09a7f12442d588f3},\n        {0xb7dcbf5354e9bece, 0x0c11ed6d538aeb30},\n        {0xe5d3ef282a242e81, 0x8f1668c8a86da5fb},\n        {0x8fa475791a569d10, 0xf96e017d694487bd},\n        {0xb38d92d760ec4455, 0x37c981dcc395a9ad},\n        {0xe070f78d3927556a, 0x85bbe253f47b1418},\n        {0x8c469ab843b89562, 0x93956d7478ccec8f},\n        {0xaf58416654a6babb, 0x387ac8d1970027b3},\n        {0xdb2e51bfe9d0696a, 0x06997b05fcc0319f},\n        {0x88fcf317f22241e2, 0x441fece3bdf81f04},\n        {0xab3c2fddeeaad25a, 0xd527e81cad7626c4},\n        {0xd60b3bd56a5586f1, 0x8a71e223d8d3b075},\n        {0x85c7056562757456, 0xf6872d5667844e4a},\n        {0xa738c6bebb12d16c, 0xb428f8ac016561dc},\n        {0xd106f86e69d785c7, 0xe13336d701beba53},\n        {0x82a45b450226b39c, 0xecc0024661173474},\n        {0xa34d721642b06084, 0x27f002d7f95d0191},\n        {0xcc20ce9bd35c78a5, 0x31ec038df7b441f5},\n        {0xff290242c83396ce, 0x7e67047175a15272},\n        {0x9f79a169bd203e41, 0x0f0062c6e984d387},\n        {0xc75809c42c684dd1, 0x52c07b78a3e60869},\n        {0xf92e0c3537826145, 0xa7709a56ccdf8a83},\n        {0x9bbcc7a142b17ccb, 0x88a66076400bb692},\n        {0xc2abf989935ddbfe, 0x6acff893d00ea436},\n        {0xf356f7ebf83552fe, 0x0583f6b8c4124d44},\n        {0x98165af37b2153de, 0xc3727a337a8b704b},\n        {0xbe1bf1b059e9a8d6, 0x744f18c0592e4c5d},\n        {0xeda2ee1c7064130c, 0x1162def06f79df74},\n        {0x9485d4d1c63e8be7, 0x8addcb5645ac2ba9},\n        {0xb9a74a0637ce2ee1, 0x6d953e2bd7173693},\n        {0xe8111c87c5c1ba99, 0xc8fa8db6ccdd0438},\n        {0x910ab1d4db9914a0, 0x1d9c9892400a22a3},\n        {0xb54d5e4a127f59c8, 0x2503beb6d00cab4c},\n        {0xe2a0b5dc971f303a, 0x2e44ae64840fd61e},\n        {0x8da471a9de737e24, 0x5ceaecfed289e5d3},\n        {0xb10d8e1456105dad, 0x7425a83e872c5f48},\n        {0xdd50f1996b947518, 0xd12f124e28f7771a},\n        {0x8a5296ffe33cc92f, 0x82bd6b70d99aaa70},\n        {0xace73cbfdc0bfb7b, 0x636cc64d1001550c},\n        {0xd8210befd30efa5a, 0x3c47f7e05401aa4f},\n        {0x8714a775e3e95c78, 0x65acfaec34810a72},\n        {0xa8d9d1535ce3b396, 0x7f1839a741a14d0e},\n        {0xd31045a8341ca07c, 0x1ede48111209a051},\n        {0x83ea2b892091e44d, 0x934aed0aab460433},\n        {0xa4e4b66b68b65d60, 0xf81da84d56178540},\n        {0xce1de40642e3f4b9, 0x36251260ab9d668f},\n        {0x80d2ae83e9ce78f3, 0xc1d72b7c6b42601a},\n        {0xa1075a24e4421730, 0xb24cf65b8612f820},\n        {0xc94930ae1d529cfc, 0xdee033f26797b628},\n        {0xfb9b7cd9a4a7443c, 0x169840ef017da3b2},\n        {0x9d412e0806e88aa5, 0x8e1f289560ee864f},\n        {0xc491798a08a2ad4e, 0xf1a6f2bab92a27e3},\n        {0xf5b5d7ec8acb58a2, 0xae10af696774b1dc},\n        {0x9991a6f3d6bf1765, 0xacca6da1e0a8ef2a},\n        {0xbff610b0cc6edd3f, 0x17fd090a58d32af4},\n        {0xeff394dcff8a948e, 0xddfc4b4cef07f5b1},\n        {0x95f83d0a1fb69cd9, 0x4abdaf101564f98f},\n        {0xbb764c4ca7a4440f, 0x9d6d1ad41abe37f2},\n        {0xea53df5fd18d5513, 0x84c86189216dc5ee},\n        {0x92746b9be2f8552c, 0x32fd3cf5b4e49bb5},\n        {0xb7118682dbb66a77, 0x3fbc8c33221dc2a2},\n        {0xe4d5e82392a40515, 0x0fabaf3feaa5334b},\n        {0x8f05b1163ba6832d, 0x29cb4d87f2a7400f},\n        {0xb2c71d5bca9023f8, 0x743e20e9ef511013},\n        {0xdf78e4b2bd342cf6, 0x914da9246b255417},\n        {0x8bab8eefb6409c1a, 0x1ad089b6c2f7548f},\n        {0xae9672aba3d0c320, 0xa184ac2473b529b2},\n        {0xda3c0f568cc4f3e8, 0xc9e5d72d90a2741f},\n        {0x8865899617fb1871, 0x7e2fa67c7a658893},\n        {0xaa7eebfb9df9de8d, 0xddbb901b98feeab8},\n        {0xd51ea6fa85785631, 0x552a74227f3ea566},\n        {0x8533285c936b35de, 0xd53a88958f872760},\n        {0xa67ff273b8460356, 0x8a892abaf368f138},\n        {0xd01fef10a657842c, 0x2d2b7569b0432d86},\n        {0x8213f56a67f6b29b, 0x9c3b29620e29fc74},\n        {0xa298f2c501f45f42, 0x8349f3ba91b47b90},\n        {0xcb3f2f7642717713, 0x241c70a936219a74},\n        {0xfe0efb53d30dd4d7, 0xed238cd383aa0111},\n        {0x9ec95d1463e8a506, 0xf4363804324a40ab},\n        {0xc67bb4597ce2ce48, 0xb143c6053edcd0d6},\n        {0xf81aa16fdc1b81da, 0xdd94b7868e94050b},\n        {0x9b10a4e5e9913128, 0xca7cf2b4191c8327},\n        {0xc1d4ce1f63f57d72, 0xfd1c2f611f63a3f1},\n        {0xf24a01a73cf2dccf, 0xbc633b39673c8ced},\n        {0x976e41088617ca01, 0xd5be0503e085d814},\n        {0xbd49d14aa79dbc82, 0x4b2d8644d8a74e19},\n        {0xec9c459d51852ba2, 0xddf8e7d60ed1219f},\n        {0x93e1ab8252f33b45, 0xcabb90e5c942b504},\n        {0xb8da1662e7b00a17, 0x3d6a751f3b936244},\n        {0xe7109bfba19c0c9d, 0x0cc512670a783ad5},\n        {0x906a617d450187e2, 0x27fb2b80668b24c6},\n        {0xb484f9dc9641e9da, 0xb1f9f660802dedf7},\n        {0xe1a63853bbd26451, 0x5e7873f8a0396974},\n        {0x8d07e33455637eb2, 0xdb0b487b6423e1e9},\n        {0xb049dc016abc5e5f, 0x91ce1a9a3d2cda63},\n        {0xdc5c5301c56b75f7, 0x7641a140cc7810fc},\n        {0x89b9b3e11b6329ba, 0xa9e904c87fcb0a9e},\n        {0xac2820d9623bf429, 0x546345fa9fbdcd45},\n        {0xd732290fbacaf133, 0xa97c177947ad4096},\n        {0x867f59a9d4bed6c0, 0x49ed8eabcccc485e},\n        {0xa81f301449ee8c70, 0x5c68f256bfff5a75},\n        {0xd226fc195c6a2f8c, 0x73832eec6fff3112},\n        {0x83585d8fd9c25db7, 0xc831fd53c5ff7eac},\n        {0xa42e74f3d032f525, 0xba3e7ca8b77f5e56},\n        {0xcd3a1230c43fb26f, 0x28ce1bd2e55f35ec},\n        {0x80444b5e7aa7cf85, 0x7980d163cf5b81b4},\n        {0xa0555e361951c366, 0xd7e105bcc3326220},\n        {0xc86ab5c39fa63440, 0x8dd9472bf3fefaa8},\n        {0xfa856334878fc150, 0xb14f98f6f0feb952},\n        {0x9c935e00d4b9d8d2, 0x6ed1bf9a569f33d4},\n        {0xc3b8358109e84f07, 0x0a862f80ec4700c9},\n        {0xf4a642e14c6262c8, 0xcd27bb612758c0fb},\n        {0x98e7e9cccfbd7dbd, 0x8038d51cb897789d},\n        {0xbf21e44003acdd2c, 0xe0470a63e6bd56c4},\n        {0xeeea5d5004981478, 0x1858ccfce06cac75},\n        {0x95527a5202df0ccb, 0x0f37801e0c43ebc9},\n        {0xbaa718e68396cffd, 0xd30560258f54e6bb},\n        {0xe950df20247c83fd, 0x47c6b82ef32a206a},\n        {0x91d28b7416cdd27e, 0x4cdc331d57fa5442},\n        {0xb6472e511c81471d, 0xe0133fe4adf8e953},\n        {0xe3d8f9e563a198e5, 0x58180fddd97723a7},\n        {0x8e679c2f5e44ff8f, 0x570f09eaa7ea7649},\n        {0xb201833b35d63f73, 0x2cd2cc6551e513db},\n        {0xde81e40a034bcf4f, 0xf8077f7ea65e58d2},\n        {0x8b112e86420f6191, 0xfb04afaf27faf783},\n        {0xadd57a27d29339f6, 0x79c5db9af1f9b564},\n        {0xd94ad8b1c7380874, 0x18375281ae7822bd},\n        {0x87cec76f1c830548, 0x8f2293910d0b15b6},\n        {0xa9c2794ae3a3c69a, 0xb2eb3875504ddb23},\n        {0xd433179d9c8cb841, 0x5fa60692a46151ec},\n        {0x849feec281d7f328, 0xdbc7c41ba6bcd334},\n        {0xa5c7ea73224deff3, 0x12b9b522906c0801},\n        {0xcf39e50feae16bef, 0xd768226b34870a01},\n        {0x81842f29f2cce375, 0xe6a1158300d46641},\n        {0xa1e53af46f801c53, 0x60495ae3c1097fd1},\n        {0xca5e89b18b602368, 0x385bb19cb14bdfc5},\n        {0xfcf62c1dee382c42, 0x46729e03dd9ed7b6},\n        {0x9e19db92b4e31ba9, 0x6c07a2c26a8346d2},\n        {0xc5a05277621be293, 0xc7098b7305241886},\n        {0xf70867153aa2db38, 0xb8cbee4fc66d1ea8},\n        {0x9a65406d44a5c903, 0x737f74f1dc043329},\n        {0xc0fe908895cf3b44, 0x505f522e53053ff3},\n        {0xf13e34aabb430a15, 0x647726b9e7c68ff0},\n        {0x96c6e0eab509e64d, 0x5eca783430dc19f6},\n        {0xbc789925624c5fe0, 0xb67d16413d132073},\n        {0xeb96bf6ebadf77d8, 0xe41c5bd18c57e890},\n        {0x933e37a534cbaae7, 0x8e91b962f7b6f15a},\n        {0xb80dc58e81fe95a1, 0x723627bbb5a4adb1},\n        {0xe61136f2227e3b09, 0xcec3b1aaa30dd91d},\n        {0x8fcac257558ee4e6, 0x213a4f0aa5e8a7b2},\n        {0xb3bd72ed2af29e1f, 0xa988e2cd4f62d19e},\n        {0xe0accfa875af45a7, 0x93eb1b80a33b8606},\n        {0x8c6c01c9498d8b88, 0xbc72f130660533c4},\n        {0xaf87023b9bf0ee6a, 0xeb8fad7c7f8680b5},\n        {0xdb68c2ca82ed2a05, 0xa67398db9f6820e2},\n#else\n        {0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7b},\n        {0xce5d73ff402d98e3, 0xfb0a3d212dc81290},\n        {0xa6b34ad8c9dfc06f, 0xf42faa48c0ea481f},\n        {0x86a8d39ef77164bc, 0xae5dff9c02033198},\n        {0xd98ddaee19068c76, 0x3badd624dd9b0958},\n        {0xafbd2350644eeacf, 0xe5d1929ef90898fb},\n        {0x8df5efabc5979c8f, 0xca8d3ffa1ef463c2},\n        {0xe55990879ddcaabd, 0xcc420a6a101d0516},\n        {0xb94470938fa89bce, 0xf808e40e8d5b3e6a},\n        {0x95a8637627989aad, 0xdde7001379a44aa9},\n        {0xf1c90080baf72cb1, 0x5324c68b12dd6339},\n        {0xc350000000000000, 0x0000000000000000},\n        {0x9dc5ada82b70b59d, 0xf020000000000000},\n        {0xfee50b7025c36a08, 0x02f236d04753d5b5},\n        {0xcde6fd5e09abcf26, 0xed4c0226b55e6f87},\n        {0xa6539930bf6bff45, 0x84db8346b786151d},\n        {0x865b86925b9bc5c2, 0x0b8a2392ba45a9b3},\n        {0xd910f7ff28069da4, 0x1b2ba1518094da05},\n        {0xaf58416654a6babb, 0x387ac8d1970027b3},\n        {0x8da471a9de737e24, 0x5ceaecfed289e5d3},\n        {0xe4d5e82392a40515, 0x0fabaf3feaa5334b},\n        {0xb8da1662e7b00a17, 0x3d6a751f3b936244},\n        {0x95527a5202df0ccb, 0x0f37801e0c43ebc9},\n        {0xf13e34aabb430a15, 0x647726b9e7c68ff0}\n#endif\n    };\n\n#if FMT_USE_FULL_CACHE_DRAGONBOX\n    return pow10_significands[k - float_info<double>::min_k];\n#else\n    static constexpr uint64_t powers_of_5_64[] = {\n        0x0000000000000001, 0x0000000000000005, 0x0000000000000019,\n        0x000000000000007d, 0x0000000000000271, 0x0000000000000c35,\n        0x0000000000003d09, 0x000000000001312d, 0x000000000005f5e1,\n        0x00000000001dcd65, 0x00000000009502f9, 0x0000000002e90edd,\n        0x000000000e8d4a51, 0x0000000048c27395, 0x000000016bcc41e9,\n        0x000000071afd498d, 0x0000002386f26fc1, 0x000000b1a2bc2ec5,\n        0x000003782dace9d9, 0x00001158e460913d, 0x000056bc75e2d631,\n        0x0001b1ae4d6e2ef5, 0x000878678326eac9, 0x002a5a058fc295ed,\n        0x00d3c21bcecceda1, 0x0422ca8b0a00a425, 0x14adf4b7320334b9};\n\n    static const int compression_ratio = 27;\n\n    // Compute base index.\n    int cache_index = (k - float_info<double>::min_k) / compression_ratio;\n    int kb = cache_index * compression_ratio + float_info<double>::min_k;\n    int offset = k - kb;\n\n    // Get base cache.\n    uint128 base_cache = pow10_significands[cache_index];\n    if (offset == 0) return base_cache;\n\n    // Compute the required amount of bit-shift.\n    int alpha = floor_log2_pow10(kb + offset) - floor_log2_pow10(kb) - offset;\n    FMT_ASSERT(alpha > 0 && alpha < 64, \"shifting error detected\");\n\n    // Try to recover the real cache.\n    uint64_t pow5 = powers_of_5_64[offset];\n    uint128 recovered_cache = umul128(base_cache.high(), pow5);\n    uint128 middle_low = umul128(base_cache.low(), pow5);\n\n    recovered_cache += middle_low.high();\n\n    uint64_t high_to_middle = recovered_cache.high() << (64 - alpha);\n    uint64_t middle_to_low = recovered_cache.low() << (64 - alpha);\n\n    recovered_cache = uint128{(recovered_cache.low() >> alpha) | high_to_middle,\n                              ((middle_low.low() >> alpha) | middle_to_low)};\n    FMT_ASSERT(recovered_cache.low() + 1 != 0, \"\");\n    return {recovered_cache.high(), recovered_cache.low() + 1};\n#endif\n  }\n\n  struct compute_mul_result {\n    carrier_uint result;\n    bool is_integer;\n  };\n  struct compute_mul_parity_result {\n    bool parity;\n    bool is_integer;\n  };\n\n  static auto compute_mul(carrier_uint u,\n                          const cache_entry_type& cache) noexcept\n      -> compute_mul_result {\n    auto r = umul192_upper128(u, cache);\n    return {r.high(), r.low() == 0};\n  }\n\n  static auto compute_delta(const cache_entry_type& cache, int beta) noexcept\n      -> uint32_t {\n    return static_cast<uint32_t>(cache.high() >> (64 - 1 - beta));\n  }\n\n  static auto compute_mul_parity(carrier_uint two_f,\n                                 const cache_entry_type& cache,\n                                 int beta) noexcept\n      -> compute_mul_parity_result {\n    FMT_ASSERT(beta >= 1, \"\");\n    FMT_ASSERT(beta < 64, \"\");\n\n    auto r = umul192_lower128(two_f, cache);\n    return {((r.high() >> (64 - beta)) & 1) != 0,\n            ((r.high() << beta) | (r.low() >> (64 - beta))) == 0};\n  }\n\n  static auto compute_left_endpoint_for_shorter_interval_case(\n      const cache_entry_type& cache, int beta) noexcept -> carrier_uint {\n    return (cache.high() -\n            (cache.high() >> (num_significand_bits<double>() + 2))) >>\n           (64 - num_significand_bits<double>() - 1 - beta);\n  }\n\n  static auto compute_right_endpoint_for_shorter_interval_case(\n      const cache_entry_type& cache, int beta) noexcept -> carrier_uint {\n    return (cache.high() +\n            (cache.high() >> (num_significand_bits<double>() + 1))) >>\n           (64 - num_significand_bits<double>() - 1 - beta);\n  }\n\n  static auto compute_round_up_for_shorter_interval_case(\n      const cache_entry_type& cache, int beta) noexcept -> carrier_uint {\n    return ((cache.high() >> (64 - num_significand_bits<double>() - 2 - beta)) +\n            1) /\n           2;\n  }\n};\n\nFMT_FUNC auto get_cached_power(int k) noexcept -> uint128 {\n  return cache_accessor<double>::get_cached_power(k);\n}\n\n// Various integer checks\ntemplate <typename T>\nauto is_left_endpoint_integer_shorter_interval(int exponent) noexcept -> bool {\n  const int case_shorter_interval_left_endpoint_lower_threshold = 2;\n  const int case_shorter_interval_left_endpoint_upper_threshold = 3;\n  return exponent >= case_shorter_interval_left_endpoint_lower_threshold &&\n         exponent <= case_shorter_interval_left_endpoint_upper_threshold;\n}\n\n// Remove trailing zeros from n and return the number of zeros removed (float).\nFMT_INLINE auto remove_trailing_zeros(uint32_t& n, int s = 0) noexcept -> int {\n  FMT_ASSERT(n != 0, \"\");\n  // Modular inverse of 5 (mod 2^32): (mod_inv_5 * 5) mod 2^32 = 1.\n  constexpr uint32_t mod_inv_5 = 0xcccccccd;\n  constexpr uint32_t mod_inv_25 = 0xc28f5c29;  // = mod_inv_5 * mod_inv_5\n\n  while (true) {\n    auto q = rotr(n * mod_inv_25, 2);\n    if (q > max_value<uint32_t>() / 100) break;\n    n = q;\n    s += 2;\n  }\n  auto q = rotr(n * mod_inv_5, 1);\n  if (q <= max_value<uint32_t>() / 10) {\n    n = q;\n    s |= 1;\n  }\n  return s;\n}\n\n// Removes trailing zeros and returns the number of zeros removed (double).\nFMT_INLINE auto remove_trailing_zeros(uint64_t& n) noexcept -> int {\n  FMT_ASSERT(n != 0, \"\");\n\n  // Is n is divisible by 10^8?\n  constexpr uint32_t ten_pow_8 = 100000000u;\n  if ((n % ten_pow_8) == 0) {\n    // If yes, work with the quotient...\n    auto n32 = static_cast<uint32_t>(n / ten_pow_8);\n    // ... and use the 32 bit variant of the function\n    int num_zeros = remove_trailing_zeros(n32, 8);\n    n = n32;\n    return num_zeros;\n  }\n\n  // If n is not divisible by 10^8, work with n itself.\n  constexpr uint64_t mod_inv_5 = 0xcccccccccccccccd;\n  constexpr uint64_t mod_inv_25 = 0x8f5c28f5c28f5c29;  // mod_inv_5 * mod_inv_5\n\n  int s = 0;\n  while (true) {\n    auto q = rotr(n * mod_inv_25, 2);\n    if (q > max_value<uint64_t>() / 100) break;\n    n = q;\n    s += 2;\n  }\n  auto q = rotr(n * mod_inv_5, 1);\n  if (q <= max_value<uint64_t>() / 10) {\n    n = q;\n    s |= 1;\n  }\n\n  return s;\n}\n\n// The main algorithm for shorter interval case\ntemplate <typename T>\nFMT_INLINE auto shorter_interval_case(int exponent) noexcept -> decimal_fp<T> {\n  decimal_fp<T> ret_value;\n  // Compute k and beta\n  const int minus_k = floor_log10_pow2_minus_log10_4_over_3(exponent);\n  const int beta = exponent + floor_log2_pow10(-minus_k);\n\n  // Compute xi and zi\n  using cache_entry_type = typename cache_accessor<T>::cache_entry_type;\n  const cache_entry_type cache = cache_accessor<T>::get_cached_power(-minus_k);\n\n  auto xi = cache_accessor<T>::compute_left_endpoint_for_shorter_interval_case(\n      cache, beta);\n  auto zi = cache_accessor<T>::compute_right_endpoint_for_shorter_interval_case(\n      cache, beta);\n\n  // If the left endpoint is not an integer, increase it\n  if (!is_left_endpoint_integer_shorter_interval<T>(exponent)) ++xi;\n\n  // Try bigger divisor\n  ret_value.significand = zi / 10;\n\n  // If succeed, remove trailing zeros if necessary and return\n  if (ret_value.significand * 10 >= xi) {\n    ret_value.exponent = minus_k + 1;\n    ret_value.exponent += remove_trailing_zeros(ret_value.significand);\n    return ret_value;\n  }\n\n  // Otherwise, compute the round-up of y\n  ret_value.significand =\n      cache_accessor<T>::compute_round_up_for_shorter_interval_case(cache,\n                                                                    beta);\n  ret_value.exponent = minus_k;\n\n  // When tie occurs, choose one of them according to the rule\n  if (exponent >= float_info<T>::shorter_interval_tie_lower_threshold &&\n      exponent <= float_info<T>::shorter_interval_tie_upper_threshold) {\n    ret_value.significand = ret_value.significand % 2 == 0\n                                ? ret_value.significand\n                                : ret_value.significand - 1;\n  } else if (ret_value.significand < xi) {\n    ++ret_value.significand;\n  }\n  return ret_value;\n}\n\ntemplate <typename T> auto to_decimal(T x) noexcept -> decimal_fp<T> {\n  // Step 1: integer promotion & Schubfach multiplier calculation.\n\n  using carrier_uint = typename float_info<T>::carrier_uint;\n  using cache_entry_type = typename cache_accessor<T>::cache_entry_type;\n  auto br = bit_cast<carrier_uint>(x);\n\n  // Extract significand bits and exponent bits.\n  const carrier_uint significand_mask =\n      (static_cast<carrier_uint>(1) << num_significand_bits<T>()) - 1;\n  carrier_uint significand = (br & significand_mask);\n  int exponent =\n      static_cast<int>((br & exponent_mask<T>()) >> num_significand_bits<T>());\n\n  if (exponent != 0) {  // Check if normal.\n    exponent -= exponent_bias<T>() + num_significand_bits<T>();\n\n    // Shorter interval case; proceed like Schubfach.\n    // In fact, when exponent == 1 and significand == 0, the interval is\n    // regular. However, it can be shown that the end-results are anyway same.\n    if (significand == 0) return shorter_interval_case<T>(exponent);\n\n    significand |= (static_cast<carrier_uint>(1) << num_significand_bits<T>());\n  } else {\n    // Subnormal case; the interval is always regular.\n    if (significand == 0) return {0, 0};\n    exponent =\n        std::numeric_limits<T>::min_exponent - num_significand_bits<T>() - 1;\n  }\n\n  const bool include_left_endpoint = (significand % 2 == 0);\n  const bool include_right_endpoint = include_left_endpoint;\n\n  // Compute k and beta.\n  const int minus_k = floor_log10_pow2(exponent) - float_info<T>::kappa;\n  const cache_entry_type cache = cache_accessor<T>::get_cached_power(-minus_k);\n  const int beta = exponent + floor_log2_pow10(-minus_k);\n\n  // Compute zi and deltai.\n  // 10^kappa <= deltai < 10^(kappa + 1)\n  const uint32_t deltai = cache_accessor<T>::compute_delta(cache, beta);\n  const carrier_uint two_fc = significand << 1;\n\n  // For the case of binary32, the result of integer check is not correct for\n  // 29711844 * 2^-82\n  // = 6.1442653300000000008655037797566933477355632930994033813476... * 10^-18\n  // and 29711844 * 2^-81\n  // = 1.2288530660000000001731007559513386695471126586198806762695... * 10^-17,\n  // and they are the unique counterexamples. However, since 29711844 is even,\n  // this does not cause any problem for the endpoints calculations; it can only\n  // cause a problem when we need to perform integer check for the center.\n  // Fortunately, with these inputs, that branch is never executed, so we are\n  // fine.\n  const typename cache_accessor<T>::compute_mul_result z_mul =\n      cache_accessor<T>::compute_mul((two_fc | 1) << beta, cache);\n\n  // Step 2: Try larger divisor; remove trailing zeros if necessary.\n\n  // Using an upper bound on zi, we might be able to optimize the division\n  // better than the compiler; we are computing zi / big_divisor here.\n  decimal_fp<T> ret_value;\n  ret_value.significand = divide_by_10_to_kappa_plus_1(z_mul.result);\n  uint32_t r = static_cast<uint32_t>(z_mul.result - float_info<T>::big_divisor *\n                                                        ret_value.significand);\n\n  if (r < deltai) {\n    // Exclude the right endpoint if necessary.\n    if (r == 0 && (z_mul.is_integer & !include_right_endpoint)) {\n      --ret_value.significand;\n      r = float_info<T>::big_divisor;\n      goto small_divisor_case_label;\n    }\n  } else if (r > deltai) {\n    goto small_divisor_case_label;\n  } else {\n    // r == deltai; compare fractional parts.\n    const typename cache_accessor<T>::compute_mul_parity_result x_mul =\n        cache_accessor<T>::compute_mul_parity(two_fc - 1, cache, beta);\n\n    if (!(x_mul.parity | (x_mul.is_integer & include_left_endpoint)))\n      goto small_divisor_case_label;\n  }\n  ret_value.exponent = minus_k + float_info<T>::kappa + 1;\n\n  // We may need to remove trailing zeros.\n  ret_value.exponent += remove_trailing_zeros(ret_value.significand);\n  return ret_value;\n\n  // Step 3: Find the significand with the smaller divisor.\n\nsmall_divisor_case_label:\n  ret_value.significand *= 10;\n  ret_value.exponent = minus_k + float_info<T>::kappa;\n\n  uint32_t dist = r - (deltai / 2) + (float_info<T>::small_divisor / 2);\n  const bool approx_y_parity =\n      ((dist ^ (float_info<T>::small_divisor / 2)) & 1) != 0;\n\n  // Is dist divisible by 10^kappa?\n  const bool divisible_by_small_divisor =\n      check_divisibility_and_divide_by_pow10<float_info<T>::kappa>(dist);\n\n  // Add dist / 10^kappa to the significand.\n  ret_value.significand += dist;\n\n  if (!divisible_by_small_divisor) return ret_value;\n\n  // Check z^(f) >= epsilon^(f).\n  // We have either yi == zi - epsiloni or yi == (zi - epsiloni) - 1,\n  // where yi == zi - epsiloni if and only if z^(f) >= epsilon^(f).\n  // Since there are only 2 possibilities, we only need to care about the\n  // parity. Also, zi and r should have the same parity since the divisor\n  // is an even number.\n  const auto y_mul = cache_accessor<T>::compute_mul_parity(two_fc, cache, beta);\n\n  // If z^(f) >= epsilon^(f), we might have a tie when z^(f) == epsilon^(f),\n  // or equivalently, when y is an integer.\n  if (y_mul.parity != approx_y_parity)\n    --ret_value.significand;\n  else if (y_mul.is_integer & (ret_value.significand % 2 != 0))\n    --ret_value.significand;\n  return ret_value;\n}\n}  // namespace dragonbox\n}  // namespace detail\n\ntemplate <> struct formatter<detail::bigint> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx)\n      -> format_parse_context::iterator {\n    return ctx.begin();\n  }\n\n  auto format(const detail::bigint& n, format_context& ctx) const\n      -> format_context::iterator {\n    auto out = ctx.out();\n    bool first = true;\n    for (auto i = n.bigits_.size(); i > 0; --i) {\n      auto value = n.bigits_[i - 1u];\n      if (first) {\n        out = fmt::format_to(out, FMT_STRING(\"{:x}\"), value);\n        first = false;\n        continue;\n      }\n      out = fmt::format_to(out, FMT_STRING(\"{:08x}\"), value);\n    }\n    if (n.exp_ > 0)\n      out = fmt::format_to(out, FMT_STRING(\"p{}\"),\n                           n.exp_ * detail::bigint::bigit_bits);\n    return out;\n  }\n};\n\nFMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) {\n  for_each_codepoint(s, [this](uint32_t cp, string_view) {\n    if (cp == invalid_code_point) FMT_THROW(std::runtime_error(\"invalid utf8\"));\n    if (cp <= 0xFFFF) {\n      buffer_.push_back(static_cast<wchar_t>(cp));\n    } else {\n      cp -= 0x10000;\n      buffer_.push_back(static_cast<wchar_t>(0xD800 + (cp >> 10)));\n      buffer_.push_back(static_cast<wchar_t>(0xDC00 + (cp & 0x3FF)));\n    }\n    return true;\n  });\n  buffer_.push_back(0);\n}\n\nFMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,\n                                  const char* message) noexcept {\n  FMT_TRY {\n    auto ec = std::error_code(error_code, std::generic_category());\n    detail::write(appender(out), std::system_error(ec, message).what());\n    return;\n  }\n  FMT_CATCH(...) {}\n  format_error_code(out, error_code, message);\n}\n\nFMT_FUNC void report_system_error(int error_code,\n                                  const char* message) noexcept {\n  do_report_error(format_system_error, error_code, message);\n}\n\nFMT_FUNC auto vformat(string_view fmt, format_args args) -> std::string {\n  // Don't optimize the \"{}\" case to keep the binary size small and because it\n  // can be better optimized in fmt::format anyway.\n  auto buffer = memory_buffer();\n  detail::vformat_to(buffer, fmt, args);\n  return to_string(buffer);\n}\n\nnamespace detail {\n\nFMT_FUNC void vformat_to(buffer<char>& buf, string_view fmt, format_args args,\n                         locale_ref loc) {\n  auto out = appender(buf);\n  if (fmt.size() == 2 && equal2(fmt.data(), \"{}\"))\n    return args.get(0).visit(default_arg_formatter<char>{out});\n  parse_format_string(fmt,\n                      format_handler<>{parse_context<>(fmt), {out, args, loc}});\n}\n\ntemplate <typename T> struct span {\n  T* data;\n  size_t size;\n};\n\ntemplate <typename F> auto flockfile(F* f) -> decltype(_lock_file(f)) {\n  _lock_file(f);\n}\ntemplate <typename F> auto funlockfile(F* f) -> decltype(_unlock_file(f)) {\n  _unlock_file(f);\n}\n\n#ifndef getc_unlocked\ntemplate <typename F> auto getc_unlocked(F* f) -> decltype(_fgetc_nolock(f)) {\n  return _fgetc_nolock(f);\n}\n#endif\n\n#ifndef FMT_USE_FLOCKFILE\n#  define FMT_USE_FLOCKFILE 1\n#endif\n\ntemplate <typename F = FILE, typename Enable = void>\nstruct has_flockfile : std::false_type {};\n\ntemplate <typename F>\nstruct has_flockfile<F, void_t<decltype(flockfile(&std::declval<F&>()))>>\n    : bool_constant<FMT_USE_FLOCKFILE != 0> {};\n\n// A FILE wrapper. F is FILE defined as a template parameter to make system API\n// detection work.\ntemplate <typename F> class file_base {\n public:\n  F* file_;\n\n public:\n  file_base(F* file) : file_(file) {}\n  operator F*() const { return file_; }\n\n  // Reads a code unit from the stream.\n  auto get() -> int {\n    int result = getc_unlocked(file_);\n    if (result == EOF && ferror(file_) != 0)\n      FMT_THROW(system_error(errno, FMT_STRING(\"getc failed\")));\n    return result;\n  }\n\n  // Puts the code unit back into the stream buffer.\n  void unget(char c) {\n    if (ungetc(c, file_) == EOF)\n      FMT_THROW(system_error(errno, FMT_STRING(\"ungetc failed\")));\n  }\n\n  void flush() { fflush(this->file_); }\n};\n\n// A FILE wrapper for glibc.\ntemplate <typename F> class glibc_file : public file_base<F> {\n private:\n  enum {\n    line_buffered = 0x200,  // _IO_LINE_BUF\n    unbuffered = 2          // _IO_UNBUFFERED\n  };\n\n public:\n  using file_base<F>::file_base;\n\n  auto is_buffered() const -> bool {\n    return (this->file_->_flags & unbuffered) == 0;\n  }\n\n  void init_buffer() {\n    if (this->file_->_IO_write_ptr < this->file_->_IO_write_end) return;\n    // Force buffer initialization by placing and removing a char in a buffer.\n    putc_unlocked(0, this->file_);\n    --this->file_->_IO_write_ptr;\n  }\n\n  // Returns the file's read buffer.\n  auto get_read_buffer() const -> span<const char> {\n    auto ptr = this->file_->_IO_read_ptr;\n    return {ptr, to_unsigned(this->file_->_IO_read_end - ptr)};\n  }\n\n  // Returns the file's write buffer.\n  auto get_write_buffer() const -> span<char> {\n    auto ptr = this->file_->_IO_write_ptr;\n    return {ptr, to_unsigned(this->file_->_IO_buf_end - ptr)};\n  }\n\n  void advance_write_buffer(size_t size) { this->file_->_IO_write_ptr += size; }\n\n  auto needs_flush() const -> bool {\n    if ((this->file_->_flags & line_buffered) == 0) return false;\n    char* end = this->file_->_IO_write_end;\n    auto size = max_of<ptrdiff_t>(this->file_->_IO_write_ptr - end, 0);\n    return memchr(end, '\\n', static_cast<size_t>(size));\n  }\n\n  void flush() { fflush_unlocked(this->file_); }\n};\n\n// A FILE wrapper for Apple's libc.\ntemplate <typename F> class apple_file : public file_base<F> {\n private:\n  enum {\n    line_buffered = 1,  // __SNBF\n    unbuffered = 2      // __SLBF\n  };\n\n public:\n  using file_base<F>::file_base;\n\n  auto is_buffered() const -> bool {\n    return (this->file_->_flags & unbuffered) == 0;\n  }\n\n  void init_buffer() {\n    if (this->file_->_p) return;\n    // Force buffer initialization by placing and removing a char in a buffer.\n    if (!FMT_CLANG_ANALYZER) putc_unlocked(0, this->file_);\n    --this->file_->_p;\n    ++this->file_->_w;\n  }\n\n  auto get_read_buffer() const -> span<const char> {\n    return {reinterpret_cast<char*>(this->file_->_p),\n            to_unsigned(this->file_->_r)};\n  }\n\n  auto get_write_buffer() const -> span<char> {\n    return {reinterpret_cast<char*>(this->file_->_p),\n            to_unsigned(this->file_->_bf._base + this->file_->_bf._size -\n                        this->file_->_p)};\n  }\n\n  void advance_write_buffer(size_t size) {\n    this->file_->_p += size;\n    this->file_->_w -= size;\n  }\n\n  auto needs_flush() const -> bool {\n    if ((this->file_->_flags & line_buffered) == 0) return false;\n    return memchr(this->file_->_p + this->file_->_w, '\\n',\n                  to_unsigned(-this->file_->_w));\n  }\n};\n\n// A fallback FILE wrapper.\ntemplate <typename F> class fallback_file : public file_base<F> {\n private:\n  char next_;  // The next unconsumed character in the buffer.\n  bool has_next_ = false;\n\n public:\n  using file_base<F>::file_base;\n\n  auto is_buffered() const -> bool { return false; }\n  auto needs_flush() const -> bool { return false; }\n  void init_buffer() {}\n\n  auto get_read_buffer() const -> span<const char> {\n    return {&next_, has_next_ ? 1u : 0u};\n  }\n\n  auto get_write_buffer() const -> span<char> { return {nullptr, 0}; }\n\n  void advance_write_buffer(size_t) {}\n\n  auto get() -> int {\n    has_next_ = false;\n    return file_base<F>::get();\n  }\n\n  void unget(char c) {\n    file_base<F>::unget(c);\n    next_ = c;\n    has_next_ = true;\n  }\n};\n\n#ifndef FMT_USE_FALLBACK_FILE\n#  define FMT_USE_FALLBACK_FILE 0\n#endif\n\ntemplate <typename F,\n          FMT_ENABLE_IF(sizeof(F::_p) != 0 && !FMT_USE_FALLBACK_FILE)>\nauto get_file(F* f, int) -> apple_file<F> {\n  return f;\n}\ntemplate <typename F,\n          FMT_ENABLE_IF(sizeof(F::_IO_read_ptr) != 0 && !FMT_USE_FALLBACK_FILE)>\ninline auto get_file(F* f, int) -> glibc_file<F> {\n  return f;\n}\n\ninline auto get_file(FILE* f, ...) -> fallback_file<FILE> { return f; }\n\nusing file_ref = decltype(get_file(static_cast<FILE*>(nullptr), 0));\n\ntemplate <typename F = FILE, typename Enable = void>\nclass file_print_buffer : public buffer<char> {\n public:\n  explicit file_print_buffer(F*) : buffer(nullptr, size_t()) {}\n};\n\ntemplate <typename F>\nclass file_print_buffer<F, enable_if_t<has_flockfile<F>::value>>\n    : public buffer<char> {\n private:\n  file_ref file_;\n\n  static void grow(buffer<char>& base, size_t) {\n    auto& self = static_cast<file_print_buffer&>(base);\n    self.file_.advance_write_buffer(self.size());\n    if (self.file_.get_write_buffer().size == 0) self.file_.flush();\n    auto buf = self.file_.get_write_buffer();\n    FMT_ASSERT(buf.size > 0, \"\");\n    self.set(buf.data, buf.size);\n    self.clear();\n  }\n\n public:\n  explicit file_print_buffer(F* f) : buffer(grow, size_t()), file_(f) {\n    flockfile(f);\n    file_.init_buffer();\n    auto buf = file_.get_write_buffer();\n    set(buf.data, buf.size);\n  }\n  ~file_print_buffer() {\n    file_.advance_write_buffer(size());\n    bool flush = file_.needs_flush();\n    F* f = file_;    // Make funlockfile depend on the template parameter F\n    funlockfile(f);  // for the system API detection to work.\n    if (flush) fflush(file_);\n  }\n};\n\n#if !defined(_WIN32) || defined(FMT_USE_WRITE_CONSOLE)\nFMT_FUNC auto write_console(int, string_view) -> bool { return false; }\n#else\nusing dword = conditional_t<sizeof(long) == 4, unsigned long, unsigned>;\nextern \"C\" __declspec(dllimport) int __stdcall WriteConsoleW(  //\n    void*, const void*, dword, dword*, void*);\n\nFMT_FUNC bool write_console(int fd, string_view text) {\n  auto u16 = utf8_to_utf16(text);\n  return WriteConsoleW(reinterpret_cast<void*>(_get_osfhandle(fd)), u16.c_str(),\n                       static_cast<dword>(u16.size()), nullptr, nullptr) != 0;\n}\n#endif\n\n#ifdef _WIN32\n// Print assuming legacy (non-Unicode) encoding.\nFMT_FUNC void vprint_mojibake(std::FILE* f, string_view fmt, format_args args,\n                              bool newline) {\n  auto buffer = memory_buffer();\n  detail::vformat_to(buffer, fmt, args);\n  if (newline) buffer.push_back('\\n');\n  fwrite_all(buffer.data(), buffer.size(), f);\n}\n#endif\n\nFMT_FUNC void print(std::FILE* f, string_view text) {\n#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)\n  int fd = _fileno(f);\n  if (_isatty(fd)) {\n    std::fflush(f);\n    if (write_console(fd, text)) return;\n  }\n#endif\n  fwrite_all(text.data(), text.size(), f);\n}\n}  // namespace detail\n\nFMT_FUNC void vprint_buffered(std::FILE* f, string_view fmt, format_args args) {\n  auto buffer = memory_buffer();\n  detail::vformat_to(buffer, fmt, args);\n  detail::print(f, {buffer.data(), buffer.size()});\n}\n\nFMT_FUNC void vprint(std::FILE* f, string_view fmt, format_args args) {\n  if (!detail::file_ref(f).is_buffered() || !detail::has_flockfile<>())\n    return vprint_buffered(f, fmt, args);\n  auto&& buffer = detail::file_print_buffer<>(f);\n  return detail::vformat_to(buffer, fmt, args);\n}\n\nFMT_FUNC void vprintln(std::FILE* f, string_view fmt, format_args args) {\n  auto buffer = memory_buffer();\n  detail::vformat_to(buffer, fmt, args);\n  buffer.push_back('\\n');\n  detail::print(f, {buffer.data(), buffer.size()});\n}\n\nFMT_FUNC void vprint(string_view fmt, format_args args) {\n  vprint(stdout, fmt, args);\n}\n\nnamespace detail {\n\nstruct singleton {\n  unsigned char upper;\n  unsigned char lower_count;\n};\n\ninline auto is_printable(uint16_t x, const singleton* singletons,\n                         size_t singletons_size,\n                         const unsigned char* singleton_lowers,\n                         const unsigned char* normal, size_t normal_size)\n    -> bool {\n  auto upper = x >> 8;\n  auto lower_start = 0;\n  for (size_t i = 0; i < singletons_size; ++i) {\n    auto s = singletons[i];\n    auto lower_end = lower_start + s.lower_count;\n    if (upper < s.upper) break;\n    if (upper == s.upper) {\n      for (auto j = lower_start; j < lower_end; ++j) {\n        if (singleton_lowers[j] == (x & 0xff)) return false;\n      }\n    }\n    lower_start = lower_end;\n  }\n\n  auto xsigned = static_cast<int>(x);\n  auto current = true;\n  for (size_t i = 0; i < normal_size; ++i) {\n    auto v = static_cast<int>(normal[i]);\n    auto len = (v & 0x80) != 0 ? (v & 0x7f) << 8 | normal[++i] : v;\n    xsigned -= len;\n    if (xsigned < 0) break;\n    current = !current;\n  }\n  return current;\n}\n\n// This code is generated by support/printable.py.\nFMT_FUNC auto is_printable(uint32_t cp) -> bool {\n  static constexpr singleton singletons0[] = {\n      {0x00, 1},  {0x03, 5},  {0x05, 6},  {0x06, 3},  {0x07, 6},  {0x08, 8},\n      {0x09, 17}, {0x0a, 28}, {0x0b, 25}, {0x0c, 20}, {0x0d, 16}, {0x0e, 13},\n      {0x0f, 4},  {0x10, 3},  {0x12, 18}, {0x13, 9},  {0x16, 1},  {0x17, 5},\n      {0x18, 2},  {0x19, 3},  {0x1a, 7},  {0x1c, 2},  {0x1d, 1},  {0x1f, 22},\n      {0x20, 3},  {0x2b, 3},  {0x2c, 2},  {0x2d, 11}, {0x2e, 1},  {0x30, 3},\n      {0x31, 2},  {0x32, 1},  {0xa7, 2},  {0xa9, 2},  {0xaa, 4},  {0xab, 8},\n      {0xfa, 2},  {0xfb, 5},  {0xfd, 4},  {0xfe, 3},  {0xff, 9},\n  };\n  static constexpr unsigned char singletons0_lower[] = {\n      0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57, 0x58, 0x8b, 0x8c, 0x90,\n      0x1c, 0x1d, 0xdd, 0x0e, 0x0f, 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f,\n      0x5c, 0x5d, 0x5f, 0xb5, 0xe2, 0x84, 0x8d, 0x8e, 0x91, 0x92, 0xa9, 0xb1,\n      0xba, 0xbb, 0xc5, 0xc6, 0xc9, 0xca, 0xde, 0xe4, 0xe5, 0xff, 0x00, 0x04,\n      0x11, 0x12, 0x29, 0x31, 0x34, 0x37, 0x3a, 0x3b, 0x3d, 0x49, 0x4a, 0x5d,\n      0x84, 0x8e, 0x92, 0xa9, 0xb1, 0xb4, 0xba, 0xbb, 0xc6, 0xca, 0xce, 0xcf,\n      0xe4, 0xe5, 0x00, 0x04, 0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31, 0x34, 0x3a,\n      0x3b, 0x45, 0x46, 0x49, 0x4a, 0x5e, 0x64, 0x65, 0x84, 0x91, 0x9b, 0x9d,\n      0xc9, 0xce, 0xcf, 0x0d, 0x11, 0x29, 0x45, 0x49, 0x57, 0x64, 0x65, 0x8d,\n      0x91, 0xa9, 0xb4, 0xba, 0xbb, 0xc5, 0xc9, 0xdf, 0xe4, 0xe5, 0xf0, 0x0d,\n      0x11, 0x45, 0x49, 0x64, 0x65, 0x80, 0x84, 0xb2, 0xbc, 0xbe, 0xbf, 0xd5,\n      0xd7, 0xf0, 0xf1, 0x83, 0x85, 0x8b, 0xa4, 0xa6, 0xbe, 0xbf, 0xc5, 0xc7,\n      0xce, 0xcf, 0xda, 0xdb, 0x48, 0x98, 0xbd, 0xcd, 0xc6, 0xce, 0xcf, 0x49,\n      0x4e, 0x4f, 0x57, 0x59, 0x5e, 0x5f, 0x89, 0x8e, 0x8f, 0xb1, 0xb6, 0xb7,\n      0xbf, 0xc1, 0xc6, 0xc7, 0xd7, 0x11, 0x16, 0x17, 0x5b, 0x5c, 0xf6, 0xf7,\n      0xfe, 0xff, 0x80, 0x0d, 0x6d, 0x71, 0xde, 0xdf, 0x0e, 0x0f, 0x1f, 0x6e,\n      0x6f, 0x1c, 0x1d, 0x5f, 0x7d, 0x7e, 0xae, 0xaf, 0xbb, 0xbc, 0xfa, 0x16,\n      0x17, 0x1e, 0x1f, 0x46, 0x47, 0x4e, 0x4f, 0x58, 0x5a, 0x5c, 0x5e, 0x7e,\n      0x7f, 0xb5, 0xc5, 0xd4, 0xd5, 0xdc, 0xf0, 0xf1, 0xf5, 0x72, 0x73, 0x8f,\n      0x74, 0x75, 0x96, 0x2f, 0x5f, 0x26, 0x2e, 0x2f, 0xa7, 0xaf, 0xb7, 0xbf,\n      0xc7, 0xcf, 0xd7, 0xdf, 0x9a, 0x40, 0x97, 0x98, 0x30, 0x8f, 0x1f, 0xc0,\n      0xc1, 0xce, 0xff, 0x4e, 0x4f, 0x5a, 0x5b, 0x07, 0x08, 0x0f, 0x10, 0x27,\n      0x2f, 0xee, 0xef, 0x6e, 0x6f, 0x37, 0x3d, 0x3f, 0x42, 0x45, 0x90, 0x91,\n      0xfe, 0xff, 0x53, 0x67, 0x75, 0xc8, 0xc9, 0xd0, 0xd1, 0xd8, 0xd9, 0xe7,\n      0xfe, 0xff,\n  };\n  static constexpr singleton singletons1[] = {\n      {0x00, 6},  {0x01, 1}, {0x03, 1},  {0x04, 2}, {0x08, 8},  {0x09, 2},\n      {0x0a, 5},  {0x0b, 2}, {0x0e, 4},  {0x10, 1}, {0x11, 2},  {0x12, 5},\n      {0x13, 17}, {0x14, 1}, {0x15, 2},  {0x17, 2}, {0x19, 13}, {0x1c, 5},\n      {0x1d, 8},  {0x24, 1}, {0x6a, 3},  {0x6b, 2}, {0xbc, 2},  {0xd1, 2},\n      {0xd4, 12}, {0xd5, 9}, {0xd6, 2},  {0xd7, 2}, {0xda, 1},  {0xe0, 5},\n      {0xe1, 2},  {0xe8, 2}, {0xee, 32}, {0xf0, 4}, {0xf8, 2},  {0xf9, 2},\n      {0xfa, 2},  {0xfb, 1},\n  };\n  static constexpr unsigned char singletons1_lower[] = {\n      0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e, 0x9e, 0x9f, 0x06, 0x07,\n      0x09, 0x36, 0x3d, 0x3e, 0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,\n      0x37, 0x56, 0x57, 0x7f, 0xaa, 0xae, 0xaf, 0xbd, 0x35, 0xe0, 0x12, 0x87,\n      0x89, 0x8e, 0x9e, 0x04, 0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31, 0x34, 0x3a,\n      0x45, 0x46, 0x49, 0x4a, 0x4e, 0x4f, 0x64, 0x65, 0x5c, 0xb6, 0xb7, 0x1b,\n      0x1c, 0x07, 0x08, 0x0a, 0x0b, 0x14, 0x17, 0x36, 0x39, 0x3a, 0xa8, 0xa9,\n      0xd8, 0xd9, 0x09, 0x37, 0x90, 0x91, 0xa8, 0x07, 0x0a, 0x3b, 0x3e, 0x66,\n      0x69, 0x8f, 0x92, 0x6f, 0x5f, 0xee, 0xef, 0x5a, 0x62, 0x9a, 0x9b, 0x27,\n      0x28, 0x55, 0x9d, 0xa0, 0xa1, 0xa3, 0xa4, 0xa7, 0xa8, 0xad, 0xba, 0xbc,\n      0xc4, 0x06, 0x0b, 0x0c, 0x15, 0x1d, 0x3a, 0x3f, 0x45, 0x51, 0xa6, 0xa7,\n      0xcc, 0xcd, 0xa0, 0x07, 0x19, 0x1a, 0x22, 0x25, 0x3e, 0x3f, 0xc5, 0xc6,\n      0x04, 0x20, 0x23, 0x25, 0x26, 0x28, 0x33, 0x38, 0x3a, 0x48, 0x4a, 0x4c,\n      0x50, 0x53, 0x55, 0x56, 0x58, 0x5a, 0x5c, 0x5e, 0x60, 0x63, 0x65, 0x66,\n      0x6b, 0x73, 0x78, 0x7d, 0x7f, 0x8a, 0xa4, 0xaa, 0xaf, 0xb0, 0xc0, 0xd0,\n      0xae, 0xaf, 0x79, 0xcc, 0x6e, 0x6f, 0x93,\n  };\n  static constexpr unsigned char normal0[] = {\n      0x00, 0x20, 0x5f, 0x22, 0x82, 0xdf, 0x04, 0x82, 0x44, 0x08, 0x1b, 0x04,\n      0x06, 0x11, 0x81, 0xac, 0x0e, 0x80, 0xab, 0x35, 0x28, 0x0b, 0x80, 0xe0,\n      0x03, 0x19, 0x08, 0x01, 0x04, 0x2f, 0x04, 0x34, 0x04, 0x07, 0x03, 0x01,\n      0x07, 0x06, 0x07, 0x11, 0x0a, 0x50, 0x0f, 0x12, 0x07, 0x55, 0x07, 0x03,\n      0x04, 0x1c, 0x0a, 0x09, 0x03, 0x08, 0x03, 0x07, 0x03, 0x02, 0x03, 0x03,\n      0x03, 0x0c, 0x04, 0x05, 0x03, 0x0b, 0x06, 0x01, 0x0e, 0x15, 0x05, 0x3a,\n      0x03, 0x11, 0x07, 0x06, 0x05, 0x10, 0x07, 0x57, 0x07, 0x02, 0x07, 0x15,\n      0x0d, 0x50, 0x04, 0x43, 0x03, 0x2d, 0x03, 0x01, 0x04, 0x11, 0x06, 0x0f,\n      0x0c, 0x3a, 0x04, 0x1d, 0x25, 0x5f, 0x20, 0x6d, 0x04, 0x6a, 0x25, 0x80,\n      0xc8, 0x05, 0x82, 0xb0, 0x03, 0x1a, 0x06, 0x82, 0xfd, 0x03, 0x59, 0x07,\n      0x15, 0x0b, 0x17, 0x09, 0x14, 0x0c, 0x14, 0x0c, 0x6a, 0x06, 0x0a, 0x06,\n      0x1a, 0x06, 0x59, 0x07, 0x2b, 0x05, 0x46, 0x0a, 0x2c, 0x04, 0x0c, 0x04,\n      0x01, 0x03, 0x31, 0x0b, 0x2c, 0x04, 0x1a, 0x06, 0x0b, 0x03, 0x80, 0xac,\n      0x06, 0x0a, 0x06, 0x21, 0x3f, 0x4c, 0x04, 0x2d, 0x03, 0x74, 0x08, 0x3c,\n      0x03, 0x0f, 0x03, 0x3c, 0x07, 0x38, 0x08, 0x2b, 0x05, 0x82, 0xff, 0x11,\n      0x18, 0x08, 0x2f, 0x11, 0x2d, 0x03, 0x20, 0x10, 0x21, 0x0f, 0x80, 0x8c,\n      0x04, 0x82, 0x97, 0x19, 0x0b, 0x15, 0x88, 0x94, 0x05, 0x2f, 0x05, 0x3b,\n      0x07, 0x02, 0x0e, 0x18, 0x09, 0x80, 0xb3, 0x2d, 0x74, 0x0c, 0x80, 0xd6,\n      0x1a, 0x0c, 0x05, 0x80, 0xff, 0x05, 0x80, 0xdf, 0x0c, 0xee, 0x0d, 0x03,\n      0x84, 0x8d, 0x03, 0x37, 0x09, 0x81, 0x5c, 0x14, 0x80, 0xb8, 0x08, 0x80,\n      0xcb, 0x2a, 0x38, 0x03, 0x0a, 0x06, 0x38, 0x08, 0x46, 0x08, 0x0c, 0x06,\n      0x74, 0x0b, 0x1e, 0x03, 0x5a, 0x04, 0x59, 0x09, 0x80, 0x83, 0x18, 0x1c,\n      0x0a, 0x16, 0x09, 0x4c, 0x04, 0x80, 0x8a, 0x06, 0xab, 0xa4, 0x0c, 0x17,\n      0x04, 0x31, 0xa1, 0x04, 0x81, 0xda, 0x26, 0x07, 0x0c, 0x05, 0x05, 0x80,\n      0xa5, 0x11, 0x81, 0x6d, 0x10, 0x78, 0x28, 0x2a, 0x06, 0x4c, 0x04, 0x80,\n      0x8d, 0x04, 0x80, 0xbe, 0x03, 0x1b, 0x03, 0x0f, 0x0d,\n  };\n  static constexpr unsigned char normal1[] = {\n      0x5e, 0x22, 0x7b, 0x05, 0x03, 0x04, 0x2d, 0x03, 0x66, 0x03, 0x01, 0x2f,\n      0x2e, 0x80, 0x82, 0x1d, 0x03, 0x31, 0x0f, 0x1c, 0x04, 0x24, 0x09, 0x1e,\n      0x05, 0x2b, 0x05, 0x44, 0x04, 0x0e, 0x2a, 0x80, 0xaa, 0x06, 0x24, 0x04,\n      0x24, 0x04, 0x28, 0x08, 0x34, 0x0b, 0x01, 0x80, 0x90, 0x81, 0x37, 0x09,\n      0x16, 0x0a, 0x08, 0x80, 0x98, 0x39, 0x03, 0x63, 0x08, 0x09, 0x30, 0x16,\n      0x05, 0x21, 0x03, 0x1b, 0x05, 0x01, 0x40, 0x38, 0x04, 0x4b, 0x05, 0x2f,\n      0x04, 0x0a, 0x07, 0x09, 0x07, 0x40, 0x20, 0x27, 0x04, 0x0c, 0x09, 0x36,\n      0x03, 0x3a, 0x05, 0x1a, 0x07, 0x04, 0x0c, 0x07, 0x50, 0x49, 0x37, 0x33,\n      0x0d, 0x33, 0x07, 0x2e, 0x08, 0x0a, 0x81, 0x26, 0x52, 0x4e, 0x28, 0x08,\n      0x2a, 0x56, 0x1c, 0x14, 0x17, 0x09, 0x4e, 0x04, 0x1e, 0x0f, 0x43, 0x0e,\n      0x19, 0x07, 0x0a, 0x06, 0x48, 0x08, 0x27, 0x09, 0x75, 0x0b, 0x3f, 0x41,\n      0x2a, 0x06, 0x3b, 0x05, 0x0a, 0x06, 0x51, 0x06, 0x01, 0x05, 0x10, 0x03,\n      0x05, 0x80, 0x8b, 0x62, 0x1e, 0x48, 0x08, 0x0a, 0x80, 0xa6, 0x5e, 0x22,\n      0x45, 0x0b, 0x0a, 0x06, 0x0d, 0x13, 0x39, 0x07, 0x0a, 0x36, 0x2c, 0x04,\n      0x10, 0x80, 0xc0, 0x3c, 0x64, 0x53, 0x0c, 0x48, 0x09, 0x0a, 0x46, 0x45,\n      0x1b, 0x48, 0x08, 0x53, 0x1d, 0x39, 0x81, 0x07, 0x46, 0x0a, 0x1d, 0x03,\n      0x47, 0x49, 0x37, 0x03, 0x0e, 0x08, 0x0a, 0x06, 0x39, 0x07, 0x0a, 0x81,\n      0x36, 0x19, 0x80, 0xb7, 0x01, 0x0f, 0x32, 0x0d, 0x83, 0x9b, 0x66, 0x75,\n      0x0b, 0x80, 0xc4, 0x8a, 0xbc, 0x84, 0x2f, 0x8f, 0xd1, 0x82, 0x47, 0xa1,\n      0xb9, 0x82, 0x39, 0x07, 0x2a, 0x04, 0x02, 0x60, 0x26, 0x0a, 0x46, 0x0a,\n      0x28, 0x05, 0x13, 0x82, 0xb0, 0x5b, 0x65, 0x4b, 0x04, 0x39, 0x07, 0x11,\n      0x40, 0x05, 0x0b, 0x02, 0x0e, 0x97, 0xf8, 0x08, 0x84, 0xd6, 0x2a, 0x09,\n      0xa2, 0xf7, 0x81, 0x1f, 0x31, 0x03, 0x11, 0x04, 0x08, 0x81, 0x8c, 0x89,\n      0x04, 0x6b, 0x05, 0x0d, 0x03, 0x09, 0x07, 0x10, 0x93, 0x60, 0x80, 0xf6,\n      0x0a, 0x73, 0x08, 0x6e, 0x17, 0x46, 0x80, 0x9a, 0x14, 0x0c, 0x57, 0x09,\n      0x19, 0x80, 0x87, 0x81, 0x47, 0x03, 0x85, 0x42, 0x0f, 0x15, 0x85, 0x50,\n      0x2b, 0x80, 0xd5, 0x2d, 0x03, 0x1a, 0x04, 0x02, 0x81, 0x70, 0x3a, 0x05,\n      0x01, 0x85, 0x00, 0x80, 0xd7, 0x29, 0x4c, 0x04, 0x0a, 0x04, 0x02, 0x83,\n      0x11, 0x44, 0x4c, 0x3d, 0x80, 0xc2, 0x3c, 0x06, 0x01, 0x04, 0x55, 0x05,\n      0x1b, 0x34, 0x02, 0x81, 0x0e, 0x2c, 0x04, 0x64, 0x0c, 0x56, 0x0a, 0x80,\n      0xae, 0x38, 0x1d, 0x0d, 0x2c, 0x04, 0x09, 0x07, 0x02, 0x0e, 0x06, 0x80,\n      0x9a, 0x83, 0xd8, 0x08, 0x0d, 0x03, 0x0d, 0x03, 0x74, 0x0c, 0x59, 0x07,\n      0x0c, 0x14, 0x0c, 0x04, 0x38, 0x08, 0x0a, 0x06, 0x28, 0x08, 0x22, 0x4e,\n      0x81, 0x54, 0x0c, 0x15, 0x03, 0x03, 0x05, 0x07, 0x09, 0x19, 0x07, 0x07,\n      0x09, 0x03, 0x0d, 0x07, 0x29, 0x80, 0xcb, 0x25, 0x0a, 0x84, 0x06,\n  };\n  auto lower = static_cast<uint16_t>(cp);\n  if (cp < 0x10000) {\n    return is_printable(lower, singletons0,\n                        sizeof(singletons0) / sizeof(*singletons0),\n                        singletons0_lower, normal0, sizeof(normal0));\n  }\n  if (cp < 0x20000) {\n    return is_printable(lower, singletons1,\n                        sizeof(singletons1) / sizeof(*singletons1),\n                        singletons1_lower, normal1, sizeof(normal1));\n  }\n  if (0x2a6de <= cp && cp < 0x2a700) return false;\n  if (0x2b735 <= cp && cp < 0x2b740) return false;\n  if (0x2b81e <= cp && cp < 0x2b820) return false;\n  if (0x2cea2 <= cp && cp < 0x2ceb0) return false;\n  if (0x2ebe1 <= cp && cp < 0x2f800) return false;\n  if (0x2fa1e <= cp && cp < 0x30000) return false;\n  if (0x3134b <= cp && cp < 0xe0100) return false;\n  if (0xe01f0 <= cp && cp < 0x110000) return false;\n  return cp < 0x110000;\n}\n\n}  // namespace detail\n\nFMT_END_NAMESPACE\n\n#endif  // FMT_FORMAT_INL_H_\n"
  },
  {
    "path": "include/fmt/format.h",
    "content": "/*\n  Formatting library for C++\n\n  Copyright (c) 2012 - present, Victor Zverovich\n\n  Permission is hereby granted, free of charge, to any person obtaining\n  a copy of this software and associated documentation files (the\n  \"Software\"), to deal in the Software without restriction, including\n  without limitation the rights to use, copy, modify, merge, publish,\n  distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so, subject to\n  the following conditions:\n\n  The above copyright notice and this permission notice shall be\n  included in all copies or substantial portions of the Software.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n  --- Optional exception to the license ---\n\n  As an exception, if, as a result of your compiling your source code, portions\n  of this Software are embedded into a machine-executable object form of such\n  source code, you may redistribute such embedded portions in such object form\n  without including the above copyright and permission notices.\n */\n\n#ifndef FMT_FORMAT_H_\n#define FMT_FORMAT_H_\n\n#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES\n#  define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES\n#  define FMT_REMOVE_TRANSITIVE_INCLUDES\n#endif\n\n#include \"base.h\"\n\n// libc++ supports string_view in pre-c++17.\n#if FMT_HAS_INCLUDE(<string_view>) && \\\n    (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))\n#  define FMT_USE_STRING_VIEW\n#endif\n\n#ifndef FMT_MODULE\n#  include <stdint.h>  // uint32_t\n#  include <stdlib.h>  // malloc, free\n#  include <string.h>  // memcpy\n\n#  include <cmath>   // std::signbit\n#  include <limits>  // std::numeric_limits\n#  if defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI)\n// Workaround for pre gcc 5 libstdc++.\n#    include <memory>  // std::allocator_traits\n#  endif\n#  include <stdexcept>     // std::runtime_error\n#  include <string>        // std::string\n#  include <system_error>  // std::system_error\n\n// Check FMT_CPLUSPLUS to avoid a warning in MSVC.\n#  if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L\n#    include <bit>  // std::bit_cast\n#  endif\n\n#  if defined(FMT_USE_STRING_VIEW)\n#    include <string_view>\n#  endif\n\n#  if FMT_MSC_VERSION\n#    include <intrin.h>  // _BitScanReverse[64], _umul128\n#  endif\n#endif  // FMT_MODULE\n\n#if defined(FMT_USE_NONTYPE_TEMPLATE_ARGS)\n// Use the provided definition.\n#elif defined(__NVCOMPILER)\n#  define FMT_USE_NONTYPE_TEMPLATE_ARGS 0\n#elif FMT_GCC_VERSION >= 903 && FMT_CPLUSPLUS >= 201709L\n#  define FMT_USE_NONTYPE_TEMPLATE_ARGS 1\n#elif defined(__cpp_nontype_template_args) && \\\n    __cpp_nontype_template_args >= 201911L\n#  define FMT_USE_NONTYPE_TEMPLATE_ARGS 1\n#elif FMT_CLANG_VERSION >= 1200 && FMT_CPLUSPLUS >= 202002L\n#  define FMT_USE_NONTYPE_TEMPLATE_ARGS 1\n#else\n#  define FMT_USE_NONTYPE_TEMPLATE_ARGS 0\n#endif\n\n#if defined __cpp_inline_variables && __cpp_inline_variables >= 201606L\n#  define FMT_INLINE_VARIABLE inline\n#else\n#  define FMT_INLINE_VARIABLE\n#endif\n\n// Check if RTTI is disabled.\n#ifdef FMT_USE_RTTI\n// Use the provided definition.\n#elif defined(__GXX_RTTI) || FMT_HAS_FEATURE(cxx_rtti) || defined(_CPPRTTI) || \\\n    defined(__INTEL_RTTI__) || defined(__RTTI)\n// __RTTI is for EDG compilers. _CPPRTTI is for MSVC.\n#  define FMT_USE_RTTI 1\n#else\n#  define FMT_USE_RTTI 0\n#endif\n\n// Visibility when compiled as a shared library/object.\n#if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)\n#  define FMT_SO_VISIBILITY(value) FMT_VISIBILITY(value)\n#else\n#  define FMT_SO_VISIBILITY(value)\n#endif\n\n#if FMT_GCC_VERSION || FMT_CLANG_VERSION\n#  define FMT_NOINLINE __attribute__((noinline))\n#else\n#  define FMT_NOINLINE\n#endif\n\n// Detect constexpr std::string.\n#if !FMT_USE_CONSTEVAL\n#  define FMT_USE_CONSTEXPR_STRING 0\n#elif defined(__cpp_lib_constexpr_string) && \\\n    __cpp_lib_constexpr_string >= 201907L\n#  if FMT_CLANG_VERSION && FMT_GLIBCXX_RELEASE\n// clang + libstdc++ are able to work only starting with gcc13.3\n// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113294\n#    if FMT_GLIBCXX_RELEASE < 13\n#      define FMT_USE_CONSTEXPR_STRING 0\n#    elif FMT_GLIBCXX_RELEASE == 13 && __GLIBCXX__ < 20240521\n#      define FMT_USE_CONSTEXPR_STRING 0\n#    else\n#      define FMT_USE_CONSTEXPR_STRING 1\n#    endif\n#  else\n#    define FMT_USE_CONSTEXPR_STRING 1\n#  endif\n#else\n#  define FMT_USE_CONSTEXPR_STRING 0\n#endif\n#if FMT_USE_CONSTEXPR_STRING\n#  define FMT_CONSTEXPR_STRING constexpr\n#else\n#  define FMT_CONSTEXPR_STRING\n#endif\n\n// GCC 4.9 doesn't support qualified names in specializations.\nnamespace std {\ntemplate <typename T> struct iterator_traits<fmt::basic_appender<T>> {\n  using iterator_category = output_iterator_tag;\n  using value_type = T;\n  using difference_type =\n      decltype(static_cast<int*>(nullptr) - static_cast<int*>(nullptr));\n  using pointer = void;\n  using reference = void;\n};\n}  // namespace std\n\n#ifdef FMT_THROW\n// Use the provided definition.\n#elif FMT_USE_EXCEPTIONS\n#  define FMT_THROW(x) throw x\n#else\n#  define FMT_THROW(x) ::fmt::assert_fail(__FILE__, __LINE__, (x).what())\n#endif\n\n#ifdef __clang_analyzer__\n#  define FMT_CLANG_ANALYZER 1\n#else\n#  define FMT_CLANG_ANALYZER 0\n#endif\n\n// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of\n// integer formatter template instantiations to just one by only using the\n// largest integer type. This results in a reduction in binary size but will\n// cause a decrease in integer formatting performance.\n#if !defined(FMT_REDUCE_INT_INSTANTIATIONS)\n#  define FMT_REDUCE_INT_INSTANTIATIONS 0\n#endif\n\nFMT_BEGIN_NAMESPACE\n\ntemplate <typename Char, typename Traits, typename Allocator>\nstruct is_contiguous<std::basic_string<Char, Traits, Allocator>>\n    : std::true_type {};\n\nnamespace detail {\n\n// __builtin_clz is broken in clang with Microsoft codegen:\n// https://github.com/fmtlib/fmt/issues/519.\n#if !FMT_MSC_VERSION\n#  if FMT_HAS_BUILTIN(__builtin_clz) || FMT_GCC_VERSION || FMT_ICC_VERSION\n#    define FMT_BUILTIN_CLZ(n) __builtin_clz(n)\n#  endif\n#  if FMT_HAS_BUILTIN(__builtin_clzll) || FMT_GCC_VERSION || FMT_ICC_VERSION\n#    define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)\n#  endif\n#endif\n\n// Some compilers masquerade as both MSVC and GCC but otherwise support\n// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the\n// MSVC intrinsics if the clz and clzll builtins are not available.\n#if FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL)\n// Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning.\n#  ifndef __clang__\n#    pragma intrinsic(_BitScanReverse)\n#    ifdef _WIN64\n#      pragma intrinsic(_BitScanReverse64)\n#    endif\n#  endif\n\ninline auto clz(uint32_t x) -> int {\n  FMT_ASSERT(x != 0, \"\");\n  unsigned long r = 0;\n  _BitScanReverse(&r, x);\n  return 31 ^ static_cast<int>(r);\n}\n#  define FMT_BUILTIN_CLZ(n) detail::clz(n)\n\ninline auto clzll(uint64_t x) -> int {\n  FMT_ASSERT(x != 0, \"\");\n  unsigned long r = 0;\n#  ifdef _WIN64\n  _BitScanReverse64(&r, x);\n#  else\n  // Scan the high 32 bits.\n  if (_BitScanReverse(&r, static_cast<uint32_t>(x >> 32)))\n    return 63 ^ static_cast<int>(r + 32);\n  // Scan the low 32 bits.\n  _BitScanReverse(&r, static_cast<uint32_t>(x));\n#  endif\n  return 63 ^ static_cast<int>(r);\n}\n#  define FMT_BUILTIN_CLZLL(n) detail::clzll(n)\n#endif  // FMT_MSC_VERSION && !defined(FMT_BUILTIN_CLZLL)\n\nFMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {\n  ignore_unused(condition);\n#ifdef FMT_FUZZ\n  if (condition) throw std::runtime_error(\"fuzzing limit reached\");\n#endif\n}\n\n#if defined(FMT_USE_STRING_VIEW)\ntemplate <typename Char> using std_string_view = std::basic_string_view<Char>;\n#else\ntemplate <typename Char> struct std_string_view {\n  operator basic_string_view<Char>() const;\n};\n#endif\n\ntemplate <typename Char, Char... C> struct string_literal {\n  static constexpr Char value[sizeof...(C)] = {C...};\n  constexpr operator basic_string_view<Char>() const {\n    return {value, sizeof...(C)};\n  }\n};\n#if FMT_CPLUSPLUS < 201703L\ntemplate <typename Char, Char... C>\nconstexpr Char string_literal<Char, C...>::value[sizeof...(C)];\n#endif\n\n// Implementation of std::bit_cast for pre-C++20.\ntemplate <typename To, typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>\nFMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {\n#ifdef __cpp_lib_bit_cast\n  if (is_constant_evaluated()) return std::bit_cast<To>(from);\n#endif\n  auto to = To();\n  // The cast suppresses a bogus -Wclass-memaccess on GCC.\n  memcpy(static_cast<void*>(&to), &from, sizeof(to));\n  return to;\n}\n\ninline auto is_big_endian() -> bool {\n#ifdef _WIN32\n  return false;\n#elif defined(__BIG_ENDIAN__)\n  return true;\n#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)\n  return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__;\n#else\n  struct bytes {\n    char data[sizeof(int)];\n  };\n  return bit_cast<bytes>(1).data[0] == 0;\n#endif\n}\n\nclass uint128 {\n private:\n  uint64_t lo_, hi_;\n\n public:\n  constexpr uint128(uint64_t hi, uint64_t lo) : lo_(lo), hi_(hi) {}\n  constexpr uint128(uint64_t value = 0) : lo_(value), hi_(0) {}\n\n  constexpr auto high() const noexcept -> uint64_t { return hi_; }\n  constexpr auto low() const noexcept -> uint64_t { return lo_; }\n\n  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\n  constexpr explicit operator T() const {\n    return static_cast<T>(lo_);\n  }\n\n  friend constexpr auto operator==(const uint128& lhs, const uint128& rhs)\n      -> bool {\n    return lhs.hi_ == rhs.hi_ && lhs.lo_ == rhs.lo_;\n  }\n  friend constexpr auto operator!=(const uint128& lhs, const uint128& rhs)\n      -> bool {\n    return !(lhs == rhs);\n  }\n  friend constexpr auto operator>(const uint128& lhs, const uint128& rhs)\n      -> bool {\n    return lhs.hi_ != rhs.hi_ ? lhs.hi_ > rhs.hi_ : lhs.lo_ > rhs.lo_;\n  }\n  friend constexpr auto operator|(const uint128& lhs, const uint128& rhs)\n      -> uint128 {\n    return {lhs.hi_ | rhs.hi_, lhs.lo_ | rhs.lo_};\n  }\n  friend constexpr auto operator&(const uint128& lhs, const uint128& rhs)\n      -> uint128 {\n    return {lhs.hi_ & rhs.hi_, lhs.lo_ & rhs.lo_};\n  }\n  friend FMT_CONSTEXPR auto operator+(const uint128& lhs, const uint128& rhs)\n      -> uint128 {\n    auto result = uint128(lhs);\n    result += rhs;\n    return result;\n  }\n  friend FMT_CONSTEXPR auto operator*(const uint128& lhs, uint32_t rhs)\n      -> uint128 {\n    FMT_ASSERT(lhs.hi_ == 0, \"\");\n    uint64_t hi = (lhs.lo_ >> 32) * rhs;\n    uint64_t lo = (lhs.lo_ & ~uint32_t()) * rhs;\n    uint64_t new_lo = (hi << 32) + lo;\n    return {(hi >> 32) + (new_lo < lo ? 1 : 0), new_lo};\n  }\n  friend constexpr auto operator-(const uint128& lhs, uint64_t rhs) -> uint128 {\n    return {lhs.hi_ - (lhs.lo_ < rhs ? 1 : 0), lhs.lo_ - rhs};\n  }\n  FMT_CONSTEXPR auto operator>>(int shift) const -> uint128 {\n    if (shift == 64) return {0, hi_};\n    if (shift > 64) return uint128(0, hi_) >> (shift - 64);\n    return {hi_ >> shift, (hi_ << (64 - shift)) | (lo_ >> shift)};\n  }\n  FMT_CONSTEXPR auto operator<<(int shift) const -> uint128 {\n    if (shift == 64) return {lo_, 0};\n    if (shift > 64) return uint128(lo_, 0) << (shift - 64);\n    return {hi_ << shift | (lo_ >> (64 - shift)), (lo_ << shift)};\n  }\n  FMT_CONSTEXPR auto operator>>=(int shift) -> uint128& {\n    return *this = *this >> shift;\n  }\n  FMT_CONSTEXPR void operator+=(uint128 n) {\n    uint64_t new_lo = lo_ + n.lo_;\n    uint64_t new_hi = hi_ + n.hi_ + (new_lo < lo_ ? 1 : 0);\n    FMT_ASSERT(new_hi >= hi_, \"\");\n    lo_ = new_lo;\n    hi_ = new_hi;\n  }\n  FMT_CONSTEXPR void operator&=(uint128 n) {\n    lo_ &= n.lo_;\n    hi_ &= n.hi_;\n  }\n\n  FMT_CONSTEXPR20 auto operator+=(uint64_t n) noexcept -> uint128& {\n    if (is_constant_evaluated()) {\n      lo_ += n;\n      hi_ += (lo_ < n ? 1 : 0);\n      return *this;\n    }\n#if FMT_HAS_BUILTIN(__builtin_addcll) && !defined(__ibmxl__)\n    ullong carry;\n    lo_ = __builtin_addcll(lo_, n, 0, &carry);\n    hi_ += carry;\n#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64) && !defined(__ibmxl__)\n    ullong result;\n    auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);\n    lo_ = result;\n    hi_ += carry;\n#elif defined(_MSC_VER) && defined(_M_AMD64)\n    auto carry = _addcarry_u64(0, lo_, n, &lo_);\n    _addcarry_u64(carry, hi_, 0, &hi_);\n#else\n    lo_ += n;\n    hi_ += (lo_ < n ? 1 : 0);\n#endif\n    return *this;\n  }\n};\n\nusing uint128_t = conditional_t<FMT_USE_INT128, native_uint128, uint128>;\n\n#ifdef UINTPTR_MAX\nusing uintptr_t = ::uintptr_t;\n#else\nusing uintptr_t = uint128_t;\n#endif\n\n// Returns the largest possible value for type T. Same as\n// std::numeric_limits<T>::max() but shorter and not affected by the max macro.\ntemplate <typename T> constexpr auto max_value() -> T {\n  return (std::numeric_limits<T>::max)();\n}\ntemplate <typename T> constexpr auto num_bits() -> int {\n  return std::numeric_limits<T>::digits;\n}\n// std::numeric_limits<T>::digits may return 0 for 128-bit ints.\ntemplate <> constexpr auto num_bits<native_int128>() -> int { return 128; }\ntemplate <> constexpr auto num_bits<native_uint128>() -> int { return 128; }\ntemplate <> constexpr auto num_bits<uint128>() -> int { return 128; }\n\n// A heterogeneous bit_cast used for converting 96-bit long double to uint128_t\n// and 128-bit pointers to uint128.\ntemplate <typename To, typename From, FMT_ENABLE_IF(sizeof(To) > sizeof(From))>\ninline auto bit_cast(const From& from) -> To {\n  constexpr auto size = static_cast<int>(sizeof(From) / sizeof(unsigned short));\n  struct data_t {\n    unsigned short value[static_cast<unsigned>(size)];\n  } data = bit_cast<data_t>(from);\n  auto result = To();\n  if (is_big_endian()) {\n    for (int i = 0; i < size; ++i)\n      result = (result << num_bits<unsigned short>()) | data.value[i];\n  } else {\n    for (int i = size - 1; i >= 0; --i)\n      result = (result << num_bits<unsigned short>()) | data.value[i];\n  }\n  return result;\n}\n\ntemplate <typename UInt>\nFMT_CONSTEXPR20 inline auto countl_zero_fallback(UInt n) -> int {\n  int lz = 0;\n  constexpr UInt msb_mask = static_cast<UInt>(1) << (num_bits<UInt>() - 1);\n  for (; (n & msb_mask) == 0; n <<= 1) lz++;\n  return lz;\n}\n\nFMT_CONSTEXPR20 inline auto countl_zero(uint32_t n) -> int {\n#ifdef FMT_BUILTIN_CLZ\n  if (!is_constant_evaluated()) return FMT_BUILTIN_CLZ(n);\n#endif\n  return countl_zero_fallback(n);\n}\n\nFMT_CONSTEXPR20 inline auto countl_zero(uint64_t n) -> int {\n#ifdef FMT_BUILTIN_CLZLL\n  if (!is_constant_evaluated()) return FMT_BUILTIN_CLZLL(n);\n#endif\n  return countl_zero_fallback(n);\n}\n\nFMT_INLINE void assume(bool condition) {\n  (void)condition;\n#if FMT_HAS_BUILTIN(__builtin_assume) && !FMT_ICC_VERSION\n  __builtin_assume(condition);\n#elif FMT_GCC_VERSION\n  if (!condition) __builtin_unreachable();\n#endif\n}\n\n// Attempts to reserve space for n extra characters in the output range.\n// Returns a pointer to the reserved range or a reference to it.\ntemplate <typename OutputIt,\n          FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value&&\n                            is_contiguous<typename OutputIt::container>::value)>\n#if FMT_CLANG_VERSION >= 307 && !FMT_ICC_VERSION\n__attribute__((no_sanitize(\"undefined\")))\n#endif\nFMT_CONSTEXPR20 inline auto reserve(OutputIt it, size_t n) ->\n    typename OutputIt::value_type* {\n  auto& c = get_container(it);\n  size_t size = c.size();\n  c.resize(size + n);\n  return &c[size];\n}\n\ntemplate <typename T>\nFMT_CONSTEXPR20 inline auto reserve(basic_appender<T> it, size_t n)\n    -> basic_appender<T> {\n  buffer<T>& buf = get_container(it);\n  buf.try_reserve(buf.size() + n);\n  return it;\n}\n\ntemplate <typename Iterator>\nconstexpr auto reserve(Iterator& it, size_t) -> Iterator& {\n  return it;\n}\n\ntemplate <typename OutputIt>\nusing reserve_iterator =\n    remove_reference_t<decltype(reserve(std::declval<OutputIt&>(), 0))>;\n\ntemplate <typename T, typename OutputIt>\nconstexpr auto to_pointer(OutputIt, size_t) -> T* {\n  return nullptr;\n}\ntemplate <typename T> FMT_CONSTEXPR auto to_pointer(T*& ptr, size_t n) -> T* {\n  T* begin = ptr;\n  ptr += n;\n  return begin;\n}\ntemplate <typename T>\nFMT_CONSTEXPR20 auto to_pointer(basic_appender<T> it, size_t n) -> T* {\n  buffer<T>& buf = get_container(it);\n  buf.try_reserve(buf.size() + n);\n  auto size = buf.size();\n  if (buf.capacity() < size + n) return nullptr;\n  buf.try_resize(size + n);\n  return buf.data() + size;\n}\n\ntemplate <typename OutputIt,\n          FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value&&\n                            is_contiguous<typename OutputIt::container>::value)>\ninline auto base_iterator(OutputIt it,\n                          typename OutputIt::container_type::value_type*)\n    -> OutputIt {\n  return it;\n}\n\ntemplate <typename Iterator>\nconstexpr auto base_iterator(Iterator, Iterator it) -> Iterator {\n  return it;\n}\n\n// <algorithm> is spectacularly slow to compile in C++20 so use a simple fill_n\n// instead (#1998).\ntemplate <typename OutputIt, typename Size, typename T>\nFMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T& value)\n    -> OutputIt {\n  for (Size i = 0; i < count; ++i) *out++ = value;\n  return out;\n}\ntemplate <typename T, typename Size>\nFMT_CONSTEXPR20 auto fill_n(T* out, Size count, char value) -> T* {\n  if (is_constant_evaluated()) return fill_n<T*, Size, T>(out, count, value);\n  static_assert(sizeof(T) == 1,\n                \"sizeof(T) must be 1 to use char for initialization\");\n  memset(out, value, to_unsigned(count));\n  return out + count;\n}\n\ntemplate <typename OutputIt, typename InputIt, typename = void>\nstruct has_back_insert_iterator_container_append : std::false_type {};\n\ntemplate <typename OutputIt, typename InputIt>\nstruct has_back_insert_iterator_container_append<\n    OutputIt, InputIt,\n    void_t<decltype(get_container(std::declval<OutputIt>())\n                        .append(std::declval<InputIt>(),\n                                std::declval<InputIt>()))>> : std::true_type {};\n\ntemplate <typename OutputIt, typename InputIt, typename = void>\nstruct has_back_insert_iterator_container_insert_at_end : std::false_type {};\n\ntemplate <typename OutputIt, typename InputIt>\nstruct has_back_insert_iterator_container_insert_at_end<\n    OutputIt, InputIt,\n    void_t<decltype(get_container(std::declval<OutputIt>())\n                        .insert(get_container(std::declval<OutputIt>()).end(),\n                                std::declval<InputIt>(),\n                                std::declval<InputIt>()))>> : std::true_type {};\n\n// An optimized version of std::copy with the output value type (T).\ntemplate <typename T, typename InputIt, typename OutputIt,\n          FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value&&\n                            has_back_insert_iterator_container_append<\n                                OutputIt, InputIt>::value)>\nFMT_CONSTEXPR auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt {\n  get_container(out).append(begin, end);\n  return out;\n}\n\ntemplate <typename T, typename InputIt, typename OutputIt,\n          FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value &&\n                        !has_back_insert_iterator_container_append<\n                            OutputIt, InputIt>::value &&\n                        has_back_insert_iterator_container_insert_at_end<\n                            OutputIt, InputIt>::value)>\nFMT_CONSTEXPR auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt {\n  auto& c = get_container(out);\n  c.insert(c.end(), begin, end);\n  return out;\n}\n\ntemplate <typename T, typename InputIt, typename OutputIt,\n          FMT_ENABLE_IF(!(is_back_insert_iterator<OutputIt>::value &&\n                          (has_back_insert_iterator_container_append<\n                               OutputIt, InputIt>::value ||\n                           has_back_insert_iterator_container_insert_at_end<\n                               OutputIt, InputIt>::value)))>\nFMT_CONSTEXPR auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt {\n  while (begin != end) *out++ = static_cast<T>(*begin++);\n  return out;\n}\n\ntemplate <typename T, typename V, typename OutputIt>\nFMT_CONSTEXPR auto copy(basic_string_view<V> s, OutputIt out) -> OutputIt {\n  return copy<T>(s.begin(), s.end(), out);\n}\n\ntemplate <typename OutChar, typename InputIt, typename OutputIt>\nFMT_CONSTEXPR FMT_NOINLINE auto copy_noinline(InputIt begin, InputIt end,\n                                              OutputIt out) -> OutputIt {\n  return copy<OutChar>(begin, end, out);\n}\n\n// A public domain branchless UTF-8 decoder by Christopher Wellons:\n// https://github.com/skeeto/branchless-utf8\n/* Decode the next character, c, from s, reporting errors in e.\n *\n * Since this is a branchless decoder, four bytes will be read from the\n * buffer regardless of the actual length of the next character. This\n * means the buffer _must_ have at least three bytes of zero padding\n * following the end of the data stream.\n *\n * Errors are reported in e, which will be non-zero if the parsed\n * character was somehow invalid: invalid byte sequence, non-canonical\n * encoding, or a surrogate half.\n *\n * The function returns a pointer to the next character. When an error\n * occurs, this pointer will be a guess that depends on the particular\n * error, but it will always advance at least one byte.\n */\nFMT_CONSTEXPR inline auto utf8_decode(const char* s, uint32_t* c, int* e)\n    -> const char* {\n  constexpr int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07};\n  constexpr uint32_t mins[] = {4194304, 0, 128, 2048, 65536};\n  constexpr int shiftc[] = {0, 18, 12, 6, 0};\n  constexpr int shifte[] = {0, 6, 4, 2, 0};\n\n  int len = \"\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\1\\0\\0\\0\\0\\0\\0\\0\\0\\2\\2\\2\\2\\3\\3\\4\"\n      [static_cast<unsigned char>(*s) >> 3];\n  // Compute the pointer to the next character early so that the next\n  // iteration can start working on the next character. Neither Clang\n  // nor GCC figure out this reordering on their own.\n  const char* next = s + len + !len;\n\n  using uchar = unsigned char;\n\n  // Assume a four-byte character and load four bytes. Unused bits are\n  // shifted out.\n  *c = uint32_t(uchar(s[0]) & masks[len]) << 18;\n  *c |= uint32_t(uchar(s[1]) & 0x3f) << 12;\n  *c |= uint32_t(uchar(s[2]) & 0x3f) << 6;\n  *c |= uint32_t(uchar(s[3]) & 0x3f) << 0;\n  *c >>= shiftc[len];\n\n  // Accumulate the various error conditions.\n  *e = (*c < mins[len]) << 6;       // non-canonical encoding\n  *e |= ((*c >> 11) == 0x1b) << 7;  // surrogate half?\n  *e |= (*c > 0x10FFFF) << 8;       // out of range?\n  *e |= (uchar(s[1]) & 0xc0) >> 2;\n  *e |= (uchar(s[2]) & 0xc0) >> 4;\n  *e |= uchar(s[3]) >> 6;\n  *e ^= 0x2a;  // top two bits of each tail byte correct?\n  *e >>= shifte[len];\n\n  return next;\n}\n\nconstexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point = ~uint32_t();\n\n// Invokes f(cp, sv) for every code point cp in s with sv being the string view\n// corresponding to the code point. cp is invalid_code_point on error.\ntemplate <typename F>\nFMT_CONSTEXPR void for_each_codepoint(string_view s, F f) {\n  auto decode = [f](const char* buf_ptr, const char* ptr) {\n    auto cp = uint32_t();\n    auto error = 0;\n    auto end = utf8_decode(buf_ptr, &cp, &error);\n    bool result = f(error ? invalid_code_point : cp,\n                    string_view(ptr, error ? 1 : to_unsigned(end - buf_ptr)));\n    return result ? (error ? buf_ptr + 1 : end) : nullptr;\n  };\n\n  auto p = s.data();\n  const size_t block_size = 4;  // utf8_decode always reads blocks of 4 chars.\n  if (s.size() >= block_size) {\n    for (auto end = p + s.size() - block_size + 1; p < end;) {\n      p = decode(p, p);\n      if (!p) return;\n    }\n  }\n  auto num_chars_left = to_unsigned(s.data() + s.size() - p);\n  if (num_chars_left == 0) return;\n\n  // Suppress bogus -Wstringop-overflow.\n  if (FMT_GCC_VERSION) num_chars_left &= 3;\n  char buf[2 * block_size - 1] = {};\n  copy<char>(p, p + num_chars_left, buf);\n  const char* buf_ptr = buf;\n  do {\n    auto end = decode(buf_ptr, p);\n    if (!end) return;\n    p += end - buf_ptr;\n    buf_ptr = end;\n  } while (buf_ptr < buf + num_chars_left);\n}\n\nFMT_CONSTEXPR inline auto display_width_of(uint32_t cp) noexcept -> size_t {\n  return to_unsigned(\n      1 + (cp >= 0x1100 &&\n           (cp <= 0x115f ||  // Hangul Jamo init. consonants\n            cp == 0x2329 ||  // LEFT-POINTING ANGLE BRACKET\n            cp == 0x232a ||  // RIGHT-POINTING ANGLE BRACKET\n            // CJK ... Yi except IDEOGRAPHIC HALF FILL SPACE:\n            (cp >= 0x2e80 && cp <= 0xa4cf && cp != 0x303f) ||\n            (cp >= 0xac00 && cp <= 0xd7a3) ||    // Hangul Syllables\n            (cp >= 0xf900 && cp <= 0xfaff) ||    // CJK Compatibility Ideographs\n            (cp >= 0xfe10 && cp <= 0xfe19) ||    // Vertical Forms\n            (cp >= 0xfe30 && cp <= 0xfe6f) ||    // CJK Compatibility Forms\n            (cp >= 0xff00 && cp <= 0xff60) ||    // Fullwidth Forms\n            (cp >= 0xffe0 && cp <= 0xffe6) ||    // Fullwidth Forms\n            (cp >= 0x20000 && cp <= 0x2fffd) ||  // CJK\n            (cp >= 0x30000 && cp <= 0x3fffd) ||\n            // Miscellaneous Symbols and Pictographs + Emoticons:\n            (cp >= 0x1f300 && cp <= 0x1f64f) ||\n            // Supplemental Symbols and Pictographs:\n            (cp >= 0x1f900 && cp <= 0x1f9ff))));\n}\n\ntemplate <typename T> struct is_integral : std::is_integral<T> {};\ntemplate <> struct is_integral<native_int128> : std::true_type {};\ntemplate <> struct is_integral<uint128_t> : std::true_type {};\n\ntemplate <typename T>\nusing is_signed =\n    std::integral_constant<bool, std::numeric_limits<T>::is_signed ||\n                                     std::is_same<T, native_int128>::value>;\n\ntemplate <typename T>\nusing is_integer =\n    bool_constant<is_integral<T>::value && !std::is_same<T, bool>::value &&\n                  !std::is_same<T, char>::value &&\n                  !std::is_same<T, wchar_t>::value>;\n\n#if defined(FMT_USE_FLOAT128)\n// Use the provided definition.\n#elif FMT_CLANG_VERSION >= 309 && FMT_HAS_INCLUDE(<quadmath.h>)\n#  define FMT_USE_FLOAT128 1\n#elif FMT_GCC_VERSION && defined(_GLIBCXX_USE_FLOAT128) && \\\n    !defined(__STRICT_ANSI__)\n#  define FMT_USE_FLOAT128 1\n#else\n#  define FMT_USE_FLOAT128 0\n#endif\n#if FMT_USE_FLOAT128\nusing float128 = __float128;\n#else\nstruct float128 {};\n#endif\n\ntemplate <typename T> using is_float128 = std::is_same<T, float128>;\n\ntemplate <typename T> struct is_floating_point : std::is_floating_point<T> {};\ntemplate <> struct is_floating_point<float128> : std::true_type {};\n\ntemplate <typename T, bool = is_floating_point<T>::value>\nstruct is_fast_float : bool_constant<std::numeric_limits<T>::is_iec559 &&\n                                     sizeof(T) <= sizeof(double)> {};\ntemplate <typename T> struct is_fast_float<T, false> : std::false_type {};\n\ntemplate <typename T>\nusing fast_float_t = conditional_t<sizeof(T) == sizeof(double), double, float>;\n\ntemplate <typename T>\nusing is_double_double = bool_constant<std::numeric_limits<T>::digits == 106>;\n\nFMT_API auto allocate(size_t size) -> void*;\n\n// An allocator that uses malloc/free to allow removing dependency on the C++\n// standard library runtime. std::decay is used for back_inserter to be found by\n// ADL when applied to memory_buffer.\ntemplate <typename T> struct allocator : private std::decay<void> {\n  using value_type = T;\n\n  auto allocate(size_t n) -> T* {\n    FMT_ASSERT(n <= max_value<size_t>() / sizeof(T), \"\");\n    return static_cast<T*>(detail::allocate(n * sizeof(T)));\n  }\n\n  void deallocate(T* p, size_t) { free(p); }\n\n  constexpr friend auto operator==(allocator, allocator) noexcept -> bool {\n    return true;  // All instances of this allocator are equivalent.\n  }\n  constexpr friend auto operator!=(allocator, allocator) noexcept -> bool {\n    return false;\n  }\n};\n\ntemplate <typename Formatter>\nFMT_CONSTEXPR auto maybe_set_debug_format(Formatter& f, bool set)\n    -> decltype(f.set_debug_format(set)) {\n  f.set_debug_format(set);\n}\ntemplate <typename Formatter>\nFMT_CONSTEXPR void maybe_set_debug_format(Formatter&, ...) {}\n\n}  // namespace detail\n\nFMT_BEGIN_EXPORT\n\n// The number of characters to store in the basic_memory_buffer object itself\n// to avoid dynamic memory allocation.\nenum { inline_buffer_size = 500 };\n\n/**\n * A dynamically growing memory buffer for trivially copyable/constructible\n * types with the first `SIZE` elements stored in the object itself. Most\n * commonly used via the `memory_buffer` alias for `char`.\n *\n * **Example**:\n *\n *     auto out = fmt::memory_buffer();\n *     fmt::format_to(std::back_inserter(out), \"The answer is {}.\", 42);\n *\n * This will append \"The answer is 42.\" to `out`. The buffer content can be\n * converted to `std::string` with `to_string(out)`.\n */\ntemplate <typename T, size_t SIZE = inline_buffer_size,\n          typename Allocator = detail::allocator<T>>\nclass basic_memory_buffer : public detail::buffer<T> {\n private:\n  T store_[SIZE];\n\n  // Don't inherit from Allocator to avoid generating type_info for it.\n  FMT_NO_UNIQUE_ADDRESS Allocator alloc_;\n\n  // Deallocate memory allocated by the buffer.\n  FMT_CONSTEXPR20 void deallocate() {\n    T* data = this->data();\n    if (data != store_) alloc_.deallocate(data, this->capacity());\n  }\n\n  static FMT_CONSTEXPR20 void grow(detail::buffer<T>& buf, size_t size) {\n    detail::abort_fuzzing_if(size > 5000);\n    auto& self = static_cast<basic_memory_buffer&>(buf);\n    const size_t max_size =\n        std::allocator_traits<Allocator>::max_size(self.alloc_);\n    size_t old_capacity = buf.capacity();\n    size_t new_capacity = old_capacity + old_capacity / 2;\n    if (size > new_capacity)\n      new_capacity = size;\n    else if (new_capacity > max_size)\n      new_capacity = max_of(size, max_size);\n    T* old_data = buf.data();\n    T* new_data = self.alloc_.allocate(new_capacity);\n    // Suppress a bogus -Wstringop-overflow in gcc 13.1 (#3481).\n    detail::assume(buf.size() <= new_capacity);\n    // The following code doesn't throw, so the raw pointer above doesn't leak.\n    memcpy(new_data, old_data, buf.size() * sizeof(T));\n    self.set(new_data, new_capacity);\n    // deallocate must not throw according to the standard, but even if it does,\n    // the buffer already uses the new storage and will deallocate it in\n    // destructor.\n    if (old_data != self.store_) self.alloc_.deallocate(old_data, old_capacity);\n  }\n\n public:\n  using value_type = T;\n  using const_reference = const T&;\n\n  FMT_CONSTEXPR explicit basic_memory_buffer(\n      const Allocator& alloc = Allocator())\n      : detail::buffer<T>(grow), alloc_(alloc) {\n    this->set(store_, SIZE);\n    if (detail::is_constant_evaluated()) detail::fill_n(store_, SIZE, T());\n  }\n  FMT_CONSTEXPR20 ~basic_memory_buffer() { deallocate(); }\n\n private:\n  template <typename Alloc = Allocator,\n            FMT_ENABLE_IF(std::allocator_traits<Alloc>::\n                              propagate_on_container_move_assignment::value)>\n  FMT_CONSTEXPR20 auto move_alloc(basic_memory_buffer& other) -> bool {\n    alloc_ = std::move(other.alloc_);\n    return true;\n  }\n  // If the allocator does not propagate then copy the data from other.\n  template <typename Alloc = Allocator,\n            FMT_ENABLE_IF(!std::allocator_traits<Alloc>::\n                              propagate_on_container_move_assignment::value)>\n  FMT_CONSTEXPR20 auto move_alloc(basic_memory_buffer& other) -> bool {\n    T* data = other.data();\n    if (alloc_ == other.alloc_ || data == other.store_) return true;\n    size_t size = other.size();\n    // Perform copy operation, allocators are different.\n    this->resize(size);\n    detail::copy<T>(data, data + size, this->data());\n    return false;\n  }\n\n  // Move data from other to this buffer.\n  FMT_CONSTEXPR20 void move(basic_memory_buffer& other) {\n    T* data = other.data();\n    size_t size = other.size(), capacity = other.capacity();\n    if (!move_alloc(other)) return;\n    if (data == other.store_) {\n      this->set(store_, capacity);\n      detail::copy<T>(other.store_, other.store_ + size, store_);\n    } else {\n      this->set(data, capacity);\n      // Set pointer to the inline array so that delete is not called\n      // when deallocating.\n      other.set(other.store_, 0);\n      other.clear();\n    }\n    this->resize(size);\n  }\n\n public:\n  /// Constructs a `basic_memory_buffer` object moving the content of the other\n  /// object to it.\n  FMT_CONSTEXPR20 basic_memory_buffer(basic_memory_buffer&& other) noexcept\n      : detail::buffer<T>(grow) {\n    move(other);\n  }\n\n  /// Moves the content of the other `basic_memory_buffer` object to this one.\n  auto operator=(basic_memory_buffer&& other) noexcept -> basic_memory_buffer& {\n    FMT_ASSERT(this != &other, \"\");\n    deallocate();\n    move(other);\n    return *this;\n  }\n\n  // Returns a copy of the allocator associated with this buffer.\n  auto get_allocator() const -> Allocator { return alloc_; }\n\n  /// Resizes the buffer to contain `count` elements. If T is a POD type new\n  /// elements may not be initialized.\n  FMT_CONSTEXPR void resize(size_t count) { this->try_resize(count); }\n\n  /// Increases the buffer capacity to `new_capacity`.\n  void reserve(size_t new_capacity) { this->try_reserve(new_capacity); }\n\n  using detail::buffer<T>::append;\n  template <typename ContiguousRange>\n  FMT_CONSTEXPR20 void append(const ContiguousRange& range) {\n    append(range.data(), range.data() + range.size());\n  }\n};\n\nusing memory_buffer = basic_memory_buffer<char>;\n\ntemplate <size_t SIZE>\nFMT_NODISCARD auto to_string(const basic_memory_buffer<char, SIZE>& buf)\n    -> std::string {\n  auto size = buf.size();\n  detail::assume(size < std::string().max_size());\n  return {buf.data(), size};\n}\n\n// A writer to a buffered stream. It doesn't own the underlying stream.\nclass writer {\n private:\n  detail::buffer<char>* buf_;\n\n  // We cannot create a file buffer in advance because any write to a FILE may\n  // invalidate it.\n  FILE* file_;\n\n public:\n  inline writer(FILE* f) : buf_(nullptr), file_(f) {}\n  inline writer(detail::buffer<char>& buf) : buf_(&buf) {}\n\n  /// Formats `args` according to specifications in `fmt` and writes the\n  /// output to the file.\n  template <typename... T> void print(format_string<T...> fmt, T&&... args) {\n    if (buf_)\n      fmt::format_to(appender(*buf_), fmt, std::forward<T>(args)...);\n    else\n      fmt::print(file_, fmt, std::forward<T>(args)...);\n  }\n};\n\nclass string_buffer {\n private:\n  std::string str_;\n  detail::container_buffer<std::string> buf_;\n\n public:\n  inline string_buffer() : buf_(str_) {}\n\n  inline operator writer() { return buf_; }\n  inline auto str() -> std::string& { return str_; }\n};\n\ntemplate <typename T, size_t SIZE, typename Allocator>\nstruct is_contiguous<basic_memory_buffer<T, SIZE, Allocator>> : std::true_type {\n};\n\n// Suppress a misleading warning in older versions of clang.\nFMT_PRAGMA_CLANG(diagnostic ignored \"-Wweak-vtables\")\n\n/// An error reported from a formatting function.\nclass FMT_SO_VISIBILITY(\"default\") format_error : public std::runtime_error {\n public:\n  using std::runtime_error::runtime_error;\n};\n\nclass loc_value;\n\nFMT_END_EXPORT\nnamespace detail {\nFMT_API auto write_console(int fd, string_view text) -> bool;\nFMT_API void print(FILE*, string_view);\n}  // namespace detail\n\nnamespace detail {\ntemplate <typename Char, size_t N> struct fixed_string {\n  FMT_CONSTEXPR fixed_string(const Char (&s)[N]) {\n    detail::copy<Char, const Char*, Char*>(static_cast<const Char*>(s), s + N,\n                                           data);\n  }\n  Char data[N] = {};\n};\n\n// Converts a compile-time string to basic_string_view.\nFMT_EXPORT template <typename Char, size_t N>\nconstexpr auto compile_string_to_view(const Char (&s)[N])\n    -> basic_string_view<Char> {\n  // Remove trailing NUL character if needed. Won't be present if this is used\n  // with a raw character array (i.e. not defined as a string).\n  return {s, N - (std::char_traits<Char>::to_int_type(s[N - 1]) == 0 ? 1 : 0)};\n}\nFMT_EXPORT template <typename Char>\nconstexpr auto compile_string_to_view(basic_string_view<Char> s)\n    -> basic_string_view<Char> {\n  return s;\n}\n\n// Returns true if value is negative, false otherwise.\n// Same as `value < 0` but doesn't produce warnings if T is an unsigned type.\ntemplate <typename T, FMT_ENABLE_IF(is_signed<T>::value)>\nconstexpr auto is_negative(T value) -> bool {\n  return value < 0;\n}\ntemplate <typename T, FMT_ENABLE_IF(!is_signed<T>::value)>\nconstexpr auto is_negative(T) -> bool {\n  return false;\n}\n\n// Smallest of uint32_t, uint64_t, uint128_t that is large enough to\n// represent all values of an integral type T.\ntemplate <typename T>\nusing uint32_or_64_or_128_t =\n    conditional_t<num_bits<T>() <= 32 && !FMT_REDUCE_INT_INSTANTIATIONS,\n                  uint32_t,\n                  conditional_t<num_bits<T>() <= 64, uint64_t, uint128_t>>;\ntemplate <typename T>\nusing uint64_or_128_t = conditional_t<num_bits<T>() <= 64, uint64_t, uint128_t>;\n\n#define FMT_POWERS_OF_10(factor)                                  \\\n  factor * 10, (factor) * 100, (factor) * 1000, (factor) * 10000, \\\n      (factor) * 100000, (factor) * 1000000, (factor) * 10000000, \\\n      (factor) * 100000000, (factor) * 1000000000\n\n// Converts value in the range [0, 100) to a string. GCC generates a bit better\n// code when value is pointer-size (https://www.godbolt.org/z/5fEPMT1cc).\ninline auto digits2(size_t value) noexcept -> const char* {\n  // Align data since unaligned access may be slower when crossing a\n  // hardware-specific boundary.\n  alignas(2) static constexpr char data[] =\n      \"0001020304050607080910111213141516171819\"\n      \"2021222324252627282930313233343536373839\"\n      \"4041424344454647484950515253545556575859\"\n      \"6061626364656667686970717273747576777879\"\n      \"8081828384858687888990919293949596979899\";\n  return &data[value * 2];\n}\n\n// Given i in [0, 100), let x be the first 7 digits after\n// the decimal point of i / 100 in base 2, the first 2 bytes\n// after digits2_i(x) is the string representation of i.\ninline auto digits2_i(size_t value) noexcept -> const char* {\n  alignas(2) static constexpr char data[] =\n      \"00010203  0405060707080910  1112\"\n      \"131414151617  18192021  222324  \"\n      \"25262728  2930313232333435  3637\"\n      \"383939404142  43444546  474849  \"\n      \"50515253  5455565757585960  6162\"\n      \"636464656667  68697071  727374  \"\n      \"75767778  7980818282838485  8687\"\n      \"888989909192  93949596  979899  \";\n  return &data[value * 2];\n}\n\ntemplate <typename Char> constexpr auto getsign(sign s) -> Char {\n  return static_cast<Char>(static_cast<char>(\n      ((' ' << 24) | ('+' << 16) | ('-' << 8)) >> (static_cast<int>(s) * 8)));\n}\n\ntemplate <typename T> FMT_CONSTEXPR auto count_digits_fallback(T n) -> int {\n  int count = 1;\n  for (;;) {\n    // Integer division is slow so do it for a group of four digits instead\n    // of for every digit. The idea comes from the talk by Alexandrescu\n    // \"Three Optimization Tips for C++\". See speed-test for a comparison.\n    if (n < 10) return count;\n    if (n < 100) return count + 1;\n    if (n < 1000) return count + 2;\n    if (n < 10000) return count + 3;\n    n /= 10000u;\n    count += 4;\n  }\n}\n#if FMT_USE_INT128\nFMT_CONSTEXPR inline auto count_digits(native_uint128 n) -> int {\n  return count_digits_fallback(n);\n}\n#endif\n\n#ifdef FMT_BUILTIN_CLZLL\n// It is a separate function rather than a part of count_digits to workaround\n// the lack of static constexpr in constexpr functions.\ninline auto do_count_digits(uint64_t n) -> int {\n  // This has comparable performance to the version by Kendall Willets\n  // (https://github.com/fmtlib/format-benchmark/blob/master/digits10)\n  // but uses smaller tables.\n  // Maps bsr(n) to ceil(log10(pow(2, bsr(n) + 1) - 1)).\n  static constexpr uint8_t bsr2log10[] = {\n      1,  1,  1,  2,  2,  2,  3,  3,  3,  4,  4,  4,  4,  5,  5,  5,\n      6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  9,  9,  9,  10, 10, 10,\n      10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 15, 15,\n      15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 19, 20};\n  auto t = bsr2log10[FMT_BUILTIN_CLZLL(n | 1) ^ 63];\n  static constexpr uint64_t zero_or_powers_of_10[] = {\n      0, 0, FMT_POWERS_OF_10(1U), FMT_POWERS_OF_10(1000000000ULL),\n      10000000000000000000ULL};\n  return t - (n < zero_or_powers_of_10[t]);\n}\n#endif\n\n// Returns the number of decimal digits in n. Leading zeros are not counted\n// except for n == 0 in which case count_digits returns 1.\nFMT_CONSTEXPR20 inline auto count_digits(uint64_t n) -> int {\n#ifdef FMT_BUILTIN_CLZLL\n  if (!is_constant_evaluated() && !FMT_OPTIMIZE_SIZE) return do_count_digits(n);\n#endif\n  return count_digits_fallback(n);\n}\n\n// Counts the number of digits in n. BITS = log2(radix).\ntemplate <int BITS, typename UInt>\nFMT_CONSTEXPR auto count_digits(UInt n) -> int {\n#ifdef FMT_BUILTIN_CLZ\n  if (!is_constant_evaluated() && num_bits<UInt>() == 32)\n    return (FMT_BUILTIN_CLZ(static_cast<uint32_t>(n) | 1) ^ 31) / BITS + 1;\n#endif\n  // Lambda avoids unreachable code warnings from NVHPC.\n  return [](UInt m) {\n    int num_digits = 0;\n    do {\n      ++num_digits;\n    } while ((m >>= BITS) != 0);\n    return num_digits;\n  }(n);\n}\n\n#ifdef FMT_BUILTIN_CLZ\n// It is a separate function rather than a part of count_digits to workaround\n// the lack of static constexpr in constexpr functions.\nFMT_INLINE auto do_count_digits(uint32_t n) -> int {\n// An optimization by Kendall Willets from https://bit.ly/3uOIQrB.\n// This increments the upper 32 bits (log10(T) - 1) when >= T is added.\n#  define FMT_INC(T) (((sizeof(#T) - 1ull) << 32) - T)\n  static constexpr uint64_t table[] = {\n      FMT_INC(0),          FMT_INC(0),          FMT_INC(0),           // 8\n      FMT_INC(10),         FMT_INC(10),         FMT_INC(10),          // 64\n      FMT_INC(100),        FMT_INC(100),        FMT_INC(100),         // 512\n      FMT_INC(1000),       FMT_INC(1000),       FMT_INC(1000),        // 4096\n      FMT_INC(10000),      FMT_INC(10000),      FMT_INC(10000),       // 32k\n      FMT_INC(100000),     FMT_INC(100000),     FMT_INC(100000),      // 256k\n      FMT_INC(1000000),    FMT_INC(1000000),    FMT_INC(1000000),     // 2048k\n      FMT_INC(10000000),   FMT_INC(10000000),   FMT_INC(10000000),    // 16M\n      FMT_INC(100000000),  FMT_INC(100000000),  FMT_INC(100000000),   // 128M\n      FMT_INC(1000000000), FMT_INC(1000000000), FMT_INC(1000000000),  // 1024M\n      FMT_INC(1000000000), FMT_INC(1000000000)                        // 4B\n  };\n  auto inc = table[FMT_BUILTIN_CLZ(n | 1) ^ 31];\n  return static_cast<int>((n + inc) >> 32);\n}\n#endif\n\n// Optional version of count_digits for better performance on 32-bit platforms.\nFMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int {\n#ifdef FMT_BUILTIN_CLZ\n  if (!is_constant_evaluated() && !FMT_OPTIMIZE_SIZE) return do_count_digits(n);\n#endif\n  return count_digits_fallback(n);\n}\n\ntemplate <typename Int> constexpr auto digits10() noexcept -> int {\n  return std::numeric_limits<Int>::digits10;\n}\ntemplate <> constexpr auto digits10<native_int128>() noexcept -> int {\n  return 38;\n}\ntemplate <> constexpr auto digits10<uint128_t>() noexcept -> int { return 38; }\n\ntemplate <typename Char> struct thousands_sep_result {\n  std::string grouping;\n  Char thousands_sep;\n};\n\ntemplate <typename Char>\nFMT_API auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result<Char>;\ntemplate <typename Char>\ninline auto thousands_sep(locale_ref loc) -> thousands_sep_result<Char> {\n  auto result = thousands_sep_impl<char>(loc);\n  return {std::move(result.grouping), Char(result.thousands_sep)};\n}\ntemplate <>\ninline auto thousands_sep(locale_ref loc) -> thousands_sep_result<wchar_t> {\n  return thousands_sep_impl<wchar_t>(loc);\n}\n\ntemplate <typename Char>\nFMT_API auto decimal_point_impl(locale_ref loc) -> Char;\ntemplate <typename Char> inline auto decimal_point(locale_ref loc) -> Char {\n  return Char(decimal_point_impl<char>(loc));\n}\ntemplate <> inline auto decimal_point(locale_ref loc) -> wchar_t {\n  return decimal_point_impl<wchar_t>(loc);\n}\n\n#ifndef FMT_HEADER_ONLY\nFMT_BEGIN_EXPORT\nextern template FMT_API auto thousands_sep_impl<char>(locale_ref)\n    -> thousands_sep_result<char>;\nextern template FMT_API auto thousands_sep_impl<wchar_t>(locale_ref)\n    -> thousands_sep_result<wchar_t>;\nextern template FMT_API auto decimal_point_impl(locale_ref) -> char;\nextern template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t;\nFMT_END_EXPORT\n#endif  // FMT_HEADER_ONLY\n\n// Compares two characters for equality.\ntemplate <typename Char> auto equal2(const Char* lhs, const char* rhs) -> bool {\n  return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]);\n}\ninline auto equal2(const char* lhs, const char* rhs) -> bool {\n  return memcmp(lhs, rhs, 2) == 0;\n}\n\n// Writes a two-digit value to out.\ntemplate <typename Char>\nFMT_CONSTEXPR20 FMT_INLINE void write2digits(Char* out, size_t value) {\n  if (!is_constant_evaluated() && std::is_same<Char, char>::value &&\n      !FMT_OPTIMIZE_SIZE) {\n    memcpy(out, digits2(value), 2);\n    return;\n  }\n  *out++ = static_cast<Char>('0' + value / 10);\n  *out = static_cast<Char>('0' + value % 10);\n}\n\ntemplate <typename Char>\nFMT_INLINE void write2digits_i(Char* out, size_t value) {\n  if (std::is_same<Char, char>::value && !FMT_OPTIMIZE_SIZE) {\n    memcpy(out, digits2_i(value), 2);\n    return;\n  }\n  *out++ = static_cast<Char>(digits2_i(value)[0]);\n  *out = static_cast<Char>(digits2_i(value)[1]);\n}\n\n// Formats a decimal unsigned integer value writing to out pointing to a buffer\n// of specified size. The caller must ensure that the buffer is large enough.\ntemplate <typename Char, typename UInt>\nFMT_CONSTEXPR20 auto do_format_decimal(Char* out, UInt value, int size)\n    -> Char* {\n  FMT_ASSERT(size >= count_digits(value), \"invalid digit count\");\n  unsigned n = to_unsigned(size);\n  while (value >= 100) {\n    n -= 2;\n    if (!is_constant_evaluated() && sizeof(UInt) == 4) {\n      auto p = value * static_cast<uint64_t>((1ull << 39) / 100 + 1);\n      write2digits_i(out + n, p >> (39 - 7) & ((1 << 7) - 1));\n      value = static_cast<UInt>(p >> 39) +\n              (static_cast<UInt>(value >= (100u << 25)) << 25);\n    } else {\n      // Integer division is slow so do it for a group of two digits instead\n      // of for every digit. The idea comes from the talk by Alexandrescu\n      // \"Three Optimization Tips for C++\". See speed-test for a comparison.\n      write2digits(out + n, static_cast<unsigned>(value % 100));\n      value /= 100;\n    }\n  }\n  if (value >= 10) {\n    n -= 2;\n    write2digits(out + n, static_cast<unsigned>(value));\n  } else {\n    out[--n] = static_cast<Char>('0' + value);\n  }\n  return out + n;\n}\n\ntemplate <typename Char, typename UInt>\nFMT_CONSTEXPR FMT_INLINE auto format_decimal(Char* out, UInt value,\n                                             int num_digits) -> Char* {\n  do_format_decimal(out, value, num_digits);\n  return out + num_digits;\n}\n\ntemplate <typename Char, typename UInt, typename OutputIt,\n          FMT_ENABLE_IF(!std::is_pointer<remove_cvref_t<OutputIt>>::value)>\nFMT_CONSTEXPR auto format_decimal(OutputIt out, UInt value, int num_digits)\n    -> OutputIt {\n  if (auto ptr = to_pointer<Char>(out, to_unsigned(num_digits))) {\n    do_format_decimal(ptr, value, num_digits);\n    return out;\n  }\n  // Buffer is large enough to hold all digits (digits10 + 1).\n  char buffer[digits10<UInt>() + 1];\n  if (is_constant_evaluated()) fill_n(buffer, sizeof(buffer), '\\0');\n  do_format_decimal(buffer, value, num_digits);\n  return copy_noinline<Char>(buffer, buffer + num_digits, out);\n}\n\ntemplate <typename Char, typename UInt>\nFMT_CONSTEXPR auto do_format_base2e(int base_bits, Char* out, UInt value,\n                                    int size, bool upper = false) -> Char* {\n  out += size;\n  do {\n    const char* digits = upper ? \"0123456789ABCDEF\" : \"0123456789abcdef\";\n    unsigned digit = static_cast<unsigned>(value & ((1u << base_bits) - 1));\n    *--out = static_cast<Char>(base_bits < 4 ? static_cast<char>('0' + digit)\n                                             : digits[digit]);\n  } while ((value >>= base_bits) != 0);\n  return out;\n}\n\n// Formats an unsigned integer in the power of two base (binary, octal, hex).\ntemplate <typename Char, typename UInt>\nFMT_CONSTEXPR auto format_base2e(int base_bits, Char* out, UInt value,\n                                 int num_digits, bool upper = false) -> Char* {\n  do_format_base2e(base_bits, out, value, num_digits, upper);\n  return out + num_digits;\n}\n\ntemplate <typename Char, typename OutputIt, typename UInt,\n          FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>\nFMT_CONSTEXPR inline auto format_base2e(int base_bits, OutputIt out, UInt value,\n                                        int num_digits, bool upper = false)\n    -> OutputIt {\n  if (auto ptr = to_pointer<Char>(out, to_unsigned(num_digits))) {\n    format_base2e(base_bits, ptr, value, num_digits, upper);\n    return out;\n  }\n  // Make buffer large enough for any base.\n  char buffer[num_bits<UInt>()];\n  if (is_constant_evaluated()) fill_n(buffer, sizeof(buffer), '\\0');\n  format_base2e(base_bits, buffer, value, num_digits, upper);\n  return detail::copy_noinline<Char>(buffer, buffer + num_digits, out);\n}\n\n// A converter from UTF-8 to UTF-16.\nclass utf8_to_utf16 {\n private:\n  basic_memory_buffer<wchar_t> buffer_;\n\n public:\n  FMT_API explicit utf8_to_utf16(string_view s);\n  inline operator basic_string_view<wchar_t>() const {\n    return {&buffer_[0], size()};\n  }\n  inline auto size() const -> size_t { return buffer_.size() - 1; }\n  inline auto c_str() const -> const wchar_t* { return &buffer_[0]; }\n  inline auto str() const -> std::wstring { return {&buffer_[0], size()}; }\n};\n\nenum class to_utf8_error_policy { abort, replace, wtf };\n\ninline void to_utf8_3bytes(buffer<char>& buf, uint32_t cp) {\n  buf.push_back(static_cast<char>(0xe0 | (cp >> 12)));\n  buf.push_back(static_cast<char>(0x80 | ((cp & 0xfff) >> 6)));\n  buf.push_back(static_cast<char>(0x80 | (cp & 0x3f)));\n}\n\n// A converter from UTF-16/UTF-32 (host endian) to UTF-8.\ntemplate <typename WChar, typename Buffer = memory_buffer> class to_utf8 {\n private:\n  Buffer buffer_;\n\n public:\n  to_utf8() {}\n  explicit to_utf8(basic_string_view<WChar> s,\n                   to_utf8_error_policy policy = to_utf8_error_policy::abort) {\n    static_assert(sizeof(WChar) == 2 || sizeof(WChar) == 4,\n                  \"expected utf16 or utf32\");\n    if (!convert(s, policy)) {\n      FMT_THROW(std::runtime_error(sizeof(WChar) == 2 ? \"invalid utf16\"\n                                                      : \"invalid utf32\"));\n    }\n  }\n  operator string_view() const { return string_view(&buffer_[0], size()); }\n  auto size() const -> size_t { return buffer_.size() - 1; }\n  auto c_str() const -> const char* { return &buffer_[0]; }\n  auto str() const -> std::string { return std::string(&buffer_[0], size()); }\n\n  // Performs conversion returning a bool instead of throwing exception on\n  // conversion error. This method may still throw in case of memory allocation\n  // error.\n  auto convert(basic_string_view<WChar> s,\n               to_utf8_error_policy policy = to_utf8_error_policy::abort)\n      -> bool {\n    if (!convert(buffer_, s, policy)) return false;\n    buffer_.push_back(0);\n    return true;\n  }\n  static auto convert(Buffer& buf, basic_string_view<WChar> s,\n                      to_utf8_error_policy policy = to_utf8_error_policy::abort)\n      -> bool {\n    for (auto p = s.begin(); p != s.end(); ++p) {\n      uint32_t c = static_cast<uint32_t>(*p);\n      if (sizeof(WChar) == 2 && c >= 0xd800 && c <= 0xdfff) {\n        // Handle a surrogate pair.\n        ++p;\n        if (p == s.end() || (c & 0xfc00) != 0xd800 || (*p & 0xfc00) != 0xdc00) {\n          switch (policy) {\n          case to_utf8_error_policy::abort: return false;\n          case to_utf8_error_policy::replace:\n            buf.append(string_view(\"\\xEF\\xBF\\xBD\"));\n            break;\n          case to_utf8_error_policy::wtf: to_utf8_3bytes(buf, c); break;\n          }\n          --p;\n          continue;\n        }\n        c = (c << 10) + static_cast<uint32_t>(*p) - 0x35fdc00;\n      }\n      if (c < 0x80) {\n        buf.push_back(static_cast<char>(c));\n      } else if (c < 0x800) {\n        buf.push_back(static_cast<char>(0xc0 | (c >> 6)));\n        buf.push_back(static_cast<char>(0x80 | (c & 0x3f)));\n      } else if ((c >= 0x800 && c <= 0xd7ff) || (c >= 0xe000 && c <= 0xffff)) {\n        to_utf8_3bytes(buf, c);\n      } else if (c >= 0x10000 && c <= 0x10ffff) {\n        buf.push_back(static_cast<char>(0xf0 | (c >> 18)));\n        buf.push_back(static_cast<char>(0x80 | ((c & 0x3ffff) >> 12)));\n        buf.push_back(static_cast<char>(0x80 | ((c & 0xfff) >> 6)));\n        buf.push_back(static_cast<char>(0x80 | (c & 0x3f)));\n      } else {\n        return false;\n      }\n    }\n    return true;\n  }\n};\n\n// Computes 128-bit result of multiplication of two 64-bit unsigned integers.\nFMT_INLINE auto umul128(uint64_t x, uint64_t y) noexcept -> uint128 {\n#if FMT_USE_INT128\n  auto p = static_cast<native_uint128>(x) * static_cast<native_uint128>(y);\n  return {static_cast<uint64_t>(p >> 64), static_cast<uint64_t>(p)};\n#elif defined(_MSC_VER) && defined(_M_AMD64)\n  auto hi = uint64_t();\n  auto lo = _umul128(x, y, &hi);\n  return {hi, lo};\n#else\n  const uint64_t mask = static_cast<uint64_t>(max_value<uint32_t>());\n\n  uint64_t a = x >> 32;\n  uint64_t b = x & mask;\n  uint64_t c = y >> 32;\n  uint64_t d = y & mask;\n\n  uint64_t ac = a * c;\n  uint64_t bc = b * c;\n  uint64_t ad = a * d;\n  uint64_t bd = b * d;\n\n  uint64_t intermediate = (bd >> 32) + (ad & mask) + (bc & mask);\n\n  return {ac + (intermediate >> 32) + (ad >> 32) + (bc >> 32),\n          (intermediate << 32) + (bd & mask)};\n#endif\n}\n\nnamespace dragonbox {\n// Computes floor(log10(pow(2, e))) for e in [-2620, 2620] using the method from\n// https://fmt.dev/papers/Dragonbox.pdf#page=28, section 6.1.\ninline auto floor_log10_pow2(int e) noexcept -> int {\n  FMT_ASSERT(e <= 2620 && e >= -2620, \"too large exponent\");\n  static_assert((-1 >> 1) == -1, \"right shift is not arithmetic\");\n  return (e * 315653) >> 20;\n}\n\ninline auto floor_log2_pow10(int e) noexcept -> int {\n  FMT_ASSERT(e <= 1233 && e >= -1233, \"too large exponent\");\n  return (e * 1741647) >> 19;\n}\n\n// Computes upper 64 bits of multiplication of two 64-bit unsigned integers.\ninline auto umul128_upper64(uint64_t x, uint64_t y) noexcept -> uint64_t {\n#if FMT_USE_INT128\n  auto p = static_cast<native_uint128>(x) * static_cast<native_uint128>(y);\n  return static_cast<uint64_t>(p >> 64);\n#elif defined(_MSC_VER) && defined(_M_AMD64)\n  return __umulh(x, y);\n#else\n  return umul128(x, y).high();\n#endif\n}\n\n// Computes upper 128 bits of multiplication of a 64-bit unsigned integer and a\n// 128-bit unsigned integer.\ninline auto umul192_upper128(uint64_t x, uint128 y) noexcept -> uint128 {\n  uint128 r = umul128(x, y.high());\n  r += umul128_upper64(x, y.low());\n  return r;\n}\n\nFMT_API auto get_cached_power(int k) noexcept -> uint128;\n\n// Type-specific information that Dragonbox uses.\ntemplate <typename T, typename Enable = void> struct float_info;\n\ntemplate <> struct float_info<float> {\n  using carrier_uint = uint32_t;\n  static constexpr int exponent_bits = 8;\n  static constexpr int kappa = 1;\n  static constexpr int big_divisor = 100;\n  static constexpr int small_divisor = 10;\n  static constexpr int min_k = -31;\n  enum { max_k = 46 };\n  static constexpr int shorter_interval_tie_lower_threshold = -35;\n  static constexpr int shorter_interval_tie_upper_threshold = -35;\n};\n\ntemplate <> struct float_info<double> {\n  using carrier_uint = uint64_t;\n  static constexpr int exponent_bits = 11;\n  static constexpr int kappa = 2;\n  static constexpr int big_divisor = 1000;\n  static constexpr int small_divisor = 100;\n  static constexpr int min_k = -292;\n  enum { max_k = 341 };\n  static constexpr int shorter_interval_tie_lower_threshold = -77;\n  static constexpr int shorter_interval_tie_upper_threshold = -77;\n};\n\n// An 80- or 128-bit floating point number.\ntemplate <typename T>\nstruct float_info<T, enable_if_t<std::numeric_limits<T>::digits == 64 ||\n                                 std::numeric_limits<T>::digits == 113 ||\n                                 is_float128<T>::value>> {\n  using carrier_uint = detail::uint128_t;\n  static const int exponent_bits = 15;\n};\n\n// A double-double floating point number.\ntemplate <typename T>\nstruct float_info<T, enable_if_t<is_double_double<T>::value>> {\n  using carrier_uint = detail::uint128_t;\n};\n\ntemplate <typename T> struct decimal_fp {\n  using significand_type = typename float_info<T>::carrier_uint;\n  significand_type significand;\n  int exponent;\n};\n\ntemplate <typename T> FMT_API auto to_decimal(T x) noexcept -> decimal_fp<T>;\n}  // namespace dragonbox\n\n// Returns true iff Float has the implicit bit which is not stored.\ntemplate <typename Float> constexpr auto has_implicit_bit() -> bool {\n  // An 80-bit FP number has a 64-bit significand an no implicit bit.\n  return std::numeric_limits<Float>::digits != 64;\n}\n\n// Returns the number of significand bits stored in Float. The implicit bit is\n// not counted since it is not stored.\ntemplate <typename Float> constexpr auto num_significand_bits() -> int {\n  // std::numeric_limits may not support __float128.\n  return is_float128<Float>() ? 112\n                              : (std::numeric_limits<Float>::digits -\n                                 (has_implicit_bit<Float>() ? 1 : 0));\n}\n\ntemplate <typename Float>\nconstexpr auto exponent_mask() ->\n    typename dragonbox::float_info<Float>::carrier_uint {\n  using float_uint = typename dragonbox::float_info<Float>::carrier_uint;\n  return ((float_uint(1) << dragonbox::float_info<Float>::exponent_bits) - 1)\n         << num_significand_bits<Float>();\n}\ntemplate <typename Float> constexpr auto exponent_bias() -> int {\n  // std::numeric_limits may not support __float128.\n  return is_float128<Float>() ? 16383\n                              : std::numeric_limits<Float>::max_exponent - 1;\n}\n\nFMT_CONSTEXPR inline auto compute_exp_size(int exp) -> int {\n  auto prefix_size = 2;  // sign + 'e'\n  auto abs_exp = exp >= 0 ? exp : -exp;\n  if (abs_exp < 100) return prefix_size + 2;\n  return prefix_size + (abs_exp >= 1000 ? 4 : 3);\n}\n\n// Writes the exponent exp in the form \"[+-]d{2,3}\" to buffer.\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write_exponent(int exp, OutputIt out) -> OutputIt {\n  FMT_ASSERT(-10000 < exp && exp < 10000, \"exponent out of range\");\n  if (exp < 0) {\n    *out++ = static_cast<Char>('-');\n    exp = -exp;\n  } else {\n    *out++ = static_cast<Char>('+');\n  }\n  auto uexp = static_cast<uint32_t>(exp);\n  if (is_constant_evaluated()) {\n    if (uexp < 10) *out++ = '0';\n    return format_decimal<Char>(out, uexp, count_digits(uexp));\n  }\n  if (uexp >= 100u) {\n    const char* top = digits2(uexp / 100);\n    if (uexp >= 1000u) *out++ = static_cast<Char>(top[0]);\n    *out++ = static_cast<Char>(top[1]);\n    uexp %= 100;\n  }\n  const char* d = digits2(uexp);\n  *out++ = static_cast<Char>(d[0]);\n  *out++ = static_cast<Char>(d[1]);\n  return out;\n}\n\n// A floating-point number f * pow(2, e) where F is an unsigned type.\ntemplate <typename F> struct basic_fp {\n  F f;\n  int e;\n\n  static constexpr int num_significand_bits =\n      static_cast<int>(sizeof(F) * num_bits<unsigned char>());\n\n  constexpr basic_fp() : f(0), e(0) {}\n  constexpr basic_fp(uint64_t f_val, int e_val) : f(f_val), e(e_val) {}\n\n  // Constructs fp from an IEEE754 floating-point number.\n  template <typename Float> FMT_CONSTEXPR basic_fp(Float n) { assign(n); }\n\n  // Assigns n to this and return true iff predecessor is closer than successor.\n  template <typename Float, FMT_ENABLE_IF(!is_double_double<Float>::value)>\n  FMT_CONSTEXPR auto assign(Float n) -> bool {\n    static_assert(std::numeric_limits<Float>::digits <= 113, \"unsupported FP\");\n    // Assume Float is in the format [sign][exponent][significand].\n    using carrier_uint = typename dragonbox::float_info<Float>::carrier_uint;\n    const auto num_float_significand_bits =\n        detail::num_significand_bits<Float>();\n    const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;\n    const auto significand_mask = implicit_bit - 1;\n    auto u = bit_cast<carrier_uint>(n);\n    f = static_cast<F>(u & significand_mask);\n    auto biased_e = static_cast<int>((u & exponent_mask<Float>()) >>\n                                     num_float_significand_bits);\n    // The predecessor is closer if n is a normalized power of 2 (f == 0)\n    // other than the smallest normalized number (biased_e > 1).\n    auto is_predecessor_closer = f == 0 && biased_e > 1;\n    if (biased_e == 0)\n      biased_e = 1;  // Subnormals use biased exponent 1 (min exponent).\n    else if (has_implicit_bit<Float>())\n      f += static_cast<F>(implicit_bit);\n    e = biased_e - exponent_bias<Float>() - num_float_significand_bits;\n    if (!has_implicit_bit<Float>()) ++e;\n    return is_predecessor_closer;\n  }\n\n  template <typename Float, FMT_ENABLE_IF(is_double_double<Float>::value)>\n  FMT_CONSTEXPR auto assign(Float n) -> bool {\n    static_assert(std::numeric_limits<double>::is_iec559, \"unsupported FP\");\n    return assign(static_cast<double>(n));\n  }\n};\n\nusing fp = basic_fp<ullong>;\n\n// Normalizes the value converted from double and multiplied by (1 << SHIFT).\ntemplate <int SHIFT = 0, typename F>\nFMT_CONSTEXPR auto normalize(basic_fp<F> value) -> basic_fp<F> {\n  // Handle subnormals.\n  const auto implicit_bit = F(1) << num_significand_bits<double>();\n  const auto shifted_implicit_bit = implicit_bit << SHIFT;\n  while ((value.f & shifted_implicit_bit) == 0) {\n    value.f <<= 1;\n    --value.e;\n  }\n  // Subtract 1 to account for hidden bit.\n  const auto offset = basic_fp<F>::num_significand_bits -\n                      num_significand_bits<double>() - SHIFT - 1;\n  value.f <<= offset;\n  value.e -= offset;\n  return value;\n}\n\n// Computes lhs * rhs / pow(2, 64) rounded to nearest with half-up tie breaking.\nFMT_CONSTEXPR inline auto multiply(uint64_t lhs, uint64_t rhs) -> uint64_t {\n#if FMT_USE_INT128\n  auto product = static_cast<__uint128_t>(lhs) * rhs;\n  auto f = static_cast<uint64_t>(product >> 64);\n  return (static_cast<uint64_t>(product) & (1ULL << 63)) != 0 ? f + 1 : f;\n#else\n  // Multiply 32-bit parts of significands.\n  uint64_t mask = (1ULL << 32) - 1;\n  uint64_t a = lhs >> 32, b = lhs & mask;\n  uint64_t c = rhs >> 32, d = rhs & mask;\n  uint64_t ac = a * c, bc = b * c, ad = a * d, bd = b * d;\n  // Compute mid 64-bit of result and round.\n  uint64_t mid = (bd >> 32) + (ad & mask) + (bc & mask) + (1U << 31);\n  return ac + (ad >> 32) + (bc >> 32) + (mid >> 32);\n#endif\n}\n\nFMT_CONSTEXPR inline auto operator*(fp x, fp y) -> fp {\n  return {multiply(x.f, y.f), x.e + y.e + 64};\n}\n\ntemplate <typename T, bool doublish = num_bits<T>() == num_bits<double>()>\nusing convert_float_result =\n    conditional_t<std::is_same<T, float>::value || doublish, double, T>;\n\ntemplate <typename T>\nconstexpr auto convert_float(T value) -> convert_float_result<T> {\n  return static_cast<convert_float_result<T>>(value);\n}\n\ntemplate <bool C, typename T, typename F, FMT_ENABLE_IF(C)>\nauto select(T true_value, F) -> T {\n  return true_value;\n}\ntemplate <bool C, typename T, typename F, FMT_ENABLE_IF(!C)>\nauto select(T, F false_value) -> F {\n  return false_value;\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR FMT_NOINLINE auto fill(OutputIt it, size_t n,\n                                     const basic_specs& specs) -> OutputIt {\n  auto fill_size = specs.fill_size();\n  if (fill_size == 1) return detail::fill_n(it, n, specs.fill_unit<Char>());\n  if (const Char* data = specs.fill<Char>()) {\n    for (size_t i = 0; i < n; ++i) it = copy<Char>(data, data + fill_size, it);\n  }\n  return it;\n}\n\n// Writes the output of f, padded according to format specifications in specs.\n// size: output size in code units.\n// width: output display width in (terminal) column positions.\ntemplate <typename Char, align default_align = align::left, typename OutputIt,\n          typename F>\nFMT_CONSTEXPR auto write_padded(OutputIt out, const format_specs& specs,\n                                size_t size, size_t width, F&& f) -> OutputIt {\n  static_assert(default_align == align::left || default_align == align::right,\n                \"\");\n  unsigned spec_width = to_unsigned(specs.width);\n  size_t padding = spec_width > width ? spec_width - width : 0;\n  // Shifts are encoded as string literals because static constexpr is not\n  // supported in constexpr functions.\n  auto* shifts =\n      default_align == align::left ? \"\\x1f\\x1f\\x00\\x01\" : \"\\x00\\x1f\\x00\\x01\";\n  size_t left_padding = padding >> shifts[static_cast<int>(specs.align())];\n  size_t right_padding = padding - left_padding;\n  auto it = reserve(out, size + padding * specs.fill_size());\n  if (left_padding != 0) it = fill<Char>(it, left_padding, specs);\n  it = f(it);\n  if (right_padding != 0) it = fill<Char>(it, right_padding, specs);\n  return base_iterator(out, it);\n}\n\ntemplate <typename Char, align default_align = align::left, typename OutputIt,\n          typename F>\nconstexpr auto write_padded(OutputIt out, const format_specs& specs,\n                            size_t size, F&& f) -> OutputIt {\n  return write_padded<Char, default_align>(out, specs, size, size, f);\n}\n\ntemplate <typename Char, align default_align = align::left, typename OutputIt>\nFMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes,\n                               const format_specs& specs = {}) -> OutputIt {\n  return write_padded<Char, default_align>(\n      out, specs, bytes.size(), [bytes](reserve_iterator<OutputIt> it) {\n        const char* data = bytes.data();\n        return copy<Char>(data, data + bytes.size(), it);\n      });\n}\n\ntemplate <typename Char, typename OutputIt, typename UIntPtr>\nauto write_ptr(OutputIt out, UIntPtr value, const format_specs* specs)\n    -> OutputIt {\n  int num_digits = count_digits<4>(value);\n  auto size = to_unsigned(num_digits) + size_t(2);\n  auto write = [=](reserve_iterator<OutputIt> it) {\n    *it++ = static_cast<Char>('0');\n    *it++ = static_cast<Char>('x');\n    return format_base2e<Char>(4, it, value, num_digits);\n  };\n  return specs ? write_padded<Char, align::right>(out, *specs, size, write)\n               : base_iterator(out, write(reserve(out, size)));\n}\n\n// Returns true iff the code point cp is printable.\nFMT_API auto is_printable(uint32_t cp) -> bool;\n\ninline auto needs_escape(uint32_t cp) -> bool {\n  if (cp < 0x20 || cp == 0x7f || cp == '\"' || cp == '\\\\') return true;\n  if FMT_CONSTEXPR20 (FMT_OPTIMIZE_SIZE > 1) return false;\n  return !is_printable(cp);\n}\n\ntemplate <typename Char> struct find_escape_result {\n  const Char* begin;\n  const Char* end;\n  uint32_t cp;\n};\n\ntemplate <typename Char>\nauto find_escape(const Char* begin, const Char* end)\n    -> find_escape_result<Char> {\n  for (; begin != end; ++begin) {\n    uint32_t cp = static_cast<unsigned_char<Char>>(*begin);\n    if (sizeof(Char) == 1 && cp >= 0x80) continue;\n    if (needs_escape(cp)) return {begin, begin + 1, cp};\n  }\n  return {begin, nullptr, 0};\n}\n\ninline auto find_escape(const char* begin, const char* end)\n    -> find_escape_result<char> {\n  if FMT_CONSTEXPR20 (!use_utf8) return find_escape<char>(begin, end);\n  auto result = find_escape_result<char>{end, nullptr, 0};\n  for_each_codepoint(string_view(begin, to_unsigned(end - begin)),\n                     [&](uint32_t cp, string_view sv) {\n                       if (needs_escape(cp)) {\n                         result = {sv.begin(), sv.end(), cp};\n                         return false;\n                       }\n                       return true;\n                     });\n  return result;\n}\n\ntemplate <size_t width, typename Char, typename OutputIt>\nauto write_codepoint(OutputIt out, char prefix, uint32_t cp) -> OutputIt {\n  *out++ = static_cast<Char>('\\\\');\n  *out++ = static_cast<Char>(prefix);\n  Char buf[width];\n  fill_n(buf, width, static_cast<Char>('0'));\n  format_base2e(4, buf, cp, width);\n  return copy<Char>(buf, buf + width, out);\n}\n\ntemplate <typename OutputIt, typename Char>\nauto write_escaped_cp(OutputIt out, const find_escape_result<Char>& escape)\n    -> OutputIt {\n  auto c = static_cast<Char>(escape.cp);\n  switch (escape.cp) {\n  case '\\n':\n    *out++ = static_cast<Char>('\\\\');\n    c = static_cast<Char>('n');\n    break;\n  case '\\r':\n    *out++ = static_cast<Char>('\\\\');\n    c = static_cast<Char>('r');\n    break;\n  case '\\t':\n    *out++ = static_cast<Char>('\\\\');\n    c = static_cast<Char>('t');\n    break;\n  case '\"':  FMT_FALLTHROUGH;\n  case '\\'': FMT_FALLTHROUGH;\n  case '\\\\': *out++ = static_cast<Char>('\\\\'); break;\n  default:\n    if (escape.cp < 0x100) return write_codepoint<2, Char>(out, 'x', escape.cp);\n    if (escape.cp < 0x10000)\n      return write_codepoint<4, Char>(out, 'u', escape.cp);\n    if (escape.cp < 0x110000)\n      return write_codepoint<8, Char>(out, 'U', escape.cp);\n    for (Char escape_char : basic_string_view<Char>(\n             escape.begin, to_unsigned(escape.end - escape.begin))) {\n      out = write_codepoint<2, Char>(out, 'x',\n                                     static_cast<uint32_t>(escape_char) & 0xFF);\n    }\n    return out;\n  }\n  *out++ = c;\n  return out;\n}\n\ntemplate <typename Char, typename OutputIt>\nauto write_escaped_string(OutputIt out, basic_string_view<Char> str)\n    -> OutputIt {\n  *out++ = static_cast<Char>('\"');\n  auto begin = str.begin(), end = str.end();\n  do {\n    auto escape = find_escape(begin, end);\n    out = copy<Char>(begin, escape.begin, out);\n    begin = escape.end;\n    if (!begin) break;\n    out = write_escaped_cp<OutputIt, Char>(out, escape);\n  } while (begin != end);\n  *out++ = static_cast<Char>('\"');\n  return out;\n}\n\ntemplate <typename Char, typename OutputIt>\nauto write_escaped_char(OutputIt out, Char v) -> OutputIt {\n  Char v_array[1] = {v};\n  *out++ = static_cast<Char>('\\'');\n  if ((needs_escape(static_cast<uint32_t>(v)) && v != static_cast<Char>('\"')) ||\n      v == static_cast<Char>('\\'')) {\n    out = write_escaped_cp(out,\n                           find_escape_result<Char>{v_array, v_array + 1,\n                                                    static_cast<uint32_t>(v)});\n  } else {\n    *out++ = v;\n  }\n  *out++ = static_cast<Char>('\\'');\n  return out;\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write_char(OutputIt out, Char value,\n                              const format_specs& specs) -> OutputIt {\n  bool is_debug = specs.type() == presentation_type::debug;\n  return write_padded<Char>(out, specs, 1, [=](reserve_iterator<OutputIt> it) {\n    if (is_debug) return write_escaped_char(it, value);\n    *it++ = value;\n    return it;\n  });\n}\n\ntemplate <typename Char> class digit_grouping {\n private:\n  std::string grouping_;\n  std::basic_string<Char> thousands_sep_;\n\n  struct next_state {\n    std::string::const_iterator group;\n    int pos;\n  };\n  auto initial_state() const -> next_state { return {grouping_.begin(), 0}; }\n\n  // Returns the next digit group separator position.\n  auto next(next_state& state) const -> int {\n    if (thousands_sep_.empty()) return max_value<int>();\n    if (state.group == grouping_.end()) return state.pos += grouping_.back();\n    if (*state.group <= 0 || *state.group == max_value<char>())\n      return max_value<int>();\n    state.pos += *state.group++;\n    return state.pos;\n  }\n\n public:\n  explicit digit_grouping(locale_ref loc, bool localized = true) {\n    if (!localized) return;\n    auto sep = thousands_sep<Char>(loc);\n    grouping_ = std::move(sep.grouping);\n    if (sep.thousands_sep) thousands_sep_.assign(1, sep.thousands_sep);\n  }\n  digit_grouping(std::string grouping, std::basic_string<Char> sep)\n      : grouping_(std::move(grouping)), thousands_sep_(std::move(sep)) {}\n\n  auto has_separator() const -> bool { return !thousands_sep_.empty(); }\n\n  auto count_separators(int num_digits) const -> int {\n    int count = 0;\n    auto state = initial_state();\n    while (num_digits > next(state)) ++count;\n    return count;\n  }\n\n  // Applies grouping to digits and writes the output to out.\n  template <typename Out, typename C>\n  auto apply(Out out, basic_string_view<C> digits) const -> Out {\n    auto num_digits = static_cast<int>(digits.size());\n    auto separators = basic_memory_buffer<int>();\n    separators.push_back(0);\n    auto state = initial_state();\n    while (int i = next(state)) {\n      if (i >= num_digits) break;\n      separators.push_back(i);\n    }\n    for (int i = 0, sep_index = static_cast<int>(separators.size() - 1);\n         i < num_digits; ++i) {\n      if (num_digits - i == separators[sep_index]) {\n        out = copy<Char>(thousands_sep_.data(),\n                         thousands_sep_.data() + thousands_sep_.size(), out);\n        --sep_index;\n      }\n      *out++ = static_cast<Char>(digits[to_unsigned(i)]);\n    }\n    return out;\n  }\n};\n\nFMT_CONSTEXPR inline void prefix_append(unsigned& prefix, unsigned value) {\n  prefix |= prefix != 0 ? value << 8 : value;\n  prefix += (1u + (value > 0xff ? 1 : 0)) << 24;\n}\n\n// Writes a decimal integer with digit grouping.\ntemplate <typename OutputIt, typename UInt, typename Char>\nauto write_int(OutputIt out, UInt value, unsigned prefix,\n               const format_specs& specs, const digit_grouping<Char>& grouping)\n    -> OutputIt {\n  static_assert(std::is_same<uint64_or_128_t<UInt>, UInt>::value, \"\");\n  int num_digits = 0;\n  auto buffer = memory_buffer();\n  switch (specs.type()) {\n  default: FMT_ASSERT(false, \"\"); FMT_FALLTHROUGH;\n  case presentation_type::none:\n  case presentation_type::dec:\n    num_digits = count_digits(value);\n    format_decimal<char>(appender(buffer), value, num_digits);\n    break;\n  case presentation_type::hex:\n    if (specs.alt())\n      prefix_append(prefix, unsigned(specs.upper() ? 'X' : 'x') << 8 | '0');\n    num_digits = count_digits<4>(value);\n    format_base2e<char>(4, appender(buffer), value, num_digits, specs.upper());\n    break;\n  case presentation_type::oct:\n    num_digits = count_digits<3>(value);\n    // Octal prefix '0' is counted as a digit, so only add it if precision\n    // is not greater than the number of digits.\n    if (specs.alt() && specs.precision <= num_digits && value != 0)\n      prefix_append(prefix, '0');\n    format_base2e<char>(3, appender(buffer), value, num_digits);\n    break;\n  case presentation_type::bin:\n    if (specs.alt())\n      prefix_append(prefix, unsigned(specs.upper() ? 'B' : 'b') << 8 | '0');\n    num_digits = count_digits<1>(value);\n    format_base2e<char>(1, appender(buffer), value, num_digits);\n    break;\n  case presentation_type::chr:\n    return write_char<Char>(out, static_cast<Char>(value), specs);\n  }\n\n  unsigned size = (prefix != 0 ? prefix >> 24 : 0) + to_unsigned(num_digits) +\n                  to_unsigned(grouping.count_separators(num_digits));\n  return write_padded<Char, align::right>(\n      out, specs, size, size, [&](reserve_iterator<OutputIt> it) {\n        for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)\n          *it++ = static_cast<Char>(p & 0xff);\n        return grouping.apply(it, string_view(buffer.data(), buffer.size()));\n      });\n}\n\n#if FMT_USE_LOCALE\n// Writes a localized value.\nFMT_API auto write_loc(appender out, loc_value value, const format_specs& specs,\n                       locale_ref loc) -> bool;\nauto write_loc(basic_appender<wchar_t> out, loc_value value,\n               const format_specs& specs, locale_ref loc) -> bool;\n#endif\ntemplate <typename OutputIt>\ninline auto write_loc(OutputIt, const loc_value&, const format_specs&,\n                      locale_ref) -> bool {\n  return false;\n}\n\ntemplate <typename UInt> struct write_int_arg {\n  UInt abs_value;\n  unsigned prefix;\n};\n\ntemplate <typename T>\nFMT_CONSTEXPR auto make_write_int_arg(T value, sign s)\n    -> write_int_arg<uint32_or_64_or_128_t<T>> {\n  auto prefix = 0u;\n  auto abs_value = static_cast<uint32_or_64_or_128_t<T>>(value);\n  if (is_negative(value)) {\n    prefix = 0x01000000 | '-';\n    abs_value = 0 - abs_value;\n  } else {\n    constexpr unsigned prefixes[4] = {0, 0, 0x1000000u | '+', 0x1000000u | ' '};\n    prefix = prefixes[static_cast<int>(s)];\n  }\n  return {abs_value, prefix};\n}\n\ntemplate <typename Char = char> struct loc_writer {\n  basic_appender<Char> out;\n  const format_specs& specs;\n  std::basic_string<Char> sep;\n  std::string grouping;\n  std::basic_string<Char> decimal_point;\n\n  template <typename T, FMT_ENABLE_IF(is_integer<T>::value)>\n  auto operator()(T value) -> bool {\n    auto arg = make_write_int_arg(value, specs.sign());\n    write_int(out, static_cast<uint64_or_128_t<T>>(arg.abs_value), arg.prefix,\n              specs, digit_grouping<Char>(grouping, sep));\n    return true;\n  }\n\n  template <typename T, FMT_ENABLE_IF(!is_integer<T>::value)>\n  auto operator()(T) -> bool {\n    return false;\n  }\n};\n\n// Size and padding computation separate from write_int to avoid template bloat.\nstruct size_padding {\n  unsigned size;\n  unsigned padding;\n\n  FMT_CONSTEXPR size_padding(int num_digits, unsigned prefix,\n                             const format_specs& specs)\n      : size((prefix >> 24) + to_unsigned(num_digits)), padding(0) {\n    if (specs.align() == align::numeric) {\n      auto width = to_unsigned(specs.width);\n      if (width > size) {\n        padding = width - size;\n        size = width;\n      }\n    } else if (specs.precision > num_digits) {\n      size = (prefix >> 24) + to_unsigned(specs.precision);\n      padding = to_unsigned(specs.precision - num_digits);\n    }\n  }\n};\n\ntemplate <typename Char, typename OutputIt, typename T>\nFMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg<T> arg,\n                                        const format_specs& specs) -> OutputIt {\n  static_assert(std::is_same<T, uint32_or_64_or_128_t<T>>::value, \"\");\n\n  constexpr size_t buffer_size = num_bits<T>();\n  char buffer[buffer_size];\n  if (is_constant_evaluated()) fill_n(buffer, buffer_size, '\\0');\n  const char* begin = nullptr;\n  const char* end = buffer + buffer_size;\n\n  auto abs_value = arg.abs_value;\n  auto prefix = arg.prefix;\n  switch (specs.type()) {\n  default: FMT_ASSERT(false, \"\"); FMT_FALLTHROUGH;\n  case presentation_type::none:\n  case presentation_type::dec:\n    begin = do_format_decimal(buffer, abs_value, buffer_size);\n    break;\n  case presentation_type::hex:\n    begin = do_format_base2e(4, buffer, abs_value, buffer_size, specs.upper());\n    if (specs.alt())\n      prefix_append(prefix, unsigned(specs.upper() ? 'X' : 'x') << 8 | '0');\n    break;\n  case presentation_type::oct: {\n    begin = do_format_base2e(3, buffer, abs_value, buffer_size);\n    // Octal prefix '0' is counted as a digit, so only add it if precision\n    // is not greater than the number of digits.\n    auto num_digits = end - begin;\n    if (specs.alt() && specs.precision <= num_digits && abs_value != 0)\n      prefix_append(prefix, '0');\n    break;\n  }\n  case presentation_type::bin:\n    begin = do_format_base2e(1, buffer, abs_value, buffer_size);\n    if (specs.alt())\n      prefix_append(prefix, unsigned(specs.upper() ? 'B' : 'b') << 8 | '0');\n    break;\n  case presentation_type::chr:\n    return write_char<Char>(out, static_cast<Char>(abs_value), specs);\n  }\n\n  // Write an integer in the format\n  //   <left-padding><prefix><numeric-padding><digits><right-padding>\n  // prefix contains chars in three lower bytes and the size in the fourth byte.\n  int num_digits = static_cast<int>(end - begin);\n  // Slightly faster check for specs.width == 0 && specs.precision == -1.\n  if ((specs.width | (specs.precision + 1)) == 0) {\n    auto it = reserve(out, to_unsigned(num_digits) + (prefix >> 24));\n    for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)\n      *it++ = static_cast<Char>(p & 0xff);\n    return base_iterator(out, copy<Char>(begin, end, it));\n  }\n  auto sp = size_padding(num_digits, prefix, specs);\n  unsigned padding = sp.padding;\n  return write_padded<Char, align::right>(\n      out, specs, sp.size, [=](reserve_iterator<OutputIt> it) {\n        for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8)\n          *it++ = static_cast<Char>(p & 0xff);\n        it = detail::fill_n(it, padding, static_cast<Char>('0'));\n        return copy<Char>(begin, end, it);\n      });\n}\n\ntemplate <typename Char, typename OutputIt, typename T>\nFMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline(OutputIt out,\n                                                   write_int_arg<T> arg,\n                                                   const format_specs& specs)\n    -> OutputIt {\n  return write_int<Char>(out, arg, specs);\n}\n\ntemplate <typename Char, typename T,\n          FMT_ENABLE_IF(is_integral<T>::value &&\n                        !std::is_same<T, bool>::value &&\n                        !std::is_same<T, Char>::value)>\nFMT_CONSTEXPR FMT_INLINE auto write(basic_appender<Char> out, T value,\n                                    const format_specs& specs, locale_ref loc)\n    -> basic_appender<Char> {\n  if (specs.localized() && write_loc(out, value, specs, loc)) return out;\n  return write_int_noinline<Char>(out, make_write_int_arg(value, specs.sign()),\n                                  specs);\n}\n\n// An inlined version of write used in format string compilation.\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(is_integral<T>::value &&\n                        !std::is_same<T, bool>::value &&\n                        !std::is_same<T, Char>::value &&\n                        !std::is_same<OutputIt, basic_appender<Char>>::value)>\nFMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value,\n                                    const format_specs& specs, locale_ref loc)\n    -> OutputIt {\n  if (specs.localized() && write_loc(out, value, specs, loc)) return out;\n  return write_int<Char>(out, make_write_int_arg(value, specs.sign()), specs);\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write(OutputIt out, Char value, const format_specs& specs,\n                         locale_ref loc = {}) -> OutputIt {\n  // char is formatted as unsigned char for consistency across platforms.\n  using unsigned_type =\n      conditional_t<std::is_same<Char, char>::value, unsigned char, unsigned>;\n  return check_char_specs(specs)\n             ? write_char<Char>(out, value, specs)\n             : write<Char>(out, static_cast<unsigned_type>(value), specs, loc);\n}\n\ntemplate <typename Char, typename OutputIt,\n          FMT_ENABLE_IF(std::is_same<Char, char>::value)>\nFMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> s,\n                         const format_specs& specs) -> OutputIt {\n  bool is_debug = specs.type() == presentation_type::debug;\n  if (specs.precision < 0 && specs.width == 0) {\n    auto&& it = reserve(out, s.size());\n    return is_debug ? write_escaped_string(it, s) : copy<char>(s, it);\n  }\n\n  size_t display_width_limit =\n      specs.precision < 0 ? SIZE_MAX : to_unsigned(specs.precision);\n  size_t display_width =\n      !is_debug || specs.precision == 0 ? 0 : 1;  // Account for opening '\"'.\n  size_t size = !is_debug || specs.precision == 0 ? 0 : 1;\n  for_each_codepoint(s, [&](uint32_t cp, string_view sv) {\n    if (is_debug && needs_escape(cp)) {\n      counting_buffer<char> buf;\n      write_escaped_cp(basic_appender<char>(buf),\n                       find_escape_result<char>{sv.begin(), sv.end(), cp});\n      // We're reinterpreting bytes as display width. That's okay\n      // because write_escaped_cp() only writes ASCII characters.\n      size_t cp_width = buf.count();\n      if (display_width + cp_width <= display_width_limit) {\n        display_width += cp_width;\n        size += cp_width;\n        // If this is the end of the string, account for closing '\"'.\n        if (display_width < display_width_limit && sv.end() == s.end()) {\n          ++display_width;\n          ++size;\n        }\n        return true;\n      }\n\n      size += display_width_limit - display_width;\n      display_width = display_width_limit;\n      return false;\n    }\n\n    size_t cp_width = display_width_of(cp);\n    if (cp_width + display_width <= display_width_limit) {\n      display_width += cp_width;\n      size += sv.size();\n      // If this is the end of the string, account for closing '\"'.\n      if (is_debug && display_width < display_width_limit &&\n          sv.end() == s.end()) {\n        ++display_width;\n        ++size;\n      }\n      return true;\n    }\n\n    return false;\n  });\n\n  struct bounded_output_iterator {\n    reserve_iterator<OutputIt> underlying_iterator;\n    size_t bound;\n\n    FMT_CONSTEXPR auto operator*() -> bounded_output_iterator& { return *this; }\n    FMT_CONSTEXPR auto operator++() -> bounded_output_iterator& {\n      return *this;\n    }\n    FMT_CONSTEXPR auto operator++(int) -> bounded_output_iterator& {\n      return *this;\n    }\n    FMT_CONSTEXPR auto operator=(char c) -> bounded_output_iterator& {\n      if (bound > 0) {\n        *underlying_iterator++ = c;\n        --bound;\n      }\n      return *this;\n    }\n  };\n\n  return write_padded<char>(\n      out, specs, size, display_width, [=](reserve_iterator<OutputIt> it) {\n        return is_debug\n                   ? write_escaped_string(bounded_output_iterator{it, size}, s)\n                         .underlying_iterator\n                   : copy<char>(s.data(), s.data() + size, it);\n      });\n}\n\ntemplate <typename Char, typename OutputIt,\n          FMT_ENABLE_IF(!std::is_same<Char, char>::value)>\nFMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> s,\n                         const format_specs& specs) -> OutputIt {\n  auto data = s.data();\n  auto size = s.size();\n  if (specs.precision >= 0 && to_unsigned(specs.precision) < size)\n    size = to_unsigned(specs.precision);\n\n  bool is_debug = specs.type() == presentation_type::debug;\n  if (is_debug) {\n    auto buf = counting_buffer<Char>();\n    write_escaped_string(basic_appender<Char>(buf), s);\n    size = buf.count();\n  }\n\n  return write_padded<Char>(\n      out, specs, size, [=](reserve_iterator<OutputIt> it) {\n        return is_debug ? write_escaped_string(it, s)\n                        : copy<Char>(data, data + size, it);\n      });\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> s,\n                         const format_specs& specs, locale_ref) -> OutputIt {\n  return write<Char>(out, s, specs);\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write(OutputIt out, const Char* s, const format_specs& specs,\n                         locale_ref) -> OutputIt {\n  if (specs.type() == presentation_type::pointer)\n    return write_ptr<Char>(out, bit_cast<uintptr_t>(s), &specs);\n  if (!s) report_error(\"string pointer is null\");\n  return write<Char>(out, basic_string_view<Char>(s), specs, {});\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(is_integral<T>::value &&\n                        !std::is_same<T, bool>::value &&\n                        !std::is_same<T, Char>::value)>\nFMT_CONSTEXPR auto write(OutputIt out, T value) -> OutputIt {\n  auto abs_value = static_cast<uint32_or_64_or_128_t<T>>(value);\n  bool negative = is_negative(value);\n  // Don't do -abs_value since it trips unsigned-integer-overflow sanitizer.\n  if (negative) abs_value = ~abs_value + 1;\n  int num_digits = count_digits(abs_value);\n  auto size = (negative ? 1 : 0) + static_cast<size_t>(num_digits);\n  if (auto ptr = to_pointer<Char>(out, size)) {\n    if (negative) *ptr++ = static_cast<Char>('-');\n    format_decimal<Char>(ptr, abs_value, num_digits);\n    return out;\n  }\n  if (negative) *out++ = static_cast<Char>('-');\n  return format_decimal<Char>(out, abs_value, num_digits);\n}\n\ntemplate <typename Char>\nFMT_CONSTEXPR auto parse_align(const Char* begin, const Char* end,\n                               format_specs& specs) -> const Char* {\n  FMT_ASSERT(begin != end, \"\");\n  auto alignment = align::none;\n  auto p = begin + code_point_length(begin);\n  if (end - p <= 0) p = begin;\n  for (;;) {\n    switch (to_ascii(*p)) {\n    case '<': alignment = align::left; break;\n    case '>': alignment = align::right; break;\n    case '^': alignment = align::center; break;\n    }\n    if (alignment != align::none) {\n      if (p != begin) {\n        auto c = *begin;\n        if (c == '}') return begin;\n        if (c == '{') {\n          report_error(\"invalid fill character '{'\");\n          return begin;\n        }\n        specs.set_fill(basic_string_view<Char>(begin, to_unsigned(p - begin)));\n        begin = p + 1;\n      } else {\n        ++begin;\n      }\n      break;\n    }\n    if (p == begin) break;\n    p = begin;\n  }\n  specs.set_align(alignment);\n  return begin;\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan,\n                                     format_specs specs, sign s) -> OutputIt {\n  auto str =\n      isnan ? (specs.upper() ? \"NAN\" : \"nan\") : (specs.upper() ? \"INF\" : \"inf\");\n  constexpr size_t str_size = 3;\n  auto size = str_size + (s != sign::none ? 1 : 0);\n  // Replace '0'-padding with space for non-finite values.\n  const bool is_zero_fill =\n      specs.fill_size() == 1 && specs.fill_unit<Char>() == '0';\n  if (is_zero_fill) specs.set_fill(' ');\n  return write_padded<Char>(out, specs, size,\n                            [=](reserve_iterator<OutputIt> it) {\n                              if (s != sign::none)\n                                *it++ = detail::getsign<Char>(s);\n                              return copy<Char>(str, str + str_size, it);\n                            });\n}\n\n// A decimal floating-point number significand * pow(10, exp).\nstruct big_decimal_fp {\n  const char* significand;\n  int significand_size;\n  int exponent;\n};\n\nconstexpr auto get_significand_size(const big_decimal_fp& f) -> int {\n  return f.significand_size;\n}\ntemplate <typename T>\ninline auto get_significand_size(const dragonbox::decimal_fp<T>& f) -> int {\n  return count_digits(f.significand);\n}\n\ntemplate <typename Char, typename OutputIt>\nconstexpr auto write_significand(OutputIt out, const char* significand,\n                                 int significand_size) -> OutputIt {\n  return copy<Char>(significand, significand + significand_size, out);\n}\ntemplate <typename Char, typename OutputIt, typename UInt>\ninline auto write_significand(OutputIt out, UInt significand,\n                              int significand_size) -> OutputIt {\n  return format_decimal<Char>(out, significand, significand_size);\n}\ntemplate <typename Char, typename OutputIt, typename T, typename Grouping>\nFMT_CONSTEXPR20 auto write_significand(OutputIt out, T significand,\n                                       int significand_size, int exponent,\n                                       const Grouping& grouping) -> OutputIt {\n  if (!grouping.has_separator()) {\n    out = write_significand<Char>(out, significand, significand_size);\n    return detail::fill_n(out, exponent, static_cast<Char>('0'));\n  }\n  auto buffer = memory_buffer();\n  write_significand<char>(appender(buffer), significand, significand_size);\n  detail::fill_n(appender(buffer), exponent, '0');\n  return grouping.apply(out, string_view(buffer.data(), buffer.size()));\n}\n\ntemplate <typename Char, typename UInt,\n          FMT_ENABLE_IF(std::is_integral<UInt>::value)>\ninline auto write_significand(Char* out, UInt significand, int significand_size,\n                              int integral_size, Char decimal_point) -> Char* {\n  if (!decimal_point) return format_decimal(out, significand, significand_size);\n  out += significand_size + 1;\n  Char* end = out;\n  int floating_size = significand_size - integral_size;\n  for (int i = floating_size / 2; i > 0; --i) {\n    out -= 2;\n    write2digits(out, static_cast<size_t>(significand % 100));\n    significand /= 100;\n  }\n  if (floating_size % 2 != 0) {\n    *--out = static_cast<Char>('0' + significand % 10);\n    significand /= 10;\n  }\n  *--out = decimal_point;\n  format_decimal(out - integral_size, significand, integral_size);\n  return end;\n}\n\ntemplate <typename OutputIt, typename UInt, typename Char,\n          FMT_ENABLE_IF(!std::is_pointer<remove_cvref_t<OutputIt>>::value)>\ninline auto write_significand(OutputIt out, UInt significand,\n                              int significand_size, int integral_size,\n                              Char decimal_point) -> OutputIt {\n  // Buffer is large enough to hold digits (digits10 + 1) and a decimal point.\n  Char buffer[digits10<UInt>() + 2];\n  auto end = write_significand(buffer, significand, significand_size,\n                               integral_size, decimal_point);\n  return detail::copy_noinline<Char>(buffer, end, out);\n}\n\ntemplate <typename OutputIt, typename Char>\nFMT_CONSTEXPR auto write_significand(OutputIt out, const char* significand,\n                                     int significand_size, int integral_size,\n                                     Char decimal_point) -> OutputIt {\n  out = detail::copy_noinline<Char>(significand, significand + integral_size,\n                                    out);\n  if (!decimal_point) return out;\n  *out++ = decimal_point;\n  return detail::copy_noinline<Char>(significand + integral_size,\n                                     significand + significand_size, out);\n}\n\ntemplate <typename OutputIt, typename Char, typename T, typename Grouping>\nFMT_CONSTEXPR20 auto write_significand(OutputIt out, T significand,\n                                       int significand_size, int integral_size,\n                                       Char decimal_point,\n                                       const Grouping& grouping) -> OutputIt {\n  if (!grouping.has_separator()) {\n    return write_significand(out, significand, significand_size, integral_size,\n                             decimal_point);\n  }\n  auto buffer = basic_memory_buffer<Char>();\n  write_significand(basic_appender<Char>(buffer), significand, significand_size,\n                    integral_size, decimal_point);\n  grouping.apply(\n      out, basic_string_view<Char>(buffer.data(), to_unsigned(integral_size)));\n  return detail::copy_noinline<Char>(buffer.data() + integral_size,\n                                     buffer.end(), out);\n}\n\n// Numbers with exponents greater or equal to the returned value will use\n// the exponential notation.\ntemplate <typename T> FMT_CONSTEVAL auto exp_upper() -> int {\n  return std::numeric_limits<T>::digits10 != 0\n             ? min_of(16, std::numeric_limits<T>::digits10 + 1)\n             : 16;\n}\n\n// Use the fixed notation if the exponent is in [-4, exp_upper),\n// e.g. 0.0001 instead of 1e-04. Otherwise use the exponent notation.\nconstexpr auto use_fixed(int exp, int exp_upper) -> bool {\n  return exp >= -4 && exp < exp_upper;\n}\n\ntemplate <typename Char> class fallback_digit_grouping {\n public:\n  constexpr fallback_digit_grouping(locale_ref, bool) {}\n\n  constexpr auto has_separator() const -> bool { return false; }\n\n  constexpr auto count_separators(int) const -> int { return 0; }\n\n  template <typename Out, typename C>\n  constexpr auto apply(Out out, basic_string_view<C>) const -> Out {\n    return out;\n  }\n};\n\ntemplate <typename Char, typename Grouping, typename OutputIt,\n          typename DecimalFP>\nFMT_CONSTEXPR20 auto write_fixed(OutputIt out, const DecimalFP& f,\n                                 int significand_size, Char decimal_point,\n                                 const format_specs& specs, sign s,\n                                 locale_ref loc = {}) -> OutputIt {\n  using iterator = reserve_iterator<OutputIt>;\n\n  int exp = f.exponent + significand_size;\n  long long size = significand_size + (s != sign::none ? 1 : 0);\n  if (f.exponent >= 0) {\n    // 1234e5 -> 123400000[.0+]\n    size += f.exponent;\n    int num_zeros = specs.precision - exp;\n    abort_fuzzing_if(num_zeros > 5000);\n    if (specs.alt()) {\n      ++size;\n      if (num_zeros <= 0 && specs.type() != presentation_type::fixed)\n        num_zeros = 0;\n      if (num_zeros > 0) size += num_zeros;\n    }\n    auto grouping = Grouping(loc, specs.localized());\n    size += grouping.count_separators(exp);\n    return write_padded<Char, align::right>(\n        out, specs, static_cast<size_t>(size), [&](iterator it) {\n          if (s != sign::none) *it++ = detail::getsign<Char>(s);\n          it = write_significand<Char>(it, f.significand, significand_size,\n                                       f.exponent, grouping);\n          if (!specs.alt()) return it;\n          *it++ = decimal_point;\n          return num_zeros > 0 ? detail::fill_n(it, num_zeros, Char('0')) : it;\n        });\n  }\n  if (exp > 0) {\n    // 1234e-2 -> 12.34[0+]\n    int num_zeros = specs.alt() ? specs.precision - significand_size : 0;\n    size += 1 + max_of(num_zeros, 0);\n    auto grouping = Grouping(loc, specs.localized());\n    size += grouping.count_separators(exp);\n    return write_padded<Char, align::right>(\n        out, specs, static_cast<size_t>(size), [&](iterator it) {\n          if (s != sign::none) *it++ = detail::getsign<Char>(s);\n          it = write_significand(it, f.significand, significand_size, exp,\n                                 decimal_point, grouping);\n          return num_zeros > 0 ? detail::fill_n(it, num_zeros, Char('0')) : it;\n        });\n  }\n  // 1234e-6 -> 0.001234\n  int num_zeros = -exp;\n  if (significand_size == 0 && specs.precision >= 0 &&\n      specs.precision < num_zeros) {\n    num_zeros = specs.precision;\n  }\n  bool pointy = num_zeros != 0 || significand_size != 0 || specs.alt();\n  size += 1 + (pointy ? 1 : 0) + num_zeros;\n  return write_padded<Char, align::right>(\n      out, specs, static_cast<size_t>(size), [&](iterator it) {\n        if (s != sign::none) *it++ = detail::getsign<Char>(s);\n        *it++ = Char('0');\n        if (!pointy) return it;\n        *it++ = decimal_point;\n        it = detail::fill_n(it, num_zeros, Char('0'));\n        return write_significand<Char>(it, f.significand, significand_size);\n      });\n}\n\ntemplate <typename Char, typename Grouping, typename OutputIt,\n          typename DecimalFP>\nFMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& f,\n                                    const format_specs& specs, sign s,\n                                    int exp_upper, locale_ref loc) -> OutputIt {\n  Char point = specs.localized() ? detail::decimal_point<Char>(loc) : Char('.');\n  int significand_size = get_significand_size(f);\n  int exp = f.exponent + significand_size - 1;\n  if (specs.type() == presentation_type::fixed ||\n      (specs.type() != presentation_type::exp &&\n       use_fixed(exp, specs.precision > 0 ? specs.precision : exp_upper))) {\n    return write_fixed<Char, Grouping>(out, f, significand_size, point, specs,\n                                       s, loc);\n  }\n\n  // Write value in the exponential format.\n  int num_zeros = 0;\n  long long size = significand_size + (s != sign::none ? 1 : 0);\n  if (specs.alt()) {\n    num_zeros = max_of(specs.precision - significand_size, 0);\n    size += num_zeros;\n  } else if (significand_size == 1) {\n    point = Char();\n  }\n  size += (point ? 1 : 0) + compute_exp_size(exp);\n  char exp_char = specs.upper() ? 'E' : 'e';\n  auto write = [=](reserve_iterator<OutputIt> it) {\n    if (s != sign::none) *it++ = detail::getsign<Char>(s);\n    // Insert a decimal point after the first digit and add an exponent.\n    it = write_significand(it, f.significand, significand_size, 1, point);\n    if (num_zeros > 0) it = detail::fill_n(it, num_zeros, Char('0'));\n    *it++ = Char(exp_char);\n    return write_exponent<Char>(exp, it);\n  };\n  size_t usize = static_cast<size_t>(size);\n  return specs.width > 0\n             ? write_padded<Char, align::right>(out, specs, usize, write)\n             : base_iterator(out, write(reserve(out, usize)));\n}\n\ntemplate <typename Char, typename OutputIt, typename DecimalFP>\nFMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP& f,\n                                 const format_specs& specs, sign s,\n                                 int exp_upper, locale_ref loc) -> OutputIt {\n  if (is_constant_evaluated()) {\n    return do_write_float<Char, fallback_digit_grouping<Char>>(out, f, specs, s,\n                                                               exp_upper, loc);\n  } else {\n    return do_write_float<Char, digit_grouping<Char>>(out, f, specs, s,\n                                                      exp_upper, loc);\n  }\n}\n\ntemplate <typename T> constexpr auto isnan(T value) -> bool {\n  return value != value;  // std::isnan doesn't support __float128.\n}\n\ntemplate <typename T, typename Enable = void>\nstruct has_isfinite : std::false_type {};\n\ntemplate <typename T>\nstruct has_isfinite<T, enable_if_t<sizeof(std::isfinite(T())) != 0>>\n    : std::true_type {};\n\ntemplate <typename T,\n          FMT_ENABLE_IF(is_floating_point<T>::value&& has_isfinite<T>::value)>\nFMT_CONSTEXPR20 auto isfinite(T value) -> bool {\n  constexpr T inf = T(std::numeric_limits<double>::infinity());\n  if (is_constant_evaluated())\n    return !detail::isnan(value) && value < inf && value > -inf;\n  return std::isfinite(value);\n}\ntemplate <typename T, FMT_ENABLE_IF(!has_isfinite<T>::value)>\nFMT_CONSTEXPR auto isfinite(T value) -> bool {\n  T inf = T(std::numeric_limits<double>::infinity());\n  // std::isfinite doesn't support __float128.\n  return !detail::isnan(value) && value < inf && value > -inf;\n}\n\ntemplate <typename T, FMT_ENABLE_IF(is_floating_point<T>::value)>\nFMT_INLINE FMT_CONSTEXPR auto signbit(T value) -> bool {\n  if (is_constant_evaluated()) {\n#ifdef __cpp_if_constexpr\n    if constexpr (std::numeric_limits<double>::is_iec559) {\n      auto bits = detail::bit_cast<uint64_t>(static_cast<double>(value));\n      return (bits >> (num_bits<uint64_t>() - 1)) != 0;\n    }\n#endif\n  }\n  return std::signbit(static_cast<double>(value));\n}\n\ninline FMT_CONSTEXPR20 void adjust_precision(int& precision, int exp10) {\n  // Adjust fixed precision by exponent because it is relative to decimal\n  // point.\n  if (exp10 > 0 && precision > max_value<int>() - exp10)\n    FMT_THROW(format_error(\"number is too big\"));\n  precision += exp10;\n}\n\nclass bigint {\n private:\n  // A bigint is a number in the form bigit_[N - 1] ... bigit_[0] * 32^exp_.\n  using bigit = uint32_t;  // A big digit.\n  using double_bigit = uint64_t;\n  enum { bigit_bits = num_bits<bigit>() };\n  enum { bigits_capacity = 32 };\n  basic_memory_buffer<bigit, bigits_capacity> bigits_;\n  int exp_;\n\n  friend struct formatter<bigint>;\n\n  FMT_CONSTEXPR auto get_bigit(int i) const -> bigit {\n    return i >= exp_ && i < num_bigits() ? bigits_[i - exp_] : 0;\n  }\n\n  FMT_CONSTEXPR void subtract_bigits(int index, bigit other, bigit& borrow) {\n    auto result = double_bigit(bigits_[index]) - other - borrow;\n    bigits_[index] = static_cast<bigit>(result);\n    borrow = static_cast<bigit>(result >> (bigit_bits * 2 - 1));\n  }\n\n  FMT_CONSTEXPR void remove_leading_zeros() {\n    int num_bigits = static_cast<int>(bigits_.size()) - 1;\n    while (num_bigits > 0 && bigits_[num_bigits] == 0) --num_bigits;\n    bigits_.resize(to_unsigned(num_bigits + 1));\n  }\n\n  // Computes *this -= other assuming aligned bigints and *this >= other.\n  FMT_CONSTEXPR void subtract_aligned(const bigint& other) {\n    FMT_ASSERT(other.exp_ >= exp_, \"unaligned bigints\");\n    FMT_ASSERT(compare(*this, other) >= 0, \"\");\n    bigit borrow = 0;\n    int i = other.exp_ - exp_;\n    for (size_t j = 0, n = other.bigits_.size(); j != n; ++i, ++j)\n      subtract_bigits(i, other.bigits_[j], borrow);\n    if (borrow != 0) subtract_bigits(i, 0, borrow);\n    FMT_ASSERT(borrow == 0, \"\");\n    remove_leading_zeros();\n  }\n\n  FMT_CONSTEXPR void multiply(uint32_t value) {\n    bigit carry = 0;\n    const double_bigit wide_value = value;\n    for (size_t i = 0, n = bigits_.size(); i < n; ++i) {\n      double_bigit result = bigits_[i] * wide_value + carry;\n      bigits_[i] = static_cast<bigit>(result);\n      carry = static_cast<bigit>(result >> bigit_bits);\n    }\n    if (carry != 0) bigits_.push_back(carry);\n  }\n\n  template <typename UInt, FMT_ENABLE_IF(std::is_same<UInt, uint64_t>::value ||\n                                         std::is_same<UInt, uint128_t>::value)>\n  FMT_CONSTEXPR void multiply(UInt value) {\n    using half_uint =\n        conditional_t<std::is_same<UInt, uint128_t>::value, uint64_t, uint32_t>;\n    const int shift = num_bits<half_uint>() - bigit_bits;\n    const UInt lower = static_cast<half_uint>(value);\n    const UInt upper = value >> num_bits<half_uint>();\n    UInt carry = 0;\n    for (size_t i = 0, n = bigits_.size(); i < n; ++i) {\n      UInt result = lower * bigits_[i] + static_cast<bigit>(carry);\n      carry = (upper * bigits_[i] << shift) + (result >> bigit_bits) +\n              (carry >> bigit_bits);\n      bigits_[i] = static_cast<bigit>(result);\n    }\n    while (carry != 0) {\n      bigits_.push_back(static_cast<bigit>(carry));\n      carry >>= bigit_bits;\n    }\n  }\n\n  template <typename UInt, FMT_ENABLE_IF(std::is_same<UInt, uint64_t>::value ||\n                                         std::is_same<UInt, uint128_t>::value)>\n  FMT_CONSTEXPR void assign(UInt n) {\n    size_t num_bigits = 0;\n    do {\n      bigits_[num_bigits++] = static_cast<bigit>(n);\n      n >>= bigit_bits;\n    } while (n != 0);\n    bigits_.resize(num_bigits);\n    exp_ = 0;\n  }\n\n public:\n  FMT_CONSTEXPR bigint() : exp_(0) {}\n  explicit bigint(uint64_t n) { assign(n); }\n\n  bigint(const bigint&) = delete;\n  void operator=(const bigint&) = delete;\n\n  FMT_CONSTEXPR void assign(const bigint& other) {\n    auto size = other.bigits_.size();\n    bigits_.resize(size);\n    auto data = other.bigits_.data();\n    copy<bigit>(data, data + size, bigits_.data());\n    exp_ = other.exp_;\n  }\n\n  template <typename Int> FMT_CONSTEXPR void operator=(Int n) {\n    FMT_ASSERT(n > 0, \"\");\n    assign(uint64_or_128_t<Int>(n));\n  }\n\n  FMT_CONSTEXPR auto num_bigits() const -> int {\n    return static_cast<int>(bigits_.size()) + exp_;\n  }\n\n  FMT_CONSTEXPR auto operator<<=(int shift) -> bigint& {\n    FMT_ASSERT(shift >= 0, \"\");\n    exp_ += shift / bigit_bits;\n    shift %= bigit_bits;\n    if (shift == 0) return *this;\n    bigit carry = 0;\n    for (size_t i = 0, n = bigits_.size(); i < n; ++i) {\n      bigit c = bigits_[i] >> (bigit_bits - shift);\n      bigits_[i] = (bigits_[i] << shift) + carry;\n      carry = c;\n    }\n    if (carry != 0) bigits_.push_back(carry);\n    return *this;\n  }\n\n  template <typename Int> FMT_CONSTEXPR auto operator*=(Int value) -> bigint& {\n    FMT_ASSERT(value > 0, \"\");\n    multiply(uint32_or_64_or_128_t<Int>(value));\n    return *this;\n  }\n\n  friend FMT_CONSTEXPR auto compare(const bigint& b1, const bigint& b2) -> int {\n    int num_bigits1 = b1.num_bigits(), num_bigits2 = b2.num_bigits();\n    if (num_bigits1 != num_bigits2) return num_bigits1 > num_bigits2 ? 1 : -1;\n    int i = static_cast<int>(b1.bigits_.size()) - 1;\n    int j = static_cast<int>(b2.bigits_.size()) - 1;\n    int end = i - j;\n    if (end < 0) end = 0;\n    for (; i >= end; --i, --j) {\n      bigit b1_bigit = b1.bigits_[i], b2_bigit = b2.bigits_[j];\n      if (b1_bigit != b2_bigit) return b1_bigit > b2_bigit ? 1 : -1;\n    }\n    if (i != j) return i > j ? 1 : -1;\n    return 0;\n  }\n\n  // Returns compare(lhs1 + lhs2, rhs).\n  friend FMT_CONSTEXPR auto add_compare(const bigint& lhs1, const bigint& lhs2,\n                                        const bigint& rhs) -> int {\n    int max_lhs_bigits = max_of(lhs1.num_bigits(), lhs2.num_bigits());\n    int num_rhs_bigits = rhs.num_bigits();\n    if (max_lhs_bigits + 1 < num_rhs_bigits) return -1;\n    if (max_lhs_bigits > num_rhs_bigits) return 1;\n    double_bigit borrow = 0;\n    int min_exp = min_of(min_of(lhs1.exp_, lhs2.exp_), rhs.exp_);\n    for (int i = num_rhs_bigits - 1; i >= min_exp; --i) {\n      double_bigit sum = double_bigit(lhs1.get_bigit(i)) + lhs2.get_bigit(i);\n      bigit rhs_bigit = rhs.get_bigit(i);\n      if (sum > rhs_bigit + borrow) return 1;\n      borrow = rhs_bigit + borrow - sum;\n      if (borrow > 1) return -1;\n      borrow <<= bigit_bits;\n    }\n    return borrow != 0 ? -1 : 0;\n  }\n\n  // Assigns pow(10, exp) to this bigint.\n  FMT_CONSTEXPR20 void assign_pow10(int exp) {\n    FMT_ASSERT(exp >= 0, \"\");\n    if (exp == 0) return *this = 1;\n    int bitmask = 1 << (num_bits<unsigned>() -\n                        countl_zero(static_cast<uint32_t>(exp)) - 1);\n    // pow(10, exp) = pow(5, exp) * pow(2, exp). First compute pow(5, exp) by\n    // repeated squaring and multiplication.\n    *this = 5;\n    bitmask >>= 1;\n    while (bitmask != 0) {\n      square();\n      if ((exp & bitmask) != 0) *this *= 5;\n      bitmask >>= 1;\n    }\n    *this <<= exp;  // Multiply by pow(2, exp) by shifting.\n  }\n\n  FMT_CONSTEXPR20 void square() {\n    int num_bigits = static_cast<int>(bigits_.size());\n    int num_result_bigits = 2 * num_bigits;\n    basic_memory_buffer<bigit, bigits_capacity> n(std::move(bigits_));\n    bigits_.resize(to_unsigned(num_result_bigits));\n    auto sum = uint128_t();\n    for (int bigit_index = 0; bigit_index < num_bigits; ++bigit_index) {\n      // Compute bigit at position bigit_index of the result by adding\n      // cross-product terms n[i] * n[j] such that i + j == bigit_index.\n      for (int i = 0, j = bigit_index; j >= 0; ++i, --j) {\n        // Most terms are multiplied twice which can be optimized in the future.\n        sum += double_bigit(n[i]) * n[j];\n      }\n      bigits_[bigit_index] = static_cast<bigit>(sum);\n      sum >>= num_bits<bigit>();  // Compute the carry.\n    }\n    // Do the same for the top half.\n    for (int bigit_index = num_bigits; bigit_index < num_result_bigits;\n         ++bigit_index) {\n      for (int j = num_bigits - 1, i = bigit_index - j; i < num_bigits;)\n        sum += double_bigit(n[i++]) * n[j--];\n      bigits_[bigit_index] = static_cast<bigit>(sum);\n      sum >>= num_bits<bigit>();\n    }\n    remove_leading_zeros();\n    exp_ *= 2;\n  }\n\n  // If this bigint has a bigger exponent than other, adds trailing zero to make\n  // exponents equal. This simplifies some operations such as subtraction.\n  FMT_CONSTEXPR void align(const bigint& other) {\n    int exp_difference = exp_ - other.exp_;\n    if (exp_difference <= 0) return;\n    int num_bigits = static_cast<int>(bigits_.size());\n    bigits_.resize(to_unsigned(num_bigits + exp_difference));\n    for (int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j)\n      bigits_[j] = bigits_[i];\n    fill_n(bigits_.data(), to_unsigned(exp_difference), 0U);\n    exp_ -= exp_difference;\n  }\n\n  // Divides this bignum by divisor, assigning the remainder to this and\n  // returning the quotient.\n  FMT_CONSTEXPR auto divmod_assign(const bigint& divisor) -> int {\n    FMT_ASSERT(this != &divisor, \"\");\n    if (compare(*this, divisor) < 0) return 0;\n    FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1u] != 0, \"\");\n    align(divisor);\n    int quotient = 0;\n    do {\n      subtract_aligned(divisor);\n      ++quotient;\n    } while (compare(*this, divisor) >= 0);\n    return quotient;\n  }\n};\n\n// format_dragon flags.\nenum dragon {\n  predecessor_closer = 1,\n  fixup = 2,  // Run fixup to correct exp10 which can be off by one.\n  fixed = 4,\n};\n\n// Formats a floating-point number using a variation of the Fixed-Precision\n// Positive Floating-Point Printout ((FPP)^2) algorithm by Steele & White:\n// https://fmt.dev/papers/p372-steele.pdf.\nFMT_CONSTEXPR20 inline void format_dragon(basic_fp<uint128_t> value,\n                                          unsigned flags, int num_digits,\n                                          buffer<char>& buf, int& exp10) {\n  bigint numerator;    // 2 * R in (FPP)^2.\n  bigint denominator;  // 2 * S in (FPP)^2.\n  // lower and upper are differences between value and corresponding boundaries.\n  bigint lower;             // (M^- in (FPP)^2).\n  bigint upper_store;       // upper's value if different from lower.\n  bigint* upper = nullptr;  // (M^+ in (FPP)^2).\n  // Shift numerator and denominator by an extra bit or two (if lower boundary\n  // is closer) to make lower and upper integers. This eliminates multiplication\n  // by 2 during later computations.\n  bool is_predecessor_closer = (flags & dragon::predecessor_closer) != 0;\n  int shift = is_predecessor_closer ? 2 : 1;\n  if (value.e >= 0) {\n    numerator = value.f;\n    numerator <<= value.e + shift;\n    lower = 1;\n    lower <<= value.e;\n    if (is_predecessor_closer) {\n      upper_store = 1;\n      upper_store <<= value.e + 1;\n      upper = &upper_store;\n    }\n    denominator.assign_pow10(exp10);\n    denominator <<= shift;\n  } else if (exp10 < 0) {\n    numerator.assign_pow10(-exp10);\n    lower.assign(numerator);\n    if (is_predecessor_closer) {\n      upper_store.assign(numerator);\n      upper_store <<= 1;\n      upper = &upper_store;\n    }\n    numerator *= value.f;\n    numerator <<= shift;\n    denominator = 1;\n    denominator <<= shift - value.e;\n  } else {\n    numerator = value.f;\n    numerator <<= shift;\n    denominator.assign_pow10(exp10);\n    denominator <<= shift - value.e;\n    lower = 1;\n    if (is_predecessor_closer) {\n      upper_store = 1ULL << 1;\n      upper = &upper_store;\n    }\n  }\n  int even = static_cast<int>((value.f & 1) == 0);\n  if (!upper) upper = &lower;\n  bool shortest = num_digits < 0;\n  if ((flags & dragon::fixup) != 0) {\n    if (add_compare(numerator, *upper, denominator) + even <= 0) {\n      --exp10;\n      numerator *= 10;\n      if (num_digits < 0) {\n        lower *= 10;\n        if (upper != &lower) *upper *= 10;\n      }\n    }\n    if ((flags & dragon::fixed) != 0) adjust_precision(num_digits, exp10 + 1);\n  }\n  // Invariant: value == (numerator / denominator) * pow(10, exp10).\n  if (shortest) {\n    // Generate the shortest representation.\n    num_digits = 0;\n    char* data = buf.data();\n    for (;;) {\n      int digit = numerator.divmod_assign(denominator);\n      bool low = compare(numerator, lower) - even < 0;  // numerator <[=] lower.\n      // numerator + upper >[=] pow10:\n      bool high = add_compare(numerator, *upper, denominator) + even > 0;\n      data[num_digits++] = static_cast<char>('0' + digit);\n      if (low || high) {\n        if (!low) {\n          ++data[num_digits - 1];\n        } else if (high) {\n          int result = add_compare(numerator, numerator, denominator);\n          // Round half to even.\n          if (result > 0 || (result == 0 && (digit % 2) != 0))\n            ++data[num_digits - 1];\n        }\n        buf.try_resize(to_unsigned(num_digits));\n        exp10 -= num_digits - 1;\n        return;\n      }\n      numerator *= 10;\n      lower *= 10;\n      if (upper != &lower) *upper *= 10;\n    }\n  }\n  // Generate the given number of digits.\n  exp10 -= num_digits - 1;\n  if (num_digits <= 0) {\n    auto digit = '0';\n    if (num_digits == 0) {\n      denominator *= 10;\n      digit = add_compare(numerator, numerator, denominator) > 0 ? '1' : '0';\n    }\n    buf.push_back(digit);\n    return;\n  }\n  buf.try_resize(to_unsigned(num_digits));\n  for (int i = 0; i < num_digits - 1; ++i) {\n    int digit = numerator.divmod_assign(denominator);\n    buf[i] = static_cast<char>('0' + digit);\n    numerator *= 10;\n  }\n  int digit = numerator.divmod_assign(denominator);\n  auto result = add_compare(numerator, numerator, denominator);\n  if (result > 0 || (result == 0 && (digit % 2) != 0)) {\n    if (digit == 9) {\n      const auto overflow = '0' + 10;\n      buf[num_digits - 1] = overflow;\n      // Propagate the carry.\n      for (int i = num_digits - 1; i > 0 && buf[i] == overflow; --i) {\n        buf[i] = '0';\n        ++buf[i - 1];\n      }\n      if (buf[0] == overflow) {\n        buf[0] = '1';\n        if ((flags & dragon::fixed) != 0)\n          buf.push_back('0');\n        else\n          ++exp10;\n      }\n      return;\n    }\n    ++digit;\n  }\n  buf[num_digits - 1] = static_cast<char>('0' + digit);\n}\n\n// Formats a floating-point number using the hexfloat format.\ntemplate <typename Float, FMT_ENABLE_IF(!is_double_double<Float>::value)>\nFMT_CONSTEXPR20 void format_hexfloat(Float value, format_specs specs,\n                                     buffer<char>& buf) {\n  // float is passed as double to reduce the number of instantiations and to\n  // simplify implementation.\n  static_assert(!std::is_same<Float, float>::value, \"\");\n\n  using info = dragonbox::float_info<Float>;\n\n  // Assume Float is in the format [sign][exponent][significand].\n  using carrier_uint = typename info::carrier_uint;\n\n  const auto num_float_significand_bits = detail::num_significand_bits<Float>();\n\n  basic_fp<carrier_uint> f(value);\n  f.e += num_float_significand_bits;\n  if (!has_implicit_bit<Float>()) --f.e;\n\n  const auto num_fraction_bits =\n      num_float_significand_bits + (has_implicit_bit<Float>() ? 1 : 0);\n  const auto num_xdigits = (num_fraction_bits + 3) / 4;\n\n  const auto leading_shift = ((num_xdigits - 1) * 4);\n  const auto leading_mask = carrier_uint(0xF) << leading_shift;\n  const auto leading_xdigit =\n      static_cast<uint32_t>((f.f & leading_mask) >> leading_shift);\n  if (leading_xdigit > 1) f.e -= (32 - countl_zero(leading_xdigit) - 1);\n\n  int print_xdigits = num_xdigits - 1;\n  if (specs.precision >= 0 && print_xdigits > specs.precision) {\n    const int shift = ((print_xdigits - specs.precision - 1) * 4);\n    const auto mask = carrier_uint(0xF) << shift;\n    const auto v = static_cast<uint32_t>((f.f & mask) >> shift);\n\n    if (v >= 8) {\n      const auto inc = carrier_uint(1) << (shift + 4);\n      f.f += inc;\n      f.f &= ~(inc - 1);\n    }\n\n    // Check long double overflow\n    if (!has_implicit_bit<Float>()) {\n      const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;\n      if ((f.f & implicit_bit) == implicit_bit) {\n        f.f >>= 4;\n        f.e += 4;\n      }\n    }\n\n    print_xdigits = specs.precision;\n  }\n\n  char xdigits[num_bits<carrier_uint>() / 4];\n  detail::fill_n(xdigits, sizeof(xdigits), '0');\n  format_base2e(4, xdigits, f.f, num_xdigits, specs.upper());\n\n  // Remove zero tail\n  while (print_xdigits > 0 && xdigits[print_xdigits] == '0') --print_xdigits;\n\n  buf.push_back('0');\n  buf.push_back(specs.upper() ? 'X' : 'x');\n  buf.push_back(xdigits[0]);\n  if (specs.alt() || print_xdigits > 0 || print_xdigits < specs.precision)\n    buf.push_back('.');\n  buf.append(xdigits + 1, xdigits + 1 + print_xdigits);\n  for (; print_xdigits < specs.precision; ++print_xdigits) buf.push_back('0');\n\n  buf.push_back(specs.upper() ? 'P' : 'p');\n\n  uint32_t abs_e;\n  if (f.e < 0) {\n    buf.push_back('-');\n    abs_e = static_cast<uint32_t>(-f.e);\n  } else {\n    buf.push_back('+');\n    abs_e = static_cast<uint32_t>(f.e);\n  }\n  format_decimal<char>(appender(buf), abs_e, detail::count_digits(abs_e));\n}\n\ntemplate <typename Float, FMT_ENABLE_IF(is_double_double<Float>::value)>\nFMT_CONSTEXPR20 void format_hexfloat(Float value, format_specs specs,\n                                     buffer<char>& buf) {\n  format_hexfloat(static_cast<double>(value), specs, buf);\n}\n\nconstexpr auto fractional_part_rounding_thresholds(int index) -> uint32_t {\n  // For checking rounding thresholds.\n  // The kth entry is chosen to be the smallest integer such that the\n  // upper 32-bits of 10^(k+1) times it is strictly bigger than 5 * 10^k.\n  // It is equal to ceil(2^31 + 2^32/10^(k + 1)).\n  // These are stored in a string literal because we cannot have static arrays\n  // in constexpr functions and non-static ones are poorly optimized.\n  return U\"\\x9999999a\\x828f5c29\\x80418938\\x80068db9\\x8000a7c6\\x800010c7\"\n         U\"\\x800001ae\\x8000002b\"[index];\n}\n\ntemplate <typename Float>\nFMT_CONSTEXPR20 auto format_float(Float value, int precision,\n                                  const format_specs& specs, bool binary32,\n                                  buffer<char>& buf) -> int {\n  // float is passed as double to reduce the number of instantiations.\n  static_assert(!std::is_same<Float, float>::value, \"\");\n  auto converted_value = convert_float(value);\n\n  const bool fixed = specs.type() == presentation_type::fixed;\n  if (value == 0) {\n    if (precision <= 0 || !fixed) {\n      buf.push_back('0');\n      return 0;\n    }\n    buf.try_resize(to_unsigned(precision));\n    fill_n(buf.data(), precision, '0');\n    return -precision;\n  }\n\n  int exp = 0;\n  bool use_dragon = true;\n  unsigned dragon_flags = 0;\n  if (!is_fast_float<Float>() || is_constant_evaluated()) {\n    const auto inv_log2_10 = 0.3010299956639812;  // 1 / log2(10)\n    using info = dragonbox::float_info<decltype(converted_value)>;\n    const auto f = basic_fp<typename info::carrier_uint>(converted_value);\n    // Compute exp, an approximate power of 10, such that\n    //   10^(exp - 1) <= value < 10^exp or 10^exp <= value < 10^(exp + 1).\n    // This is based on log10(value) == log2(value) / log2(10) and approximation\n    // of log2(value) by e + num_fraction_bits idea from double-conversion.\n    auto e = (f.e + count_digits<1>(f.f) - 1) * inv_log2_10 - 1e-10;\n    exp = static_cast<int>(e);\n    if (e > exp) ++exp;  // Compute ceil.\n    dragon_flags = dragon::fixup;\n  } else {\n    // Extract significand bits and exponent bits.\n    using info = dragonbox::float_info<double>;\n    auto br = bit_cast<uint64_t>(static_cast<double>(value));\n\n    const uint64_t significand_mask =\n        (static_cast<uint64_t>(1) << num_significand_bits<double>()) - 1;\n    uint64_t significand = (br & significand_mask);\n    int exponent = static_cast<int>((br & exponent_mask<double>()) >>\n                                    num_significand_bits<double>());\n\n    if (exponent != 0) {  // Check if normal.\n      exponent -= exponent_bias<double>() + num_significand_bits<double>();\n      significand |=\n          (static_cast<uint64_t>(1) << num_significand_bits<double>());\n      significand <<= 1;\n    } else {\n      // Normalize subnormal inputs.\n      FMT_ASSERT(significand != 0, \"zeros should not appear here\");\n      int shift = countl_zero(significand);\n      FMT_ASSERT(shift >= num_bits<uint64_t>() - num_significand_bits<double>(),\n                 \"\");\n      shift -= (num_bits<uint64_t>() - num_significand_bits<double>() - 2);\n      exponent = (std::numeric_limits<double>::min_exponent -\n                  num_significand_bits<double>()) -\n                 shift;\n      significand <<= shift;\n    }\n\n    // Compute the first several nonzero decimal significand digits.\n    // We call the number we get the first segment.\n    const int k = info::kappa - dragonbox::floor_log10_pow2(exponent);\n    exp = -k;\n    const int beta = exponent + dragonbox::floor_log2_pow10(k);\n    uint64_t first_segment;\n    bool has_more_segments;\n    int digits_in_the_first_segment;\n    {\n      const auto r = dragonbox::umul192_upper128(\n          significand << beta, dragonbox::get_cached_power(k));\n      first_segment = r.high();\n      has_more_segments = r.low() != 0;\n\n      // The first segment can have 18 ~ 19 digits.\n      if (first_segment >= 1000000000000000000ULL) {\n        digits_in_the_first_segment = 19;\n      } else {\n        // When it is of 18-digits, we align it to 19-digits by adding a bogus\n        // zero at the end.\n        digits_in_the_first_segment = 18;\n        first_segment *= 10;\n      }\n    }\n\n    // Compute the actual number of decimal digits to print.\n    if (fixed) adjust_precision(precision, exp + digits_in_the_first_segment);\n\n    // Use Dragon4 only when there might be not enough digits in the first\n    // segment.\n    if (digits_in_the_first_segment > precision) {\n      use_dragon = false;\n\n      if (precision <= 0) {\n        exp += digits_in_the_first_segment;\n\n        if (precision < 0) {\n          // Nothing to do, since all we have are just leading zeros.\n          buf.try_resize(0);\n        } else {\n          // We may need to round-up.\n          buf.try_resize(1);\n          if ((first_segment | static_cast<uint64_t>(has_more_segments)) >\n              5000000000000000000ULL) {\n            buf[0] = '1';\n          } else {\n            buf[0] = '0';\n          }\n        }\n      }  // precision <= 0\n      else {\n        exp += digits_in_the_first_segment - precision;\n\n        // When precision > 0, we divide the first segment into three\n        // subsegments, each with 9, 9, and 0 ~ 1 digits so that each fits\n        // in 32-bits which usually allows faster calculation than in\n        // 64-bits. Since some compiler (e.g. MSVC) doesn't know how to optimize\n        // division-by-constant for large 64-bit divisors, we do it here\n        // manually. The magic number 7922816251426433760 below is equal to\n        // ceil(2^(64+32) / 10^10).\n        const uint32_t first_subsegment = static_cast<uint32_t>(\n            dragonbox::umul128_upper64(first_segment, 7922816251426433760ULL) >>\n            32);\n        const uint64_t second_third_subsegments =\n            first_segment - first_subsegment * 10000000000ULL;\n\n        uint64_t prod;\n        uint32_t digits;\n        bool should_round_up;\n        int number_of_digits_to_print = min_of(precision, 9);\n\n        // Print a 9-digits subsegment, either the first or the second.\n        auto print_subsegment = [&](uint32_t subsegment, char* buffer) {\n          int number_of_digits_printed = 0;\n\n          // If we want to print an odd number of digits from the subsegment,\n          if ((number_of_digits_to_print & 1) != 0) {\n            // Convert to 64-bit fixed-point fractional form with 1-digit\n            // integer part. The magic number 720575941 is a good enough\n            // approximation of 2^(32 + 24) / 10^8; see\n            // https://jk-jeon.github.io/posts/2022/12/fixed-precision-formatting/#fixed-length-case\n            // for details.\n            prod = ((subsegment * static_cast<uint64_t>(720575941)) >> 24) + 1;\n            digits = static_cast<uint32_t>(prod >> 32);\n            *buffer = static_cast<char>('0' + digits);\n            number_of_digits_printed++;\n          }\n          // If we want to print an even number of digits from the\n          // first_subsegment,\n          else {\n            // Convert to 64-bit fixed-point fractional form with 2-digits\n            // integer part. The magic number 450359963 is a good enough\n            // approximation of 2^(32 + 20) / 10^7; see\n            // https://jk-jeon.github.io/posts/2022/12/fixed-precision-formatting/#fixed-length-case\n            // for details.\n            prod = ((subsegment * static_cast<uint64_t>(450359963)) >> 20) + 1;\n            digits = static_cast<uint32_t>(prod >> 32);\n            write2digits(buffer, digits);\n            number_of_digits_printed += 2;\n          }\n\n          // Print all digit pairs.\n          while (number_of_digits_printed < number_of_digits_to_print) {\n            prod = static_cast<uint32_t>(prod) * static_cast<uint64_t>(100);\n            digits = static_cast<uint32_t>(prod >> 32);\n            write2digits(buffer + number_of_digits_printed, digits);\n            number_of_digits_printed += 2;\n          }\n        };\n\n        // Print first subsegment.\n        print_subsegment(first_subsegment, buf.data());\n\n        // Perform rounding if the first subsegment is the last subsegment to\n        // print.\n        if (precision <= 9) {\n          // Rounding inside the subsegment.\n          // We round-up if:\n          //  - either the fractional part is strictly larger than 1/2, or\n          //  - the fractional part is exactly 1/2 and the last digit is odd.\n          // We rely on the following observations:\n          //  - If fractional_part >= threshold, then the fractional part is\n          //    strictly larger than 1/2.\n          //  - If the MSB of fractional_part is set, then the fractional part\n          //    must be at least 1/2.\n          //  - When the MSB of fractional_part is set, either\n          //    second_third_subsegments being nonzero or has_more_segments\n          //    being true means there are further digits not printed, so the\n          //    fractional part is strictly larger than 1/2.\n          if (precision < 9) {\n            uint32_t fractional_part = static_cast<uint32_t>(prod);\n            should_round_up =\n                fractional_part >= fractional_part_rounding_thresholds(\n                                       8 - number_of_digits_to_print) ||\n                ((fractional_part >> 31) &\n                 ((digits & 1) | (second_third_subsegments != 0) |\n                  has_more_segments)) != 0;\n          }\n          // Rounding at the subsegment boundary.\n          // In this case, the fractional part is at least 1/2 if and only if\n          // second_third_subsegments >= 5000000000ULL, and is strictly larger\n          // than 1/2 if we further have either second_third_subsegments >\n          // 5000000000ULL or has_more_segments == true.\n          else {\n            should_round_up = second_third_subsegments > 5000000000ULL ||\n                              (second_third_subsegments == 5000000000ULL &&\n                               ((digits & 1) != 0 || has_more_segments));\n          }\n        }\n        // Otherwise, print the second subsegment.\n        else {\n          // Compilers are not aware of how to leverage the maximum value of\n          // second_third_subsegments to find out a better magic number which\n          // allows us to eliminate an additional shift. 1844674407370955162 =\n          // ceil(2^64/10) < ceil(2^64*(10^9/(10^10 - 1))).\n          const uint32_t second_subsegment =\n              static_cast<uint32_t>(dragonbox::umul128_upper64(\n                  second_third_subsegments, 1844674407370955162ULL));\n          const uint32_t third_subsegment =\n              static_cast<uint32_t>(second_third_subsegments) -\n              second_subsegment * 10;\n\n          number_of_digits_to_print = precision - 9;\n          print_subsegment(second_subsegment, buf.data() + 9);\n\n          // Rounding inside the subsegment.\n          if (precision < 18) {\n            // The condition third_subsegment != 0 implies that the segment was\n            // of 19 digits, so in this case the third segment should be\n            // consisting of a genuine digit from the input.\n            uint32_t fractional_part = static_cast<uint32_t>(prod);\n            should_round_up =\n                fractional_part >= fractional_part_rounding_thresholds(\n                                       8 - number_of_digits_to_print) ||\n                ((fractional_part >> 31) &\n                 ((digits & 1) | (third_subsegment != 0) |\n                  has_more_segments)) != 0;\n          }\n          // Rounding at the subsegment boundary.\n          else {\n            // In this case, the segment must be of 19 digits, thus\n            // the third subsegment should be consisting of a genuine digit from\n            // the input.\n            should_round_up = third_subsegment > 5 ||\n                              (third_subsegment == 5 &&\n                               ((digits & 1) != 0 || has_more_segments));\n          }\n        }\n\n        // Round-up if necessary.\n        if (should_round_up) {\n          ++buf[precision - 1];\n          for (int i = precision - 1; i > 0 && buf[i] > '9'; --i) {\n            buf[i] = '0';\n            ++buf[i - 1];\n          }\n          if (buf[0] > '9') {\n            buf[0] = '1';\n            if (fixed)\n              buf[precision++] = '0';\n            else\n              ++exp;\n          }\n        }\n        buf.try_resize(to_unsigned(precision));\n      }\n    }  // if (digits_in_the_first_segment > precision)\n    else {\n      // Adjust the exponent for its use in Dragon4.\n      exp += digits_in_the_first_segment - 1;\n    }\n  }\n  if (use_dragon) {\n    auto f = basic_fp<uint128_t>();\n    bool is_predecessor_closer = binary32 ? f.assign(static_cast<float>(value))\n                                          : f.assign(converted_value);\n    if (is_predecessor_closer) dragon_flags |= dragon::predecessor_closer;\n    if (fixed) dragon_flags |= dragon::fixed;\n    // Limit precision to the maximum possible number of significant digits in\n    // an IEEE754 double because we don't need to generate zeros.\n    const int max_double_digits = 767;\n    if (precision > max_double_digits) precision = max_double_digits;\n    format_dragon(f, dragon_flags, precision, buf, exp);\n  }\n  if (!fixed && !specs.alt()) {\n    // Remove trailing zeros.\n    auto num_digits = buf.size();\n    while (num_digits > 0 && buf[num_digits - 1] == '0') {\n      --num_digits;\n      ++exp;\n    }\n    buf.try_resize(num_digits);\n  }\n  return exp;\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(is_floating_point<T>::value)>\nFMT_CONSTEXPR20 auto write(OutputIt out, T value, format_specs specs,\n                           locale_ref loc = {}) -> OutputIt {\n  if (specs.localized() && write_loc(out, value, specs, loc)) return out;\n\n  // Use signbit because value < 0 is false for NaN.\n  sign s = detail::signbit(value) ? sign::minus : specs.sign();\n\n  if (!detail::isfinite(value))\n    return write_nonfinite<Char>(out, detail::isnan(value), specs, s);\n\n  if (specs.align() == align::numeric && s != sign::none) {\n    *out++ = detail::getsign<Char>(s);\n    s = sign::none;\n    if (specs.width != 0) --specs.width;\n  }\n\n  const int exp_upper = detail::exp_upper<T>();\n  int precision = specs.precision;\n  if (precision < 0) {\n    if (specs.type() != presentation_type::none) {\n      precision = 6;\n    } else if (is_fast_float<T>::value && !is_constant_evaluated()) {\n      // Use Dragonbox for the shortest format.\n      auto dec = dragonbox::to_decimal(static_cast<fast_float_t<T>>(value));\n      return write_float<Char>(out, dec, specs, s, exp_upper, loc);\n    }\n  }\n\n  memory_buffer buffer;\n  if (specs.type() == presentation_type::hexfloat) {\n    if (s != sign::none) buffer.push_back(detail::getsign<char>(s));\n    format_hexfloat(convert_float(value), specs, buffer);\n    return write_bytes<Char, align::right>(out, {buffer.data(), buffer.size()},\n                                           specs);\n  }\n\n  if (specs.type() == presentation_type::exp) {\n    if (precision == max_value<int>())\n      report_error(\"number is too big\");\n    else\n      ++precision;\n    if (specs.precision != 0) specs.set_alt();\n  } else if (specs.type() == presentation_type::fixed) {\n    if (specs.precision != 0) specs.set_alt();\n  } else if (precision == 0) {\n    precision = 1;\n  }\n  int exp = format_float(convert_float(value), precision, specs,\n                         std::is_same<T, float>(), buffer);\n\n  specs.precision = precision;\n  auto f = big_decimal_fp{buffer.data(), static_cast<int>(buffer.size()), exp};\n  return write_float<Char>(out, f, specs, s, exp_upper, loc);\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(is_fast_float<T>::value)>\nFMT_CONSTEXPR20 auto write(OutputIt out, T value) -> OutputIt {\n  if (is_constant_evaluated()) return write<Char>(out, value, format_specs());\n\n  auto s = detail::signbit(value) ? sign::minus : sign::none;\n  auto mask = exponent_mask<fast_float_t<T>>();\n  if ((bit_cast<decltype(mask)>(value) & mask) == mask)\n    return write_nonfinite<Char>(out, std::isnan(value), {}, s);\n\n  auto dec = dragonbox::to_decimal(static_cast<fast_float_t<T>>(value));\n  auto significand = dec.significand;\n  int significand_size = count_digits(significand);\n  int exponent = dec.exponent + significand_size - 1;\n  if (use_fixed(exponent, detail::exp_upper<T>())) {\n    return write_fixed<Char, fallback_digit_grouping<Char>>(\n        out, dec, significand_size, Char('.'), {}, s);\n  }\n\n  // Write value in the exponential format.\n  const char* prefix = \"e+\";\n  int abs_exponent = exponent;\n  if (exponent < 0) {\n    abs_exponent = -exponent;\n    prefix = \"e-\";\n  }\n  auto has_decimal_point = significand_size != 1;\n  size_t size = std::is_pointer<OutputIt>::value\n                    ? 0u\n                    : to_unsigned((s != sign::none ? 1 : 0) + significand_size +\n                                  (has_decimal_point ? 1 : 0) +\n                                  (abs_exponent >= 100 ? 5 : 4));\n  if (auto ptr = to_pointer<Char>(out, size)) {\n    if (s != sign::none) *ptr++ = Char('-');\n    if (has_decimal_point) {\n      auto begin = ptr;\n      ptr = format_decimal<Char>(ptr, significand, significand_size + 1);\n      *begin = begin[1];\n      begin[1] = '.';\n    } else {\n      *ptr++ = static_cast<Char>('0' + significand);\n    }\n    if (std::is_same<Char, char>::value) {\n      memcpy(ptr, prefix, 2);\n      ptr += 2;\n    } else {\n      *ptr++ = static_cast<Char>(prefix[0]);\n      *ptr++ = static_cast<Char>(prefix[1]);\n    }\n    if (abs_exponent >= 100) {\n      *ptr++ = static_cast<Char>('0' + abs_exponent / 100);\n      abs_exponent %= 100;\n    }\n    write2digits(ptr, static_cast<unsigned>(abs_exponent));\n    return select<std::is_pointer<OutputIt>::value>(ptr + 2, out);\n  }\n  auto it = reserve(out, size);\n  if (s != sign::none) *it++ = Char('-');\n  // Insert a decimal point after the first digit and add an exponent.\n  it = write_significand(it, significand, significand_size, 1,\n                         has_decimal_point ? Char('.') : Char());\n  *it++ = Char('e');\n  it = write_exponent<Char>(exponent, it);\n  return base_iterator(out, it);\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(is_floating_point<T>::value &&\n                        !is_fast_float<T>::value)>\ninline auto write(OutputIt out, T value) -> OutputIt {\n  return write<Char>(out, value, {});\n}\n\ntemplate <typename Char, typename OutputIt>\nauto write(OutputIt out, monostate, format_specs = {}, locale_ref = {})\n    -> OutputIt {\n  FMT_ASSERT(false, \"\");\n  return out;\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> value)\n    -> OutputIt {\n  return copy_noinline<Char>(value.begin(), value.end(), out);\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(has_to_string_view<T>::value)>\nconstexpr auto write(OutputIt out, const T& value) -> OutputIt {\n  return write<Char>(out, to_string_view(value));\n}\n\n// FMT_ENABLE_IF() condition separated to workaround an MSVC bug.\ntemplate <\n    typename Char, typename OutputIt, typename T,\n    bool check = std::is_enum<T>::value && !std::is_same<T, Char>::value &&\n                 mapped_type_constant<T, Char>::value != type::custom_type,\n    FMT_ENABLE_IF(check)>\nFMT_CONSTEXPR auto write(OutputIt out, T value) -> OutputIt {\n  return write<Char>(out, static_cast<underlying_t<T>>(value));\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(std::is_same<T, bool>::value)>\nFMT_CONSTEXPR auto write(OutputIt out, T value, const format_specs& specs = {},\n                         locale_ref = {}) -> OutputIt {\n  return specs.type() != presentation_type::none &&\n                 specs.type() != presentation_type::string\n             ? write<Char>(out, value ? 1 : 0, specs, {})\n             : write_bytes<Char>(out, value ? \"true\" : \"false\", specs);\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR auto write(OutputIt out, Char value) -> OutputIt {\n  auto it = reserve(out, 1);\n  *it++ = value;\n  return base_iterator(out, it);\n}\n\ntemplate <typename Char, typename OutputIt>\nFMT_CONSTEXPR20 auto write(OutputIt out, const Char* value) -> OutputIt {\n  if (value) return write(out, basic_string_view<Char>(value));\n  report_error(\"string pointer is null\");\n  return out;\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(std::is_same<T, void>::value)>\nauto write(OutputIt out, const T* value, const format_specs& specs = {},\n           locale_ref = {}) -> OutputIt {\n  return write_ptr<Char>(out, bit_cast<uintptr_t>(value), &specs);\n}\n\ntemplate <typename Char, typename OutputIt, typename T,\n          FMT_ENABLE_IF(mapped_type_constant<T, Char>::value ==\n                            type::custom_type &&\n                        !std::is_fundamental<T>::value)>\nFMT_CONSTEXPR auto write(OutputIt out, const T& value) -> OutputIt {\n  auto f = formatter<T, Char>();\n  auto parse_ctx = parse_context<Char>({});\n  f.parse(parse_ctx);\n  auto ctx = basic_format_context<OutputIt, Char>(out, {}, {});\n  return f.format(value, ctx);\n}\n\ntemplate <typename T>\nusing is_builtin =\n    bool_constant<std::is_same<T, int>::value || FMT_BUILTIN_TYPES>;\n\n// An argument visitor that formats the argument and writes it via the output\n// iterator. It's a class and not a generic lambda for compatibility with C++11.\ntemplate <typename Char> struct default_arg_formatter {\n  using context = buffered_context<Char>;\n\n  basic_appender<Char> out;\n\n  void operator()(monostate) { report_error(\"argument not found\"); }\n\n  template <typename T, FMT_ENABLE_IF(is_builtin<T>::value)>\n  void operator()(T value) {\n    write<Char>(out, value);\n  }\n\n  template <typename T, FMT_ENABLE_IF(!is_builtin<T>::value)>\n  void operator()(T) {\n    FMT_ASSERT(false, \"\");\n  }\n\n  void operator()(typename basic_format_arg<context>::handle h) {\n    // Use a null locale since the default format must be unlocalized.\n    auto parse_ctx = parse_context<Char>({});\n    auto format_ctx = context(out, {}, {});\n    h.format(parse_ctx, format_ctx);\n  }\n};\n\ntemplate <typename Char> struct arg_formatter {\n  basic_appender<Char> out;\n  const format_specs& specs;\n  FMT_NO_UNIQUE_ADDRESS locale_ref locale;\n\n  template <typename T, FMT_ENABLE_IF(is_builtin<T>::value)>\n  FMT_CONSTEXPR FMT_INLINE void operator()(T value) {\n    detail::write<Char>(out, value, specs, locale);\n  }\n\n  template <typename T, FMT_ENABLE_IF(!is_builtin<T>::value)>\n  void operator()(T) {\n    FMT_ASSERT(false, \"\");\n  }\n\n  void operator()(typename basic_format_arg<buffered_context<Char>>::handle) {\n    // User-defined types are handled separately because they require access\n    // to the parse context.\n  }\n};\n\nstruct dynamic_spec_getter {\n  template <typename T, FMT_ENABLE_IF(is_integer<T>::value)>\n  FMT_CONSTEXPR auto operator()(T value) -> ullong {\n    return is_negative(value) ? ~0ull : static_cast<ullong>(value);\n  }\n\n  template <typename T, FMT_ENABLE_IF(!is_integer<T>::value)>\n  FMT_CONSTEXPR auto operator()(T) -> ullong {\n    report_error(\"width/precision is not integer\");\n    return 0;\n  }\n};\n\ntemplate <typename Context>\nFMT_CONSTEXPR void handle_dynamic_spec(\n    arg_id_kind kind, int& value,\n    const arg_ref<typename Context::char_type>& ref, Context& ctx) {\n  if (kind == arg_id_kind::none) return;\n  auto arg =\n      kind == arg_id_kind::index ? ctx.arg(ref.index) : ctx.arg(ref.name);\n  if (!arg) report_error(\"argument not found\");\n  ullong result = arg.visit(dynamic_spec_getter());\n  if (result > to_unsigned(max_value<int>()))\n    report_error(\"width/precision is out of range\");\n  value = static_cast<int>(result);\n}\n\n#if FMT_USE_NONTYPE_TEMPLATE_ARGS\ntemplate <typename T, typename Char, size_t N,\n          fmt::detail::fixed_string<Char, N> Str>\nstruct static_named_arg : view {\n  static constexpr auto name = Str.data;\n\n  const T& value;\n  static_named_arg(const T& v) : value(v) {}\n};\n\ntemplate <typename T, typename Char, size_t N,\n          fmt::detail::fixed_string<Char, N> Str>\nstruct is_named_arg<static_named_arg<T, Char, N, Str>> : std::true_type {};\n\ntemplate <typename T, typename Char, size_t N,\n          fmt::detail::fixed_string<Char, N> Str>\nstruct is_static_named_arg<static_named_arg<T, Char, N, Str>> : std::true_type {\n};\n\ntemplate <typename Char, size_t N, fmt::detail::fixed_string<Char, N> Str>\nstruct udl_arg {\n  template <typename T> auto operator=(T&& value) const {\n    return static_named_arg<T, Char, N, Str>(std::forward<T>(value));\n  }\n};\n#else\ntemplate <typename Char> struct udl_arg {\n  const Char* str;\n\n  template <typename T> auto operator=(T&& value) const -> named_arg<T, Char> {\n    return {str, std::forward<T>(value)};\n  }\n};\n#endif  // FMT_USE_NONTYPE_TEMPLATE_ARGS\n\ntemplate <typename Char = char> struct format_handler {\n  parse_context<Char> parse_ctx;\n  buffered_context<Char> ctx;\n\n  void on_text(const Char* begin, const Char* end) {\n    copy_noinline<Char>(begin, end, ctx.out());\n  }\n\n  FMT_CONSTEXPR auto on_arg_id() -> int { return parse_ctx.next_arg_id(); }\n  FMT_CONSTEXPR auto on_arg_id(int id) -> int {\n    parse_ctx.check_arg_id(id);\n    return id;\n  }\n  FMT_CONSTEXPR auto on_arg_id(basic_string_view<Char> id) -> int {\n    parse_ctx.check_arg_id(id);\n    int arg_id = ctx.arg_id(id);\n    if (arg_id < 0) report_error(\"argument not found\");\n    return arg_id;\n  }\n\n  FMT_INLINE void on_replacement_field(int id, const Char*) {\n    ctx.arg(id).visit(default_arg_formatter<Char>{ctx.out()});\n  }\n\n  auto on_format_specs(int id, const Char* begin, const Char* end)\n      -> const Char* {\n    auto arg = ctx.arg(id);\n    if (!arg) report_error(\"argument not found\");\n    // Not using a visitor for custom types gives better codegen.\n    if (arg.format_custom(begin, parse_ctx, ctx)) return parse_ctx.begin();\n\n    auto specs = dynamic_format_specs<Char>();\n    begin = parse_format_specs(begin, end, specs, parse_ctx, arg.type());\n    if (specs.dynamic()) {\n      handle_dynamic_spec(specs.dynamic_width(), specs.width, specs.width_ref,\n                          ctx);\n      handle_dynamic_spec(specs.dynamic_precision(), specs.precision,\n                          specs.precision_ref, ctx);\n    }\n\n    arg.visit(arg_formatter<Char>{ctx.out(), specs, ctx.locale()});\n    return begin;\n  }\n\n  FMT_NORETURN void on_error(const char* message) { report_error(message); }\n};\n\n// It is used in format-inl.h and os.cc.\nusing format_func = void (*)(detail::buffer<char>&, int, const char*);\nFMT_API void do_report_error(format_func func, int error_code,\n                             const char* message) noexcept;\n\nFMT_API void format_error_code(buffer<char>& out, int error_code,\n                               string_view message) noexcept;\n\ntemplate <typename T, typename Char, type TYPE>\ntemplate <typename FormatContext>\nFMT_CONSTEXPR auto native_formatter<T, Char, TYPE>::format(\n    const T& val, FormatContext& ctx) const -> decltype(ctx.out()) {\n  if (!specs_.dynamic())\n    return write<Char>(ctx.out(), val, specs_, ctx.locale());\n  auto specs = format_specs(specs_);\n  handle_dynamic_spec(specs.dynamic_width(), specs.width, specs_.width_ref,\n                      ctx);\n  handle_dynamic_spec(specs.dynamic_precision(), specs.precision,\n                      specs_.precision_ref, ctx);\n  return write<Char>(ctx.out(), val, specs, ctx.locale());\n}\n}  // namespace detail\n\nFMT_BEGIN_EXPORT\n\n// A generic formatting context with custom output iterator and character\n// (code unit) support. Char is the format string code unit type which can be\n// different from OutputIt::value_type.\ntemplate <typename OutputIt, typename Char> class generic_context {\n private:\n  OutputIt out_;\n  basic_format_args<generic_context> args_;\n  locale_ref loc_;\n\n public:\n  using char_type = Char;\n  using iterator = OutputIt;\n  enum { builtin_types = FMT_BUILTIN_TYPES };\n\n  constexpr generic_context(OutputIt out,\n                            basic_format_args<generic_context> args,\n                            locale_ref loc = {})\n      : out_(out), args_(args), loc_(loc) {}\n  generic_context(generic_context&&) = default;\n  generic_context(const generic_context&) = delete;\n  void operator=(const generic_context&) = delete;\n\n  constexpr auto arg(int id) const -> basic_format_arg<generic_context> {\n    return args_.get(id);\n  }\n  auto arg(basic_string_view<Char> name) const\n      -> basic_format_arg<generic_context> {\n    return args_.get(name);\n  }\n  constexpr auto arg_id(basic_string_view<Char> name) const -> int {\n    return args_.get_id(name);\n  }\n\n  constexpr auto out() const -> iterator { return out_; }\n\n  void advance_to(iterator it) {\n    if (!detail::is_back_insert_iterator<iterator>()) out_ = it;\n  }\n\n  constexpr auto locale() const -> locale_ref { return loc_; }\n};\n\nclass loc_value {\n private:\n  basic_format_arg<context> value_;\n\n public:\n  template <typename T, FMT_ENABLE_IF(!detail::is_float128<T>::value)>\n  loc_value(T value) : value_(value) {}\n\n  template <typename T, FMT_ENABLE_IF(detail::is_float128<T>::value)>\n  loc_value(T) {}\n\n  template <typename Visitor> auto visit(Visitor&& vis) -> decltype(vis(0)) {\n    return value_.visit(vis);\n  }\n};\n\n// A locale facet that formats values in UTF-8.\n// It is parameterized on the locale to avoid the heavy <locale> include.\ntemplate <typename Locale> class format_facet : public Locale::facet {\n private:\n  std::string separator_;\n  std::string grouping_;\n  std::string decimal_point_;\n\n protected:\n  virtual auto do_put(appender out, loc_value val,\n                      const format_specs& specs) const -> bool;\n\n public:\n  static FMT_API typename Locale::id id;\n\n  explicit format_facet(Locale& loc);\n  explicit format_facet(string_view sep = \"\", std::string grouping = \"\\3\",\n                        std::string decimal_point = \".\")\n      : separator_(sep.data(), sep.size()),\n        grouping_(std::move(grouping)),\n        decimal_point_(std::move(decimal_point)) {}\n\n  auto put(appender out, loc_value val, const format_specs& specs) const\n      -> bool {\n    return do_put(out, val, specs);\n  }\n};\n\n#define FMT_FORMAT_AS(Type, Base)                                   \\\n  template <typename Char>                                          \\\n  struct formatter<Type, Char> : formatter<Base, Char> {            \\\n    template <typename FormatContext>                               \\\n    FMT_CONSTEXPR auto format(Type value, FormatContext& ctx) const \\\n        -> decltype(ctx.out()) {                                    \\\n      return formatter<Base, Char>::format(value, ctx);             \\\n    }                                                               \\\n  }\n\nFMT_FORMAT_AS(signed char, int);\nFMT_FORMAT_AS(unsigned char, unsigned);\nFMT_FORMAT_AS(short, int);\nFMT_FORMAT_AS(unsigned short, unsigned);\nFMT_FORMAT_AS(long, detail::long_type);\nFMT_FORMAT_AS(unsigned long, detail::ulong_type);\nFMT_FORMAT_AS(Char*, const Char*);\nFMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);\nFMT_FORMAT_AS(std::nullptr_t, const void*);\nFMT_FORMAT_AS(void*, const void*);\n\ntemplate <typename Char, size_t N>\nstruct formatter<Char[N], Char> : formatter<basic_string_view<Char>, Char> {};\n\ntemplate <typename Char, typename Traits, typename Allocator>\nclass formatter<std::basic_string<Char, Traits, Allocator>, Char>\n    : public formatter<basic_string_view<Char>, Char> {};\n\ntemplate <typename Char>\nstruct formatter<detail::float128, Char>\n    : detail::native_formatter<detail::float128, Char,\n                               detail::type::float_type> {};\n\ntemplate <typename T, typename Char>\nstruct formatter<T, Char, void_t<detail::format_as_result<T>>>\n    : formatter<detail::format_as_result<T>, Char> {\n  template <typename FormatContext>\n  FMT_CONSTEXPR auto format(const T& value, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto&& val = format_as(value);  // Make an lvalue reference for format.\n    return formatter<detail::format_as_result<T>, Char>::format(val, ctx);\n  }\n};\n\n/**\n * Converts `p` to `const void*` for pointer formatting.\n *\n * **Example**:\n *\n *     auto s = fmt::format(\"{}\", fmt::ptr(p));\n */\ntemplate <typename T> auto ptr(T p) -> const void* {\n  static_assert(std::is_pointer<T>::value, \"fmt::ptr used with non-pointer\");\n  return detail::bit_cast<const void*>(p);\n}\n\n/**\n * Converts `e` to the underlying type.\n *\n * **Example**:\n *\n *     enum class color { red, green, blue };\n *     auto s = fmt::format(\"{}\", fmt::underlying(color::red));  // s == \"0\"\n */\ntemplate <typename Enum>\nconstexpr auto underlying(Enum e) noexcept -> underlying_t<Enum> {\n  return static_cast<underlying_t<Enum>>(e);\n}\n\nnamespace enums {\ntemplate <typename Enum, FMT_ENABLE_IF(std::is_enum<Enum>::value)>\nconstexpr auto format_as(Enum e) noexcept -> underlying_t<Enum> {\n  return static_cast<underlying_t<Enum>>(e);\n}\n}  // namespace enums\n\nstruct bytes {\n  string_view data;\n\n  inline explicit bytes(string_view s) : data(s) {}\n};\n\ntemplate <> struct formatter<bytes> {\n private:\n  detail::dynamic_format_specs<> specs_;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {\n    return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,\n                              detail::type::string_type);\n  }\n\n  template <typename FormatContext>\n  auto format(bytes b, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto specs = specs_;\n    detail::handle_dynamic_spec(specs.dynamic_width(), specs.width,\n                                specs.width_ref, ctx);\n    detail::handle_dynamic_spec(specs.dynamic_precision(), specs.precision,\n                                specs.precision_ref, ctx);\n    return detail::write_bytes<char>(ctx.out(), b.data, specs);\n  }\n};\n\n// group_digits_view is not derived from view because it copies the argument.\ntemplate <typename T> struct group_digits_view {\n  T value;\n};\n\n/**\n * Returns a view that formats an integer value using ',' as a\n * locale-independent thousands separator.\n *\n * **Example**:\n *\n *     fmt::print(\"{}\", fmt::group_digits(12345));\n *     // Output: \"12,345\"\n */\ntemplate <typename T> auto group_digits(T value) -> group_digits_view<T> {\n  return {value};\n}\n\ntemplate <typename T> struct formatter<group_digits_view<T>> : formatter<T> {\n private:\n  detail::dynamic_format_specs<> specs_;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {\n    return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,\n                              detail::type::int_type);\n  }\n\n  template <typename FormatContext>\n  auto format(group_digits_view<T> view, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto specs = specs_;\n    detail::handle_dynamic_spec(specs.dynamic_width(), specs.width,\n                                specs.width_ref, ctx);\n    detail::handle_dynamic_spec(specs.dynamic_precision(), specs.precision,\n                                specs.precision_ref, ctx);\n    auto arg = detail::make_write_int_arg(view.value, specs.sign());\n    return detail::write_int(\n        ctx.out(), static_cast<detail::uint64_or_128_t<T>>(arg.abs_value),\n        arg.prefix, specs, detail::digit_grouping<char>(\"\\3\", \",\"));\n  }\n};\n\ntemplate <typename T, typename Char> struct nested_view {\n  const formatter<T, Char>* fmt;\n  const T* value;\n};\n\ntemplate <typename T, typename Char>\nstruct formatter<nested_view<T, Char>, Char> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return ctx.begin();\n  }\n  template <typename FormatContext>\n  auto format(nested_view<T, Char> view, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return view.fmt->format(*view.value, ctx);\n  }\n};\n\ntemplate <typename T, typename Char = char> struct nested_formatter {\n private:\n  basic_specs specs_;\n  int width_;\n  formatter<T, Char> formatter_;\n\n public:\n  constexpr nested_formatter() : width_(0) {}\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it == end) return it;\n    auto specs = format_specs();\n    it = detail::parse_align(it, end, specs);\n    specs_ = specs;\n    Char c = *it;\n    auto width_ref = detail::arg_ref<Char>();\n    if ((c >= '0' && c <= '9') || c == '{') {\n      it = detail::parse_width(it, end, specs, width_ref, ctx);\n      width_ = specs.width;\n    }\n    ctx.advance_to(it);\n    return formatter_.parse(ctx);\n  }\n\n  template <typename FormatContext, typename F>\n  auto write_padded(FormatContext& ctx, F write) const -> decltype(ctx.out()) {\n    if (width_ == 0) return write(ctx.out());\n    auto buf = basic_memory_buffer<Char>();\n    write(basic_appender<Char>(buf));\n    auto specs = format_specs();\n    specs.width = width_;\n    specs.copy_fill_from(specs_);\n    specs.set_align(specs_.align());\n    return detail::write<Char>(\n        ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);\n  }\n\n  auto nested(const T& value) const -> nested_view<T, Char> {\n    return nested_view<T, Char>{&formatter_, &value};\n  }\n};\n\ninline namespace literals {\n#if FMT_USE_NONTYPE_TEMPLATE_ARGS\n/**\n * User-defined literal equivalent of `fmt::arg`, but with compile-time checks.\n *\n * **Example**:\n *\n *     using namespace fmt::literals;\n *     fmt::print(\"The answer is {answer}.\", \"answer\"_a=42);\n */\ntemplate <detail::fixed_string S> constexpr auto operator\"\"_a() {\n  using char_t = remove_cvref_t<decltype(*S.data)>;\n  return detail::udl_arg<char_t, sizeof(S.data) / sizeof(char_t), S>();\n}\n#else\n/**\n * User-defined literal equivalent of `fmt::arg`.\n *\n * **Example**:\n *\n *     using namespace fmt::literals;\n *     fmt::print(\"The answer is {answer}.\", \"answer\"_a=42);\n */\nconstexpr auto operator\"\"_a(const char* s, size_t) -> detail::udl_arg<char> {\n  return {s};\n}\n#endif  // FMT_USE_NONTYPE_TEMPLATE_ARGS\n}  // namespace literals\n\n/// A fast integer formatter.\nclass format_int {\n private:\n  // Buffer should be large enough to hold all digits (digits10 + 1),\n  // a sign and a null character.\n  enum { buffer_size = std::numeric_limits<ullong>::digits10 + 3 };\n  mutable char buffer_[buffer_size];\n  char* str_;\n\n  template <typename UInt>\n  FMT_CONSTEXPR20 auto format_unsigned(UInt value) -> char* {\n    auto n = static_cast<detail::uint32_or_64_or_128_t<UInt>>(value);\n    return detail::do_format_decimal(buffer_, n, buffer_size - 1);\n  }\n\n  template <typename Int>\n  FMT_CONSTEXPR20 auto format_signed(Int value) -> char* {\n    auto abs_value = static_cast<detail::uint32_or_64_or_128_t<Int>>(value);\n    bool negative = value < 0;\n    if (negative) abs_value = 0 - abs_value;\n    auto begin = format_unsigned(abs_value);\n    if (negative) *--begin = '-';\n    return begin;\n  }\n\n public:\n  FMT_CONSTEXPR20 explicit format_int(int value) : str_(format_signed(value)) {}\n  FMT_CONSTEXPR20 explicit format_int(long value)\n      : str_(format_signed(value)) {}\n  FMT_CONSTEXPR20 explicit format_int(long long value)\n      : str_(format_signed(value)) {}\n  FMT_CONSTEXPR20 explicit format_int(unsigned value)\n      : str_(format_unsigned(value)) {}\n  FMT_CONSTEXPR20 explicit format_int(unsigned long value)\n      : str_(format_unsigned(value)) {}\n  FMT_CONSTEXPR20 explicit format_int(ullong value)\n      : str_(format_unsigned(value)) {}\n\n  /// Returns the number of characters written to the output buffer.\n  FMT_CONSTEXPR20 auto size() const -> size_t {\n    return detail::to_unsigned(buffer_ - str_ + buffer_size - 1);\n  }\n\n  /// Returns a pointer to the output buffer content. No terminating null\n  /// character is appended.\n  FMT_CONSTEXPR20 auto data() const -> const char* { return str_; }\n\n  /// Returns a pointer to the output buffer content with terminating null\n  /// character appended.\n  FMT_CONSTEXPR20 auto c_str() const -> const char* {\n    buffer_[buffer_size - 1] = '\\0';\n    return str_;\n  }\n\n  /// Returns the content of the output buffer as an `std::string`.\n  inline auto str() const -> std::string { return {str_, size()}; }\n};\n\n#if FMT_CLANG_ANALYZER\n#  define FMT_STRING_IMPL(s, base) s\n#else\n#  define FMT_STRING_IMPL(s, base)                                           \\\n    [] {                                                                     \\\n      /* Use the hidden visibility as a workaround for a GCC bug (#1973). */ \\\n      /* Use a macro-like name to avoid shadowing warnings. */               \\\n      struct FMT_VISIBILITY(\"hidden\") FMT_COMPILE_STRING : base {            \\\n        using char_type = fmt::remove_cvref_t<decltype(s[0])>;               \\\n        constexpr explicit operator fmt::basic_string_view<char_type>()      \\\n            const {                                                          \\\n          return fmt::detail::compile_string_to_view<char_type>(s);          \\\n        }                                                                    \\\n      };                                                                     \\\n      using FMT_STRING_VIEW =                                                \\\n          fmt::basic_string_view<typename FMT_COMPILE_STRING::char_type>;    \\\n      fmt::detail::ignore_unused(FMT_STRING_VIEW(FMT_COMPILE_STRING()));     \\\n      return FMT_COMPILE_STRING();                                           \\\n    }()\n#endif  // FMT_CLANG_ANALYZER\n\n/**\n * Constructs a legacy compile-time format string from a string literal `s`.\n *\n * **Example**:\n *\n *     // A compile-time error because 'd' is an invalid specifier for strings.\n *     std::string s = fmt::format(FMT_STRING(\"{:d}\"), \"foo\");\n */\n#if FMT_USE_CONSTEVAL\n#  define FMT_STRING(s) s\n#else\n#  define FMT_STRING(s) FMT_STRING_IMPL(s, fmt::detail::compile_string)\n#endif  // FMT_USE_CONSTEVAL\n\nFMT_API auto vsystem_error(int error_code, string_view fmt, format_args args)\n    -> std::system_error;\n\n/**\n * Constructs `std::system_error` with a message formatted with\n * `fmt::format(fmt, args...)`.\n * `error_code` is a system error code as given by `errno`.\n *\n * **Example**:\n *\n *     // This throws std::system_error with the description\n *     //   cannot open file 'madeup': No such file or directory\n *     // or similar (system message may vary).\n *     const char* filename = \"madeup\";\n *     FILE* file = fopen(filename, \"r\");\n *     if (!file)\n *       throw fmt::system_error(errno, \"cannot open file '{}'\", filename);\n */\ntemplate <typename... T>\nauto system_error(int error_code, format_string<T...> fmt, T&&... args)\n    -> std::system_error {\n  return vsystem_error(error_code, fmt.str, vargs<T...>{{args...}});\n}\n\n/**\n * Formats an error message for an error returned by an operating system or a\n * language runtime, for example a file opening error, and writes it to `out`.\n * The format is the same as the one used by `std::system_error(ec, message)`\n * where `ec` is `std::error_code(error_code, std::generic_category())`.\n * It is implementation-defined but normally looks like:\n *\n *     <message>: <system-message>\n *\n * where `<message>` is the passed message and `<system-message>` is the system\n * message corresponding to the error code.\n * `error_code` is a system error code as given by `errno`.\n */\nFMT_API void format_system_error(detail::buffer<char>& out, int error_code,\n                                 const char* message) noexcept;\n\n// Reports a system error without throwing an exception.\n// Can be used to report errors from destructors.\nFMT_API void report_system_error(int error_code, const char* message) noexcept;\n\ninline auto vformat(locale_ref loc, string_view fmt, format_args args)\n    -> std::string {\n  auto buf = memory_buffer();\n  detail::vformat_to(buf, fmt, args, loc);\n  return {buf.data(), buf.size()};\n}\n\ntemplate <typename... T>\nFMT_INLINE auto format(locale_ref loc, format_string<T...> fmt, T&&... args)\n    -> std::string {\n  return vformat(loc, fmt.str, vargs<T...>{{args...}});\n}\n\ntemplate <typename OutputIt,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>\nauto vformat_to(OutputIt out, locale_ref loc, string_view fmt, format_args args)\n    -> OutputIt {\n  auto&& buf = detail::get_buffer<char>(out);\n  detail::vformat_to(buf, fmt, args, loc);\n  return detail::get_iterator(buf, out);\n}\n\ntemplate <typename OutputIt, typename... T,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, char>::value)>\nFMT_INLINE auto format_to(OutputIt out, locale_ref loc, format_string<T...> fmt,\n                          T&&... args) -> OutputIt {\n  return fmt::vformat_to(out, loc, fmt.str, vargs<T...>{{args...}});\n}\n\ntemplate <typename... T>\nFMT_NODISCARD FMT_INLINE auto formatted_size(locale_ref loc,\n                                             format_string<T...> fmt,\n                                             T&&... args) -> size_t {\n  auto buf = detail::counting_buffer<>();\n  detail::vformat_to(buf, fmt.str, vargs<T...>{{args...}}, loc);\n  return buf.count();\n}\n\nFMT_API auto vformat(string_view fmt, format_args args) -> std::string;\n\n/**\n * Formats `args` according to specifications in `fmt` and returns the result\n * as a string.\n *\n * **Example**:\n *\n *     #include <fmt/format.h>\n *     std::string message = fmt::format(\"The answer is {}.\", 42);\n */\ntemplate <typename... T>\nFMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)\n    -> std::string {\n  return vformat(fmt.str, vargs<T...>{{args...}});\n}\n\n/**\n * Converts `value` to `std::string` using the default format for type `T`.\n *\n * **Example**:\n *\n *     std::string answer = fmt::to_string(42);\n */\ntemplate <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\nFMT_NODISCARD FMT_CONSTEXPR_STRING auto to_string(T value) -> std::string {\n  // The buffer should be large enough to store the number including the sign\n  // or \"false\" for bool.\n  char buffer[max_of(detail::digits10<T>() + 2, 5)];\n  return {buffer, detail::write<char>(buffer, value)};\n}\n\ntemplate <typename T, FMT_ENABLE_IF(detail::use_format_as<T>::value)>\nFMT_NODISCARD FMT_CONSTEXPR_STRING auto to_string(const T& value)\n    -> std::string {\n  return to_string(format_as(value));\n}\n\ntemplate <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value &&\n                                    !detail::use_format_as<T>::value)>\nFMT_NODISCARD FMT_CONSTEXPR_STRING auto to_string(const T& value)\n    -> std::string {\n  auto buffer = memory_buffer();\n  detail::write<char>(appender(buffer), value);\n  return {buffer.data(), buffer.size()};\n}\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#ifdef FMT_HEADER_ONLY\n#  define FMT_FUNC inline\n#  include \"format-inl.h\"\n#endif\n\n// Restore _LIBCPP_REMOVE_TRANSITIVE_INCLUDES.\n#ifdef FMT_REMOVE_TRANSITIVE_INCLUDES\n#  undef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES\n#endif\n\n#endif  // FMT_FORMAT_H_\n"
  },
  {
    "path": "include/fmt/os.h",
    "content": "// Formatting library for C++ - optional OS-specific functionality\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_OS_H_\n#define FMT_OS_H_\n\n#include \"format.h\"\n\n#ifndef FMT_MODULE\n#  include <cerrno>\n#  include <cstddef>\n#  include <cstdio>\n#  include <system_error>  // std::system_error\n\n#  if FMT_HAS_INCLUDE(<xlocale.h>)\n#    include <xlocale.h>  // LC_NUMERIC_MASK on macOS\n#  endif\n#endif  // FMT_MODULE\n\n#ifndef FMT_USE_FCNTL\n// UWP doesn't provide _pipe.\n#  if FMT_HAS_INCLUDE(\"winapifamily.h\")\n#    include <winapifamily.h>\n#  endif\n#  if (FMT_HAS_INCLUDE(<fcntl.h>) || defined(__APPLE__) || \\\n       defined(__linux__)) &&                              \\\n      (!defined(WINAPI_FAMILY) ||                          \\\n       (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) &&    \\\n      !defined(__wasm__)\n#    include <fcntl.h>  // for O_RDONLY\n#    define FMT_USE_FCNTL 1\n#  else\n#    define FMT_USE_FCNTL 0\n#  endif\n#endif\n\n#ifndef FMT_POSIX\n#  if defined(_WIN32) && !defined(__MINGW32__)\n// Fix warnings about deprecated symbols.\n#    define FMT_POSIX(call) _##call\n#  else\n#    define FMT_POSIX(call) call\n#  endif\n#endif\n\n// Calls to system functions are wrapped in FMT_SYSTEM for testability.\n#ifdef FMT_SYSTEM\n#  define FMT_HAS_SYSTEM\n#  define FMT_POSIX_CALL(call) FMT_SYSTEM(call)\n#else\n#  define FMT_SYSTEM(call) ::call\n#  ifdef _WIN32\n// Fix warnings about deprecated symbols.\n#    define FMT_POSIX_CALL(call) ::_##call\n#  else\n#    define FMT_POSIX_CALL(call) ::call\n#  endif\n#endif\n\n// Retries the expression while it evaluates to error_result and errno\n// equals to EINTR.\n#ifndef _WIN32\n#  define FMT_RETRY_VAL(result, expression, error_result) \\\n    do {                                                  \\\n      (result) = (expression);                            \\\n    } while ((result) == (error_result) && errno == EINTR)\n#else\n#  define FMT_RETRY_VAL(result, expression, error_result) result = (expression)\n#endif\n\n#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)\n\nFMT_BEGIN_NAMESPACE\nFMT_BEGIN_EXPORT\n\n/**\n * A reference to a null-terminated string. It can be constructed from a C\n * string or `std::string`.\n *\n * You can use one of the following type aliases for common character types:\n *\n * +---------------+-----------------------------+\n * | Type          | Definition                  |\n * +===============+=============================+\n * | cstring_view  | basic_cstring_view<char>    |\n * +---------------+-----------------------------+\n * | wcstring_view | basic_cstring_view<wchar_t> |\n * +---------------+-----------------------------+\n *\n * This class is most useful as a parameter type for functions that wrap C APIs.\n */\ntemplate <typename Char> class basic_cstring_view {\n private:\n  const Char* data_;\n\n public:\n  /// Constructs a string reference object from a C string.\n  basic_cstring_view(const Char* s) : data_(s) {}\n\n  /// Constructs a string reference from an `std::string` object.\n  basic_cstring_view(const std::basic_string<Char>& s) : data_(s.c_str()) {}\n\n  /// Returns the pointer to a C string.\n  auto c_str() const -> const Char* { return data_; }\n};\n\nusing cstring_view = basic_cstring_view<char>;\nusing wcstring_view = basic_cstring_view<wchar_t>;\n\n#ifdef _WIN32\nFMT_API const std::error_category& system_category() noexcept;\n\nnamespace detail {\nFMT_API void format_windows_error(buffer<char>& out, int error_code,\n                                  const char* message) noexcept;\n}\n\nFMT_API std::system_error vwindows_error(int error_code, string_view fmt,\n                                         format_args args);\n\n/**\n * Constructs a `std::system_error` object with the description of the form\n *\n *     <message>: <system-message>\n *\n * where `<message>` is the formatted message and `<system-message>` is the\n * system message corresponding to the error code.\n * `error_code` is a Windows error code as given by `GetLastError`.\n * If `error_code` is not a valid error code such as -1, the system message\n * will look like \"error -1\".\n *\n * **Example**:\n *\n *     // This throws a system_error with the description\n *     //   cannot open file 'foo': The system cannot find the file specified.\n *     // or similar (system message may vary) if the file doesn't exist.\n *     const char *filename = \"foo\";\n *     LPOFSTRUCT of = LPOFSTRUCT();\n *     HFILE file = OpenFile(filename, &of, OF_READ);\n *     if (file == HFILE_ERROR) {\n *       throw fmt::windows_error(GetLastError(),\n *                                \"cannot open file '{}'\", filename);\n *     }\n */\ntemplate <typename... T>\nauto windows_error(int error_code, string_view message, const T&... args)\n    -> std::system_error {\n  return vwindows_error(error_code, message, vargs<T...>{{args...}});\n}\n\n// Reports a Windows error without throwing an exception.\n// Can be used to report errors from destructors.\nFMT_API void report_windows_error(int error_code, const char* message) noexcept;\n#else\ninline auto system_category() noexcept -> const std::error_category& {\n  return std::system_category();\n}\n#endif  // _WIN32\n\n// A buffered file.\nclass buffered_file {\n private:\n  FILE* file_;\n\n  friend class file;\n\n  inline explicit buffered_file(FILE* f) : file_(f) {}\n\n public:\n  buffered_file(const buffered_file&) = delete;\n  void operator=(const buffered_file&) = delete;\n\n  // Constructs a buffered_file object which doesn't represent any file.\n  inline buffered_file() noexcept : file_(nullptr) {}\n\n  // Destroys the object closing the file it represents if any.\n  FMT_API ~buffered_file() noexcept;\n\n public:\n  inline buffered_file(buffered_file&& other) noexcept : file_(other.file_) {\n    other.file_ = nullptr;\n  }\n\n  inline auto operator=(buffered_file&& other) -> buffered_file& {\n    close();\n    file_ = other.file_;\n    other.file_ = nullptr;\n    return *this;\n  }\n\n  // Opens a file.\n  FMT_API buffered_file(cstring_view filename, cstring_view mode);\n\n  // Closes the file.\n  FMT_API void close();\n\n  // Returns the pointer to a FILE object representing this file.\n  inline auto get() const noexcept -> FILE* { return file_; }\n\n  FMT_API auto descriptor() const -> int;\n\n  template <typename... T>\n  inline void print(string_view fmt, const T&... args) {\n    fmt::vargs<T...> vargs = {{args...}};\n    detail::is_locking<T...>() ? fmt::vprint_buffered(file_, fmt, vargs)\n                               : fmt::vprint(file_, fmt, vargs);\n  }\n};\n\n#if FMT_USE_FCNTL\n\n// A file. Closed file is represented by a file object with descriptor -1.\n// Methods that are not declared with noexcept may throw\n// fmt::system_error in case of failure. Note that some errors such as\n// closing the file multiple times will cause a crash on Windows rather\n// than an exception. You can get standard behavior by overriding the\n// invalid parameter handler with _set_invalid_parameter_handler.\nclass FMT_API file {\n private:\n  int fd_;  // File descriptor.\n\n  // Constructs a file object with a given descriptor.\n  explicit file(int fd) : fd_(fd) {}\n\n  friend struct pipe;\n\n public:\n  // Possible values for the oflag argument to the constructor.\n  enum {\n    RDONLY = FMT_POSIX(O_RDONLY),  // Open for reading only.\n    WRONLY = FMT_POSIX(O_WRONLY),  // Open for writing only.\n    RDWR = FMT_POSIX(O_RDWR),      // Open for reading and writing.\n    CREATE = FMT_POSIX(O_CREAT),   // Create if the file doesn't exist.\n    APPEND = FMT_POSIX(O_APPEND),  // Open in append mode.\n    TRUNC = FMT_POSIX(O_TRUNC)     // Truncate the content of the file.\n  };\n\n  // Constructs a file object which doesn't represent any file.\n  inline file() noexcept : fd_(-1) {}\n\n  // Opens a file and constructs a file object representing this file.\n  file(cstring_view path, int oflag);\n\n public:\n  file(const file&) = delete;\n  void operator=(const file&) = delete;\n\n  inline file(file&& other) noexcept : fd_(other.fd_) { other.fd_ = -1; }\n\n  // Move assignment is not noexcept because close may throw.\n  inline auto operator=(file&& other) -> file& {\n    close();\n    fd_ = other.fd_;\n    other.fd_ = -1;\n    return *this;\n  }\n\n  // Destroys the object closing the file it represents if any.\n  ~file() noexcept;\n\n  // Returns the file descriptor.\n  inline auto descriptor() const noexcept -> int { return fd_; }\n\n  // Closes the file.\n  void close();\n\n  // Returns the file size. The size has signed type for consistency with\n  // stat::st_size.\n  auto size() const -> long long;\n\n  // Attempts to read count bytes from the file into the specified buffer.\n  auto read(void* buffer, size_t count) -> size_t;\n\n  // Attempts to write count bytes from the specified buffer to the file.\n  auto write(const void* buffer, size_t count) -> size_t;\n\n  // Duplicates a file descriptor with the dup function and returns\n  // the duplicate as a file object.\n  static auto dup(int fd) -> file;\n\n  // Makes fd be the copy of this file descriptor, closing fd first if\n  // necessary.\n  void dup2(int fd);\n\n  // Makes fd be the copy of this file descriptor, closing fd first if\n  // necessary.\n  void dup2(int fd, std::error_code& ec) noexcept;\n\n  // Creates a buffered_file object associated with this file and detaches\n  // this file object from the file.\n  auto fdopen(const char* mode) -> buffered_file;\n\n#  if defined(_WIN32) && !defined(__MINGW32__)\n  // Opens a file and constructs a file object representing this file by\n  // wcstring_view filename. Windows only.\n  static file open_windows_file(wcstring_view path, int oflag);\n#  endif\n};\n\nstruct FMT_API pipe {\n  file read_end;\n  file write_end;\n\n  // Creates a pipe setting up read_end and write_end file objects for reading\n  // and writing respectively.\n  pipe();\n};\n\n// Returns the memory page size.\nauto getpagesize() -> long;\n\nnamespace detail {\n\nstruct buffer_size {\n  constexpr buffer_size() = default;\n  size_t value = 0;\n  FMT_CONSTEXPR auto operator=(size_t val) const -> buffer_size {\n    auto bs = buffer_size();\n    bs.value = val;\n    return bs;\n  }\n};\n\nstruct ostream_params {\n  int oflag = file::WRONLY | file::CREATE | file::TRUNC;\n  size_t buffer_size = BUFSIZ > 32768 ? BUFSIZ : 32768;\n\n  constexpr ostream_params() {}\n\n  template <typename... T>\n  ostream_params(T... params, int new_oflag) : ostream_params(params...) {\n    oflag = new_oflag;\n  }\n\n  template <typename... T>\n  ostream_params(T... params, detail::buffer_size bs)\n      : ostream_params(params...) {\n    this->buffer_size = bs.value;\n  }\n\n// Intel has a bug that results in failure to deduce a constructor\n// for empty parameter packs.\n#  if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 2000\n  ostream_params(int new_oflag) : oflag(new_oflag) {}\n  ostream_params(detail::buffer_size bs) : buffer_size(bs.value) {}\n#  endif\n};\n\n}  // namespace detail\n\nFMT_INLINE_VARIABLE constexpr auto buffer_size = detail::buffer_size();\n\n/// A fast buffered output stream for writing from a single thread. Writing from\n/// multiple threads without external synchronization may result in a data race.\nclass ostream : private detail::buffer<char> {\n private:\n  file file_;\n\n  FMT_API ostream(cstring_view path, const detail::ostream_params& params);\n\n  FMT_API static void grow(buffer<char>& buf, size_t);\n\n public:\n  FMT_API ostream(ostream&& other) noexcept;\n  FMT_API ~ostream();\n\n  operator writer() {\n    detail::buffer<char>& buf = *this;\n    return buf;\n  }\n\n  inline void flush() {\n    if (size() == 0) return;\n    file_.write(data(), size() * sizeof(data()[0]));\n    clear();\n  }\n\n  template <typename... T>\n  friend auto output_file(cstring_view path, T... params) -> ostream;\n\n  inline void close() {\n    flush();\n    file_.close();\n  }\n\n  /// Formats `args` according to specifications in `fmt` and writes the\n  /// output to the file.\n  template <typename... T> void print(format_string<T...> fmt, T&&... args) {\n    vformat_to(appender(*this), fmt.str, vargs<T...>{{args...}});\n  }\n};\n\n/**\n * Opens a file for writing. Supported parameters passed in `params`:\n *\n * - `<integer>`: Flags passed to [open](\n *   https://pubs.opengroup.org/onlinepubs/007904875/functions/open.html)\n *   (`file::WRONLY | file::CREATE | file::TRUNC` by default)\n * - `buffer_size=<integer>`: Output buffer size\n *\n * **Example**:\n *\n *     auto out = fmt::output_file(\"guide.txt\");\n *     out.print(\"Don't {}\", \"Panic\");\n */\ntemplate <typename... T>\ninline auto output_file(cstring_view path, T... params) -> ostream {\n  return {path, detail::ostream_params(params...)};\n}\n#endif  // FMT_USE_FCNTL\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_OS_H_\n"
  },
  {
    "path": "include/fmt/ostream.h",
    "content": "// Formatting library for C++ - std::ostream support\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_OSTREAM_H_\n#define FMT_OSTREAM_H_\n\n#ifndef FMT_MODULE\n#  include <fstream>  // std::filebuf\n#endif\n\n#ifdef _WIN32\n#  ifdef __GLIBCXX__\n#    include <ext/stdio_filebuf.h>\n#    include <ext/stdio_sync_filebuf.h>\n#  endif\n#  include <io.h>\n#endif\n\n#include \"chrono.h\"  // formatbuf\n\n#ifdef _MSVC_STL_UPDATE\n#  define FMT_MSVC_STL_UPDATE _MSVC_STL_UPDATE\n#elif defined(_MSC_VER) && _MSC_VER < 1912  // VS 15.5\n#  define FMT_MSVC_STL_UPDATE _MSVC_LANG\n#else\n#  define FMT_MSVC_STL_UPDATE 0\n#endif\n\nFMT_BEGIN_NAMESPACE\nnamespace detail {\n\n// Generate a unique explicit instantiation in every translation unit using a\n// tag type in an anonymous namespace.\nnamespace {\nstruct file_access_tag {};\n}  // namespace\ntemplate <typename Tag, typename BufType, FILE* BufType::* FileMemberPtr>\nclass file_access {\n  friend auto get_file(BufType& obj) -> FILE* { return obj.*FileMemberPtr; }\n};\n\n#if FMT_MSVC_STL_UPDATE\ntemplate class file_access<file_access_tag, std::filebuf,\n                           &std::filebuf::_Myfile>;\nauto get_file(std::filebuf&) -> FILE*;\n#endif\n\n// Write the content of buf to os.\n// It is a separate function rather than a part of vprint to simplify testing.\ntemplate <typename Char>\nvoid write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {\n  const Char* buf_data = buf.data();\n  using unsigned_streamsize = make_unsigned_t<std::streamsize>;\n  unsigned_streamsize size = buf.size();\n  unsigned_streamsize max_size = to_unsigned(max_value<std::streamsize>());\n  do {\n    unsigned_streamsize n = size <= max_size ? size : max_size;\n    os.write(buf_data, static_cast<std::streamsize>(n));\n    buf_data += n;\n    size -= n;\n  } while (size != 0);\n}\n\ntemplate <typename T> struct streamed_view {\n  const T& value;\n};\n}  // namespace detail\n\n// Formats an object of type T that has an overloaded ostream operator<<.\ntemplate <typename Char>\nstruct basic_ostream_formatter : formatter<basic_string_view<Char>, Char> {\n  void set_debug_format() = delete;\n\n  template <typename T, typename Context>\n  auto format(const T& value, Context& ctx) const -> decltype(ctx.out()) {\n    auto buffer = basic_memory_buffer<Char>();\n    auto&& formatbuf = detail::formatbuf<std::basic_streambuf<Char>>(buffer);\n    auto&& output = std::basic_ostream<Char>(&formatbuf);\n    output.imbue(std::locale::classic());  // The default is always unlocalized.\n    output << value;\n    output.exceptions(std::ios_base::failbit | std::ios_base::badbit);\n    return formatter<basic_string_view<Char>, Char>::format(\n        {buffer.data(), buffer.size()}, ctx);\n  }\n};\n\nusing ostream_formatter = basic_ostream_formatter<char>;\n\ntemplate <typename T, typename Char>\nstruct formatter<detail::streamed_view<T>, Char>\n    : basic_ostream_formatter<Char> {\n  template <typename Context>\n  auto format(detail::streamed_view<T> view, Context& ctx) const\n      -> decltype(ctx.out()) {\n    return basic_ostream_formatter<Char>::format(view.value, ctx);\n  }\n};\n\n/**\n * Returns a view that formats `value` via an ostream `operator<<`.\n *\n * **Example**:\n *\n *     fmt::print(\"Current thread id: {}\\n\",\n *                fmt::streamed(std::this_thread::get_id()));\n */\ntemplate <typename T>\nconstexpr auto streamed(const T& value) -> detail::streamed_view<T> {\n  return {value};\n}\n\ninline void vprint(std::ostream& os, string_view fmt, format_args args) {\n  auto buffer = memory_buffer();\n  detail::vformat_to(buffer, fmt, args);\n  FILE* f = nullptr;\n#if FMT_MSVC_STL_UPDATE && FMT_USE_RTTI\n  if (auto* buf = dynamic_cast<std::filebuf*>(os.rdbuf()))\n    f = detail::get_file(*buf);\n#elif defined(_WIN32) && defined(__GLIBCXX__) && FMT_USE_RTTI\n  auto* rdbuf = os.rdbuf();\n  if (auto* sfbuf = dynamic_cast<__gnu_cxx::stdio_sync_filebuf<char>*>(rdbuf))\n    f = sfbuf->file();\n  else if (auto* fbuf = dynamic_cast<__gnu_cxx::stdio_filebuf<char>*>(rdbuf))\n    f = fbuf->file();\n#endif\n#ifdef _WIN32\n  if (f) {\n    int fd = _fileno(f);\n    if (_isatty(fd)) {\n      os.flush();\n      if (detail::write_console(fd, {buffer.data(), buffer.size()})) return;\n    }\n  }\n#endif\n  detail::ignore_unused(f);\n  detail::write_buffer(os, buffer);\n}\n\n/**\n * Prints formatted data to the stream `os`.\n *\n * **Example**:\n *\n *     fmt::print(cerr, \"Don't {}!\", \"panic\");\n */\nFMT_EXPORT template <typename... T>\nvoid print(std::ostream& os, format_string<T...> fmt, T&&... args) {\n  fmt::vargs<T...> vargs = {{args...}};\n  if FMT_CONSTEXPR20 (detail::use_utf8) return vprint(os, fmt.str, vargs);\n  auto buffer = memory_buffer();\n  detail::vformat_to(buffer, fmt.str, vargs);\n  detail::write_buffer(os, buffer);\n}\n\nFMT_EXPORT template <typename... T>\nvoid println(std::ostream& os, format_string<T...> fmt, T&&... args) {\n  fmt::print(os, FMT_STRING(\"{}\\n\"),\n             fmt::format(fmt, std::forward<T>(args)...));\n}\n\nFMT_END_NAMESPACE\n\n#endif  // FMT_OSTREAM_H_\n"
  },
  {
    "path": "include/fmt/printf.h",
    "content": "// Formatting library for C++ - legacy printf implementation\n//\n// Copyright (c) 2012 - 2016, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_PRINTF_H_\n#define FMT_PRINTF_H_\n\n#ifndef FMT_MODULE\n#  include <algorithm>  // std::find\n#  include <limits>     // std::numeric_limits\n#endif\n\n#include \"format.h\"\n\nFMT_BEGIN_NAMESPACE\nFMT_BEGIN_EXPORT\n\ntemplate <typename Char> class basic_printf_context {\n private:\n  basic_appender<Char> out_;\n  basic_format_args<basic_printf_context> args_;\n\n  static_assert(std::is_same<Char, char>::value ||\n                    std::is_same<Char, wchar_t>::value,\n                \"Unsupported code unit type.\");\n\n public:\n  using char_type = Char;\n  enum { builtin_types = 1 };\n\n  /// Constructs a `printf_context` object. References to the arguments are\n  /// stored in the context object so make sure they have appropriate lifetimes.\n  basic_printf_context(basic_appender<Char> out,\n                       basic_format_args<basic_printf_context> args)\n      : out_(out), args_(args) {}\n\n  auto out() -> basic_appender<Char> { return out_; }\n  void advance_to(basic_appender<Char>) {}\n\n  auto locale() -> locale_ref { return {}; }\n\n  auto arg(int id) const -> basic_format_arg<basic_printf_context> {\n    return args_.get(id);\n  }\n};\n\nnamespace detail {\n\n// Return the result via the out param to workaround gcc bug 77539.\ntemplate <bool IS_CONSTEXPR, typename T, typename Ptr = const T*>\nFMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr& out) -> bool {\n  for (out = first; out != last; ++out) {\n    if (*out == value) return true;\n  }\n  return false;\n}\n\ntemplate <>\ninline auto find<false, char>(const char* first, const char* last, char value,\n                              const char*& out) -> bool {\n  out =\n      static_cast<const char*>(memchr(first, value, to_unsigned(last - first)));\n  return out != nullptr;\n}\n\n// Checks if a value fits in int - used to avoid warnings about comparing\n// signed and unsigned integers.\ntemplate <bool IS_SIGNED> struct int_checker {\n  template <typename T> static auto fits_in_int(T value) -> bool {\n    return value <= to_unsigned(max_value<int>());\n  }\n  inline static auto fits_in_int(bool) -> bool { return true; }\n};\n\ntemplate <> struct int_checker<true> {\n  template <typename T> static auto fits_in_int(T value) -> bool {\n    return value >= (std::numeric_limits<int>::min)() &&\n           value <= max_value<int>();\n  }\n  inline static auto fits_in_int(int) -> bool { return true; }\n};\n\nstruct printf_precision_handler {\n  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\n  auto operator()(T value) -> int {\n    if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))\n      report_error(\"number is too big\");\n    return max_of(static_cast<int>(value), 0);\n  }\n\n  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>\n  auto operator()(T) -> int {\n    report_error(\"precision is not integer\");\n    return 0;\n  }\n};\n\n// An argument visitor that returns true iff arg is a zero integer.\nstruct is_zero_int {\n  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\n  auto operator()(T value) -> bool {\n    return value == 0;\n  }\n\n  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>\n  auto operator()(T) -> bool {\n    return false;\n  }\n};\n\ntemplate <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};\n\ntemplate <> struct make_unsigned_or_bool<bool> {\n  using type = bool;\n};\n\ntemplate <typename T, typename Context> class arg_converter {\n private:\n  using char_type = typename Context::char_type;\n\n  basic_format_arg<Context>& arg_;\n  char_type type_;\n\n public:\n  arg_converter(basic_format_arg<Context>& arg, char_type type)\n      : arg_(arg), type_(type) {}\n\n  void operator()(bool value) {\n    if (type_ != 's') operator()<bool>(value);\n  }\n\n  template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>\n  void operator()(U value) {\n    bool is_signed = type_ == 'd' || type_ == 'i';\n    using target_type = conditional_t<std::is_same<T, void>::value, U, T>;\n    if FMT_CONSTEXPR20 (sizeof(target_type) <= sizeof(int)) {\n      // Extra casts are used to silence warnings.\n      using unsigned_type = typename make_unsigned_or_bool<target_type>::type;\n      if (is_signed)\n        arg_ = static_cast<int>(static_cast<target_type>(value));\n      else\n        arg_ = static_cast<unsigned>(static_cast<unsigned_type>(value));\n    } else {\n      // glibc's printf doesn't sign extend arguments of smaller types:\n      //   std::printf(\"%lld\", -42);  // prints \"4294967254\"\n      // but we don't have to do the same because it's a UB.\n      if (is_signed)\n        arg_ = static_cast<long long>(value);\n      else\n        arg_ = static_cast<typename make_unsigned_or_bool<U>::type>(value);\n    }\n  }\n\n  template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>\n  void operator()(U) {}  // No conversion needed for non-integral types.\n};\n\n// Converts an integer argument to T for printf, if T is an integral type.\n// If T is void, the argument is converted to corresponding signed or unsigned\n// type depending on the type specifier: 'd' and 'i' - signed, other -\n// unsigned).\ntemplate <typename T, typename Context, typename Char>\nvoid convert_arg(basic_format_arg<Context>& arg, Char type) {\n  arg.visit(arg_converter<T, Context>(arg, type));\n}\n\n// Converts an integer argument to char for printf.\ntemplate <typename Context> class char_converter {\n private:\n  basic_format_arg<Context>& arg_;\n\n public:\n  explicit char_converter(basic_format_arg<Context>& arg) : arg_(arg) {}\n\n  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\n  void operator()(T value) {\n    arg_ = static_cast<typename Context::char_type>(value);\n  }\n\n  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>\n  void operator()(T) {}  // No conversion needed for non-integral types.\n};\n\n// An argument visitor that return a pointer to a C string if argument is a\n// string or null otherwise.\ntemplate <typename Char> struct get_cstring {\n  template <typename T> auto operator()(T) -> const Char* { return nullptr; }\n  auto operator()(const Char* s) -> const Char* { return s; }\n};\n\n// Checks if an argument is a valid printf width specifier and sets\n// left alignment if it is negative.\nclass printf_width_handler {\n private:\n  format_specs& specs_;\n\n public:\n  inline explicit printf_width_handler(format_specs& specs) : specs_(specs) {}\n\n  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>\n  auto operator()(T value) -> unsigned {\n    auto width = static_cast<uint32_or_64_or_128_t<T>>(value);\n    if (detail::is_negative(value)) {\n      specs_.set_align(align::left);\n      width = 0 - width;\n    }\n    unsigned int_max = to_unsigned(max_value<int>());\n    if (width > int_max) report_error(\"number is too big\");\n    return static_cast<unsigned>(width);\n  }\n\n  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>\n  auto operator()(T) -> unsigned {\n    report_error(\"width is not integer\");\n    return 0;\n  }\n};\n\n// Workaround for a bug with the XL compiler when initializing\n// printf_arg_formatter's base class.\ntemplate <typename Char>\nauto make_arg_formatter(basic_appender<Char> iter, format_specs& s)\n    -> arg_formatter<Char> {\n  return {iter, s, locale_ref()};\n}\n\n// The `printf` argument formatter.\ntemplate <typename Char>\nclass printf_arg_formatter : public arg_formatter<Char> {\n private:\n  using base = arg_formatter<Char>;\n  using context_type = basic_printf_context<Char>;\n\n  context_type& context_;\n\n  void write_null_pointer(bool is_string = false) {\n    auto s = this->specs;\n    s.set_type(presentation_type::none);\n    write_bytes<Char>(this->out, is_string ? \"(null)\" : \"(nil)\", s);\n  }\n\n  template <typename T> void write(T value) {\n    detail::write<Char>(this->out, value, this->specs, this->locale);\n  }\n\n public:\n  printf_arg_formatter(basic_appender<Char> iter, format_specs& s,\n                       context_type& ctx)\n      : base(make_arg_formatter(iter, s)), context_(ctx) {}\n\n  void operator()(monostate value) { write(value); }\n\n  template <typename T, FMT_ENABLE_IF(detail::is_integral<T>::value)>\n  void operator()(T value) {\n    // MSVC2013 fails to compile separate overloads for bool and Char so use\n    // std::is_same instead.\n    if (!std::is_same<T, Char>::value) {\n      write(value);\n      return;\n    }\n    format_specs s = this->specs;\n    if (s.type() != presentation_type::none &&\n        s.type() != presentation_type::chr) {\n      return (*this)(static_cast<int>(value));\n    }\n    s.set_sign(sign::none);\n    s.clear_alt();\n    s.set_fill(' ');  // Ignore '0' flag for char types.\n    // align::numeric needs to be overwritten here since the '0' flag is\n    // ignored for non-numeric types\n    if (s.align() == align::none || s.align() == align::numeric)\n      s.set_align(align::right);\n    detail::write<Char>(this->out, static_cast<Char>(value), s);\n  }\n\n  template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>\n  void operator()(T value) {\n    write(value);\n  }\n\n  void operator()(const char* value) {\n    if (value)\n      write(value);\n    else\n      write_null_pointer(this->specs.type() != presentation_type::pointer);\n  }\n\n  void operator()(const wchar_t* value) {\n    if (value)\n      write(value);\n    else\n      write_null_pointer(this->specs.type() != presentation_type::pointer);\n  }\n\n  void operator()(basic_string_view<Char> value) { write(value); }\n\n  void operator()(const void* value) {\n    if (value)\n      write(value);\n    else\n      write_null_pointer();\n  }\n\n  void operator()(typename basic_format_arg<context_type>::handle handle) {\n    auto parse_ctx = parse_context<Char>({});\n    handle.format(parse_ctx, context_);\n  }\n};\n\ntemplate <typename Char>\nvoid parse_flags(format_specs& specs, const Char*& it, const Char* end) {\n  for (; it != end; ++it) {\n    switch (*it) {\n    case '-': specs.set_align(align::left); break;\n    case '+': specs.set_sign(sign::plus); break;\n    case '0': specs.set_fill('0'); break;\n    case ' ':\n      if (specs.sign() != sign::plus) specs.set_sign(sign::space);\n      break;\n    case '#': specs.set_alt(); break;\n    default:  return;\n    }\n  }\n}\n\ntemplate <typename Char, typename GetArg>\nauto parse_header(const Char*& it, const Char* end, format_specs& specs,\n                  GetArg get_arg) -> int {\n  int arg_index = -1;\n  Char c = *it;\n  if (c >= '0' && c <= '9') {\n    // Parse an argument index (if followed by '$') or a width possibly\n    // preceded with '0' flag(s).\n    int value = parse_nonnegative_int(it, end, -1);\n    if (it != end && *it == '$') {  // value is an argument index\n      ++it;\n      arg_index = value != -1 ? value : max_value<int>();\n    } else {\n      if (c == '0') specs.set_fill('0');\n      if (value != 0) {\n        // Nonzero value means that we parsed width and don't need to\n        // parse it or flags again, so return now.\n        if (value == -1) report_error(\"number is too big\");\n        specs.width = value;\n        return arg_index;\n      }\n    }\n  }\n  parse_flags(specs, it, end);\n  // Parse width.\n  if (it != end) {\n    if (*it >= '0' && *it <= '9') {\n      specs.width = parse_nonnegative_int(it, end, -1);\n      if (specs.width == -1) report_error(\"number is too big\");\n    } else if (*it == '*') {\n      ++it;\n      // Check for positional width argument like *1$\n      if (it != end && *it >= '0' && *it <= '9') {\n        int width_index = parse_nonnegative_int(it, end, -1);\n        if (it != end && *it == '$') {\n          ++it;\n          specs.width = static_cast<int>(\n              get_arg(width_index).visit(detail::printf_width_handler(specs)));\n        } else {\n          // Invalid format, rewind and treat as non-positional\n          report_error(\"invalid format specifier\");\n        }\n      } else {\n        specs.width = static_cast<int>(\n            get_arg(-1).visit(detail::printf_width_handler(specs)));\n      }\n    }\n  }\n  return arg_index;\n}\n\ninline auto parse_printf_presentation_type(char c, type t, bool& upper)\n    -> presentation_type {\n  using pt = presentation_type;\n  constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;\n  switch (c) {\n  case 'd': return in(t, integral_set) ? pt::dec : pt::none;\n  case 'o': return in(t, integral_set) ? pt::oct : pt::none;\n  case 'X': upper = true; FMT_FALLTHROUGH;\n  case 'x': return in(t, integral_set) ? pt::hex : pt::none;\n  case 'E': upper = true; FMT_FALLTHROUGH;\n  case 'e': return in(t, float_set) ? pt::exp : pt::none;\n  case 'F': upper = true; FMT_FALLTHROUGH;\n  case 'f': return in(t, float_set) ? pt::fixed : pt::none;\n  case 'G': upper = true; FMT_FALLTHROUGH;\n  case 'g': return in(t, float_set) ? pt::general : pt::none;\n  case 'A': upper = true; FMT_FALLTHROUGH;\n  case 'a': return in(t, float_set) ? pt::hexfloat : pt::none;\n  case 'c': return in(t, integral_set) ? pt::chr : pt::none;\n  case 's': return in(t, string_set | cstring_set) ? pt::string : pt::none;\n  case 'p': return in(t, pointer_set | cstring_set) ? pt::pointer : pt::none;\n  default:  return pt::none;\n  }\n}\n\ntemplate <typename Char, typename Context>\nvoid vprintf(buffer<Char>& buf, basic_string_view<Char> format,\n             basic_format_args<Context> args) {\n  using iterator = basic_appender<Char>;\n  auto out = iterator(buf);\n  auto context = basic_printf_context<Char>(out, args);\n  auto parse_ctx = parse_context<Char>(format);\n\n  // Returns the argument with specified index or, if arg_index is -1, the next\n  // argument.\n  auto get_arg = [&](int arg_index) {\n    if (arg_index < 0)\n      arg_index = parse_ctx.next_arg_id();\n    else\n      parse_ctx.check_arg_id(--arg_index);\n    auto arg = context.arg(arg_index);\n    if (!arg) report_error(\"argument not found\");\n    return arg;\n  };\n\n  const Char* start = parse_ctx.begin();\n  const Char* end = parse_ctx.end();\n  auto it = start;\n  while (it != end) {\n    if (!find<false, Char>(it, end, '%', it)) {\n      it = end;  // find leaves it == nullptr if it doesn't find '%'.\n      break;\n    }\n    Char c = *it++;\n    if (it != end && *it == c) {\n      write(out, basic_string_view<Char>(start, to_unsigned(it - start)));\n      start = ++it;\n      continue;\n    }\n    write(out, basic_string_view<Char>(start, to_unsigned(it - 1 - start)));\n\n    auto specs = format_specs();\n    specs.set_align(align::right);\n\n    // Parse argument index, flags and width.\n    int arg_index = parse_header(it, end, specs, get_arg);\n    if (arg_index == 0) report_error(\"argument not found\");\n\n    // Parse precision.\n    if (it != end && *it == '.') {\n      ++it;\n      c = it != end ? *it : 0;\n      if ('0' <= c && c <= '9') {\n        specs.precision = parse_nonnegative_int(it, end, 0);\n      } else if (c == '*') {\n        ++it;\n        // Check for positional precision argument like .*1$\n        if (it != end && *it >= '0' && *it <= '9') {\n          int precision_index = parse_nonnegative_int(it, end, -1);\n          if (it != end && *it == '$') {\n            ++it;\n            specs.precision = static_cast<int>(\n                get_arg(precision_index).visit(printf_precision_handler()));\n          } else {\n            // Invalid format, rewind and treat as non-positional\n            report_error(\"invalid format specifier\");\n          }\n        } else {\n          specs.precision =\n              static_cast<int>(get_arg(-1).visit(printf_precision_handler()));\n        }\n      } else {\n        specs.precision = 0;\n      }\n    }\n\n    auto arg = get_arg(arg_index);\n    // For d, i, o, u, x and X conversion specifiers, if a precision is\n    // specified, the '0' flag is ignored\n    if (specs.precision >= 0 && is_integral_type(arg.type())) {\n      // Ignore '0' for non-numeric types or if '-' present.\n      specs.set_fill(' ');\n    }\n    if (specs.precision >= 0 && arg.type() == type::cstring_type) {\n      auto str = arg.visit(get_cstring<Char>());\n      auto str_end = str + specs.precision;\n      auto nul = std::find(str, str_end, Char());\n      auto sv = basic_string_view<Char>(\n          str, to_unsigned(nul != str_end ? nul - str : specs.precision));\n      arg = sv;\n    }\n    if (specs.alt() && arg.visit(is_zero_int())) specs.clear_alt();\n    if (specs.fill_unit<Char>() == '0') {\n      if (is_arithmetic_type(arg.type()) && specs.align() != align::left) {\n        specs.set_align(align::numeric);\n      } else {\n        // Ignore '0' flag for non-numeric types or if '-' flag is also present.\n        specs.set_fill(' ');\n      }\n    }\n\n    // Parse length and convert the argument to the required type.\n    c = it != end ? *it++ : 0;\n    Char t = it != end ? *it : 0;\n    switch (c) {\n    case 'h':\n      if (t == 'h') {\n        ++it;\n        t = it != end ? *it : 0;\n        convert_arg<signed char>(arg, t);\n      } else {\n        convert_arg<short>(arg, t);\n      }\n      break;\n    case 'l':\n      if (t == 'l') {\n        ++it;\n        t = it != end ? *it : 0;\n        convert_arg<long long>(arg, t);\n      } else {\n        convert_arg<long>(arg, t);\n      }\n      break;\n    case 'j': convert_arg<intmax_t>(arg, t); break;\n    case 'z': convert_arg<size_t>(arg, t); break;\n    case 't': convert_arg<std::ptrdiff_t>(arg, t); break;\n    case 'L':\n      // printf produces garbage when 'L' is omitted for long double, no\n      // need to do the same.\n      break;\n    default: --it; convert_arg<void>(arg, c);\n    }\n\n    // Parse type.\n    if (it == end) report_error(\"invalid format string\");\n    char type = static_cast<char>(*it++);\n    if (is_integral_type(arg.type())) {\n      // Normalize type.\n      switch (type) {\n      case 'i':\n      case 'u': type = 'd'; break;\n      case 'c':\n        arg.visit(char_converter<basic_printf_context<Char>>(arg));\n        break;\n      }\n    }\n    bool upper = false;\n    specs.set_type(parse_printf_presentation_type(type, arg.type(), upper));\n    if (specs.type() == presentation_type::none)\n      report_error(\"invalid format specifier\");\n    if (upper) specs.set_upper();\n\n    start = it;\n\n    // Format argument.\n    arg.visit(printf_arg_formatter<Char>(out, specs, context));\n  }\n  write(out, basic_string_view<Char>(start, to_unsigned(it - start)));\n}\n}  // namespace detail\n\nusing printf_context = basic_printf_context<char>;\nusing wprintf_context = basic_printf_context<wchar_t>;\n\nusing printf_args = basic_format_args<printf_context>;\nusing wprintf_args = basic_format_args<wprintf_context>;\n\n/// Constructs an `format_arg_store` object that contains references to\n/// arguments and can be implicitly converted to `printf_args`.\ntemplate <typename Char = char, typename... T>\ninline auto make_printf_args(T&... args)\n    -> decltype(fmt::make_format_args<basic_printf_context<Char>>(args...)) {\n  return fmt::make_format_args<basic_printf_context<Char>>(args...);\n}\n\ntemplate <typename Char> struct vprintf_args {\n  using type = basic_format_args<basic_printf_context<Char>>;\n};\n\ntemplate <typename Char>\ninline auto vsprintf(basic_string_view<Char> fmt,\n                     typename vprintf_args<Char>::type args)\n    -> std::basic_string<Char> {\n  auto buf = basic_memory_buffer<Char>();\n  detail::vprintf(buf, fmt, args);\n  return {buf.data(), buf.size()};\n}\n\n/**\n * Formats `args` according to specifications in `fmt` and returns the result\n * as string.\n *\n * **Example**:\n *\n *     std::string message = fmt::sprintf(\"The answer is %d\", 42);\n */\ntemplate <typename... T>\ninline auto sprintf(string_view fmt, const T&... args) -> std::string {\n  return vsprintf(fmt, make_printf_args(args...));\n}\ntemplate <typename... T>\nFMT_DEPRECATED auto sprintf(basic_string_view<wchar_t> fmt, const T&... args)\n    -> std::wstring {\n  return vsprintf(fmt, make_printf_args<wchar_t>(args...));\n}\n\ntemplate <typename Char>\nauto vfprintf(std::FILE* f, basic_string_view<Char> fmt,\n              typename vprintf_args<Char>::type args) -> int {\n  auto buf = basic_memory_buffer<Char>();\n  detail::vprintf(buf, fmt, args);\n  size_t size = buf.size();\n  return std::fwrite(buf.data(), sizeof(Char), size, f) < size\n             ? -1\n             : static_cast<int>(size);\n}\n\n/**\n * Formats `args` according to specifications in `fmt` and writes the output\n * to `f`.\n *\n * **Example**:\n *\n *     fmt::fprintf(stderr, \"Don't %s!\", \"panic\");\n */\ntemplate <typename... T>\ninline auto fprintf(std::FILE* f, string_view fmt, const T&... args) -> int {\n  return vfprintf(f, fmt, make_printf_args(args...));\n}\ntemplate <typename... T>\nFMT_DEPRECATED auto fprintf(std::FILE* f, basic_string_view<wchar_t> fmt,\n                            const T&... args) -> int {\n  return vfprintf(f, fmt, make_printf_args<wchar_t>(args...));\n}\n\n/**\n * Formats `args` according to specifications in `fmt` and writes the output\n * to `stdout`.\n *\n * **Example**:\n *\n *   fmt::printf(\"Elapsed time: %.2f seconds\", 1.23);\n */\ntemplate <typename... T>\ninline auto printf(string_view fmt, const T&... args) -> int {\n  return vfprintf(stdout, fmt, make_printf_args(args...));\n}\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_PRINTF_H_\n"
  },
  {
    "path": "include/fmt/ranges.h",
    "content": "// Formatting library for C++ - range and tuple support\n//\n// Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_RANGES_H_\n#define FMT_RANGES_H_\n\n#ifndef FMT_MODULE\n#  include <initializer_list>\n#  include <iterator>\n#  include <tuple>\n#  include <type_traits>\n#  include <utility>\n#endif\n\n#include \"format.h\"\n\n#if FMT_HAS_CPP_ATTRIBUTE(clang::lifetimebound)\n#  define FMT_LIFETIMEBOUND [[clang::lifetimebound]]\n#else\n#  define FMT_LIFETIMEBOUND\n#endif\nFMT_PRAGMA_CLANG(diagnostic error \"-Wreturn-stack-address\")\n\nFMT_BEGIN_NAMESPACE\n\nFMT_EXPORT\nenum class range_format { disabled, map, set, sequence, string, debug_string };\n\nnamespace detail {\n\ntemplate <typename T> class is_map {\n  template <typename U> static auto check(U*) -> typename U::mapped_type;\n  template <typename> static void check(...);\n\n public:\n  static constexpr bool value =\n      !std::is_void<decltype(check<T>(nullptr))>::value;\n};\n\ntemplate <typename T> class is_set {\n  template <typename U> static auto check(U*) -> typename U::key_type;\n  template <typename> static void check(...);\n\n public:\n  static constexpr bool value =\n      !std::is_void<decltype(check<T>(nullptr))>::value && !is_map<T>::value;\n};\n\n// C array overload\ntemplate <typename T, size_t N>\nauto range_begin(const T (&arr)[N]) -> const T* {\n  return arr;\n}\ntemplate <typename T, size_t N> auto range_end(const T (&arr)[N]) -> const T* {\n  return arr + N;\n}\n\ntemplate <typename T, typename Enable = void>\nstruct has_member_fn_begin_end_t : std::false_type {};\n\ntemplate <typename T>\nstruct has_member_fn_begin_end_t<T, void_t<decltype(*std::declval<T>().begin()),\n                                           decltype(std::declval<T>().end())>>\n    : std::true_type {};\n\n// Member function overloads.\ntemplate <typename T>\nauto range_begin(T&& rng) -> decltype(static_cast<T&&>(rng).begin()) {\n  return static_cast<T&&>(rng).begin();\n}\ntemplate <typename T>\nauto range_end(T&& rng) -> decltype(static_cast<T&&>(rng).end()) {\n  return static_cast<T&&>(rng).end();\n}\n\n// ADL overloads. Only participate in overload resolution if member functions\n// are not found.\ntemplate <typename T>\nauto range_begin(T&& rng)\n    -> enable_if_t<!has_member_fn_begin_end_t<T&&>::value,\n                   decltype(begin(static_cast<T&&>(rng)))> {\n  return begin(static_cast<T&&>(rng));\n}\ntemplate <typename T>\nauto range_end(T&& rng) -> enable_if_t<!has_member_fn_begin_end_t<T&&>::value,\n                                       decltype(end(static_cast<T&&>(rng)))> {\n  return end(static_cast<T&&>(rng));\n}\n\ntemplate <typename T, typename Enable = void>\nstruct has_const_begin_end : std::false_type {};\ntemplate <typename T, typename Enable = void>\nstruct has_mutable_begin_end : std::false_type {};\n\ntemplate <typename T>\nstruct has_const_begin_end<\n    T, void_t<decltype(*detail::range_begin(\n                  std::declval<const remove_cvref_t<T>&>())),\n              decltype(detail::range_end(\n                  std::declval<const remove_cvref_t<T>&>()))>>\n    : std::true_type {};\n\ntemplate <typename T>\nstruct has_mutable_begin_end<\n    T, void_t<decltype(*detail::range_begin(std::declval<T&>())),\n              decltype(detail::range_end(std::declval<T&>())),\n              // the extra int here is because older versions of MSVC don't\n              // SFINAE properly unless there are distinct types\n              int>> : std::true_type {};\n\ntemplate <typename T, typename _ = void> struct is_range_ : std::false_type {};\ntemplate <typename T>\nstruct is_range_<T, void>\n    : std::integral_constant<bool, (has_const_begin_end<T>::value ||\n                                    has_mutable_begin_end<T>::value)> {};\n\n// tuple_size and tuple_element check.\ntemplate <typename T> class is_tuple_like_ {\n  template <typename U, typename V = typename std::remove_cv<U>::type>\n  static auto check(U* p) -> decltype(std::tuple_size<V>::value, 0);\n  template <typename> static void check(...);\n\n public:\n  static constexpr bool value =\n      !std::is_void<decltype(check<T>(nullptr))>::value;\n};\n\n// Check for integer_sequence\n#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VERSION >= 1900\ntemplate <typename T, T... N>\nusing integer_sequence = std::integer_sequence<T, N...>;\ntemplate <size_t... N> using index_sequence = std::index_sequence<N...>;\ntemplate <size_t N> using make_index_sequence = std::make_index_sequence<N>;\n#else\ntemplate <typename T, T... N> struct integer_sequence {\n  using value_type = T;\n\n  static FMT_CONSTEXPR auto size() -> size_t { return sizeof...(N); }\n};\n\ntemplate <size_t... N> using index_sequence = integer_sequence<size_t, N...>;\n\ntemplate <typename T, size_t N, T... Ns>\nstruct make_integer_sequence : make_integer_sequence<T, N - 1, N - 1, Ns...> {};\ntemplate <typename T, T... Ns>\nstruct make_integer_sequence<T, 0, Ns...> : integer_sequence<T, Ns...> {};\n\ntemplate <size_t N>\nusing make_index_sequence = make_integer_sequence<size_t, N>;\n#endif\n\ntemplate <typename T>\nusing tuple_index_sequence = make_index_sequence<std::tuple_size<T>::value>;\n\ntemplate <typename T, typename C, bool = is_tuple_like_<T>::value>\nclass is_tuple_formattable_ {\n public:\n  static constexpr bool value = false;\n};\ntemplate <typename T, typename C> class is_tuple_formattable_<T, C, true> {\n  template <size_t... Is>\n  static auto all_true(index_sequence<Is...>,\n                       integer_sequence<bool, (Is >= 0)...>) -> std::true_type;\n  static auto all_true(...) -> std::false_type;\n\n  template <size_t... Is>\n  static auto check(index_sequence<Is...>) -> decltype(all_true(\n      index_sequence<Is...>{},\n      integer_sequence<bool,\n                       (is_formattable<typename std::tuple_element<Is, T>::type,\n                                       C>::value)...>{}));\n\n public:\n  static constexpr bool value =\n      decltype(check(tuple_index_sequence<T>{}))::value;\n};\n\ntemplate <typename Tuple, typename F, size_t... Is>\nFMT_CONSTEXPR void for_each(index_sequence<Is...>, Tuple&& t, F&& f) {\n  using std::get;\n  // Using a free function get<Is>(Tuple) now.\n  const int unused[] = {0, ((void)f(get<Is>(t)), 0)...};\n  ignore_unused(unused);\n}\n\ntemplate <typename Tuple, typename F>\nFMT_CONSTEXPR void for_each(Tuple&& t, F&& f) {\n  for_each(tuple_index_sequence<remove_cvref_t<Tuple>>(),\n           std::forward<Tuple>(t), std::forward<F>(f));\n}\n\ntemplate <typename Tuple1, typename Tuple2, typename F, size_t... Is>\nvoid for_each2(index_sequence<Is...>, Tuple1&& t1, Tuple2&& t2, F&& f) {\n  using std::get;\n  const int unused[] = {0, ((void)f(get<Is>(t1), get<Is>(t2)), 0)...};\n  ignore_unused(unused);\n}\n\ntemplate <typename Tuple1, typename Tuple2, typename F>\nvoid for_each2(Tuple1&& t1, Tuple2&& t2, F&& f) {\n  for_each2(tuple_index_sequence<remove_cvref_t<Tuple1>>(),\n            std::forward<Tuple1>(t1), std::forward<Tuple2>(t2),\n            std::forward<F>(f));\n}\n\nnamespace tuple {\n// Workaround a bug in MSVC 2019 (v140).\ntemplate <typename Char, typename... T>\nusing result_t = std::tuple<formatter<remove_cvref_t<T>, Char>...>;\n\nusing std::get;\ntemplate <typename Tuple, typename Char, size_t... Is>\nauto get_formatters(index_sequence<Is...>)\n    -> result_t<Char, decltype(get<Is>(std::declval<Tuple>()))...>;\n}  // namespace tuple\n\n#if FMT_MSC_VERSION && FMT_MSC_VERSION < 1920\n// Older MSVC doesn't get the reference type correctly for arrays.\ntemplate <typename R> struct range_reference_type_impl {\n  using type = decltype(*detail::range_begin(std::declval<R&>()));\n};\n\ntemplate <typename T, size_t N> struct range_reference_type_impl<T[N]> {\n  using type = T&;\n};\n\ntemplate <typename T>\nusing range_reference_type = typename range_reference_type_impl<T>::type;\n#else\ntemplate <typename Range>\nusing range_reference_type =\n    decltype(*detail::range_begin(std::declval<Range&>()));\n#endif\n\n// We don't use the Range's value_type for anything, but we do need the Range's\n// reference type, with cv-ref stripped.\ntemplate <typename Range>\nusing uncvref_type = remove_cvref_t<range_reference_type<Range>>;\n\ntemplate <typename T>\nstruct range_format_kind_\n    : std::integral_constant<range_format,\n                             std::is_same<uncvref_type<T>, T>::value\n                                 ? range_format::disabled\n                             : is_map<T>::value ? range_format::map\n                             : is_set<T>::value ? range_format::set\n                                                : range_format::sequence> {};\n\ntemplate <range_format K>\nusing range_format_constant = std::integral_constant<range_format, K>;\n\n// These are not generic lambdas for compatibility with C++11.\ntemplate <typename Char> struct parse_empty_specs {\n  template <typename Formatter> FMT_CONSTEXPR void operator()(Formatter& f) {\n    f.parse(ctx);\n    detail::maybe_set_debug_format(f, true);\n  }\n  parse_context<Char>& ctx;\n};\ntemplate <typename FormatContext> struct format_tuple_element {\n  using char_type = typename FormatContext::char_type;\n\n  template <typename T>\n  void operator()(const formatter<T, char_type>& f, const T& v) {\n    if (i > 0) ctx.advance_to(detail::copy<char_type>(separator, ctx.out()));\n    ctx.advance_to(f.format(v, ctx));\n    ++i;\n  }\n\n  int i;\n  FormatContext& ctx;\n  basic_string_view<char_type> separator;\n};\n\n}  // namespace detail\n\nFMT_EXPORT\ntemplate <typename T> struct is_tuple_like {\n  static constexpr bool value =\n      detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;\n};\n\nFMT_EXPORT\ntemplate <typename T, typename C> struct is_tuple_formattable {\n  static constexpr bool value = detail::is_tuple_formattable_<T, C>::value;\n};\n\ntemplate <typename Tuple, typename Char>\nstruct formatter<Tuple, Char,\n                 enable_if_t<fmt::is_tuple_like<Tuple>::value &&\n                             fmt::is_tuple_formattable<Tuple, Char>::value>> {\n private:\n  decltype(detail::tuple::get_formatters<Tuple, Char>(\n      detail::tuple_index_sequence<Tuple>())) formatters_;\n\n  basic_string_view<Char> separator_ = detail::string_literal<Char, ',', ' '>{};\n  basic_string_view<Char> opening_bracket_ =\n      detail::string_literal<Char, '('>{};\n  basic_string_view<Char> closing_bracket_ =\n      detail::string_literal<Char, ')'>{};\n\n public:\n  FMT_CONSTEXPR formatter() {}\n\n  FMT_CONSTEXPR void set_separator(basic_string_view<Char> sep) {\n    separator_ = sep;\n  }\n\n  FMT_CONSTEXPR void set_brackets(basic_string_view<Char> open,\n                                  basic_string_view<Char> close) {\n    opening_bracket_ = open;\n    closing_bracket_ = close;\n  }\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin();\n    auto end = ctx.end();\n    if (it != end && detail::to_ascii(*it) == 'n') {\n      ++it;\n      set_brackets({}, {});\n      set_separator({});\n    }\n    if (it != end && *it != '}') report_error(\"invalid format specifier\");\n    ctx.advance_to(it);\n    detail::for_each(formatters_, detail::parse_empty_specs<Char>{ctx});\n    return it;\n  }\n\n  template <typename FormatContext>\n  auto format(const Tuple& value, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    ctx.advance_to(detail::copy<Char>(opening_bracket_, ctx.out()));\n    detail::for_each2(\n        formatters_, value,\n        detail::format_tuple_element<FormatContext>{0, ctx, separator_});\n    return detail::copy<Char>(closing_bracket_, ctx.out());\n  }\n};\n\nFMT_EXPORT\ntemplate <typename T, typename Char> struct is_range {\n  static constexpr bool value =\n      detail::is_range_<T>::value && !detail::has_to_string_view<T>::value;\n};\n\nnamespace detail {\n\ntemplate <typename Char, typename Element>\nusing range_formatter_type = formatter<remove_cvref_t<Element>, Char>;\n\ntemplate <typename R>\nusing maybe_const_range =\n    conditional_t<has_const_begin_end<R>::value, const R, R>;\n\ntemplate <typename R, typename Char>\nstruct is_formattable_delayed\n    : is_formattable<uncvref_type<maybe_const_range<R>>, Char> {};\n}  // namespace detail\n\ntemplate <typename...> struct conjunction : std::true_type {};\ntemplate <typename P> struct conjunction<P> : P {};\ntemplate <typename P1, typename... Pn>\nstruct conjunction<P1, Pn...>\n    : conditional_t<bool(P1::value), conjunction<Pn...>, P1> {};\n\nFMT_EXPORT\ntemplate <typename T, typename Char, typename Enable = void>\nstruct range_formatter;\n\ntemplate <typename T, typename Char>\nstruct range_formatter<\n    T, Char,\n    enable_if_t<conjunction<std::is_same<T, remove_cvref_t<T>>,\n                            is_formattable<T, Char>>::value>> {\n private:\n  detail::range_formatter_type<Char, T> underlying_;\n  basic_string_view<Char> separator_ = detail::string_literal<Char, ',', ' '>{};\n  basic_string_view<Char> opening_bracket_ =\n      detail::string_literal<Char, '['>{};\n  basic_string_view<Char> closing_bracket_ =\n      detail::string_literal<Char, ']'>{};\n  bool is_debug = false;\n\n  template <typename Output, typename It, typename Sentinel, typename U = T,\n            FMT_ENABLE_IF(std::is_same<U, Char>::value)>\n  auto write_debug_string(Output& out, It it, Sentinel end) const -> Output {\n    auto buf = basic_memory_buffer<Char>();\n    for (; it != end; ++it) buf.push_back(*it);\n    auto specs = format_specs();\n    specs.set_type(presentation_type::debug);\n    return detail::write<Char>(\n        out, basic_string_view<Char>(buf.data(), buf.size()), specs);\n  }\n\n  template <typename Output, typename It, typename Sentinel, typename U = T,\n            FMT_ENABLE_IF(!std::is_same<U, Char>::value)>\n  auto write_debug_string(Output& out, It, Sentinel) const -> Output {\n    return out;\n  }\n\n public:\n  FMT_CONSTEXPR range_formatter() {}\n\n  FMT_CONSTEXPR auto underlying() -> detail::range_formatter_type<Char, T>& {\n    return underlying_;\n  }\n\n  FMT_CONSTEXPR void set_separator(basic_string_view<Char> sep) {\n    separator_ = sep;\n  }\n\n  FMT_CONSTEXPR void set_brackets(basic_string_view<Char> open,\n                                  basic_string_view<Char> close) {\n    opening_bracket_ = open;\n    closing_bracket_ = close;\n  }\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin();\n    auto end = ctx.end();\n    detail::maybe_set_debug_format(underlying_, true);\n    if (it == end) return underlying_.parse(ctx);\n\n    switch (detail::to_ascii(*it)) {\n    case 'n':\n      set_brackets({}, {});\n      ++it;\n      break;\n    case '?':\n      is_debug = true;\n      set_brackets({}, {});\n      ++it;\n      if (it == end || *it != 's') report_error(\"invalid format specifier\");\n      FMT_FALLTHROUGH;\n    case 's':\n      if (!std::is_same<T, Char>::value)\n        report_error(\"invalid format specifier\");\n      if (!is_debug) {\n        set_brackets(detail::string_literal<Char, '\"'>{},\n                     detail::string_literal<Char, '\"'>{});\n        set_separator({});\n        detail::maybe_set_debug_format(underlying_, false);\n      }\n      ++it;\n      return it;\n    }\n\n    if (it != end && *it != '}') {\n      if (*it != ':') report_error(\"invalid format specifier\");\n      detail::maybe_set_debug_format(underlying_, false);\n      ++it;\n    }\n\n    ctx.advance_to(it);\n    return underlying_.parse(ctx);\n  }\n\n  template <typename R, typename FormatContext>\n  auto format(R&& range, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    auto it = detail::range_begin(range);\n    auto end = detail::range_end(range);\n    if (is_debug) return write_debug_string(out, std::move(it), end);\n\n    out = detail::copy<Char>(opening_bracket_, out);\n    int i = 0;\n    for (; it != end; ++it) {\n      if (i > 0) out = detail::copy<Char>(separator_, out);\n      ctx.advance_to(out);\n      auto&& item = *it;  // Need an lvalue\n      out = underlying_.format(item, ctx);\n      ++i;\n    }\n    out = detail::copy<Char>(closing_bracket_, out);\n    return out;\n  }\n};\n\nFMT_EXPORT\ntemplate <typename T, typename Char, typename Enable = void>\nstruct range_format_kind\n    : conditional_t<\n          is_range<T, Char>::value, detail::range_format_kind_<T>,\n          std::integral_constant<range_format, range_format::disabled>> {};\n\ntemplate <typename R, typename Char>\nstruct formatter<\n    R, Char,\n    enable_if_t<conjunction<\n        bool_constant<\n            range_format_kind<R, Char>::value != range_format::disabled &&\n            range_format_kind<R, Char>::value != range_format::map &&\n            range_format_kind<R, Char>::value != range_format::string &&\n            range_format_kind<R, Char>::value != range_format::debug_string>,\n        detail::is_formattable_delayed<R, Char>>::value>> {\n private:\n  using range_type = detail::maybe_const_range<R>;\n  range_formatter<detail::uncvref_type<range_type>, Char> range_formatter_;\n\n public:\n  using nonlocking = void;\n\n  FMT_CONSTEXPR formatter() {\n    if FMT_CONSTEXPR20 (range_format_kind<R, Char>::value != range_format::set)\n      return;\n    range_formatter_.set_brackets(detail::string_literal<Char, '{'>{},\n                                  detail::string_literal<Char, '}'>{});\n  }\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return range_formatter_.parse(ctx);\n  }\n\n  template <typename FormatContext>\n  auto format(range_type& range, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return range_formatter_.format(range, ctx);\n  }\n};\n\n// A map formatter.\ntemplate <typename R, typename Char>\nstruct formatter<\n    R, Char,\n    enable_if_t<conjunction<\n        bool_constant<range_format_kind<R, Char>::value == range_format::map>,\n        detail::is_formattable_delayed<R, Char>>::value>> {\n private:\n  using map_type = detail::maybe_const_range<R>;\n  using element_type = detail::uncvref_type<map_type>;\n\n  decltype(detail::tuple::get_formatters<element_type, Char>(\n      detail::tuple_index_sequence<element_type>())) formatters_;\n  bool no_delimiters_ = false;\n\n public:\n  FMT_CONSTEXPR formatter() {}\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    auto it = ctx.begin();\n    auto end = ctx.end();\n    if (it != end) {\n      if (detail::to_ascii(*it) == 'n') {\n        no_delimiters_ = true;\n        ++it;\n      }\n      if (it != end && *it != '}') {\n        if (*it != ':') report_error(\"invalid format specifier\");\n        ++it;\n      }\n      ctx.advance_to(it);\n    }\n    detail::for_each(formatters_, detail::parse_empty_specs<Char>{ctx});\n    return it;\n  }\n\n  template <typename FormatContext>\n  auto format(map_type& map, FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    basic_string_view<Char> open = detail::string_literal<Char, '{'>{};\n    if (!no_delimiters_) out = detail::copy<Char>(open, out);\n    int i = 0;\n    basic_string_view<Char> sep = detail::string_literal<Char, ',', ' '>{};\n    for (auto&& value : map) {\n      if (i > 0) out = detail::copy<Char>(sep, out);\n      ctx.advance_to(out);\n      detail::for_each2(formatters_, value,\n                        detail::format_tuple_element<FormatContext>{\n                            0, ctx, detail::string_literal<Char, ':', ' '>{}});\n      ++i;\n    }\n    basic_string_view<Char> close = detail::string_literal<Char, '}'>{};\n    if (!no_delimiters_) out = detail::copy<Char>(close, out);\n    return out;\n  }\n};\n\n// A (debug_)string formatter.\ntemplate <typename R, typename Char>\nstruct formatter<\n    R, Char,\n    enable_if_t<range_format_kind<R, Char>::value == range_format::string ||\n                range_format_kind<R, Char>::value ==\n                    range_format::debug_string>> {\n private:\n  using range_type = detail::maybe_const_range<R>;\n  using string_type =\n      conditional_t<std::is_constructible<\n                        detail::std_string_view<Char>,\n                        decltype(detail::range_begin(std::declval<R>())),\n                        decltype(detail::range_end(std::declval<R>()))>::value,\n                    detail::std_string_view<Char>, std::basic_string<Char>>;\n\n  formatter<string_type, Char> underlying_;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return underlying_.parse(ctx);\n  }\n\n  template <typename FormatContext>\n  auto format(range_type& range, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    if FMT_CONSTEXPR20 (range_format_kind<R, Char>::value ==\n                        range_format::debug_string) {\n      *out++ = '\"';\n    }\n    out = underlying_.format(\n        string_type{detail::range_begin(range), detail::range_end(range)}, ctx);\n    if FMT_CONSTEXPR20 (range_format_kind<R, Char>::value ==\n                        range_format::debug_string)\n      *out++ = '\"';\n    return out;\n  }\n};\n\ntemplate <typename It, typename Sentinel, typename Char = char>\nstruct join_view : detail::view {\n  It begin;\n  Sentinel end;\n  basic_string_view<Char> sep;\n\n  join_view(It b, Sentinel e, basic_string_view<Char> s)\n      : begin(std::move(b)), end(e), sep(s) {}\n};\n\ntemplate <typename It, typename Sentinel, typename Char>\nstruct formatter<join_view<It, Sentinel, Char>, Char> {\n private:\n  using value_type =\n#ifdef __cpp_lib_ranges\n      std::iter_value_t<It>;\n#else\n      typename std::iterator_traits<It>::value_type;\n#endif\n  formatter<remove_cvref_t<value_type>, Char> value_formatter_;\n\n  using view = conditional_t<std::is_copy_constructible<It>::value,\n                             const join_view<It, Sentinel, Char>,\n                             join_view<It, Sentinel, Char>>;\n\n public:\n  using nonlocking = void;\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return value_formatter_.parse(ctx);\n  }\n\n  template <typename FormatContext>\n  auto format(view& value, FormatContext& ctx) const -> decltype(ctx.out()) {\n    using iter =\n        conditional_t<std::is_copy_constructible<view>::value, It, It&>;\n    iter it = value.begin;\n    auto out = ctx.out();\n    if (it == value.end) return out;\n    out = value_formatter_.format(*it, ctx);\n    ++it;\n    while (it != value.end) {\n      out = detail::copy<Char>(value.sep.begin(), value.sep.end(), out);\n      ctx.advance_to(out);\n      out = value_formatter_.format(*it, ctx);\n      ++it;\n    }\n    return out;\n  }\n};\n\nFMT_EXPORT\ntemplate <typename Tuple, typename Char> struct tuple_join_view : detail::view {\n  const Tuple& tuple;\n  basic_string_view<Char> sep;\n\n  tuple_join_view(const Tuple& t, basic_string_view<Char> s)\n      : tuple(t), sep{s} {}\n};\n\n// Define FMT_TUPLE_JOIN_SPECIFIERS to enable experimental format specifiers\n// support in tuple_join. It is disabled by default because of issues with\n// the dynamic width and precision.\n#ifndef FMT_TUPLE_JOIN_SPECIFIERS\n#  define FMT_TUPLE_JOIN_SPECIFIERS 0\n#endif\n\ntemplate <typename Tuple, typename Char>\nstruct formatter<tuple_join_view<Tuple, Char>, Char,\n                 enable_if_t<is_tuple_like<Tuple>::value>> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return do_parse(ctx, std::tuple_size<Tuple>());\n  }\n\n  template <typename FormatContext>\n  auto format(const tuple_join_view<Tuple, Char>& value,\n              FormatContext& ctx) const -> typename FormatContext::iterator {\n    return do_format(value, ctx, std::tuple_size<Tuple>());\n  }\n\n private:\n  decltype(detail::tuple::get_formatters<Tuple, Char>(\n      detail::tuple_index_sequence<Tuple>())) formatters_;\n\n  FMT_CONSTEXPR auto do_parse(parse_context<Char>& ctx,\n                              std::integral_constant<size_t, 0>)\n      -> const Char* {\n    return ctx.begin();\n  }\n\n  template <size_t N>\n  FMT_CONSTEXPR auto do_parse(parse_context<Char>& ctx,\n                              std::integral_constant<size_t, N>)\n      -> const Char* {\n    auto end = ctx.begin();\n#if FMT_TUPLE_JOIN_SPECIFIERS\n    end = std::get<std::tuple_size<Tuple>::value - N>(formatters_).parse(ctx);\n    if (N > 1) {\n      auto end1 = do_parse(ctx, std::integral_constant<size_t, N - 1>());\n      if (end != end1)\n        report_error(\"incompatible format specs for tuple elements\");\n    }\n#endif\n    return end;\n  }\n\n  template <typename FormatContext>\n  auto do_format(const tuple_join_view<Tuple, Char>&, FormatContext& ctx,\n                 std::integral_constant<size_t, 0>) const ->\n      typename FormatContext::iterator {\n    return ctx.out();\n  }\n\n  template <typename FormatContext, size_t N>\n  auto do_format(const tuple_join_view<Tuple, Char>& value, FormatContext& ctx,\n                 std::integral_constant<size_t, N>) const ->\n      typename FormatContext::iterator {\n    using std::get;\n    auto out =\n        std::get<std::tuple_size<Tuple>::value - N>(formatters_)\n            .format(get<std::tuple_size<Tuple>::value - N>(value.tuple), ctx);\n    if (N <= 1) return out;\n    out = detail::copy<Char>(value.sep, out);\n    ctx.advance_to(out);\n    return do_format(value, ctx, std::integral_constant<size_t, N - 1>());\n  }\n};\n\nnamespace detail {\ntemplate <typename Container> struct all {\n  const Container& c;\n  auto begin() const -> typename Container::const_iterator { return c.begin(); }\n  auto end() const -> typename Container::const_iterator { return c.end(); }\n};\n}  // namespace detail\n\n/**\n * Specifies if `T` is a container adaptor (like `std::stack`) that should be\n * formatted as the underlying container.\n */\nFMT_EXPORT\ntemplate <typename T> struct is_container_adaptor {\n private:\n  template <typename U> static auto check(U* p) -> typename U::container_type;\n  template <typename> static void check(...);\n\n public:\n  static constexpr bool value =\n      !std::is_void<decltype(check<T>(nullptr))>::value;\n};\n\ntemplate <typename T, typename Char>\nstruct formatter<\n    T, Char,\n    enable_if_t<conjunction<is_container_adaptor<T>,\n                            bool_constant<range_format_kind<T, Char>::value ==\n                                          range_format::disabled>>::value>>\n    : formatter<detail::all<typename T::container_type>, Char> {\n  using all = detail::all<typename T::container_type>;\n  template <typename FormatContext>\n  auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) {\n    struct getter : T {\n      static auto get(const T& v) -> all {\n        return {v.*(&getter::c)};  // Access c through the derived class.\n      }\n    };\n    return formatter<all>::format(getter::get(value), ctx);\n  }\n};\n\nFMT_BEGIN_EXPORT\n\n/// Returns a view that formats the iterator range `[begin, end)` with elements\n/// separated by `sep`.\ntemplate <typename It, typename Sentinel>\nauto join(It begin, Sentinel end, string_view sep) -> join_view<It, Sentinel> {\n  return {std::move(begin), end, sep};\n}\n\n/**\n * Returns a view that formats `range` with elements separated by `sep`.\n *\n * **Example**:\n *\n *     auto v = std::vector<int>{1, 2, 3};\n *     fmt::print(\"{}\", fmt::join(v, \", \"));\n *     // Output: 1, 2, 3\n *\n * `fmt::join` applies passed format specifiers to the range elements:\n *\n *     fmt::print(\"{:02}\", fmt::join(v, \", \"));\n *     // Output: 01, 02, 03\n */\ntemplate <typename Range, FMT_ENABLE_IF(!is_tuple_like<Range>::value)>\nauto join(Range&& r, string_view sep)\n    -> join_view<decltype(detail::range_begin(r)),\n                 decltype(detail::range_end(r))> {\n  return {detail::range_begin(r), detail::range_end(r), sep};\n}\n\n/**\n * Returns an object that formats `std::tuple` with elements separated by `sep`.\n *\n * **Example**:\n *\n *     auto t = std::tuple<int, char>(1, 'a');\n *     fmt::print(\"{}\", fmt::join(t, \", \"));\n *     // Output: 1, a\n */\ntemplate <typename Tuple, FMT_ENABLE_IF(is_tuple_like<Tuple>::value)>\nFMT_CONSTEXPR auto join(const Tuple& tuple FMT_LIFETIMEBOUND, string_view sep)\n    -> tuple_join_view<Tuple, char> {\n  return {tuple, sep};\n}\n\n/**\n * Returns an object that formats `std::initializer_list` with elements\n * separated by `sep`.\n *\n * **Example**:\n *\n *     fmt::print(\"{}\", fmt::join({1, 2, 3}, \", \"));\n *     // Output: \"1, 2, 3\"\n */\ntemplate <typename T>\nFMT_DEPRECATED auto join(std::initializer_list<T> list, string_view sep)\n    -> join_view<const T*, const T*> {\n  return join(std::begin(list), std::end(list), sep);\n}\n\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_RANGES_H_\n"
  },
  {
    "path": "include/fmt/std.h",
    "content": "// Formatting library for C++ - formatters for standard library types\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_STD_H_\n#define FMT_STD_H_\n\n#include \"format.h\"\n#include \"ostream.h\"\n\n#ifndef FMT_MODULE\n#  include <atomic>\n#  include <bitset>\n#  include <complex>\n#  include <cstddef>     // std::byte\n#  include <exception>   // std::exception\n#  include <functional>  // std::reference_wrapper\n#  include <memory>\n#  include <thread>\n#  include <type_traits>\n#  include <typeinfo>  // std::type_info\n#  include <utility>   // std::make_index_sequence\n\n// Check FMT_CPLUSPLUS to suppress a bogus warning in MSVC.\n#  if FMT_CPLUSPLUS >= 201703L\n#    if FMT_HAS_INCLUDE(<filesystem>) && \\\n        (!defined(FMT_CPP_LIB_FILESYSTEM) || FMT_CPP_LIB_FILESYSTEM != 0)\n#      include <filesystem>\n#    endif\n#    if FMT_HAS_INCLUDE(<variant>)\n#      include <variant>\n#    endif\n#    if FMT_HAS_INCLUDE(<optional>)\n#      include <optional>\n#    endif\n#  endif\n// Use > instead of >= in the version check because <source_location> may be\n// available after C++17 but before C++20 is marked as implemented.\n#  if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<source_location>)\n#    include <source_location>\n#  endif\n#  if FMT_CPLUSPLUS > 202002L && FMT_HAS_INCLUDE(<expected>)\n#    include <expected>\n#  endif\n#endif  // FMT_MODULE\n\n#if FMT_HAS_INCLUDE(<version>)\n#  include <version>\n#endif\n\n// GCC 4 does not support FMT_HAS_INCLUDE.\n#if FMT_HAS_INCLUDE(<cxxabi.h>) || defined(__GLIBCXX__)\n#  include <cxxabi.h>\n// Android NDK with gabi++ library on some architectures does not implement\n// abi::__cxa_demangle().\n#  ifndef __GABIXX_CXXABI_H__\n#    define FMT_HAS_ABI_CXA_DEMANGLE\n#  endif\n#endif\n\n#ifdef FMT_CPP_LIB_FILESYSTEM\n// Use the provided definition.\n#elif defined(__cpp_lib_filesystem)\n#  define FMT_CPP_LIB_FILESYSTEM __cpp_lib_filesystem\n#else\n#  define FMT_CPP_LIB_FILESYSTEM 0\n#endif\n\n#ifdef FMT_CPP_LIB_VARIANT\n// Use the provided definition.\n#elif defined(__cpp_lib_variant)\n#  define FMT_CPP_LIB_VARIANT __cpp_lib_variant\n#else\n#  define FMT_CPP_LIB_VARIANT 0\n#endif\n\nFMT_BEGIN_NAMESPACE\nnamespace detail {\n\n#ifdef FMT_USE_BITINT\n// Use the provided definition.\n#elif FMT_CLANG_VERSION >= 1500 && !defined(__CUDACC__)\n#  define FMT_USE_BITINT 1\n#else\n#  define FMT_USE_BITINT 0\n#endif\n\n#if FMT_USE_BITINT\nFMT_PRAGMA_CLANG(diagnostic ignored \"-Wbit-int-extension\")\ntemplate <int N> using bitint = _BitInt(N);\ntemplate <int N> using ubitint = unsigned _BitInt(N);\n#else\ntemplate <int N> struct bitint {};\ntemplate <int N> struct ubitint {};\n#endif  // FMT_USE_BITINT\n\n#if FMT_CPP_LIB_FILESYSTEM\n\ntemplate <typename Char, typename PathChar>\nauto get_path_string(const std::filesystem::path& p,\n                     const std::basic_string<PathChar>& native) {\n  if constexpr (std::is_same_v<Char, char> &&\n                std::is_same_v<PathChar, wchar_t>) {\n    return to_utf8<wchar_t>(native, to_utf8_error_policy::wtf);\n  } else {\n    return p.string<Char>();\n  }\n}\n\ntemplate <typename Char, typename PathChar>\nvoid write_escaped_path(basic_memory_buffer<Char>& quoted,\n                        const std::filesystem::path& p,\n                        const std::basic_string<PathChar>& native) {\n  if constexpr (std::is_same_v<Char, char> &&\n                std::is_same_v<PathChar, wchar_t>) {\n    auto buf = basic_memory_buffer<wchar_t>();\n    write_escaped_string<wchar_t>(std::back_inserter(buf), native);\n    bool valid = to_utf8<wchar_t>::convert(quoted, {buf.data(), buf.size()});\n    FMT_ASSERT(valid, \"invalid utf16\");\n  } else if constexpr (std::is_same_v<Char, PathChar>) {\n    write_escaped_string<std::filesystem::path::value_type>(\n        std::back_inserter(quoted), native);\n  } else {\n    write_escaped_string<Char>(std::back_inserter(quoted), p.string<Char>());\n  }\n}\n\n#endif  // FMT_CPP_LIB_FILESYSTEM\n\n#if defined(__cpp_lib_expected) || FMT_CPP_LIB_VARIANT\n\ntemplate <typename Char, typename OutputIt, typename T, typename FormatContext>\nauto write_escaped_alternative(OutputIt out, const T& v, FormatContext& ctx)\n    -> OutputIt {\n  if constexpr (has_to_string_view<T>::value)\n    return write_escaped_string<Char>(out, detail::to_string_view(v));\n  if constexpr (std::is_same_v<T, Char>) return write_escaped_char(out, v);\n\n  formatter<std::remove_cv_t<T>, Char> underlying;\n  maybe_set_debug_format(underlying, true);\n  return underlying.format(v, ctx);\n}\n#endif\n\n#if FMT_CPP_LIB_VARIANT\n\ntemplate <typename> struct is_variant_like_ : std::false_type {};\ntemplate <typename... Types>\nstruct is_variant_like_<std::variant<Types...>> : std::true_type {};\n\ntemplate <typename Variant, typename Char> class is_variant_formattable {\n  template <size_t... Is>\n  static auto check(std::index_sequence<Is...>) -> std::conjunction<\n      is_formattable<std::variant_alternative_t<Is, Variant>, Char>...>;\n\n public:\n  static constexpr bool value = decltype(check(\n      std::make_index_sequence<std::variant_size<Variant>::value>()))::value;\n};\n\n#endif  // FMT_CPP_LIB_VARIANT\n\n#if FMT_USE_RTTI\ninline auto normalize_libcxx_inline_namespaces(string_view demangled_name_view,\n                                               char* begin) -> string_view {\n  // Normalization of stdlib inline namespace names.\n  // libc++ inline namespaces.\n  //  std::__1::*       -> std::*\n  //  std::__1::__fs::* -> std::*\n  // libstdc++ inline namespaces.\n  //  std::__cxx11::*             -> std::*\n  //  std::filesystem::__cxx11::* -> std::filesystem::*\n  if (demangled_name_view.starts_with(\"std::\")) {\n    char* to = begin + 5;  // std::\n    for (const char *from = to, *end = begin + demangled_name_view.size();\n         from < end;) {\n      // This is safe, because demangled_name is NUL-terminated.\n      if (from[0] == '_' && from[1] == '_') {\n        const char* next = from + 1;\n        while (next < end && *next != ':') next++;\n        if (next[0] == ':' && next[1] == ':') {\n          from = next + 2;\n          continue;\n        }\n      }\n      *to++ = *from++;\n    }\n    demangled_name_view = {begin, detail::to_unsigned(to - begin)};\n  }\n  return demangled_name_view;\n}\n\ntemplate <class OutputIt>\nauto normalize_msvc_abi_name(string_view abi_name_view, OutputIt out)\n    -> OutputIt {\n  const string_view demangled_name(abi_name_view);\n  for (size_t i = 0; i < demangled_name.size(); ++i) {\n    auto sub = demangled_name;\n    sub.remove_prefix(i);\n    if (sub.starts_with(\"enum \")) {\n      i += 4;\n      continue;\n    }\n    if (sub.starts_with(\"class \") || sub.starts_with(\"union \")) {\n      i += 5;\n      continue;\n    }\n    if (sub.starts_with(\"struct \")) {\n      i += 6;\n      continue;\n    }\n    if (*sub.begin() != ' ') *out++ = *sub.begin();\n  }\n  return out;\n}\n\ntemplate <typename OutputIt>\nauto write_demangled_name(OutputIt out, const std::type_info& ti) -> OutputIt {\n#  ifdef FMT_HAS_ABI_CXA_DEMANGLE\n  int status = 0;\n  size_t size = 0;\n  std::unique_ptr<char, void (*)(void*)> demangled_name_ptr(\n      abi::__cxa_demangle(ti.name(), nullptr, &size, &status), &free);\n\n  string_view demangled_name_view;\n  if (demangled_name_ptr) {\n    demangled_name_view = normalize_libcxx_inline_namespaces(\n        demangled_name_ptr.get(), demangled_name_ptr.get());\n  } else {\n    demangled_name_view = string_view(ti.name());\n  }\n  return detail::write_bytes<char>(out, demangled_name_view);\n#  elif FMT_MSC_VERSION && defined(_MSVC_STL_UPDATE)\n  return normalize_msvc_abi_name(ti.name(), out);\n#  elif FMT_MSC_VERSION && defined(_LIBCPP_VERSION)\n  const string_view demangled_name = ti.name();\n  std::string name_copy(demangled_name.size(), '\\0');\n  // normalize_msvc_abi_name removes class, struct, union etc that MSVC has in\n  // front of types\n  name_copy.erase(normalize_msvc_abi_name(demangled_name, name_copy.begin()),\n                  name_copy.end());\n  // normalize_libcxx_inline_namespaces removes the inline __1, __2, etc\n  // namespaces libc++ uses for ABI versioning On MSVC ABI + libc++\n  // environments, we need to eliminate both of them.\n  const string_view normalized_name =\n      normalize_libcxx_inline_namespaces(name_copy, name_copy.data());\n  return detail::write_bytes<char>(out, normalized_name);\n#  else\n  return detail::write_bytes<char>(out, string_view(ti.name()));\n#  endif\n}\n\n#endif  // FMT_USE_RTTI\n\ntemplate <typename T, typename Enable = void>\nstruct has_flip : std::false_type {};\n\ntemplate <typename T>\nstruct has_flip<T, void_t<decltype(std::declval<T>().flip())>>\n    : std::true_type {};\n\ntemplate <typename T> struct is_bit_reference_like {\n  static constexpr bool value = std::is_convertible<T, bool>::value &&\n                                std::is_nothrow_assignable<T, bool>::value &&\n                                has_flip<T>::value;\n};\n\n// Workaround for libc++ incompatibility with C++ standard.\n// According to the Standard, `bitset::operator[] const` returns bool.\n#if defined(_LIBCPP_VERSION) && !defined(FMT_IMPORT_STD)\ntemplate <typename C>\nstruct is_bit_reference_like<std::__bit_const_reference<C>> {\n  static constexpr bool value = true;\n};\n#endif\n\ntemplate <typename T, typename Enable = void>\nstruct has_format_as : std::false_type {};\ntemplate <typename T>\nstruct has_format_as<T, void_t<decltype(format_as(std::declval<const T&>()))>>\n    : std::true_type {};\n\ntemplate <typename T, typename Enable = void>\nstruct has_format_as_member : std::false_type {};\ntemplate <typename T>\nstruct has_format_as_member<\n    T, void_t<decltype(formatter<T>::format_as(std::declval<const T&>()))>>\n    : std::true_type {};\n\n}  // namespace detail\n\ntemplate <typename T, typename Deleter>\nauto ptr(const std::unique_ptr<T, Deleter>& p) -> const void* {\n  return p.get();\n}\ntemplate <typename T> auto ptr(const std::shared_ptr<T>& p) -> const void* {\n  return p.get();\n}\n\n#if FMT_CPP_LIB_FILESYSTEM\n\ntemplate <typename Char> struct formatter<std::filesystem::path, Char> {\n private:\n  format_specs specs_;\n  detail::arg_ref<Char> width_ref_;\n  bool debug_ = false;\n  char path_type_ = 0;\n\n public:\n  FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; }\n\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it == end) return it;\n\n    it = detail::parse_align(it, end, specs_);\n    if (it == end) return it;\n\n    Char c = *it;\n    if ((c >= '0' && c <= '9') || c == '{')\n      it = detail::parse_width(it, end, specs_, width_ref_, ctx);\n    if (it != end && *it == '?') {\n      debug_ = true;\n      ++it;\n    }\n    if (it != end && (*it == 'g')) path_type_ = detail::to_ascii(*it++);\n    return it;\n  }\n\n  template <typename FormatContext>\n  auto format(const std::filesystem::path& p, FormatContext& ctx) const {\n    auto specs = specs_;\n    auto path_string =\n        !path_type_ ? p.native()\n                    : p.generic_string<std::filesystem::path::value_type>();\n\n    detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,\n                                ctx);\n    if (!debug_) {\n      auto s = detail::get_path_string<Char>(p, path_string);\n      return detail::write(ctx.out(), basic_string_view<Char>(s), specs);\n    }\n    auto quoted = basic_memory_buffer<Char>();\n    detail::write_escaped_path(quoted, p, path_string);\n    return detail::write(ctx.out(),\n                         basic_string_view<Char>(quoted.data(), quoted.size()),\n                         specs);\n  }\n};\n\nclass path : public std::filesystem::path {\n public:\n  auto display_string() const -> std::string {\n    const std::filesystem::path& base = *this;\n    return fmt::format(FMT_STRING(\"{}\"), base);\n  }\n  auto system_string() const -> std::string { return string(); }\n\n  auto generic_display_string() const -> std::string {\n    const std::filesystem::path& base = *this;\n    return fmt::format(FMT_STRING(\"{:g}\"), base);\n  }\n  auto generic_system_string() const -> std::string { return generic_string(); }\n};\n\n#endif  // FMT_CPP_LIB_FILESYSTEM\n\ntemplate <size_t N, typename Char>\nstruct formatter<std::bitset<N>, Char>\n    : nested_formatter<basic_string_view<Char>, Char> {\n private:\n  // This is a functor because C++11 doesn't support generic lambdas.\n  struct writer {\n    const std::bitset<N>& bs;\n\n    template <typename OutputIt>\n    FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {\n      for (auto pos = N; pos > 0; --pos)\n        out = detail::write<Char>(out, bs[pos - 1] ? Char('1') : Char('0'));\n      return out;\n    }\n  };\n\n public:\n  template <typename FormatContext>\n  auto format(const std::bitset<N>& bs, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return this->write_padded(ctx, writer{bs});\n  }\n};\n\ntemplate <typename Char>\nstruct formatter<std::thread::id, Char> : basic_ostream_formatter<Char> {};\n\n#ifdef __cpp_lib_optional\ntemplate <typename T, typename Char>\nstruct formatter<std::optional<T>, Char,\n                 std::enable_if_t<is_formattable<T, Char>::value>> {\n private:\n  formatter<std::remove_cv_t<T>, Char> underlying_;\n  static constexpr basic_string_view<Char> optional =\n      detail::string_literal<Char, 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l',\n                             '('>{};\n  static constexpr basic_string_view<Char> none =\n      detail::string_literal<Char, 'n', 'o', 'n', 'e'>{};\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) {\n    detail::maybe_set_debug_format(underlying_, true);\n    return underlying_.parse(ctx);\n  }\n\n  template <typename FormatContext>\n  auto format(const std::optional<T>& opt, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    if (!opt) return detail::write<Char>(ctx.out(), none);\n\n    auto out = ctx.out();\n    out = detail::write<Char>(out, optional);\n    ctx.advance_to(out);\n    out = underlying_.format(*opt, ctx);\n    return detail::write(out, ')');\n  }\n};\n#endif  // __cpp_lib_optional\n\n#ifdef __cpp_lib_expected\ntemplate <typename T, typename E, typename Char>\nstruct formatter<std::expected<T, E>, Char,\n                 std::enable_if_t<(std::is_void<T>::value ||\n                                   is_formattable<T, Char>::value) &&\n                                  is_formattable<E, Char>::value>> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return ctx.begin();\n  }\n\n  template <typename FormatContext>\n  auto format(const std::expected<T, E>& value, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n\n    if (value.has_value()) {\n      out = detail::write<Char>(out, \"expected(\");\n      if constexpr (!std::is_void<T>::value)\n        out = detail::write_escaped_alternative<Char>(out, *value, ctx);\n    } else {\n      out = detail::write<Char>(out, \"unexpected(\");\n      out = detail::write_escaped_alternative<Char>(out, value.error(), ctx);\n    }\n    *out++ = ')';\n    return out;\n  }\n};\n\ntemplate <typename E, typename Char>\nstruct formatter<std::unexpected<E>, Char,\n                 std::enable_if_t<is_formattable<E, Char>::value>> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return ctx.begin();\n  }\n\n  template <typename FormatContext>\n  auto format(const std::unexpected<E>& value, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n\n    out = detail::write<Char>(out, \"unexpected(\");\n    out = detail::write_escaped_alternative<Char>(out, value.error(), ctx);\n\n    *out++ = ')';\n    return out;\n  }\n};\n#endif  // __cpp_lib_expected\n\n#ifdef __cpp_lib_source_location\ntemplate <> struct formatter<std::source_location> {\n  FMT_CONSTEXPR auto parse(parse_context<>& ctx) { return ctx.begin(); }\n\n  template <typename FormatContext>\n  auto format(const std::source_location& loc, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    out = detail::write(out, loc.file_name());\n    out = detail::write(out, ':');\n    out = detail::write<char>(out, loc.line());\n    out = detail::write(out, ':');\n    out = detail::write<char>(out, loc.column());\n    out = detail::write(out, \": \");\n    out = detail::write(out, loc.function_name());\n    return out;\n  }\n};\n#endif\n\n#if FMT_CPP_LIB_VARIANT\n\ntemplate <typename T> struct is_variant_like {\n  static constexpr bool value = detail::is_variant_like_<T>::value;\n};\n\ntemplate <typename Char> struct formatter<std::monostate, Char> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return ctx.begin();\n  }\n\n  template <typename FormatContext>\n  auto format(const std::monostate&, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return detail::write<Char>(ctx.out(), \"monostate\");\n  }\n};\n\ntemplate <typename Variant, typename Char>\nstruct formatter<Variant, Char,\n                 std::enable_if_t<std::conjunction_v<\n                     is_variant_like<Variant>,\n                     detail::is_variant_formattable<Variant, Char>>>> {\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    return ctx.begin();\n  }\n\n  template <typename FormatContext>\n  auto format(const Variant& value, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n\n    out = detail::write<Char>(out, \"variant(\");\n    FMT_TRY {\n      std::visit(\n          [&](const auto& v) {\n            out = detail::write_escaped_alternative<Char>(out, v, ctx);\n          },\n          value);\n    }\n    FMT_CATCH(const std::bad_variant_access&) {\n      detail::write<Char>(out, \"valueless by exception\");\n    }\n    *out++ = ')';\n    return out;\n  }\n};\n\n#endif  // FMT_CPP_LIB_VARIANT\n\ntemplate <> struct formatter<std::error_code> {\n private:\n  format_specs specs_;\n  detail::arg_ref<char> width_ref_;\n  bool debug_ = false;\n\n public:\n  FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; }\n\n  FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it == end) return it;\n\n    it = detail::parse_align(it, end, specs_);\n\n    char c = *it;\n    if (it != end && ((c >= '0' && c <= '9') || c == '{'))\n      it = detail::parse_width(it, end, specs_, width_ref_, ctx);\n\n    if (it != end && *it == '?') {\n      debug_ = true;\n      ++it;\n    }\n    if (it != end && *it == 's') {\n      specs_.set_type(presentation_type::string);\n      ++it;\n    }\n    return it;\n  }\n\n  template <typename FormatContext>\n  FMT_CONSTEXPR20 auto format(const std::error_code& ec,\n                              FormatContext& ctx) const -> decltype(ctx.out()) {\n    auto specs = specs_;\n    detail::handle_dynamic_spec(specs.dynamic_width(), specs.width, width_ref_,\n                                ctx);\n    auto buf = memory_buffer();\n    if (specs_.type() == presentation_type::string) {\n      buf.append(ec.message());\n    } else {\n      buf.append(string_view(ec.category().name()));\n      buf.push_back(':');\n      detail::write<char>(appender(buf), ec.value());\n    }\n    auto quoted = memory_buffer();\n    auto str = string_view(buf.data(), buf.size());\n    if (debug_) {\n      detail::write_escaped_string<char>(std::back_inserter(quoted), str);\n      str = string_view(quoted.data(), quoted.size());\n    }\n    return detail::write<char>(ctx.out(), str, specs);\n  }\n};\n\n#if FMT_USE_RTTI\ntemplate <> struct formatter<std::type_info> {\n public:\n  FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {\n    return ctx.begin();\n  }\n\n  template <typename Context>\n  auto format(const std::type_info& ti, Context& ctx) const\n      -> decltype(ctx.out()) {\n    return detail::write_demangled_name(ctx.out(), ti);\n  }\n};\n#endif  // FMT_USE_RTTI\n\ntemplate <typename T>\nstruct formatter<\n    T, char,\n    typename std::enable_if<std::is_base_of<std::exception, T>::value>::type> {\n private:\n  bool with_typename_ = false;\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {\n    auto it = ctx.begin();\n    auto end = ctx.end();\n    if (it == end || *it == '}') return it;\n    if (*it == 't') {\n      ++it;\n      with_typename_ = FMT_USE_RTTI != 0;\n    }\n    return it;\n  }\n\n  template <typename Context>\n  auto format(const std::exception& ex, Context& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n#if FMT_USE_RTTI\n    if (with_typename_) {\n      out = detail::write_demangled_name(out, typeid(ex));\n      *out++ = ':';\n      *out++ = ' ';\n    }\n#endif\n    return detail::write_bytes<char>(out, string_view(ex.what()));\n  }\n};\n\ntemplate <int N, typename Char>\nstruct formatter<detail::bitint<N>, Char> : formatter<long long, Char> {\n  static_assert(N <= 64, \"unsupported _BitInt\");\n  static auto format_as(detail::bitint<N> x) -> long long {\n    return static_cast<long long>(x);\n  }\n  template <typename Context>\n  auto format(detail::bitint<N> x, Context& ctx) const -> decltype(ctx.out()) {\n    return formatter<long long, Char>::format(format_as(x), ctx);\n  }\n};\n\ntemplate <int N, typename Char>\nstruct formatter<detail::ubitint<N>, Char> : formatter<ullong, Char> {\n  static_assert(N <= 64, \"unsupported _BitInt\");\n  static auto format_as(detail::ubitint<N> x) -> ullong {\n    return static_cast<ullong>(x);\n  }\n  template <typename Context>\n  auto format(detail::ubitint<N> x, Context& ctx) const -> decltype(ctx.out()) {\n    return formatter<ullong, Char>::format(format_as(x), ctx);\n  }\n};\n\n// We can't use std::vector<bool, Allocator>::reference and\n// std::bitset<N>::reference because the compiler can't deduce Allocator and N\n// in partial specialization.\ntemplate <typename BitRef, typename Char>\nstruct formatter<BitRef, Char,\n                 enable_if_t<detail::is_bit_reference_like<BitRef>::value>>\n    : formatter<bool, Char> {\n  template <typename FormatContext>\n  FMT_CONSTEXPR auto format(const BitRef& v, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<bool, Char>::format(v, ctx);\n  }\n};\n\n#ifdef __cpp_lib_byte\ntemplate <typename Char>\nstruct formatter<std::byte, Char> : formatter<unsigned, Char> {\n  static auto format_as(std::byte b) -> unsigned char {\n    return static_cast<unsigned char>(b);\n  }\n  template <typename Context>\n  auto format(std::byte b, Context& ctx) const -> decltype(ctx.out()) {\n    return formatter<unsigned, Char>::format(format_as(b), ctx);\n  }\n};\n#endif\n\ntemplate <typename T, typename Char>\nstruct formatter<std::atomic<T>, Char,\n                 enable_if_t<is_formattable<T, Char>::value>>\n    : formatter<T, Char> {\n  template <typename FormatContext>\n  auto format(const std::atomic<T>& v, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<T, Char>::format(v.load(), ctx);\n  }\n};\n\n#ifdef __cpp_lib_atomic_flag_test\ntemplate <typename Char>\nstruct formatter<std::atomic_flag, Char> : formatter<bool, Char> {\n  template <typename FormatContext>\n  auto format(const std::atomic_flag& v, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<bool, Char>::format(v.test(), ctx);\n  }\n};\n#endif  // __cpp_lib_atomic_flag_test\n\ntemplate <typename T> struct is_tuple_like;\n\ntemplate <typename T>\nstruct is_tuple_like<std::complex<T>> : std::false_type {};\n\ntemplate <typename T, typename Char> struct formatter<std::complex<T>, Char> {\n private:\n  detail::dynamic_format_specs<Char> specs_;\n\n  template <typename FormatContext, typename OutputIt>\n  FMT_CONSTEXPR auto do_format(const std::complex<T>& c,\n                               detail::dynamic_format_specs<Char>& specs,\n                               FormatContext& ctx, OutputIt out) const\n      -> OutputIt {\n    if (c.real() != 0) {\n      *out++ = Char('(');\n      out = detail::write<Char>(out, c.real(), specs, ctx.locale());\n      specs.set_sign(sign::plus);\n      out = detail::write<Char>(out, c.imag(), specs, ctx.locale());\n      if (!detail::isfinite(c.imag())) *out++ = Char(' ');\n      *out++ = Char('i');\n      *out++ = Char(')');\n      return out;\n    }\n    out = detail::write<Char>(out, c.imag(), specs, ctx.locale());\n    if (!detail::isfinite(c.imag())) *out++ = Char(' ');\n    *out++ = Char('i');\n    return out;\n  }\n\n public:\n  FMT_CONSTEXPR auto parse(parse_context<Char>& ctx) -> const Char* {\n    if (ctx.begin() == ctx.end() || *ctx.begin() == '}') return ctx.begin();\n    return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,\n                              detail::type_constant<T, Char>::value);\n  }\n\n  template <typename FormatContext>\n  auto format(const std::complex<T>& c, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    auto specs = specs_;\n    if (specs.dynamic()) {\n      detail::handle_dynamic_spec(specs.dynamic_width(), specs.width,\n                                  specs.width_ref, ctx);\n      detail::handle_dynamic_spec(specs.dynamic_precision(), specs.precision,\n                                  specs.precision_ref, ctx);\n    }\n\n    if (specs.width == 0) return do_format(c, specs, ctx, ctx.out());\n    auto buf = basic_memory_buffer<Char>();\n\n    auto outer_specs = format_specs();\n    outer_specs.width = specs.width;\n    outer_specs.copy_fill_from(specs);\n    outer_specs.set_align(specs.align());\n\n    specs.width = 0;\n    specs.set_fill({});\n    specs.set_align(align::none);\n\n    do_format(c, specs, ctx, basic_appender<Char>(buf));\n    return detail::write<Char>(ctx.out(),\n                               basic_string_view<Char>(buf.data(), buf.size()),\n                               outer_specs);\n  }\n};\n\ntemplate <typename T, typename Char>\nstruct formatter<std::reference_wrapper<T>, Char,\n                 // Guard against format_as because reference_wrapper is\n                 // implicitly convertible to T&.\n                 enable_if_t<is_formattable<remove_cvref_t<T>, Char>::value &&\n                             !detail::has_format_as<T>::value &&\n                             !detail::has_format_as_member<T>::value>>\n    : formatter<remove_cvref_t<T>, Char> {\n  template <typename FormatContext>\n  auto format(std::reference_wrapper<T> ref, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<remove_cvref_t<T>, Char>::format(ref.get(), ctx);\n  }\n};\n\nFMT_END_NAMESPACE\n\n#endif  // FMT_STD_H_\n"
  },
  {
    "path": "include/fmt/xchar.h",
    "content": "// Formatting library for C++ - optional wchar_t and exotic character support\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_XCHAR_H_\n#define FMT_XCHAR_H_\n\n#include \"color.h\"\n#include \"format.h\"\n#include \"ostream.h\"\n#include \"ranges.h\"\n\n#ifndef FMT_MODULE\n#  include <cwchar>\n#  if FMT_USE_LOCALE\n#    include <locale>\n#  endif\n#endif\n\nFMT_BEGIN_NAMESPACE\nnamespace detail {\n\ntemplate <typename T>\nusing is_exotic_char = bool_constant<!std::is_same<T, char>::value>;\n\ntemplate <typename S, typename = void> struct format_string_char {};\n\ntemplate <typename S>\nstruct format_string_char<\n    S, void_t<decltype(sizeof(detail::to_string_view(std::declval<S>())))>> {\n  using type = char_t<S>;\n};\n\ntemplate <typename S>\nstruct format_string_char<\n    S, enable_if_t<std::is_base_of<detail::compile_string, S>::value>> {\n  using type = typename S::char_type;\n};\n\ntemplate <typename S>\nusing format_string_char_t = typename format_string_char<S>::type;\n\ninline auto write_loc(basic_appender<wchar_t> out, loc_value value,\n                      const format_specs& specs, locale_ref loc) -> bool {\n#if FMT_USE_LOCALE\n  auto& numpunct =\n      std::use_facet<std::numpunct<wchar_t>>(loc.get<std::locale>());\n  auto separator = std::wstring();\n  auto grouping = numpunct.grouping();\n  if (!grouping.empty()) separator = std::wstring(1, numpunct.thousands_sep());\n  return value.visit(loc_writer<wchar_t>{out, specs, separator, grouping, {}});\n#endif\n  return false;\n}\n\ntemplate <typename Char>\nvoid vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,\n                basic_format_args<buffered_context<Char>> args,\n                locale_ref loc = {}) {\n  static_assert(!std::is_same<Char, char>::value, \"\");\n  auto out = basic_appender<Char>(buf);\n  parse_format_string(\n      fmt, format_handler<Char>{parse_context<Char>(fmt), {out, args, loc}});\n}\n}  // namespace detail\n\nFMT_BEGIN_EXPORT\n\nusing wstring_view = basic_string_view<wchar_t>;\nusing wformat_parse_context = parse_context<wchar_t>;\nusing wformat_context = buffered_context<wchar_t>;\nusing wformat_args = basic_format_args<wformat_context>;\nusing wmemory_buffer = basic_memory_buffer<wchar_t>;\n\ntemplate <typename Char, typename... T> struct basic_fstring {\n private:\n  basic_string_view<Char> str_;\n\n  static constexpr int num_static_named_args =\n      detail::count_static_named_args<T...>();\n\n  using checker = detail::format_string_checker<\n      Char, static_cast<int>(sizeof...(T)), num_static_named_args,\n      num_static_named_args != detail::count_named_args<T...>()>;\n\n  using arg_pack = detail::arg_pack<T...>;\n\n public:\n  using t = basic_fstring;\n\n  template <typename S,\n            FMT_ENABLE_IF(\n                std::is_convertible<const S&, basic_string_view<Char>>::value)>\n  FMT_CONSTEVAL FMT_ALWAYS_INLINE basic_fstring(const S& s) : str_(s) {\n    if (FMT_USE_CONSTEVAL)\n      detail::parse_format_string<Char>(s, checker(s, arg_pack()));\n  }\n  template <typename S,\n            FMT_ENABLE_IF(std::is_base_of<detail::compile_string, S>::value&&\n                              std::is_same<typename S::char_type, Char>::value)>\n  FMT_ALWAYS_INLINE basic_fstring(const S&) : str_(S()) {\n    FMT_CONSTEXPR auto sv = basic_string_view<Char>(S());\n    FMT_CONSTEXPR int ignore =\n        (parse_format_string(sv, checker(sv, arg_pack())), 0);\n    detail::ignore_unused(ignore);\n  }\n  basic_fstring(runtime_format_string<Char> fmt) : str_(fmt.str) {}\n\n  FMT_DEPRECATED operator basic_string_view<Char>() const { return str_; }\n  auto get() const -> basic_string_view<Char> { return str_; }\n};\n\ntemplate <typename Char, typename... T>\nusing basic_format_string = basic_fstring<Char, T...>;\n\ntemplate <typename... T>\nusing wformat_string = typename basic_format_string<wchar_t, T...>::t;\ninline auto runtime(wstring_view s) -> runtime_format_string<wchar_t> {\n  return {{s}};\n}\n\ntemplate <typename... T>\nconstexpr auto make_wformat_args(T&... args)\n    -> decltype(fmt::make_format_args<wformat_context>(args...)) {\n  return fmt::make_format_args<wformat_context>(args...);\n}\n\n#if !FMT_USE_NONTYPE_TEMPLATE_ARGS\ninline namespace literals {\ninline auto operator\"\"_a(const wchar_t* s, size_t) -> detail::udl_arg<wchar_t> {\n  return {s};\n}\n}  // namespace literals\n#endif\n\ntemplate <typename T>\nauto arg(const wchar_t* name, const T& arg) -> named_arg<T, wchar_t> {\n  return {name, arg};\n}\n\ntemplate <typename It, typename Sentinel, typename S,\n          typename Char = typename decltype(detail::to_string_view(\n              std::declval<S>()))::value_type,\n          FMT_ENABLE_IF(detail::is_exotic_char<Char>::value)>\nauto join(It begin, Sentinel end, S&& sep) -> join_view<It, Sentinel, Char> {\n  return {begin, end, detail::to_string_view(sep)};\n}\n\ntemplate <typename Range, typename S,\n          typename Char = typename decltype(detail::to_string_view(\n              std::declval<S>()))::value_type,\n          FMT_ENABLE_IF(detail::is_exotic_char<Char>::value &&\n                        !is_tuple_like<Range>::value)>\nauto join(Range&& range, S&& sep)\n    -> join_view<decltype(std::begin(range)), decltype(std::end(range)), Char> {\n  return {std::begin(range), std::end(range), detail::to_string_view(sep)};\n}\n\ntemplate <typename T>\nFMT_DEPRECATED auto join(std::initializer_list<T> list, wstring_view sep)\n    -> join_view<const T*, const T*, wchar_t> {\n  return join(std::begin(list), std::end(list), sep);\n}\n\ntemplate <typename Tuple, typename S,\n          typename Char = typename decltype(detail::to_string_view(\n              std::declval<S>()))::value_type,\n          FMT_ENABLE_IF(detail::is_exotic_char<Char>::value&&\n                            is_tuple_like<Tuple>::value)>\nauto join(const Tuple& tuple, S&& sep) -> tuple_join_view<Tuple, Char> {\n  return {tuple, detail::to_string_view(sep)};\n}\n\ntemplate <typename Char, FMT_ENABLE_IF(!std::is_same<Char, char>::value)>\nauto vformat(basic_string_view<Char> fmt,\n             basic_format_args<buffered_context<Char>> args)\n    -> std::basic_string<Char> {\n  auto buf = basic_memory_buffer<Char>();\n  detail::vformat_to(buf, fmt, args);\n  return {buf.data(), buf.size()};\n}\n\ntemplate <typename... T>\nauto format(wformat_string<T...> fmt, T&&... args) -> std::wstring {\n  return vformat(fmt.get(), fmt::make_wformat_args(args...));\n}\n\ntemplate <typename OutputIt, typename... T>\nauto format_to(OutputIt out, wformat_string<T...> fmt, T&&... args)\n    -> OutputIt {\n  return vformat_to(out, fmt.get(), fmt::make_wformat_args(args...));\n}\n\n// Pass char_t as a default template parameter instead of using\n// std::basic_string<char_t<S>> to reduce the symbol size.\ntemplate <typename S, typename... T,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(!std::is_same<Char, char>::value &&\n                        !std::is_same<Char, wchar_t>::value)>\nauto format(const S& fmt, T&&... args) -> std::basic_string<Char> {\n  return vformat(detail::to_string_view(fmt),\n                 fmt::make_format_args<buffered_context<Char>>(args...));\n}\n\ntemplate <typename S, typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_exotic_char<Char>::value)>\ninline auto vformat(locale_ref loc, const S& fmt,\n                    basic_format_args<buffered_context<Char>> args)\n    -> std::basic_string<Char> {\n  auto buf = basic_memory_buffer<Char>();\n  detail::vformat_to(buf, detail::to_string_view(fmt), args, loc);\n  return {buf.data(), buf.size()};\n}\n\ntemplate <typename S, typename... T,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_exotic_char<Char>::value)>\ninline auto format(locale_ref loc, const S& fmt, T&&... args)\n    -> std::basic_string<Char> {\n  return vformat(loc, detail::to_string_view(fmt),\n                 fmt::make_format_args<buffered_context<Char>>(args...));\n}\n\ntemplate <typename OutputIt, typename S,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&\n                            detail::is_exotic_char<Char>::value)>\nauto vformat_to(OutputIt out, const S& fmt,\n                basic_format_args<buffered_context<Char>> args) -> OutputIt {\n  auto&& buf = detail::get_buffer<Char>(out);\n  detail::vformat_to(buf, detail::to_string_view(fmt), args);\n  return detail::get_iterator(buf, out);\n}\n\ntemplate <typename OutputIt, typename S, typename... T,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value &&\n                        !std::is_same<Char, char>::value &&\n                        !std::is_same<Char, wchar_t>::value)>\ninline auto format_to(OutputIt out, const S& fmt, T&&... args) -> OutputIt {\n  return vformat_to(out, detail::to_string_view(fmt),\n                    fmt::make_format_args<buffered_context<Char>>(args...));\n}\n\ntemplate <typename S, typename OutputIt, typename... Args,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&\n                            detail::is_exotic_char<Char>::value)>\ninline auto vformat_to(OutputIt out, locale_ref loc, const S& fmt,\n                       basic_format_args<buffered_context<Char>> args)\n    -> OutputIt {\n  auto&& buf = detail::get_buffer<Char>(out);\n  vformat_to(buf, detail::to_string_view(fmt), args, loc);\n  return detail::get_iterator(buf, out);\n}\n\ntemplate <typename OutputIt, typename S, typename... T,\n          typename Char = detail::format_string_char_t<S>,\n          bool enable = detail::is_output_iterator<OutputIt, Char>::value &&\n                        detail::is_exotic_char<Char>::value>\ninline auto format_to(OutputIt out, locale_ref loc, const S& fmt, T&&... args)\n    -> typename std::enable_if<enable, OutputIt>::type {\n  return vformat_to(out, loc, detail::to_string_view(fmt),\n                    fmt::make_format_args<buffered_context<Char>>(args...));\n}\n\ntemplate <typename OutputIt, typename Char, typename... Args,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&\n                            detail::is_exotic_char<Char>::value)>\ninline auto vformat_to_n(OutputIt out, size_t n, basic_string_view<Char> fmt,\n                         basic_format_args<buffered_context<Char>> args)\n    -> format_to_n_result<OutputIt> {\n  using traits = detail::fixed_buffer_traits;\n  auto buf = detail::iterator_buffer<OutputIt, Char, traits>(out, n);\n  detail::vformat_to(buf, fmt, args);\n  return {buf.out(), buf.count()};\n}\n\ntemplate <typename OutputIt, typename S, typename... T,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&\n                            detail::is_exotic_char<Char>::value)>\ninline auto format_to_n(OutputIt out, size_t n, const S& fmt, T&&... args)\n    -> format_to_n_result<OutputIt> {\n  return vformat_to_n(out, n, fmt::basic_string_view<Char>(fmt),\n                      fmt::make_format_args<buffered_context<Char>>(args...));\n}\n\ntemplate <typename S, typename... T,\n          typename Char = detail::format_string_char_t<S>,\n          FMT_ENABLE_IF(detail::is_exotic_char<Char>::value)>\ninline auto formatted_size(const S& fmt, T&&... args) -> size_t {\n  auto buf = detail::counting_buffer<Char>();\n  detail::vformat_to(buf, detail::to_string_view(fmt),\n                     fmt::make_format_args<buffered_context<Char>>(args...));\n  return buf.count();\n}\n\ninline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {\n  auto buf = wmemory_buffer();\n  detail::vformat_to(buf, fmt, args);\n  buf.push_back(L'\\0');\n  if (std::fputws(buf.data(), f) == -1)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot write to file\")));\n}\n\ninline void vprint(wstring_view fmt, wformat_args args) {\n  vprint(stdout, fmt, args);\n}\n\ntemplate <typename... T>\nvoid print(std::FILE* f, wformat_string<T...> fmt, T&&... args) {\n  return vprint(f, fmt.get(), fmt::make_wformat_args(args...));\n}\n\ntemplate <typename... T> void print(wformat_string<T...> fmt, T&&... args) {\n  return vprint(fmt.get(), fmt::make_wformat_args(args...));\n}\n\ntemplate <typename... T>\nvoid println(std::FILE* f, wformat_string<T...> fmt, T&&... args) {\n  return print(f, L\"{}\\n\", fmt::format(fmt, std::forward<T>(args)...));\n}\n\ntemplate <typename... T> void println(wformat_string<T...> fmt, T&&... args) {\n  return print(L\"{}\\n\", fmt::format(fmt, std::forward<T>(args)...));\n}\n\ninline auto vformat(text_style ts, wstring_view fmt, wformat_args args)\n    -> std::wstring {\n  auto buf = wmemory_buffer();\n  detail::vformat_to(buf, ts, fmt, args);\n  return {buf.data(), buf.size()};\n}\n\ntemplate <typename... T>\ninline auto format(text_style ts, wformat_string<T...> fmt, T&&... args)\n    -> std::wstring {\n  return fmt::vformat(ts, fmt.get(), fmt::make_wformat_args(args...));\n}\n\ninline void vprint(std::wostream& os, wstring_view fmt, wformat_args args) {\n  auto buffer = basic_memory_buffer<wchar_t>();\n  detail::vformat_to(buffer, fmt, args);\n  detail::write_buffer(os, buffer);\n}\n\ntemplate <typename... T>\nvoid print(std::wostream& os, wformat_string<T...> fmt, T&&... args) {\n  vprint(os, fmt.get(),\n         fmt::make_format_args<buffered_context<wchar_t>>(args...));\n}\n\ntemplate <typename... T>\nvoid println(std::wostream& os, wformat_string<T...> fmt, T&&... args) {\n  print(os, L\"{}\\n\", fmt::format(fmt, std::forward<T>(args)...));\n}\n\n/// Converts `value` to `std::wstring` using the default format for type `T`.\ntemplate <typename T> inline auto to_wstring(const T& value) -> std::wstring {\n  return format(FMT_STRING(L\"{}\"), value);\n}\nFMT_END_EXPORT\nFMT_END_NAMESPACE\n\n#endif  // FMT_XCHAR_H_\n"
  },
  {
    "path": "src/fmt-c.cc",
    "content": "// Formatting library for C++ - the C API\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/fmt-c.h\"\n\n#include <fmt/base.h>\n\nextern \"C\" int fmt_vformat(char* buffer, size_t size, const char* fmt,\n                           const fmt_arg* args, size_t num_args) {\n  constexpr size_t max_args = 16;\n  if (num_args > max_args) return fmt_error_invalid_arg;\n\n  fmt::basic_format_arg<fmt::format_context> format_args[max_args];\n  for (size_t i = 0; i < num_args; ++i) {\n    switch (args[i].type) {\n    case fmt_int:    format_args[i] = args[i].value.int_value; break;\n    case fmt_uint:   format_args[i] = args[i].value.uint_value; break;\n    case fmt_bool:   format_args[i] = args[i].value.bool_value; break;\n    case fmt_char:   format_args[i] = args[i].value.char_value; break;\n    case fmt_float:  format_args[i] = args[i].value.float_value; break;\n    case fmt_double: format_args[i] = args[i].value.double_value; break;\n    case fmt_long_double:\n      format_args[i] = args[i].value.long_double_value;\n      break;\n    case fmt_cstring: format_args[i] = args[i].value.cstring; break;\n    case fmt_pointer: format_args[i] = args[i].value.pointer; break;\n    default:          return fmt_error_invalid_arg;\n    }\n  }\n  try {\n    auto result = fmt::vformat_to_n(\n        buffer, size, fmt,\n        fmt::format_args(format_args, static_cast<int>(num_args)));\n    return static_cast<int>(result.size);\n  } catch (...) {\n  }\n  return fmt_error;\n}\n"
  },
  {
    "path": "src/fmt.cc",
    "content": "module;\n\n#define FMT_MODULE\n\n#ifdef _MSVC_LANG\n#  define FMT_CPLUSPLUS _MSVC_LANG\n#else\n#  define FMT_CPLUSPLUS __cplusplus\n#endif\n\n// Put all implementation-provided headers into the global module fragment\n// to prevent attachment to this module.\n#ifndef FMT_IMPORT_STD\n#  include <algorithm>\n#  include <bitset>\n#  include <chrono>\n#  include <cmath>\n#  include <complex>\n#  include <cstddef>\n#  include <cstdint>\n#  include <cstdio>\n#  include <cstdlib>\n#  include <cstring>\n#  include <ctime>\n#  include <exception>\n#  if FMT_CPLUSPLUS > 202002L\n#    include <expected>\n#  endif\n#  include <filesystem>\n#  include <fstream>\n#  include <functional>\n#  include <iterator>\n#  include <limits>\n#  include <locale>\n#  include <memory>\n#  include <optional>\n#  include <ostream>\n#  include <source_location>\n#  include <stdexcept>\n#  include <string>\n#  include <string_view>\n#  include <system_error>\n#  include <thread>\n#  include <type_traits>\n#  include <typeinfo>\n#  include <utility>\n#  include <variant>\n#  include <vector>\n#else\n#  include <limits.h>\n#  include <stdint.h>\n#  include <stdio.h>\n#  include <stdlib.h>\n#  include <string.h>\n#  include <time.h>\n#endif\n#include <cerrno>\n#include <climits>\n#include <version>\n\n#if __has_include(<cxxabi.h>)\n#  include <cxxabi.h>\n#endif\n#if defined(_MSC_VER) || defined(__MINGW32__)\n#  include <intrin.h>\n#endif\n#if defined __APPLE__ || defined(__FreeBSD__)\n#  include <xlocale.h>\n#endif\n#if __has_include(<winapifamily.h>)\n#  include <winapifamily.h>\n#endif\n#if (__has_include(<fcntl.h>) || defined(__APPLE__) || \\\n     defined(__linux__)) &&                            \\\n    (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))\n#  include <fcntl.h>\n#  include <sys/stat.h>\n#  include <sys/types.h>\n#  ifndef _WIN32\n#    include <unistd.h>\n#  else\n#    include <io.h>\n#  endif\n#endif\n#ifdef _WIN32\n#  if defined(__GLIBCXX__)\n#    include <ext/stdio_filebuf.h>\n#    include <ext/stdio_sync_filebuf.h>\n#  endif\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#endif\n\nexport module fmt;\n\n#ifdef FMT_IMPORT_STD\nimport std;\n#endif\n\n#define FMT_EXPORT export\n#define FMT_BEGIN_EXPORT export {\n#define FMT_END_EXPORT }\n\n// If you define FMT_ATTACH_TO_GLOBAL_MODULE\n//  - all declarations are detached from module 'fmt'\n//  - the module behaves like a traditional static library, too\n//  - all library symbols are mangled traditionally\n//  - you can mix TUs with either importing or #including the {fmt} API\n#ifdef FMT_ATTACH_TO_GLOBAL_MODULE\nextern \"C++\" {\n#endif\n\n#ifndef FMT_OS\n#  define FMT_OS 1\n#endif\n\n// All library-provided declarations and definitions must be in the module\n// purview to be exported.\n#include \"fmt/args.h\"\n#include \"fmt/chrono.h\"\n#include \"fmt/color.h\"\n#include \"fmt/compile.h\"\n#include \"fmt/format.h\"\n#if FMT_OS\n#  include \"fmt/os.h\"\n#endif\n#include \"fmt/ostream.h\"\n#include \"fmt/printf.h\"\n#include \"fmt/ranges.h\"\n#include \"fmt/std.h\"\n#include \"fmt/xchar.h\"\n\n#ifdef FMT_ATTACH_TO_GLOBAL_MODULE\n}\n#endif\n\n// gcc doesn't yet implement private module fragments\n#if !FMT_GCC_VERSION\nmodule :private;\n#endif\n\n#ifdef FMT_ATTACH_TO_GLOBAL_MODULE\nextern \"C++\" {\n#endif\n\n#if FMT_HAS_INCLUDE(\"format.cc\")\n#  include \"format.cc\"\n#endif\n#if FMT_OS && FMT_HAS_INCLUDE(\"os.cc\")\n#  include \"os.cc\"\n#endif\n\n#ifdef FMT_ATTACH_TO_GLOBAL_MODULE\n}\n#endif\n"
  },
  {
    "path": "src/format.cc",
    "content": "// Formatting library for C++\n//\n// Copyright (c) 2012 - 2016, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/format-inl.h\"\n\nFMT_BEGIN_NAMESPACE\n\n#if FMT_USE_LOCALE\ntemplate FMT_API locale_ref::locale_ref(const std::locale& loc);  // DEPRECATED!\ntemplate FMT_API auto locale_ref::get<std::locale>() const -> std::locale;\n#endif\n\nnamespace detail {\n\ntemplate FMT_API auto dragonbox::to_decimal(float x) noexcept\n    -> dragonbox::decimal_fp<float>;\ntemplate FMT_API auto dragonbox::to_decimal(double x) noexcept\n    -> dragonbox::decimal_fp<double>;\n\n// Explicit instantiations for char.\n\ntemplate FMT_API auto thousands_sep_impl(locale_ref)\n    -> thousands_sep_result<char>;\ntemplate FMT_API auto decimal_point_impl(locale_ref) -> char;\n\n// DEPRECATED!\ntemplate FMT_API void buffer<char>::append(const char*, const char*);\n\n// Explicit instantiations for wchar_t.\n\ntemplate FMT_API auto thousands_sep_impl(locale_ref)\n    -> thousands_sep_result<wchar_t>;\ntemplate FMT_API auto decimal_point_impl(locale_ref) -> wchar_t;\n\n// DEPRECATED!\ntemplate FMT_API void buffer<wchar_t>::append(const wchar_t*, const wchar_t*);\n\n}  // namespace detail\nFMT_END_NAMESPACE\n"
  },
  {
    "path": "src/os.cc",
    "content": "// Formatting library for C++ - optional OS-specific functionality\n//\n// Copyright (c) 2012 - 2016, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n// Disable bogus MSVC warnings.\n#if !defined(_CRT_SECURE_NO_WARNINGS) && defined(_MSC_VER)\n#  define _CRT_SECURE_NO_WARNINGS\n#endif\n\n#include \"fmt/os.h\"\n\n#ifndef FMT_MODULE\n#  include <climits>\n\n#  if FMT_USE_FCNTL\n#    include <sys/stat.h>\n#    include <sys/types.h>\n\n#    ifdef _WRS_KERNEL    // VxWorks7 kernel\n#      include <ioLib.h>  // getpagesize\n#    endif\n\n#    ifndef _WIN32\n#      include <unistd.h>\n#    else\n#      ifndef WIN32_LEAN_AND_MEAN\n#        define WIN32_LEAN_AND_MEAN\n#      endif\n#      include <io.h>\n#    endif  // _WIN32\n#  endif    // FMT_USE_FCNTL\n\n#  ifdef _WIN32\n#    include <windows.h>\n#  endif\n#endif\n\n#ifdef _WIN32\n#  ifndef S_IRUSR\n#    define S_IRUSR _S_IREAD\n#  endif\n#  ifndef S_IWUSR\n#    define S_IWUSR _S_IWRITE\n#  endif\n#  ifndef S_IRGRP\n#    define S_IRGRP 0\n#  endif\n#  ifndef S_IWGRP\n#    define S_IWGRP 0\n#  endif\n#  ifndef S_IROTH\n#    define S_IROTH 0\n#  endif\n#  ifndef S_IWOTH\n#    define S_IWOTH 0\n#  endif\n#endif\n\nnamespace {\n#ifdef _WIN32\n\n// Return type of read and write functions.\nusing rwresult = int;\n\n// On Windows the count argument to read and write is unsigned, so convert\n// it from size_t preventing integer overflow.\ninline unsigned convert_rwcount(size_t count) {\n  return count <= UINT_MAX ? static_cast<unsigned>(count) : UINT_MAX;\n}\n\nclass system_message {\n  system_message(const system_message&) = delete;\n  void operator=(const system_message&) = delete;\n\n  unsigned long result_;\n  wchar_t* message_;\n\n  static bool is_whitespace(wchar_t c) noexcept {\n    return c == L' ' || c == L'\\n' || c == L'\\r' || c == L'\\t' || c == L'\\0';\n  }\n\n public:\n  explicit system_message(unsigned long error_code)\n      : result_(0), message_(nullptr) {\n    result_ = FormatMessageW(\n        FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |\n            FORMAT_MESSAGE_IGNORE_INSERTS,\n        nullptr, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n        reinterpret_cast<wchar_t*>(&message_), 0, nullptr);\n    if (result_ != 0) {\n      while (result_ != 0 && is_whitespace(message_[result_ - 1])) {\n        --result_;\n      }\n    }\n  }\n  ~system_message() { LocalFree(message_); }\n  explicit operator bool() const noexcept { return result_ != 0; }\n  operator fmt::basic_string_view<wchar_t>() const noexcept {\n    return fmt::basic_string_view<wchar_t>(message_, result_);\n  }\n};\n\nclass utf8_system_category final : public std::error_category {\n public:\n  const char* name() const noexcept override { return \"system\"; }\n  std::string message(int error_code) const override {\n    auto&& msg = system_message(error_code);\n    if (msg) {\n      auto utf8_message = fmt::detail::to_utf8<wchar_t>();\n      if (utf8_message.convert(msg)) {\n        return utf8_message.str();\n      }\n    }\n    return \"unknown error\";\n  }\n};\n\n#elif FMT_USE_FCNTL\n\n// Return type of read and write functions.\nusing rwresult = ssize_t;\n\ninline auto convert_rwcount(size_t count) -> size_t { return count; }\n\n#endif\n}  // namespace\n\nFMT_BEGIN_NAMESPACE\n\n#ifdef _WIN32\n\nFMT_API const std::error_category& system_category() noexcept {\n  static const utf8_system_category category;\n  return category;\n}\n\nstd::system_error vwindows_error(int err_code, string_view format_str,\n                                 format_args args) {\n  auto ec = std::error_code(err_code, system_category());\n  return std::system_error(ec, vformat(format_str, args));\n}\n\nvoid detail::format_windows_error(detail::buffer<char>& out, int error_code,\n                                  const char* message) noexcept {\n  FMT_TRY {\n    auto&& msg = system_message(error_code);\n    if (msg) {\n      auto utf8_message = to_utf8<wchar_t>();\n      if (utf8_message.convert(msg)) {\n        fmt::format_to(appender(out), FMT_STRING(\"{}: {}\"), message,\n                       string_view(utf8_message));\n        return;\n      }\n    }\n  }\n  FMT_CATCH(...) {}\n  format_error_code(out, error_code, message);\n}\n\nvoid report_windows_error(int error_code, const char* message) noexcept {\n  do_report_error(detail::format_windows_error, error_code, message);\n}\n\n#endif  // _WIN32\n\nbuffered_file::~buffered_file() noexcept {\n  if (file_ && FMT_SYSTEM(fclose(file_)) != 0)\n    report_system_error(errno, \"cannot close file\");\n}\n\nbuffered_file::buffered_file(cstring_view filename, cstring_view mode) {\n  FMT_RETRY_VAL(file_, FMT_SYSTEM(fopen(filename.c_str(), mode.c_str())),\n                nullptr);\n  if (!file_)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot open file {}\"),\n                           filename.c_str()));\n}\n\nvoid buffered_file::close() {\n  if (!file_) return;\n  int result = FMT_SYSTEM(fclose(file_));\n  file_ = nullptr;\n  if (result != 0)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot close file\")));\n}\n\nauto buffered_file::descriptor() const -> int {\n#ifdef FMT_HAS_SYSTEM\n  // fileno is a macro on OpenBSD.\n#  ifdef fileno\n#    undef fileno\n#  endif\n  int fd = FMT_POSIX_CALL(fileno(file_));\n#elif defined(_WIN32)\n  int fd = _fileno(file_);\n#else\n  int fd = fileno(file_);\n#endif\n  if (fd == -1)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot get file descriptor\")));\n  return fd;\n}\n\n#if FMT_USE_FCNTL\n#  ifdef _WIN32\nusing mode_t = int;\n#  endif\n\nconstexpr mode_t default_open_mode =\n    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;\n\nfile::file(cstring_view path, int oflag) {\n#  if defined(_WIN32) && !defined(__MINGW32__)\n  fd_ = -1;\n  auto converted = detail::utf8_to_utf16(string_view(path.c_str()));\n  *this = file::open_windows_file(converted.c_str(), oflag);\n#  else\n  FMT_RETRY(fd_, FMT_POSIX_CALL(open(path.c_str(), oflag, default_open_mode)));\n  if (fd_ == -1)\n    FMT_THROW(\n        system_error(errno, FMT_STRING(\"cannot open file {}\"), path.c_str()));\n#  endif\n}\n\nfile::~file() noexcept {\n  // Don't retry close in case of EINTR!\n  // See http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html\n  if (fd_ != -1 && FMT_POSIX_CALL(close(fd_)) != 0)\n    report_system_error(errno, \"cannot close file\");\n}\n\nvoid file::close() {\n  if (fd_ == -1) return;\n  // Don't retry close in case of EINTR!\n  // See http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html\n  int result = FMT_POSIX_CALL(close(fd_));\n  fd_ = -1;\n  if (result != 0)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot close file\")));\n}\n\nauto file::size() const -> long long {\n#  ifdef _WIN32\n  // Use GetFileSize instead of GetFileSizeEx for the case when _WIN32_WINNT\n  // is less than 0x0500 as is the case with some default MinGW builds.\n  // Both functions support large file sizes.\n  DWORD size_upper = 0;\n  HANDLE handle = reinterpret_cast<HANDLE>(_get_osfhandle(fd_));\n  DWORD size_lower = FMT_SYSTEM(GetFileSize(handle, &size_upper));\n  if (size_lower == INVALID_FILE_SIZE) {\n    DWORD error = GetLastError();\n    if (error != NO_ERROR)\n      FMT_THROW(windows_error(error, \"cannot get file size\"));\n  }\n  unsigned long long long_size = size_upper;\n  return (long_size << sizeof(DWORD) * CHAR_BIT) | size_lower;\n#  else\n  using Stat = struct stat;\n  Stat file_stat = Stat();\n  if (FMT_POSIX_CALL(fstat(fd_, &file_stat)) == -1)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot get file attributes\")));\n  static_assert(sizeof(long long) >= sizeof(file_stat.st_size),\n                \"return type of file::size is not large enough\");\n  return file_stat.st_size;\n#  endif\n}\n\nauto file::read(void* buffer, size_t count) -> size_t {\n  rwresult result = 0;\n  FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count))));\n  if (result < 0)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot read from file\")));\n  return detail::to_unsigned(result);\n}\n\nauto file::write(const void* buffer, size_t count) -> size_t {\n  rwresult result = 0;\n  FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));\n  if (result < 0)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot write to file\")));\n  return detail::to_unsigned(result);\n}\n\nauto file::dup(int fd) -> file {\n  // Don't retry as dup doesn't return EINTR.\n  // http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html\n  int new_fd = FMT_POSIX_CALL(dup(fd));\n  if (new_fd == -1)\n    FMT_THROW(system_error(\n        errno, FMT_STRING(\"cannot duplicate file descriptor {}\"), fd));\n  return file(new_fd);\n}\n\nvoid file::dup2(int fd) {\n  int result = 0;\n  FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd)));\n  if (result == -1) {\n    FMT_THROW(system_error(\n        errno, FMT_STRING(\"cannot duplicate file descriptor {} to {}\"), fd_,\n        fd));\n  }\n}\n\nvoid file::dup2(int fd, std::error_code& ec) noexcept {\n  int result = 0;\n  FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd)));\n  if (result == -1) ec = std::error_code(errno, std::generic_category());\n}\n\nauto file::fdopen(const char* mode) -> buffered_file {\n// Don't retry as fdopen doesn't return EINTR.\n#  if defined(__MINGW32__) && defined(_POSIX_)\n  FILE* f = ::fdopen(fd_, mode);\n#  else\n  FILE* f = FMT_POSIX_CALL(fdopen(fd_, mode));\n#  endif\n  if (!f) {\n    FMT_THROW(system_error(\n        errno, FMT_STRING(\"cannot associate stream with file descriptor\")));\n  }\n  buffered_file bf(f);\n  fd_ = -1;\n  return bf;\n}\n\n#  if defined(_WIN32) && !defined(__MINGW32__)\nfile file::open_windows_file(wcstring_view path, int oflag) {\n  int fd = -1;\n  auto err = _wsopen_s(&fd, path.c_str(), oflag, _SH_DENYNO, default_open_mode);\n  if (fd == -1) {\n    FMT_THROW(system_error(err, FMT_STRING(\"cannot open file {}\"),\n                           detail::to_utf8<wchar_t>(path.c_str()).c_str()));\n  }\n  return file(fd);\n}\n#  endif\n\npipe::pipe() {\n  int fds[2] = {};\n#  ifdef _WIN32\n  // Make the default pipe capacity same as on Linux 2.6.11+.\n  enum { DEFAULT_CAPACITY = 65536 };\n  int result = FMT_POSIX_CALL(pipe(fds, DEFAULT_CAPACITY, _O_BINARY));\n#  else\n  // Don't retry as the pipe function doesn't return EINTR.\n  // http://pubs.opengroup.org/onlinepubs/009696799/functions/pipe.html\n  int result = FMT_POSIX_CALL(pipe(fds));\n#  endif\n  if (result != 0)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot create pipe\")));\n  // The following assignments don't throw.\n  read_end = file(fds[0]);\n  write_end = file(fds[1]);\n}\n\n#  if !defined(__MSDOS__)\nauto getpagesize() -> long {\n#    ifdef _WIN32\n  SYSTEM_INFO si;\n  GetSystemInfo(&si);\n  return si.dwPageSize;\n#    else\n#      ifdef _WRS_KERNEL\n  long size = FMT_POSIX_CALL(getpagesize());\n#      else\n  long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE));\n#      endif\n\n  if (size < 0)\n    FMT_THROW(system_error(errno, FMT_STRING(\"cannot get memory page size\")));\n  return size;\n#    endif\n}\n#  endif\n\nvoid ostream::grow(buffer<char>& buf, size_t) {\n  if (buf.size() == buf.capacity()) static_cast<ostream&>(buf).flush();\n}\n\nostream::ostream(cstring_view path, const detail::ostream_params& params)\n    : buffer<char>(grow), file_(path, params.oflag) {\n  set(new char[params.buffer_size], params.buffer_size);\n}\n\nostream::ostream(ostream&& other) noexcept\n    : buffer<char>(grow, other.data(), other.size(), other.capacity()),\n      file_(std::move(other.file_)) {\n  other.clear();\n  other.set(nullptr, 0);\n}\n\nostream::~ostream() {\n  flush();\n  delete[] data();\n}\n#endif  // FMT_USE_FCNTL\nFMT_END_NAMESPACE\n"
  },
  {
    "path": "support/Android.mk",
    "content": "LOCAL_PATH := $(call my-dir)\ninclude $(CLEAR_VARS)\n\nLOCAL_MODULE := fmt_static\nLOCAL_MODULE_FILENAME := libfmt\n\nLOCAL_SRC_FILES := ../src/format.cc\n\nLOCAL_C_INCLUDES := $(LOCAL_PATH)\nLOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)\n\nLOCAL_CFLAGS += -std=c++11 -fexceptions\n\ninclude $(BUILD_STATIC_LIBRARY)\n\n"
  },
  {
    "path": "support/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">\n        </manifest>\n"
  },
  {
    "path": "support/C++.sublime-syntax",
    "content": "%YAML 1.2\n---\n# http://www.sublimetext.com/docs/3/syntax.html\nname: C++ (fmt)\ncomment: I don't think anyone uses .hp. .cp tends to be paired with .h. (I could be wrong. :) -- chris\nfile_extensions:\n  - cpp\n  - cc\n  - cp\n  - cxx\n  - c++\n  - C\n  - h\n  - hh\n  - hpp\n  - hxx\n  - h++\n  - inl\n  - ipp\nfirst_line_match: '-\\*- C\\+\\+ -\\*-'\nscope: source.c++\nvariables:\n  identifier: \\b[[:alpha:]_][[:alnum:]_]*\\b # upper and lowercase\n  macro_identifier: \\b[[:upper:]_][[:upper:][:digit:]_]{2,}\\b # only uppercase, at least 3 chars\n  path_lookahead: '(?:::\\s*)?(?:{{identifier}}\\s*::\\s*)*(?:template\\s+)?{{identifier}}'\n  operator_method_name: '\\boperator\\s*(?:[-+*/%^&|~!=<>]|[-+*/%^&|=!<>]=|<<=?|>>=?|&&|\\|\\||\\+\\+|--|,|->\\*?|\\(\\)|\\[\\]|\"\"\\s*{{identifier}})'\n  casts: 'const_cast|dynamic_cast|reinterpret_cast|static_cast'\n  operator_keywords: 'and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|xor|xor_eq|noexcept'\n  control_keywords: 'break|case|catch|continue|default|do|else|for|goto|if|_Pragma|return|switch|throw|try|while'\n  memory_operators: 'new|delete'\n  basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void'\n  before_tag: 'struct|union|enum\\s+class|enum\\s+struct|enum|class'\n  declspec: '__declspec\\(\\s*\\w+(?:\\([^)]+\\))?\\s*\\)'\n  storage_classes: 'static|export|extern|friend|explicit|virtual|register|thread_local'\n  type_qualifier: 'const|constexpr|mutable|typename|volatile'\n  compiler_directive: 'inline|restrict|__restrict__|__restrict'\n  visibility_modifiers: 'private|protected|public'\n  other_keywords: 'typedef|nullptr|{{visibility_modifiers}}|static_assert|sizeof|using|typeid|alignof|alignas|namespace|template'\n  modifiers: '{{storage_classes}}|{{type_qualifier}}|{{compiler_directive}}'\n  non_angle_brackets: '(?=<<|<=)'\n\n  regular: '[^(){}&;*^%=<>-]*'\n  paren_open: (?:\\(\n  paren_close: '\\))?'\n  generic_open: (?:<\n  generic_close: '>)?'\n  balance_parentheses: '{{regular}}{{paren_open}}{{regular}}{{paren_close}}{{regular}}'\n  generic_lookahead: <{{regular}}{{generic_open}}{{regular}}{{generic_open}}{{regular}}{{generic_close}}\\s*{{generic_close}}{{balance_parentheses}}>\n\n  data_structures_forward_decl_lookahead: '(\\s+{{macro_identifier}})*\\s*(:\\s*({{path_lookahead}}|{{visibility_modifiers}}|,|\\s|<[^;]*>)+)?;'\n  non_func_keywords: 'if|for|switch|while|decltype|sizeof|__declspec|__attribute__|typeid|alignof|alignas|static_assert'\n\n  format_spec: |-\n    (?x:\n      (?:.? [<>=^])?     # fill align\n      [ +-]?             # sign\n      \\#?                # alternate form\n      # technically, octal and hexadecimal integers are also supported as 'width', but rarely used\n      \\d*                # width\n      ,?                 # thousands separator\n      (?:\\.\\d+)?         # precision\n      [bcdeEfFgGnosxX%]? # type\n    )\n\ncontexts:\n  main:\n    - include: preprocessor-global\n    - include: global\n\n  #############################################################################\n  # Reusable contexts\n  #\n  # The follow contexts are currently constructed to be reused in the\n  # Objetive-C++ syntax. They are specifically constructed to not push into\n  # sub-contexts, which ensures that Objective-C++ code isn't accidentally\n  # lexed as plain C++.\n  #\n  # The \"unique-*\" contexts are additions that C++ makes over C, and thus can\n  # be directly reused in Objective-C++ along with contexts from Objective-C\n  # and C.\n  #############################################################################\n\n  unique-late-expressions:\n    # This is highlighted after all of the other control keywords\n    # to allow operator overloading to be lexed properly\n    - match: \\boperator\\b\n      scope: keyword.control.c++\n\n  unique-modifiers:\n    - match: \\b({{modifiers}})\\b\n      scope: storage.modifier.c++\n\n  unique-variables:\n    - match: \\bthis\\b\n      scope: variable.language.c++\n    # common C++ instance var naming idiom -- fMemberName\n    - match: '\\b(f|m)[[:upper:]]\\w*\\b'\n      scope: variable.other.readwrite.member.c++\n    # common C++ instance var naming idiom -- m_member_name\n    - match: '\\bm_[[:alnum:]_]+\\b'\n      scope: variable.other.readwrite.member.c++\n\n  unique-constants:\n    - match: \\bnullptr\\b\n      scope: constant.language.c++\n\n  unique-keywords:\n    - match: \\busing\\b\n      scope: keyword.control.c++\n    - match: \\bbreak\\b\n      scope: keyword.control.flow.break.c++\n    - match: \\bcontinue\\b\n      scope: keyword.control.flow.continue.c++\n    - match: \\bgoto\\b\n      scope: keyword.control.flow.goto.c++\n    - match: \\breturn\\b\n      scope: keyword.control.flow.return.c++\n    - match: \\bthrow\\b\n      scope: keyword.control.flow.throw.c++\n    - match: \\b({{control_keywords}})\\b\n      scope: keyword.control.c++\n    - match: '\\bdelete\\b(\\s*\\[\\])?|\\bnew\\b(?!])'\n      scope: keyword.control.c++\n    - match: \\b({{operator_keywords}})\\b\n      scope: keyword.operator.word.c++\n\n  unique-types:\n    - match: \\b(char16_t|char32_t|wchar_t|nullptr_t)\\b\n      scope: storage.type.c++\n    - match: \\bclass\\b\n      scope: storage.type.c++\n\n  unique-strings:\n    - match: '((?:L|u8|u|U)?R)(\"([^\\(\\)\\\\ ]{0,16})\\()'\n      captures:\n        1: storage.type.string.c++\n        2: punctuation.definition.string.begin.c++\n      push:\n        - meta_scope: string.quoted.double.c++\n        - match: '\\)\\3\"'\n          scope: punctuation.definition.string.end.c++\n          pop: true\n        - match: '\\{\\{|\\}\\}'\n          scope: constant.character.escape.c++\n        - include: formatting-syntax\n\n  unique-numbers:\n    - match: |-\n        (?x)\n        (?:\n        # floats\n          (?:\n          (?:\\b\\d(?:[\\d']*\\d)?\\.\\d(?:[\\d']*\\d)?|\\B\\.\\d(?:[\\d']*\\d)?)(?:[Ee][+-]?\\d(?:[\\d']*\\d)?)?(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\\w*))?\\b\n          |\n          (?:\\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)\n          |\n          \\b\\d(?:[\\d']*\\d)?(?:[Ee][+-]?\\d(?:[\\d']*\\d)?)(?:[fFlL]|(?:i[fl]?|h|min|[mun]?s|_\\w*))?\\b\n          )\n        |\n        # ints\n          \\b(?:\n          (?:\n          # dec\n          [1-9](?:[\\d']*\\d)?\n          |\n          # oct\n          0(?:[0-7']*[0-7])?\n          |\n          # hex\n          0[Xx][\\da-fA-F](?:[\\da-fA-F']*[\\da-fA-F])?\n          |\n          # bin\n          0[Bb][01](?:[01']*[01])?\n          )\n          # int suffixes\n          (?:(?:l{1,2}|L{1,2})[uU]?|[uU](?:l{0,2}|L{0,2})|(?:i[fl]?|h|min|[mun]?s|_\\w*))?)\\b\n        )\n        (?!\\.) # Number must not be followed by a decimal point\n      scope: constant.numeric.c++\n\n  identifiers:\n    - match: '{{identifier}}\\s*(::)\\s*'\n      captures:\n        1: punctuation.accessor.c++\n    - match: '(?:(::)\\s*)?{{identifier}}'\n      captures:\n        1: punctuation.accessor.c++\n\n  function-specifiers:\n    - match: \\b(const|final|noexcept|override)\\b\n      scope: storage.modifier.c++\n\n  #############################################################################\n  # The following are C++-specific contexts that should not be reused. This is\n  # because they push into subcontexts and use variables that are C++-specific.\n  #############################################################################\n\n  ## Common context layout\n\n  global:\n    - match: '(?=\\btemplate\\b)'\n      push:\n        - include: template\n        - match: (?=\\S)\n          set: global-modifier\n    - include: namespace\n    - include: keywords-angle-brackets\n    - match: '(?={{path_lookahead}}\\s*<)'\n      push: global-modifier\n    # Take care of comments just before a function definition.\n    - match: /\\*\n      scope: punctuation.definition.comment.c\n      push:\n        - - match: \\s*(?=\\w)\n            set: global-modifier\n          - match: \"\"\n            pop: true\n        - - meta_scope: comment.block.c\n          - match: \\*/\n            scope: punctuation.definition.comment.c\n            pop: true\n    - include: early-expressions\n    - match: ^\\s*\\b(extern)(?=\\s+\"C(\\+\\+)?\")\n      scope: storage.modifier.c++\n      push:\n        - include: comments\n        - include: strings\n        - match: '\\{'\n          scope: punctuation.section.block.begin.c++\n          set:\n            - meta_scope: meta.extern-c.c++\n            - match: '^\\s*(#\\s*ifdef)\\s*__cplusplus\\s*'\n              scope: meta.preprocessor.c++\n              captures:\n                1: keyword.control.import.c++\n              set:\n                - match: '\\}'\n                  scope: punctuation.section.block.end.c++\n                  pop: true\n                - include: preprocessor-global\n                - include: global\n            - match: '\\}'\n              scope: punctuation.section.block.end.c++\n              pop: true\n            - include: preprocessor-global\n            - include: global\n        - match: (?=\\S)\n          set: global-modifier\n    - match: ^\\s*(?=\\w)\n      push: global-modifier\n    - include: late-expressions\n\n  statements:\n    - include: preprocessor-statements\n    - include: scope:source.c#label\n    - include: expressions\n\n  expressions:\n    - include: early-expressions\n    - include: late-expressions\n\n  early-expressions:\n    - include: early-expressions-before-generic-type\n    - include: generic-type\n    - include: early-expressions-after-generic-type\n\n  early-expressions-before-generic-type:\n    - include: preprocessor-expressions\n    - include: comments\n    - include: case-default\n    - include: typedef\n    - include: keywords-angle-brackets\n    - include: keywords-parens\n    - include: keywords\n    - include: numbers\n    # Prevent a '<' from getting scoped as the start of another template\n    # parameter list, if in reality a less-than-or-equals sign is meant.\n    - match: <=\n      scope: keyword.operator.comparison.c\n\n  early-expressions-after-generic-type:\n    - include: members-arrow\n    - include: operators\n    - include: members-dot\n    - include: strings\n    - include: parens\n    - include: brackets\n    - include: block\n    - include: variables\n    - include: constants\n    - match: ','\n      scope: punctuation.separator.c++\n    - match: '\\)|\\}'\n      scope: invalid.illegal.stray-bracket-end.c++\n\n  expressions-minus-generic-type:\n    - include: early-expressions-before-generic-type\n    - include: angle-brackets\n    - include: early-expressions-after-generic-type\n    - include: late-expressions\n\n  expressions-minus-generic-type-function-call:\n    - include: early-expressions-before-generic-type\n    - include: angle-brackets\n    - include: early-expressions-after-generic-type\n    - include: late-expressions-before-function-call\n    - include: identifiers\n    - match: ';'\n      scope: punctuation.terminator.c++\n\n  late-expressions:\n    - include: late-expressions-before-function-call\n    - include: function-call\n    - include: identifiers\n    - match: ';'\n      scope: punctuation.terminator.c++\n\n  late-expressions-before-function-call:\n    - include: unique-late-expressions\n    - include: modifiers-parens\n    - include: modifiers\n    - include: types\n\n  expressions-minus-function-call:\n    - include: early-expressions\n    - include: late-expressions-before-function-call\n    - include: identifiers\n    - match: ';'\n      scope: punctuation.terminator.c++\n\n  comments:\n    - include: scope:source.c#comments\n\n  operators:\n    - include: scope:source.c#operators\n\n  modifiers:\n    - include: unique-modifiers\n    - include: scope:source.c#modifiers\n\n  variables:\n    - include: unique-variables\n    - include: scope:source.c#variables\n\n  constants:\n    - include: unique-constants\n    - include: scope:source.c#constants\n\n  keywords:\n    - include: unique-keywords\n    - include: scope:source.c#keywords\n\n  types:\n    - include: unique-types\n    - include: types-parens\n    - include: scope:source.c#types\n\n  strings:\n    - include: unique-strings\n    - match: '(L|u8|u|U)?(\")'\n      captures:\n        1: storage.type.string.c++\n        2: punctuation.definition.string.begin.c++\n      push:\n        - meta_scope: string.quoted.double.c++\n        - match: '\"'\n          scope: punctuation.definition.string.end.c++\n          pop: true\n        - include: scope:source.c#string_escaped_char\n        - match: |-\n            (?x)%\n              (\\d+\\$)?                                      # field (argument #)\n              [#0\\- +']*                                    # flags\n              [,;:_]?                                       # separator character (AltiVec)\n              ((-?\\d+)|\\*(-?\\d+\\$)?)?                       # minimum field width\n              (\\.((-?\\d+)|\\*(-?\\d+\\$)?)?)?                  # precision\n              (hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?          # length modifier\n              (\\[[^\\]]+\\]|[am]s|[diouxXDOUeEfFgGaACcSspn%]) # conversion type\n          scope: constant.other.placeholder.c++\n        - match: '\\{\\{|\\}\\}'\n          scope: constant.character.escape.c++\n        - include: formatting-syntax\n    - include: scope:source.c#strings\n\n  formatting-syntax:\n    # https://docs.python.org/3.6/library/string.html#formatstrings\n    - match: |- # simple form\n        (?x)\n        (\\{)\n          (?: [\\w.\\[\\]]+)?             # field_name\n          (   ! [ars])?                # conversion\n          (   : (?:{{format_spec}}|    # format_spec OR\n                   [^}%]*%.[^}]*)      # any format-like string\n          )?\n        (\\})\n      scope: constant.other.placeholder.c++\n      captures:\n        1: punctuation.definition.placeholder.begin.c++\n        2: storage.modifier.c++onversion.c++\n        3: constant.other.format-spec.c++\n        4: punctuation.definition.placeholder.end.c++\n    - match: \\{(?=[^\\}\"']+\\{[^\"']*\\}) # complex (nested) form\n      scope: punctuation.definition.placeholder.begin.c++\n      push:\n        - meta_scope: constant.other.placeholder.c++\n        - match: \\}\n          scope: punctuation.definition.placeholder.end.c++\n          pop: true\n        - match: '[\\w.\\[\\]]+'\n        - match: '![ars]'\n          scope: storage.modifier.conversion.c++\n        - match: ':'\n          push:\n            - meta_scope: meta.format-spec.c++ constant.other.format-spec.c++\n            - match: (?=\\})\n              pop: true\n            - include: formatting-syntax\n\n  numbers:\n    - include: unique-numbers\n    - include: scope:source.c#numbers\n\n  ## C++-specific contexts\n\n  case-default:\n    - match: '\\b(default|case)\\b'\n      scope: keyword.control.c++\n      push:\n        - match: (?=[);,])\n          pop: true\n        - match: ':'\n          scope: punctuation.separator.c++\n          pop: true\n        - include: expressions\n\n  modifiers-parens:\n    - match: '\\b(alignas)\\b\\s*(\\()'\n      captures:\n        1: storage.modifier.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push:\n        - meta_content_scope: meta.group.c++\n        - match: '\\)'\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n        - include: expressions\n    - match: \\b(__attribute__)\\s*(\\(\\()\n      captures:\n        1: storage.modifier.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push :\n        - meta_scope: meta.attribute.c++\n        - meta_content_scope: meta.group.c++\n        - include: parens\n        - include: strings\n        - match: \\)\\)\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n    - match: \\b(__declspec)(\\()\n      captures:\n        1: storage.modifier.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push:\n        - meta_content_scope: meta.group.c++\n        - match: '\\)'\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n        - match: '\\b(align|allocate|code_seg|deprecated|property|uuid)\\b\\s*(\\()'\n          captures:\n            1: storage.modifier.c++\n            2: meta.group.c++ punctuation.section.group.begin.c++\n          push:\n            - meta_content_scope: meta.group.c++\n            - match: '\\)'\n              scope: meta.group.c++ punctuation.section.group.end.c++\n              pop: true\n            - include: numbers\n            - include: strings\n            - match: \\b(get|put)\\b\n              scope: variable.parameter.c++\n            - match: ','\n              scope: punctuation.separator.c++\n            - match: '='\n              scope: keyword.operator.assignment.c++\n        - match: '\\b(appdomain|deprecated|dllimport|dllexport|jintrinsic|naked|noalias|noinline|noreturn|nothrow|novtable|process|restrict|safebuffers|selectany|thread)\\b'\n          scope: constant.other.c++\n\n  types-parens:\n    - match: '\\b(decltype)\\b\\s*(\\()'\n      captures:\n        1: storage.type.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push:\n        - meta_content_scope: meta.group.c++\n        - match: '\\)'\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n        - include: expressions\n\n  keywords-angle-brackets:\n    - match: \\b({{casts}})\\b\\s*\n      scope: keyword.operator.word.cast.c++\n      push:\n        - match: '>'\n          scope: punctuation.section.generic.end.c++\n          pop: true\n        - match: '<'\n          scope: punctuation.section.generic.begin.c++\n          push:\n            - match: '(?=>)'\n              pop: true\n            - include: expressions-minus-generic-type-function-call\n\n  keywords-parens:\n    - match: '\\b(alignof|typeid|static_assert|sizeof)\\b\\s*(\\()'\n      captures:\n        1: keyword.operator.word.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push:\n        - meta_content_scope: meta.group.c++\n        - match: '\\)'\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n        - include: expressions\n\n  namespace:\n    - match: '\\b(using)\\s+(namespace)\\s+(?={{path_lookahead}})'\n      captures:\n        1: keyword.control.c++\n        2: keyword.control.c++\n      push:\n        - include: identifiers\n        - match: ''\n          pop: true\n    - match: '\\b(namespace)\\s+(?=({{path_lookahead}})?(?!\\s*[;,]))'\n      scope: meta.namespace.c++\n      captures:\n        1: keyword.control.c++\n      push:\n        - meta_content_scope: meta.namespace.c++ entity.name.namespace.c++\n        - include: identifiers\n        - match: ''\n          set:\n            - meta_scope: meta.namespace.c++\n            - include: comments\n            - match: '='\n              scope: keyword.operator.alias.c++\n            - match: '(?=;)'\n              pop: true\n            - match: '\\}'\n              scope: meta.block.c++ punctuation.section.block.end.c++\n              pop: true\n            - match: '\\{'\n              scope: punctuation.section.block.begin.c++\n              push:\n                - meta_scope: meta.block.c++\n                - match: '(?=\\})'\n                  pop: true\n                - include: preprocessor-global\n                - include: global\n            - include: expressions\n\n  template-common:\n    # Exit the template scope if we hit some basic invalid characters. This\n    # helps when a user is in the middle of typing their template types and\n    # prevents re-highlighting the whole file until the next > is found.\n    - match: (?=[{};])\n      pop: true\n    - include: expressions\n\n  template:\n    - match: \\btemplate\\b\n      scope: storage.type.template.c++\n      push:\n        - meta_scope: meta.template.c++\n        # Explicitly include comments here at the top, in order to NOT match the\n        # \\S lookahead in the case of comments.\n        - include: comments\n        - match: <\n          scope: punctuation.section.generic.begin.c++\n          set:\n            - meta_content_scope: meta.template.c++\n            - match: '>'\n              scope: meta.template.c++ punctuation.section.generic.end.c++\n              pop: true\n            - match: \\.{3}\n              scope: keyword.operator.variadic.c++\n            - match: \\b(typename|{{before_tag}})\\b\n              scope: storage.type.c++\n            - include: template # include template here for nested templates\n            - include: template-common\n        - match: (?=\\S)\n          set:\n            - meta_content_scope: meta.template.c++\n            - match: \\b({{before_tag}})\\b\n              scope: storage.type.c++\n            - include: template-common\n\n  generic-type:\n    - match: '(?=(?!template){{path_lookahead}}\\s*{{generic_lookahead}}\\s*\\()'\n      push:\n        - meta_scope: meta.function-call.c++\n        - match: \\btemplate\\b\n          scope: storage.type.template.c++\n        - match: '(?:(::)\\s*)?{{identifier}}\\s*(::)\\s*'\n          captures:\n            1: punctuation.accessor.double-colon.c++\n            2: punctuation.accessor.double-colon.c++\n        - match: (?:(::)\\s*)?({{identifier}})\\s*(<)\n          captures:\n            1: punctuation.accessor.double-colon.c++\n            2: variable.function.c++\n            3: punctuation.section.generic.begin.c++\n          push:\n            - match: '>'\n              scope: punctuation.section.generic.end.c++\n              pop: true\n            - include: expressions-minus-generic-type-function-call\n        - match: (?:(::)\\s*)?({{identifier}})\\s*(\\()\n          captures:\n            1: punctuation.accessor.double-colon.c++\n            2: variable.function.c++\n            3: punctuation.section.group.begin.c++\n          set:\n            - meta_scope: meta.function-call.c++\n            - meta_content_scope: meta.group.c++\n            - match: '\\)'\n              scope: meta.group.c++ punctuation.section.group.end.c++\n              pop: true\n            - include: expressions\n        - include: angle-brackets\n        - match: '\\('\n          scope: meta.group.c++ punctuation.section.group.begin.c++\n          set:\n            - meta_scope: meta.function-call.c++\n            - meta_content_scope: meta.group.c++\n            - match: '\\)'\n              scope: meta.group.c++ punctuation.section.group.end.c++\n              pop: true\n            - include: expressions\n    - match: '(?=(?!template){{path_lookahead}}\\s*{{generic_lookahead}})'\n      push:\n        - include: identifiers\n        - match: '<'\n          scope: punctuation.section.generic.begin.c++\n          set:\n            - match: '>'\n              scope: punctuation.section.generic.end.c++\n              pop: true\n            - include: expressions-minus-generic-type-function-call\n\n  angle-brackets:\n    - match: '<(?!<)'\n      scope: punctuation.section.generic.begin.c++\n      push:\n        - match: '>'\n          scope: punctuation.section.generic.end.c++\n          pop: true\n        - include: expressions-minus-generic-type-function-call\n\n  block:\n    - match: '\\{'\n      scope: punctuation.section.block.begin.c++\n      push:\n        - meta_scope: meta.block.c++\n        - match: (?=^\\s*#\\s*(elif|else|endif)\\b)\n          pop: true\n        - match: '\\}'\n          scope: punctuation.section.block.end.c++\n          pop: true\n        - include: statements\n\n  function-call:\n    - match: (?={{path_lookahead}}\\s*\\()\n      push:\n        - meta_scope: meta.function-call.c++\n        - include: scope:source.c#c99\n        - match: '(?:(::)\\s*)?{{identifier}}\\s*(::)\\s*'\n          scope: variable.function.c++\n          captures:\n            1: punctuation.accessor.c++\n            2: punctuation.accessor.c++\n        - match: '(?:(::)\\s*)?{{identifier}}'\n          scope: variable.function.c++\n          captures:\n            1: punctuation.accessor.c++\n        - match: '\\('\n          scope: meta.group.c++ punctuation.section.group.begin.c++\n          set:\n            - meta_content_scope: meta.function-call.c++ meta.group.c++\n            - match: '\\)'\n              scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++\n              pop: true\n            - include: expressions\n\n  members-inside-function-call:\n    - meta_content_scope: meta.method-call.c++ meta.group.c++\n    - match: \\)\n      scope: meta.method-call.c++ meta.group.c++ punctuation.section.group.end.c++\n      pop: true\n    - include: expressions\n\n  members-after-accessor-junction:\n    # After we've seen an accessor (dot or arrow), this context decides what\n    # kind of entity we're accessing.\n    - include: comments\n    - match: \\btemplate\\b\n      scope: meta.method-call.c++ storage.type.template.c++\n      # Guaranteed to be a template member function call after we match this\n      set:\n        - meta_content_scope: meta.method-call.c++\n        - include: comments\n        - match: '{{identifier}}'\n          scope: variable.function.member.c++\n          set:\n            - meta_content_scope: meta.method-call.c++\n            - match: \\(\n              scope: meta.group.c++ punctuation.section.group.begin.c++\n              set: members-inside-function-call\n            - include: comments\n            - include: angle-brackets\n            - match: (?=\\S) # safety pop\n              pop: true\n        - match: (?=\\S) # safety pop\n          pop: true\n    # Operator overloading\n    - match: '({{operator_method_name}})\\s*(\\()'\n      captures:\n        0: meta.method-call.c++\n        1: variable.function.member.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      set: members-inside-function-call\n    # Non-templated member function call\n    - match: (~?{{identifier}})\\s*(\\()\n      captures:\n        0: meta.method-call.c++\n        1: variable.function.member.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      set: members-inside-function-call\n    # Templated member function call\n    - match: (~?{{identifier}})\\s*(?={{generic_lookahead}})\n      captures:\n        1: variable.function.member.c++\n      set:\n        - meta_scope: meta.method-call.c++\n        - match: <\n          scope: punctuation.section.generic.begin.c++\n          set:\n            - meta_content_scope: meta.method-call.c++\n            - match: '>'\n              scope: punctuation.section.generic.end.c++\n              set:\n                - meta_content_scope: meta.method-call.c++\n                - include: comments\n                - match: \\(\n                  scope: punctuation.section.group.begin.c++\n                  set: members-inside-function-call\n                - match: (?=\\S) # safety pop\n                  pop: true\n            - include: expressions\n    # Explicit base-class access\n    - match: ({{identifier}})\\s*(::)\n      captures:\n        1: variable.other.base-class.c++\n        2: punctuation.accessor.double-colon.c++\n      set: members-after-accessor-junction # reset\n    # Just a regular member variable\n    - match: '{{identifier}}'\n      scope: variable.other.readwrite.member.c++\n      pop: true\n\n  members-dot:\n    - include: scope:source.c#access-illegal\n    # No lookahead required because members-dot goes after operators in the\n    # early-expressions-after-generic-type context. This means triple dots\n    # (i.e. \"...\" or \"variadic\") is attempted first.\n    - match: \\.\n      scope: punctuation.accessor.dot.c++\n      push: members-after-accessor-junction\n\n  members-arrow:\n    # This needs to be before operators in the\n    # early-expressions-after-generic-type context because otherwise the \"->\"\n    # from the C language will match.\n    - match: ->\n      scope: punctuation.accessor.arrow.c++\n      push: members-after-accessor-junction\n\n  typedef:\n    - match: \\btypedef\\b\n      scope: storage.type.c++\n      push:\n        - match: ({{identifier}})?\\s*(?=;)\n          captures:\n            1: entity.name.type.typedef.c++\n          pop: true\n        - match: \\b(struct)\\s+({{identifier}})\\b\n          captures:\n            1: storage.type.c++\n        - include: expressions-minus-generic-type\n\n  parens:\n    - match: \\(\n      scope: punctuation.section.group.begin.c++\n      push:\n        - meta_scope: meta.group.c++\n        - match: \\)\n          scope: punctuation.section.group.end.c++\n          pop: true\n        - include: expressions\n\n  brackets:\n    - match: \\[\n      scope: punctuation.section.brackets.begin.c++\n      push:\n        - meta_scope: meta.brackets.c++\n        - match: \\]\n          scope: punctuation.section.brackets.end.c++\n          pop: true\n        - include: expressions\n\n  function-trailing-return-type:\n    - match: '{{non_angle_brackets}}'\n      pop: true\n    - include: angle-brackets\n    - include: types\n    - include: modifiers-parens\n    - include: modifiers\n    - include: identifiers\n    - match: \\*|&\n      scope: keyword.operator.c++\n    - include: function-trailing-return-type-parens\n    - match: '(?=\\S)'\n      pop: true\n\n  function-trailing-return-type-parens:\n    - match: \\(\n      scope: punctuation.section.group.begin.c++\n      push:\n        - meta_scope: meta.group.c++\n        - match: \\)\n          scope: punctuation.section.group.end.c++\n          pop: true\n        - include: function-trailing-return-type\n\n  ## Detection of function and data structure definitions at the global level\n\n  global-modifier:\n    - include: comments\n    - include: modifiers-parens\n    - include: modifiers\n    # Constructors and destructors don't have a type\n    - match: '(?={{path_lookahead}}\\s*::\\s*{{identifier}}\\s*(\\(|$))'\n      set:\n        - meta_content_scope: meta.function.c++ entity.name.function.constructor.c++\n        - include: identifiers\n        - match: '(?=[^\\w\\s])'\n          set: function-definition-params\n    - match: '(?={{path_lookahead}}\\s*::\\s*~{{identifier}}\\s*(\\(|$))'\n      set:\n        - meta_content_scope: meta.function.c++ entity.name.function.destructor.c++\n        - include: identifiers\n        - match: '~{{identifier}}'\n        - match: '(?=[^\\w\\s])'\n          set: function-definition-params\n    # If we see a path ending in :: before a newline, we don't know if it is\n    # a constructor or destructor, or a long return type, so we are just going\n    # to treat it like a regular function. Most likely it is a constructor,\n    # since it doesn't seem most developers would create such a long typename.\n    - match: '(?={{path_lookahead}}\\s*::\\s*$)'\n      set:\n        - meta_content_scope: meta.function.c++ entity.name.function.c++\n        - include: identifiers\n        - match: '~{{identifier}}'\n        - match: '(?=[^\\w\\s])'\n          set: function-definition-params\n    - include: unique-strings\n    - match: '(?=\\S)'\n      set: global-type\n\n  global-type:\n    - include: comments\n    - match: \\*|&\n      scope: keyword.operator.c++\n    - match: '(?=\\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\\b)'\n      pop: true\n    - match: '(?=\\s)'\n      set: global-maybe-function\n    # If a class/struct/enum followed by a name that is not a macro or declspec\n    # then this is likely a return type of a function. This is uncommon.\n    - match: |-\n        (?x:\n          ({{before_tag}})\n          \\s+\n          (?=\n            (?![[:upper:][:digit:]_]+\\b|__declspec|{{before_tag}})\n            {{path_lookahead}}\n            (\\s+{{identifier}}\\s*\\(|\\s*[*&])\n          )\n        )\n      captures:\n        1: storage.type.c++\n      set:\n        - include: identifiers\n        - match: ''\n          set: global-maybe-function\n    # The previous match handles return types of struct/enum/etc from a func,\n    # there this one exits the context to allow matching an actual struct/class\n    - match: '(?=\\b({{before_tag}})\\b)'\n      set: data-structures\n    - match: '(?=\\b({{casts}})\\b\\s*<)'\n      pop: true\n    - match: '{{non_angle_brackets}}'\n      pop: true\n    - include: angle-brackets\n    - include: types\n    # Allow a macro call\n    - match: '({{identifier}})\\s*(\\()(?=[^\\)]+\\))'\n      captures:\n        1: variable.function.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push:\n        - meta_scope: meta.function-call.c++\n        - meta_content_scope: meta.group.c++\n        - match: '\\)'\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n        - include: expressions\n    - match: '(?={{path_lookahead}}\\s*\\()'\n      set:\n        - include: function-call\n        - match: ''\n          pop: true\n    - include: variables\n    - include: constants\n    - include: identifiers\n    - match: (?=\\W)\n      pop: true\n\n  global-maybe-function:\n    - include: comments\n    # Consume pointer info, macros and any type info that was offset by macros\n    - match: \\*|&\n      scope: keyword.operator.c++\n    - match: '(?=\\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\\b)'\n      pop: true\n    - match: '\\b({{type_qualifier}})\\b'\n      scope: storage.modifier.c++\n    - match: '{{non_angle_brackets}}'\n      pop: true\n    - include: angle-brackets\n    - include: types\n    - include: modifiers-parens\n    - include: modifiers\n    # All uppercase identifier just before a newline is most likely a macro\n    - match: '[[:upper:][:digit:]_]+\\s*$'\n    # Operator overloading\n    - match: '(?=({{path_lookahead}}\\s*(?:{{generic_lookahead}})?::\\s*)?{{operator_method_name}}\\s*(\\(|$))'\n      set:\n        - meta_content_scope: meta.function.c++ entity.name.function.c++\n        - include: identifiers\n        - match: '(?=\\s*(\\(|$))'\n          set: function-definition-params\n    # Identifier that is not the function name - likely a macro or type\n    - match: '(?={{path_lookahead}}([ \\t]+|[*&])(?!\\s*(<|::|\\(|$)))'\n      push:\n        - include: identifiers\n        - match: ''\n          pop: true\n    # Real function definition\n    - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\\s*(\\(|$))'\n      set: [function-definition-params, global-function-identifier-generic]\n    - match: '(?={{path_lookahead}}\\s*(\\(|$))'\n      set: [function-definition-params, global-function-identifier]\n    - match: '(?={{path_lookahead}}\\s*::\\s*$)'\n      set: [function-definition-params, global-function-identifier]\n    - match: '(?=\\S)'\n      pop: true\n\n  global-function-identifier-generic:\n    - include: angle-brackets\n    - match: '::'\n      scope: punctuation.accessor.c++\n    - match: '(?={{identifier}}<.*>\\s*\\()'\n      push:\n        - meta_content_scope: entity.name.function.c++\n        - include: identifiers\n        - match: '(?=<)'\n          pop: true\n    - match: '(?={{identifier}}\\s*\\()'\n      push:\n        - meta_content_scope: entity.name.function.c++\n        - include: identifiers\n        - match: ''\n          pop: true\n    - match: '(?=\\()'\n      pop: true\n\n  global-function-identifier:\n    - meta_content_scope: entity.name.function.c++\n    - include: identifiers\n    - match: '(?=\\S)'\n      pop: true\n\n  function-definition-params:\n    - meta_content_scope: meta.function.c++\n    - include: comments\n    - match: '(?=\\()'\n      set:\n        - match: \\(\n          scope: meta.function.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++\n          set:\n            - meta_content_scope: meta.function.parameters.c++ meta.group.c++\n            - match : \\)\n              scope: punctuation.section.group.end.c++\n              set: function-definition-continue\n            - match: '\\bvoid\\b'\n              scope: storage.type.c++\n            - match: '{{identifier}}(?=\\s*(\\[|,|\\)|=))'\n              scope: variable.parameter.c++\n            - match: '='\n              scope: keyword.operator.assignment.c++\n              push:\n                - match: '(?=,|\\))'\n                  pop: true\n                - include: expressions-minus-generic-type\n                - include: scope:source.c#preprocessor-line-continuation\n            - include: expressions-minus-generic-type\n            - include: scope:source.c#preprocessor-line-continuation\n    - match: (?=\\S)\n      pop: true\n\n  function-definition-continue:\n    - meta_content_scope: meta.function.c++\n    - include: comments\n    - match: '(?=;)'\n      pop: true\n    - match: '->'\n      scope: punctuation.separator.c++\n      set: function-definition-trailing-return\n    - include: function-specifiers\n    - match: '='\n      scope: keyword.operator.assignment.c++\n    - match: '&'\n      scope: keyword.operator.c++\n    - match: \\b0\\b\n      scope: constant.numeric.c++\n    - match: \\b(default|delete)\\b\n      scope: storage.modifier.c++\n    - match: '(?=\\{)'\n      set: function-definition-body\n    - match: '(?=\\S)'\n      pop: true\n\n  function-definition-trailing-return:\n    - include: comments\n    - match: '(?=;)'\n      pop: true\n    - match: '(?=\\{)'\n      set: function-definition-body\n    - include: function-specifiers\n    - include: function-trailing-return-type\n\n  function-definition-body:\n    - meta_content_scope: meta.function.c++ meta.block.c++\n    - match: '\\{'\n      scope: punctuation.section.block.begin.c++\n      set:\n        - meta_content_scope: meta.function.c++ meta.block.c++\n        - match: '\\}'\n          scope: meta.function.c++ meta.block.c++ punctuation.section.block.end.c++\n          pop: true\n        - match: (?=^\\s*#\\s*(elif|else|endif)\\b)\n          pop: true\n        - match: '(?=({{before_tag}})([^(;]+$|.*\\{))'\n          push: data-structures\n        - include: statements\n\n  ## Data structures including classes, structs, unions and enums\n\n  data-structures:\n    - match: '\\bclass\\b'\n      scope: storage.type.c++\n      set: data-structures-class-definition\n    # Detect variable type definitions using struct/enum/union followed by a tag\n    - match: '\\b({{before_tag}})(?=\\s+{{path_lookahead}}\\s+{{path_lookahead}}\\s*[=;\\[])'\n      scope: storage.type.c++\n    - match: '\\bstruct\\b'\n      scope: storage.type.c++\n      set: data-structures-struct-definition\n    - match: '\\benum(\\s+(class|struct))?\\b'\n      scope: storage.type.c++\n      set: data-structures-enum-definition\n    - match: '\\bunion\\b'\n      scope: storage.type.c++\n      set: data-structures-union-definition\n    - match: '(?=\\S)'\n      pop: true\n\n  preprocessor-workaround-eat-macro-before-identifier:\n    # Handle macros so they aren't matched as the class name\n    - match: ({{macro_identifier}})(?=\\s+~?{{identifier}})\n      captures:\n        1: meta.assumed-macro.c\n\n  data-structures-class-definition:\n    - meta_scope: meta.class.c++\n    - include: data-structures-definition-common-begin\n    - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})'\n      scope: entity.name.class.forward-decl.c++\n      set: data-structures-class-definition-after-identifier\n    - match: '{{identifier}}'\n      scope: entity.name.class.c++\n      set: data-structures-class-definition-after-identifier\n    - match: '(?=[:{])'\n      set: data-structures-class-definition-after-identifier\n    - match: '(?=;)'\n      pop: true\n\n  data-structures-class-definition-after-identifier:\n    - meta_content_scope: meta.class.c++\n    - include: data-structures-definition-common-begin\n    # No matching of identifiers since they should all be macros at this point\n    - include: data-structures-definition-common-end\n    - match: '\\{'\n      scope: meta.block.c++ punctuation.section.block.begin.c++\n      set:\n        - meta_content_scope: meta.class.c++ meta.block.c++\n        - match: '\\}'\n          scope: meta.class.c++ meta.block.c++ punctuation.section.block.end.c++\n          pop: true\n        - include: data-structures-body\n\n  data-structures-struct-definition:\n    - meta_scope: meta.struct.c++\n    - include: data-structures-definition-common-begin\n    - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})'\n      scope: entity.name.struct.forward-decl.c++\n      set: data-structures-struct-definition-after-identifier\n    - match: '{{identifier}}'\n      scope: entity.name.struct.c++\n      set: data-structures-struct-definition-after-identifier\n    - match: '(?=[:{])'\n      set: data-structures-struct-definition-after-identifier\n    - match: '(?=;)'\n      pop: true\n\n  data-structures-struct-definition-after-identifier:\n    - meta_content_scope: meta.struct.c++\n    - include: data-structures-definition-common-begin\n    # No matching of identifiers since they should all be macros at this point\n    - include: data-structures-definition-common-end\n    - match: '\\{'\n      scope: meta.block.c++ punctuation.section.block.begin.c++\n      set:\n        - meta_content_scope: meta.struct.c++ meta.block.c++\n        - match: '\\}'\n          scope: meta.struct.c++ meta.block.c++ punctuation.section.block.end.c++\n          pop: true\n        - include: data-structures-body\n\n  data-structures-enum-definition:\n    - meta_scope: meta.enum.c++\n    - include: data-structures-definition-common-begin\n    - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})'\n      scope: entity.name.enum.forward-decl.c++\n      set: data-structures-enum-definition-after-identifier\n    - match: '{{identifier}}'\n      scope: entity.name.enum.c++\n      set: data-structures-enum-definition-after-identifier\n    - match: '(?=[:{])'\n      set: data-structures-enum-definition-after-identifier\n    - match: '(?=;)'\n      pop: true\n\n  data-structures-enum-definition-after-identifier:\n    - meta_content_scope: meta.enum.c++\n    - include: data-structures-definition-common-begin\n    # No matching of identifiers since they should all be macros at this point\n    - include: data-structures-definition-common-end\n    - match: '\\{'\n      scope: meta.block.c++ punctuation.section.block.begin.c++\n      set:\n        - meta_content_scope: meta.enum.c++ meta.block.c++\n        # Enums don't support methods so we have a simplified body\n        - match: '\\}'\n          scope: meta.enum.c++ meta.block.c++ punctuation.section.block.end.c++\n          pop: true\n        - include: statements\n\n  data-structures-union-definition:\n    - meta_scope: meta.union.c++\n    - include: data-structures-definition-common-begin\n    - match: '{{identifier}}(?={{data_structures_forward_decl_lookahead}})'\n      scope: entity.name.union.forward-decl.c++\n      set: data-structures-union-definition-after-identifier\n    - match: '{{identifier}}'\n      scope: entity.name.union.c++\n      set: data-structures-union-definition-after-identifier\n    - match: '(?=[{])'\n      set: data-structures-union-definition-after-identifier\n    - match: '(?=;)'\n      pop: true\n\n  data-structures-union-definition-after-identifier:\n    - meta_content_scope: meta.union.c++\n    - include: data-structures-definition-common-begin\n    # No matching of identifiers since they should all be macros at this point\n    # Unions don't support base classes\n    - include: angle-brackets\n    - match: '\\{'\n      scope: meta.block.c++ punctuation.section.block.begin.c++\n      set:\n        - meta_content_scope: meta.union.c++ meta.block.c++\n        - match: '\\}'\n          scope: meta.union.c++ meta.block.c++ punctuation.section.block.end.c++\n          pop: true\n        - include: data-structures-body\n    - match: '(?=;)'\n      pop: true\n\n  data-structures-definition-common-begin:\n    - include: comments\n    - match: '(?=\\b(?:{{before_tag}}|{{control_keywords}})\\b)'\n      pop: true\n    - include: preprocessor-other\n    - include: modifiers-parens\n    - include: modifiers\n    - include: preprocessor-workaround-eat-macro-before-identifier\n\n  data-structures-definition-common-end:\n    - include: angle-brackets\n    - match: \\bfinal\\b\n      scope: storage.modifier.c++\n    - match: ':'\n      scope: punctuation.separator.c++\n      push:\n        - include: comments\n        - include: preprocessor-other\n        - include: modifiers-parens\n        - include: modifiers\n        - match: '\\b(virtual|{{visibility_modifiers}})\\b'\n          scope: storage.modifier.c++\n        - match: (?={{path_lookahead}})\n          push:\n            - meta_scope: entity.other.inherited-class.c++\n            - include: identifiers\n            - match: ''\n              pop: true\n        - include: angle-brackets\n        - match: ','\n          scope: punctuation.separator.c++\n        - match: (?=\\{|;)\n          pop: true\n    - match: '(?=;)'\n      pop: true\n\n  data-structures-body:\n    - include: preprocessor-data-structures\n    - match: '(?=\\btemplate\\b)'\n      push:\n        - include: template\n        - match: (?=\\S)\n          set: data-structures-modifier\n    - include: typedef\n    - match: \\b({{visibility_modifiers}})\\s*(:)(?!:)\n      captures:\n        1: storage.modifier.c++\n        2: punctuation.section.class.c++\n    - match: '^\\s*(?=(?:~?\\w+|::))'\n      push: data-structures-modifier\n    - include: expressions-minus-generic-type\n\n  data-structures-modifier:\n    - match: '\\bfriend\\b'\n      scope: storage.modifier.c++\n      push:\n        - match: (?=;)\n          pop: true\n        - match: '\\{'\n          scope: punctuation.section.block.begin.c++\n          set:\n            - meta_scope: meta.block.c++\n            - match: '\\}'\n              scope: punctuation.section.block.end.c++\n              pop: true\n            - include: statements\n        - match: '\\b({{before_tag}})\\b'\n          scope: storage.type.c++\n        - include: expressions-minus-function-call\n    - include: comments\n    - include: modifiers-parens\n    - include: modifiers\n    - match: '\\bstatic_assert(?=\\s*\\()'\n      scope: meta.static-assert.c++ keyword.operator.word.c++\n      push:\n        - match: '\\('\n          scope: meta.group.c++ punctuation.section.group.begin.c++\n          set:\n            - meta_content_scope: meta.function-call.c++ meta.group.c++\n            - match: '\\)'\n              scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++\n              pop: true\n            - include: expressions\n    # Destructor\n    - match: '(?:{{identifier}}\\s*(::)\\s*)?~{{identifier}}(?=\\s*(\\(|$))'\n      scope: meta.method.destructor.c++ entity.name.function.destructor.c++\n      captures:\n        1: punctuation.accessor.c++\n      set: method-definition-params\n    # It's a macro, not a constructor if there is no type in the first param\n    - match: '({{identifier}})\\s*(\\()(?=\\s*(?!void){{identifier}}\\s*[),])'\n      captures:\n        1: variable.function.c++\n        2: meta.group.c++ punctuation.section.group.begin.c++\n      push:\n        - meta_scope: meta.function-call.c++\n        - meta_content_scope: meta.group.c++\n        - match: '\\)'\n          scope: meta.group.c++ punctuation.section.group.end.c++\n          pop: true\n        - include: expressions\n    # Constructor\n    - include: preprocessor-workaround-eat-macro-before-identifier\n    - match: '((?!{{before_tag}}|template){{identifier}})(?=\\s*\\()'\n      scope: meta.method.constructor.c++ entity.name.function.constructor.c++\n      set: method-definition-params\n    # Long form constructor\n    - match: '({{identifier}}\\s*(::)\\s*{{identifier}})(?=\\s*\\()'\n      captures:\n        1: meta.method.constructor.c++ entity.name.function.constructor.c++\n        2: punctuation.accessor.c++\n      push: method-definition-params\n    - match: '(?=\\S)'\n      set: data-structures-type\n\n  data-structures-type:\n    - include: comments\n    - match: \\*|&\n      scope: keyword.operator.c++\n      # Cast methods\n    - match: '(operator)\\s+({{identifier}})(?=\\s*(\\(|$))'\n      captures:\n        1: keyword.control.c++\n        2: meta.method.c++ entity.name.function.c++\n      set: method-definition-params\n    - match: '(?=\\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}}|operator)\\b)'\n      pop: true\n    - match: '(?=\\s)'\n      set: data-structures-maybe-method\n    # If a class/struct/enum followed by a name that is not a macro or declspec\n    # then this is likely a return type of a function. This is uncommon.\n    - match: |-\n        (?x:\n          ({{before_tag}})\n          \\s+\n          (?=\n            (?![[:upper:][:digit:]_]+\\b|__declspec|{{before_tag}})\n            {{path_lookahead}}\n            (\\s+{{identifier}}\\s*\\(|\\s*[*&])\n          )\n        )\n      captures:\n        1: storage.type.c++\n      set:\n        - include: identifiers\n        - match: ''\n          set: data-structures-maybe-method\n    # The previous match handles return types of struct/enum/etc from a func,\n    # there this one exits the context to allow matching an actual struct/class\n    - match: '(?=\\b({{before_tag}})\\b)'\n      set: data-structures\n    - match: '(?=\\b({{casts}})\\b\\s*<)'\n      pop: true\n    - match: '{{non_angle_brackets}}'\n      pop: true\n    - include: angle-brackets\n    - include: types\n    - include: variables\n    - include: constants\n    - include: identifiers\n    - match: (?=[&*])\n      set: data-structures-maybe-method\n    - match: (?=\\W)\n      pop: true\n\n  data-structures-maybe-method:\n    - include: comments\n    # Consume pointer info, macros and any type info that was offset by macros\n    - match: \\*|&\n      scope: keyword.operator.c++\n    - match: '(?=\\b({{control_keywords}}|{{operator_keywords}}|{{casts}}|{{memory_operators}}|{{other_keywords}})\\b)'\n      pop: true\n    - match: '\\b({{type_qualifier}})\\b'\n      scope: storage.modifier.c++\n    - match: '{{non_angle_brackets}}'\n      pop: true\n    - include: angle-brackets\n    - include: types\n    - include: modifiers-parens\n    - include: modifiers\n    # Operator overloading\n    - match: '{{operator_method_name}}(?=\\s*(\\(|$))'\n      scope: meta.method.c++ entity.name.function.c++\n      set: method-definition-params\n    # Identifier that is not the function name - likely a macro or type\n    - match: '(?={{path_lookahead}}([ \\t]+|[*&])(?!\\s*(<|::|\\()))'\n      push:\n        - include: identifiers\n        - match: ''\n          pop: true\n    # Real function definition\n    - match: '(?={{path_lookahead}}({{generic_lookahead}})\\s*(\\())'\n      set: [method-definition-params, data-structures-function-identifier-generic]\n    - match: '(?={{path_lookahead}}\\s*(\\())'\n      set: [method-definition-params, data-structures-function-identifier]\n    - match: '(?={{path_lookahead}}\\s*::\\s*$)'\n      set: [method-definition-params, data-structures-function-identifier]\n    - match: '(?=\\S)'\n      pop: true\n\n  data-structures-function-identifier-generic:\n    - include: angle-brackets\n    - match: '(?={{identifier}})'\n      push:\n        - meta_content_scope: entity.name.function.c++\n        - include: identifiers\n        - match: '(?=<)'\n          pop: true\n    - match: '(?=\\()'\n      pop: true\n\n  data-structures-function-identifier:\n    - meta_content_scope: entity.name.function.c++\n    - include: identifiers\n    - match: '(?=\\S)'\n      pop: true\n\n  method-definition-params:\n    - meta_content_scope: meta.method.c++\n    - include: comments\n    - match: '(?=\\()'\n      set:\n        - match: \\(\n          scope: meta.method.parameters.c++ meta.group.c++ punctuation.section.group.begin.c++\n          set:\n            - meta_content_scope: meta.method.parameters.c++ meta.group.c++\n            - match : \\)\n              scope: punctuation.section.group.end.c++\n              set: method-definition-continue\n            - match: '\\bvoid\\b'\n              scope: storage.type.c++\n            - match: '{{identifier}}(?=\\s*(\\[|,|\\)|=))'\n              scope: variable.parameter.c++\n            - match: '='\n              scope: keyword.operator.assignment.c++\n              push:\n                - match: '(?=,|\\))'\n                  pop: true\n                - include: expressions-minus-generic-type\n            - include: expressions-minus-generic-type\n    - match: '(?=\\S)'\n      pop: true\n\n  method-definition-continue:\n    - meta_content_scope: meta.method.c++\n    - include: comments\n    - match: '(?=;)'\n      pop: true\n    - match: '->'\n      scope: punctuation.separator.c++\n      set: method-definition-trailing-return\n    - include: function-specifiers\n    - match: '='\n      scope: keyword.operator.assignment.c++\n    - match: '&'\n      scope: keyword.operator.c++\n    - match: \\b0\\b\n      scope: constant.numeric.c++\n    - match: \\b(default|delete)\\b\n      scope: storage.modifier.c++\n    - match: '(?=:)'\n      set:\n        - match: ':'\n          scope: punctuation.separator.initializer-list.c++\n          set:\n            - meta_scope: meta.method.constructor.initializer-list.c++\n            - match: '{{identifier}}'\n              scope: variable.other.readwrite.member.c++\n              push:\n                - match: \\(\n                  scope: meta.group.c++ punctuation.section.group.begin.c++\n                  set:\n                    - meta_content_scope: meta.group.c++\n                    - match: \\)\n                      scope: meta.group.c++ punctuation.section.group.end.c++\n                      pop: true\n                    - include: expressions\n                - match: \\{\n                  scope: meta.group.c++ punctuation.section.group.begin.c++\n                  set:\n                    - meta_content_scope: meta.group.c++\n                    - match: \\}\n                      scope: meta.group.c++ punctuation.section.group.end.c++\n                      pop: true\n                    - include: expressions\n                - include: comments\n            - match: (?=\\{|;)\n              set: method-definition-continue\n            - include: expressions\n    - match: '(?=\\{)'\n      set: method-definition-body\n    - match: '(?=\\S)'\n      pop: true\n\n  method-definition-trailing-return:\n    - include: comments\n    - match: '(?=;)'\n      pop: true\n    - match: '(?=\\{)'\n      set: method-definition-body\n    - include: function-specifiers\n    - include: function-trailing-return-type\n\n  method-definition-body:\n    - meta_content_scope: meta.method.c++ meta.block.c++\n    - match: '\\{'\n      scope: punctuation.section.block.begin.c++\n      set:\n        - meta_content_scope: meta.method.c++ meta.block.c++\n        - match: '\\}'\n          scope: meta.method.c++ meta.block.c++ punctuation.section.block.end.c++\n          pop: true\n        - match: (?=^\\s*#\\s*(elif|else|endif)\\b)\n          pop: true\n        - match: '(?=({{before_tag}})([^(;]+$|.*\\{))'\n          push: data-structures\n        - include: statements\n\n  ## Preprocessor for data-structures\n\n  preprocessor-data-structures:\n    - include: preprocessor-rule-enabled-data-structures\n    - include: preprocessor-rule-disabled-data-structures\n    - include: preprocessor-practical-workarounds\n\n  preprocessor-rule-disabled-data-structures:\n    - match: ^\\s*((#if)\\s+(0))\\b\n      captures:\n        1: meta.preprocessor.c++\n        2: keyword.control.import.c++\n        3: constant.numeric.preprocessor.c++\n      push:\n        - match: ^\\s*(#\\s*endif)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.c++\n          pop: true\n        - match: ^\\s*(#\\s*else)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.else.c++\n          push:\n            - match: (?=^\\s*#\\s*endif\\b)\n              pop: true\n            - include: negated-block\n            - include: data-structures-body\n        - match: \"\"\n          push:\n            - meta_scope: comment.block.preprocessor.if-branch.c++\n            - match: (?=^\\s*#\\s*(else|endif)\\b)\n              pop: true\n            - include: scope:source.c#preprocessor-disabled\n\n  preprocessor-rule-enabled-data-structures:\n    - match: ^\\s*((#if)\\s+(0*1))\\b\n      captures:\n        1: meta.preprocessor.c++\n        2: keyword.control.import.c++\n        3: constant.numeric.preprocessor.c++\n      push:\n        - match: ^\\s*(#\\s*endif)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.c++\n          pop: true\n        - match: ^\\s*(#\\s*else)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.else.c++\n          push:\n            - meta_content_scope: comment.block.preprocessor.else-branch.c++\n            - match: (?=^\\s*#\\s*endif\\b)\n              pop: true\n            - include: scope:source.c#preprocessor-disabled\n        - match: \"\"\n          push:\n            - match: (?=^\\s*#\\s*(else|endif)\\b)\n              pop: true\n            - include: negated-block\n            - include: data-structures-body\n\n  ## Preprocessor for global\n\n  preprocessor-global:\n    - include: preprocessor-rule-enabled-global\n    - include: preprocessor-rule-disabled-global\n    - include: preprocessor-rule-other-global\n\n  preprocessor-statements:\n    - include: preprocessor-rule-enabled-statements\n    - include: preprocessor-rule-disabled-statements\n    - include: preprocessor-rule-other-statements\n\n  preprocessor-expressions:\n    - include: scope:source.c#incomplete-inc\n    - include: preprocessor-macro-define\n    - include: scope:source.c#pragma-mark\n    - include: preprocessor-other\n\n  preprocessor-rule-disabled-global:\n    - match: ^\\s*((#if)\\s+(0))\\b\n      captures:\n        1: meta.preprocessor.c++\n        2: keyword.control.import.c++\n        3: constant.numeric.preprocessor.c++\n      push:\n        - match: ^\\s*(#\\s*endif)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.c++\n          pop: true\n        - match: ^\\s*(#\\s*else)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.else.c++\n          push:\n            - match: (?=^\\s*#\\s*endif\\b)\n              pop: true\n            - include: preprocessor-global\n            - include: negated-block\n            - include: global\n        - match: \"\"\n          push:\n            - meta_scope: comment.block.preprocessor.if-branch.c++\n            - match: (?=^\\s*#\\s*(else|endif)\\b)\n              pop: true\n            - include: scope:source.c#preprocessor-disabled\n\n  preprocessor-rule-enabled-global:\n    - match: ^\\s*((#if)\\s+(0*1))\\b\n      captures:\n        1: meta.preprocessor.c++\n        2: keyword.control.import.c++\n        3: constant.numeric.preprocessor.c++\n      push:\n        - match: ^\\s*(#\\s*endif)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.c++\n          pop: true\n        - match: ^\\s*(#\\s*else)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.else.c++\n          push:\n            - meta_content_scope: comment.block.preprocessor.else-branch.c++\n            - match: (?=^\\s*#\\s*endif\\b)\n              pop: true\n            - include: scope:source.c#preprocessor-disabled\n        - match: \"\"\n          push:\n            - match: (?=^\\s*#\\s*(else|endif)\\b)\n              pop: true\n            - include: preprocessor-global\n            - include: negated-block\n            - include: global\n\n  preprocessor-rule-other-global:\n    - match: ^\\s*(#\\s*(?:if|ifdef|ifndef))\\b\n      captures:\n        1: keyword.control.import.c++\n      push:\n        - meta_scope: meta.preprocessor.c++\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-comments\n        - match: \\bdefined\\b\n          scope: keyword.control.c++\n        # Enter a new scope where all elif/else branches have their\n        # contexts popped by a subsequent elif/else/endif. This ensures that\n        # preprocessor branches don't push multiple meta.block scopes on\n        # the stack, thus messing up the \"global\" context's detection of\n        # functions.\n        - match: $\\n\n          set: preprocessor-if-branch-global\n\n  # These gymnastics here ensure that we are properly handling scope even\n  # when the preprocessor is used to create different scope beginnings, such\n  # as a different if/while condition\n  preprocessor-if-branch-global:\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      pop: true\n    - match: (?=^\\s*#\\s*(elif|else)\\b)\n      push: preprocessor-elif-else-branch-global\n    - match: \\{\n      scope: punctuation.section.block.begin.c++\n      set: preprocessor-block-if-branch-global\n    - include: preprocessor-global\n    - include: negated-block\n    - include: global\n\n  preprocessor-block-if-branch-global:\n    - meta_scope: meta.block.c++\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      set: preprocessor-block-finish-global\n    - match: (?=^\\s*#\\s*(elif|else)\\b)\n      push: preprocessor-elif-else-branch-global\n    - match: \\}\n      scope: punctuation.section.block.end.c++\n      set: preprocessor-if-branch-global\n    - include: statements\n\n  preprocessor-block-finish-global:\n    - meta_scope: meta.block.c++\n    - match: ^\\s*(#\\s*(?:if|ifdef|ifndef))\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      set: preprocessor-block-finish-if-branch-global\n    - match: \\}\n      scope: punctuation.section.block.end.c++\n      pop: true\n    - include: statements\n\n  preprocessor-block-finish-if-branch-global:\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: keyword.control.import.c++\n      pop: true\n    - match: \\}\n      scope: punctuation.section.block.end.c++\n      set: preprocessor-if-branch-global\n    - include: statements\n\n  preprocessor-elif-else-branch-global:\n    - match: (?=^\\s*#\\s*(endif)\\b)\n      pop: true\n    - include: preprocessor-global\n    - include: negated-block\n    - include: global\n\n  ## Preprocessor for statements\n\n  preprocessor-rule-disabled-statements:\n    - match: ^\\s*((#if)\\s+(0))\\b\n      captures:\n        1: meta.preprocessor.c++\n        2: keyword.control.import.c++\n        3: constant.numeric.preprocessor.c++\n      push:\n        - match: ^\\s*(#\\s*endif)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.c++\n          pop: true\n        - match: ^\\s*(#\\s*else)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.else.c++\n          push:\n            - match: (?=^\\s*#\\s*endif\\b)\n              pop: true\n            - include: negated-block\n            - include: statements\n        - match: \"\"\n          push:\n            - meta_scope: comment.block.preprocessor.if-branch.c++\n            - match: (?=^\\s*#\\s*(else|endif)\\b)\n              pop: true\n            - include: scope:source.c#preprocessor-disabled\n\n  preprocessor-rule-enabled-statements:\n    - match: ^\\s*((#if)\\s+(0*1))\\b\n      captures:\n        1: meta.preprocessor.c++\n        2: keyword.control.import.c++\n        3: constant.numeric.preprocessor.c++\n      push:\n        - match: ^\\s*(#\\s*endif)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.c++\n          pop: true\n        - match: ^\\s*(#\\s*else)\\b\n          captures:\n            1: meta.preprocessor.c++ keyword.control.import.else.c++\n          push:\n            - meta_content_scope: comment.block.preprocessor.else-branch.c++\n            - match: (?=^\\s*#\\s*endif\\b)\n              pop: true\n            - include: scope:source.c#preprocessor-disabled\n        - match: \"\"\n          push:\n            - match: (?=^\\s*#\\s*(else|endif)\\b)\n              pop: true\n            - include: negated-block\n            - include: statements\n\n  preprocessor-rule-other-statements:\n    - match: ^\\s*(#\\s*(?:if|ifdef|ifndef))\\b\n      captures:\n        1: keyword.control.import.c++\n      push:\n        - meta_scope: meta.preprocessor.c++\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-comments\n        - match: \\bdefined\\b\n          scope: keyword.control.c++\n        # Enter a new scope where all elif/else branches have their\n        # contexts popped by a subsequent elif/else/endif. This ensures that\n        # preprocessor branches don't push multiple meta.block scopes on\n        # the stack, thus messing up the \"global\" context's detection of\n        # functions.\n        - match: $\\n\n          set: preprocessor-if-branch-statements\n\n  # These gymnastics here ensure that we are properly handling scope even\n  # when the preprocessor is used to create different scope beginnings, such\n  # as a different if/while condition\n  preprocessor-if-branch-statements:\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      pop: true\n    - match: (?=^\\s*#\\s*(elif|else)\\b)\n      push: preprocessor-elif-else-branch-statements\n    - match: \\{\n      scope: punctuation.section.block.begin.c++\n      set: preprocessor-block-if-branch-statements\n    - match: (?=(?!{{non_func_keywords}}){{path_lookahead}}\\s*\\()\n      set: preprocessor-if-branch-function-call\n    - include: negated-block\n    - include: statements\n\n  preprocessor-if-branch-function-call:\n    - meta_content_scope: meta.function-call.c++\n    - include: scope:source.c#c99\n    - match: '(?:(::)\\s*)?{{identifier}}\\s*(::)\\s*'\n      scope: variable.function.c++\n      captures:\n        1: punctuation.accessor.c++\n        2: punctuation.accessor.c++\n    - match: '(?:(::)\\s*)?{{identifier}}'\n      scope: variable.function.c++\n      captures:\n        1: punctuation.accessor.c++\n    - match: '\\('\n      scope: meta.group.c++ punctuation.section.group.begin.c++\n      set: preprocessor-if-branch-function-call-arguments\n\n  preprocessor-if-branch-function-call-arguments:\n    - meta_content_scope: meta.function-call.c++ meta.group.c++\n    - match : \\)\n      scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++\n      set: preprocessor-if-branch-statements\n    - match: ^\\s*(#\\s*(?:elif|else))\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      set: preprocessor-if-branch-statements\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      set: preprocessor-if-branch-function-call-arguments-finish\n    - include: expressions\n\n  preprocessor-if-branch-function-call-arguments-finish:\n    - meta_content_scope: meta.function-call.c++ meta.group.c++\n    - match: \\)\n      scope: meta.function-call.c++ meta.group.c++ punctuation.section.group.end.c++\n      pop: true\n    - include: expressions\n\n  preprocessor-block-if-branch-statements:\n    - meta_scope: meta.block.c++\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      set: preprocessor-block-finish-statements\n    - match: (?=^\\s*#\\s*(elif|else)\\b)\n      push: preprocessor-elif-else-branch-statements\n    - match: \\}\n      scope: punctuation.section.block.end.c++\n      set: preprocessor-if-branch-statements\n    - include: statements\n\n  preprocessor-block-finish-statements:\n    - meta_scope: meta.block.c++\n    - match: ^\\s*(#\\s*(?:if|ifdef|ifndef))\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n      set: preprocessor-block-finish-if-branch-statements\n    - match: \\}\n      scope: punctuation.section.block.end.c++\n      pop: true\n    - include: statements\n\n  preprocessor-block-finish-if-branch-statements:\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: keyword.control.import.c++\n      pop: true\n    - match: \\}\n      scope: meta.block.c++ punctuation.section.block.end.c++\n      set: preprocessor-if-branch-statements\n    - include: statements\n\n  preprocessor-elif-else-branch-statements:\n    - match: (?=^\\s*#\\s*endif\\b)\n      pop: true\n    - include: negated-block\n    - include: statements\n\n  ## Preprocessor other\n\n  negated-block:\n    - match: '\\}'\n      scope: punctuation.section.block.end.c++\n      push:\n        - match: '\\{'\n          scope: punctuation.section.block.begin.c++\n          pop: true\n        - match: (?=^\\s*#\\s*(elif|else|endif)\\b)\n          pop: true\n        - include: statements\n\n  preprocessor-macro-define:\n    - match: ^\\s*(\\#\\s*define)\\b\n      captures:\n        1: meta.preprocessor.macro.c++ keyword.control.import.define.c++\n      push:\n        - meta_content_scope: meta.preprocessor.macro.c++\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-line-ending\n        - include: scope:source.c#preprocessor-comments\n        - match: '({{identifier}})(?=\\()'\n          scope: entity.name.function.preprocessor.c++\n          set:\n            - match: '\\('\n              scope: punctuation.section.group.begin.c++\n              set: preprocessor-macro-params\n        - match: '{{identifier}}'\n          scope: entity.name.constant.preprocessor.c++\n          set: preprocessor-macro-definition\n\n  preprocessor-macro-params:\n    - meta_scope: meta.preprocessor.macro.parameters.c++ meta.group.c++\n    - match: '{{identifier}}'\n      scope: variable.parameter.c++\n    - match: \\)\n      scope: punctuation.section.group.end.c++\n      set: preprocessor-macro-definition\n    - match: ','\n      scope: punctuation.separator.c++\n      push:\n        - match: '{{identifier}}'\n          scope: variable.parameter.c++\n          pop: true\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-comments\n        - match: '\\.\\.\\.'\n          scope: keyword.operator.variadic.c++\n        - match: '(?=\\))'\n          pop: true\n        - match: (/\\*).*(\\*/)\n          scope: comment.block.c++\n          captures:\n            1: punctuation.definition.comment.c++\n            2: punctuation.definition.comment.c++\n        - match: '\\S+'\n          scope: invalid.illegal.unexpected-character.c++\n    - include: scope:source.c#preprocessor-line-continuation\n    - include: scope:source.c#preprocessor-comments\n    - match: '\\.\\.\\.'\n      scope: keyword.operator.variadic.c++\n    - match: (/\\*).*(\\*/)\n      scope: comment.block.c++\n      captures:\n        1: punctuation.definition.comment.c++\n        2: punctuation.definition.comment.c++\n    - match: $\\n\n      scope: invalid.illegal.unexpected-end-of-line.c++\n\n  preprocessor-macro-definition:\n    - meta_content_scope: meta.preprocessor.macro.c++\n    - include: scope:source.c#preprocessor-line-continuation\n    - include: scope:source.c#preprocessor-line-ending\n    - include: scope:source.c#preprocessor-comments\n    # Don't define blocks in define statements\n    - match: '\\{'\n      scope: punctuation.section.block.begin.c++\n    - match: '\\}'\n      scope: punctuation.section.block.end.c++\n    - include: expressions\n\n  preprocessor-practical-workarounds:\n    - include: preprocessor-convention-ignore-uppercase-ident-lines\n    - include: scope:source.c#preprocessor-convention-ignore-uppercase-calls-without-semicolon\n\n  preprocessor-convention-ignore-uppercase-ident-lines:\n    - match: ^(\\s*{{macro_identifier}})+\\s*$\n      scope: meta.assumed-macro.c++\n      push:\n        # It's possible that we are dealing with a function return type on its own line, and the\n        # name of the function is on the subsequent line.\n        - match: '(?={{path_lookahead}}({{generic_lookahead}}({{path_lookahead}})?)\\s*\\()'\n          set: [function-definition-params, global-function-identifier-generic]\n        - match: '(?={{path_lookahead}}\\s*\\()'\n          set: [function-definition-params, global-function-identifier]\n        - match: ^\n          pop: true\n\n  preprocessor-other:\n    - match: ^\\s*(#\\s*(?:if|ifdef|ifndef|elif|else|line|pragma|undef))\\b\n      captures:\n        1: keyword.control.import.c++\n      push:\n        - meta_scope: meta.preprocessor.c++\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-line-ending\n        - include: scope:source.c#preprocessor-comments\n        - match: \\bdefined\\b\n          scope: keyword.control.c++\n    - match: ^\\s*(#\\s*endif)\\b\n      captures:\n        1: meta.preprocessor.c++ keyword.control.import.c++\n    - match: ^\\s*(#\\s*(?:error|warning))\\b\n      captures:\n        1: keyword.control.import.error.c++\n      push:\n        - meta_scope: meta.preprocessor.diagnostic.c++\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-line-ending\n        - include: scope:source.c#preprocessor-comments\n        - include: strings\n        - match: '\\S+'\n          scope: string.unquoted.c++\n    - match: ^\\s*(#\\s*(?:include|include_next|import))\\b\n      captures:\n        1: keyword.control.import.include.c++\n      push:\n        - meta_scope: meta.preprocessor.include.c++\n        - include: scope:source.c#preprocessor-line-continuation\n        - include: scope:source.c#preprocessor-line-ending\n        - include: scope:source.c#preprocessor-comments\n        - match: '\"'\n          scope: punctuation.definition.string.begin.c++\n          push:\n            - meta_scope: string.quoted.double.include.c++\n            - match: '\"'\n              scope: punctuation.definition.string.end.c++\n              pop: true\n        - match: <\n          scope: punctuation.definition.string.begin.c++\n          push:\n            - meta_scope: string.quoted.other.lt-gt.include.c++\n            - match: '>'\n              scope: punctuation.definition.string.end.c++\n              pop: true\n    - include: preprocessor-practical-workarounds\n"
  },
  {
    "path": "support/README",
    "content": "This directory contains build support files such as\n\n* CMake modules\n* Build scripts\n"
  },
  {
    "path": "support/Vagrantfile",
    "content": "# -*- mode: ruby -*-\n# vi: set ft=ruby :\n\n# A vagrant config for testing against gcc-4.8.\nVagrant.configure(\"2\") do |config|\n  config.vm.box = \"bento/ubuntu-22.04-arm64\"\n\n  config.vm.provider \"vmware_desktop\" do |vb|\n    vb.memory = \"4096\"\n  end\n\n  config.vm.provision \"shell\", inline: <<-SHELL\n    apt-get update\n    apt-get install -y g++ make wget git\n    wget -q https://github.com/Kitware/CMake/releases/download/v3.26.0/cmake-3.26.0-Linux-x86_64.tar.gz\n    tar xzf cmake-3.26.0-Linux-x86_64.tar.gz\n    ln -s `pwd`/cmake-3.26.0-Linux-x86_64/bin/cmake /usr/local/bin\n  SHELL\nend\n"
  },
  {
    "path": "support/build.gradle",
    "content": "import java.nio.file.Paths\n\n// General gradle arguments for root project\nbuildscript {    \n    repositories {\n        google()\n        mavenCentral()\n    }\n    dependencies {\n        classpath \"com.android.tools.build:gradle:9.0.0\"\n    }\n}\nrepositories {\n    google()\n    mavenCentral()\n}\n\n// Project's root where CMakeLists.txt exists: rootDir/support/.cxx -> rootDir\n\ndef rootDir = Paths.get(project.buildDir.getParent()).getParent()\nprintln(\"rootDir: ${rootDir}\")\n\n// Output: Shared library (.so) for Android\n\napply plugin: \"com.android.library\"\nandroid {\n    namespace = \"dev.fmt\"\n\n    compileSdk 36   // Target Android 16 (API 36).\n\n    /*  Target ABI\n      - This option controls target platform of module\n      - The platform might be limited by compiler's support\n        some can work with Clang(default), but some can work only with GCC...\n        if bad, both toolchains might not support it\n    */\n\n    ndkVersion = \"28.2.13676358\"\n\n    defaultConfig {\n        minSdk 21    // Android 5.0+\n        targetSdkVersion 36 // Follow Compile SDK\n        versionCode 34      // Follow release count\n        versionName \"7.1.2\" // Follow Official version\n\n        ndk{\n            abiFilters \"arm64-v8a\", \"armeabi-v7a\", \"x86_64\"\n        }\n\n        externalNativeBuild {\n            cmake {\n                arguments \"-DANDROID_STL=c++_shared\"    // Specify Android STL\n                arguments \"-DBUILD_SHARED_LIBS=true\"    // Build shared object\n                arguments \"-DFMT_TEST=false\"            // Skip test\n                arguments \"-DFMT_DOC=false\"             // Skip documentation\n                cppFlags  \"-std=c++17\"\n                targets   \"fmt\"\n            }\n        }\n        println(externalNativeBuild.cmake.cppFlags)\n        println(externalNativeBuild.cmake.arguments)\n    }\n\n    // External Native build\n    //  - Use existing CMakeList.txt\n    //  - Give path to CMake. This gradle file should be \n    //    neighbor of the top level cmake\n    externalNativeBuild {\n        cmake {\n            version = \"3.22.1\"\n            path \"${rootDir}/CMakeLists.txt\"\n            // buildStagingDirectory \"./build\"  // Custom path for cmake output\n        }\n    }\n    \n    sourceSets{\n        // Android Manifest for Gradle\n        main {\n            manifest.srcFile \"AndroidManifest.xml\"\n        }\n    }\n\n    // https://developer.android.com/studio/build/native-dependencies#build_system_configuration\n    buildFeatures {\n        prefab = true\n        prefabPublishing = true\n    }\n    prefab {\n        fmt {\n            headers = \"${rootDir}/include\"\n        }\n    }\n}\n\nassemble.doLast\n{\n    /*\n    *- Instead of `ninja install`, Gradle will deploy the files.\n    *- We are doing this since FMT is dependent to the ANDROID_STL after build\n    */\n    copy {\n        from \"build/intermediates/cmake\"\n        into \"${rootDir}/libs\"\n    }\n    // Copy debug binaries\n    copy {\n        from \"${rootDir}/libs/debug/obj\"\n        into \"${rootDir}/libs/debug\"\n    }\n    // Copy Release binaries\n    copy {\n        from \"${rootDir}/libs/release/obj\"\n        into \"${rootDir}/libs/release\"\n    }\n    // Remove empty directory\n    delete \"${rootDir}/libs/debug/obj\"\n    delete \"${rootDir}/libs/release/obj\"\n\n    // Copy AAR files. Notice that the aar is named after the folder of this script.\n    copy {\n        from \"build/outputs/aar/support-release.aar\"\n        into \"${rootDir}/libs\"\n        rename \"support-release.aar\", \"fmt-release.aar\"\n    }\n    copy {\n        from \"build/outputs/aar/support-debug.aar\"\n        into \"${rootDir}/libs\"\n        rename \"support-debug.aar\", \"fmt-debug.aar\"\n    }\n}\n"
  },
  {
    "path": "support/check-commits",
    "content": "#!/usr/bin/env python3\n\n\"\"\"Compile source on a range of commits\n\nUsage:\n  check-commits <start> <source>\n\"\"\"\n\nimport docopt, os, sys, tempfile\nfrom subprocess import check_call, check_output, run\n\nargs = docopt.docopt(__doc__)\nstart = args.get('<start>')\nsource = args.get('<source>')\n\ncwd = os.getcwd()\n\nwith tempfile.TemporaryDirectory() as work_dir:\n  check_call(['git', 'clone', 'https://github.com/fmtlib/fmt.git'],\n             cwd=work_dir)\n  repo_dir = os.path.join(work_dir, 'fmt')\n  commits = check_output(\n    ['git', 'rev-list', f'{start}..HEAD', '--abbrev-commit',\n     '--', 'include', 'src'],\n    text=True, cwd=repo_dir).rstrip().split('\\n')\n  commits.reverse()\n  print('Time\\tCommit')\n  for commit in commits:\n    check_call(['git', '-c', 'advice.detachedHead=false', 'checkout', commit],\n               cwd=repo_dir)\n    returncode = run(\n      ['c++', '-std=c++11', '-O3', '-DNDEBUG', '-I', 'include',\n       'src/format.cc', os.path.join(cwd, source)], cwd=repo_dir).returncode\n    if returncode != 0:\n      continue\n    times = []\n    for i in range(5):\n      output = check_output([os.path.join(repo_dir, 'a.out')], text=True)\n      times.append(float(output))\n    message = check_output(['git', 'log', '-1', '--pretty=format:%s', commit],\n                           cwd=repo_dir, text=True)\n    print(f'{min(times)}\\t{commit} {message[:40]}')\n    sys.stdout.flush()\n"
  },
  {
    "path": "support/cmake/FindSetEnv.cmake",
    "content": "# A CMake script to find SetEnv.cmd.\n\nfind_program(\n  WINSDK_SETENV\n  NAMES SetEnv.cmd\n  PATHS\n    \"[HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows;CurrentInstallFolder]/bin\"\n)\nif (WINSDK_SETENV AND PRINT_PATH)\n  execute_process(COMMAND ${CMAKE_COMMAND} -E echo \"${WINSDK_SETENV}\")\nendif ()\n"
  },
  {
    "path": "support/cmake/JoinPaths.cmake",
    "content": "# This module provides function for joining paths known from from most languages\n#\n# Original license:\n# SPDX-License-Identifier: (MIT OR CC0-1.0)\n# Explicit permission given to distribute this module under the terms of the\n# project as described in /LICENSE.md.\n# Copyright 2020 Jan Tojnar\n# https://github.com/jtojnar/cmake-snips\n#\n# Modelled after Python’s os.path.join\n# https://docs.python.org/3.7/library/os.path.html#os.path.join\n# Windows not supported\n\nfunction (join_paths joined_path first_path_segment)\n  set(temp_path \"${first_path_segment}\")\n  foreach (current_segment IN LISTS ARGN)\n    if (NOT (\"${current_segment}\" STREQUAL \"\"))\n      if (IS_ABSOLUTE \"${current_segment}\")\n        set(temp_path \"${current_segment}\")\n      else ()\n        set(temp_path \"${temp_path}/${current_segment}\")\n      endif ()\n    endif ()\n  endforeach ()\n  set(${joined_path}\n      \"${temp_path}\"\n      PARENT_SCOPE)\nendfunction ()\n"
  },
  {
    "path": "support/cmake/fmt-config.cmake.in",
    "content": "@PACKAGE_INIT@\n\nif (NOT TARGET fmt::fmt)\n  include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)\nendif ()\n\ncheck_required_components(fmt)\n"
  },
  {
    "path": "support/cmake/fmt.pc.in",
    "content": "prefix=@CMAKE_INSTALL_PREFIX@\nexec_prefix=@CMAKE_INSTALL_PREFIX@\nlibdir=@libdir_for_pc_file@\nincludedir=@includedir_for_pc_file@\n\nName: fmt\nDescription: A modern formatting library\nVersion: @FMT_VERSION@\nLibs: -L${libdir} -l@FMT_LIB_NAME@\nCflags: -I${includedir}\n\n"
  },
  {
    "path": "support/docopt.py",
    "content": "\"\"\"Pythonic command-line interface parser that will make you smile.\n\n * http://docopt.org\n * Repository and issue-tracker: https://github.com/docopt/docopt\n * Licensed under terms of MIT license (see LICENSE-MIT)\n * Copyright (c) 2013 Vladimir Keleshev, vladimir@keleshev.com\n\n\"\"\"\nimport sys\nimport re\n\n\n__all__ = ['docopt']\n__version__ = '0.6.1'\n\n\nclass DocoptLanguageError(Exception):\n\n    \"\"\"Error in construction of usage-message by developer.\"\"\"\n\n\nclass DocoptExit(SystemExit):\n\n    \"\"\"Exit in case user invoked program with incorrect arguments.\"\"\"\n\n    usage = ''\n\n    def __init__(self, message=''):\n        SystemExit.__init__(self, (message + '\\n' + self.usage).strip())\n\n\nclass Pattern(object):\n\n    def __eq__(self, other):\n        return repr(self) == repr(other)\n\n    def __hash__(self):\n        return hash(repr(self))\n\n    def fix(self):\n        self.fix_identities()\n        self.fix_repeating_arguments()\n        return self\n\n    def fix_identities(self, uniq=None):\n        \"\"\"Make pattern-tree tips point to same object if they are equal.\"\"\"\n        if not hasattr(self, 'children'):\n            return self\n        uniq = list(set(self.flat())) if uniq is None else uniq\n        for i, child in enumerate(self.children):\n            if not hasattr(child, 'children'):\n                assert child in uniq\n                self.children[i] = uniq[uniq.index(child)]\n            else:\n                child.fix_identities(uniq)\n\n    def fix_repeating_arguments(self):\n        \"\"\"Fix elements that should accumulate/increment values.\"\"\"\n        either = [list(child.children) for child in transform(self).children]\n        for case in either:\n            for e in [child for child in case if case.count(child) > 1]:\n                if type(e) is Argument or type(e) is Option and e.argcount:\n                    if e.value is None:\n                        e.value = []\n                    elif type(e.value) is not list:\n                        e.value = e.value.split()\n                if type(e) is Command or type(e) is Option and e.argcount == 0:\n                    e.value = 0\n        return self\n\n\ndef transform(pattern):\n    \"\"\"Expand pattern into an (almost) equivalent one, but with single Either.\n\n    Example: ((-a | -b) (-c | -d)) => (-a -c | -a -d | -b -c | -b -d)\n    Quirks: [-a] => (-a), (-a...) => (-a -a)\n\n    \"\"\"\n    result = []\n    groups = [[pattern]]\n    while groups:\n        children = groups.pop(0)\n        parents = [Required, Optional, OptionsShortcut, Either, OneOrMore]\n        if any(t in map(type, children) for t in parents):\n            child = [c for c in children if type(c) in parents][0]\n            children.remove(child)\n            if type(child) is Either:\n                for c in child.children:\n                    groups.append([c] + children)\n            elif type(child) is OneOrMore:\n                groups.append(child.children * 2 + children)\n            else:\n                groups.append(child.children + children)\n        else:\n            result.append(children)\n    return Either(*[Required(*e) for e in result])\n\n\nclass LeafPattern(Pattern):\n\n    \"\"\"Leaf/terminal node of a pattern tree.\"\"\"\n\n    def __init__(self, name, value=None):\n        self.name, self.value = name, value\n\n    def __repr__(self):\n        return '%s(%r, %r)' % (self.__class__.__name__, self.name, self.value)\n\n    def flat(self, *types):\n        return [self] if not types or type(self) in types else []\n\n    def match(self, left, collected=None):\n        collected = [] if collected is None else collected\n        pos, match = self.single_match(left)\n        if match is None:\n            return False, left, collected\n        left_ = left[:pos] + left[pos + 1:]\n        same_name = [a for a in collected if a.name == self.name]\n        if type(self.value) in (int, list):\n            if type(self.value) is int:\n                increment = 1\n            else:\n                increment = ([match.value] if type(match.value) is str\n                             else match.value)\n            if not same_name:\n                match.value = increment\n                return True, left_, collected + [match]\n            same_name[0].value += increment\n            return True, left_, collected\n        return True, left_, collected + [match]\n\n\nclass BranchPattern(Pattern):\n\n    \"\"\"Branch/inner node of a pattern tree.\"\"\"\n\n    def __init__(self, *children):\n        self.children = list(children)\n\n    def __repr__(self):\n        return '%s(%s)' % (self.__class__.__name__,\n                           ', '.join(repr(a) for a in self.children))\n\n    def flat(self, *types):\n        if type(self) in types:\n            return [self]\n        return sum([child.flat(*types) for child in self.children], [])\n\n\nclass Argument(LeafPattern):\n\n    def single_match(self, left):\n        for n, pattern in enumerate(left):\n            if type(pattern) is Argument:\n                return n, Argument(self.name, pattern.value)\n        return None, None\n\n    @classmethod\n    def parse(class_, source):\n        name = re.findall('(<\\S*?>)', source)[0]\n        value = re.findall('\\[default: (.*)\\]', source, flags=re.I)\n        return class_(name, value[0] if value else None)\n\n\nclass Command(Argument):\n\n    def __init__(self, name, value=False):\n        self.name, self.value = name, value\n\n    def single_match(self, left):\n        for n, pattern in enumerate(left):\n            if type(pattern) is Argument:\n                if pattern.value == self.name:\n                    return n, Command(self.name, True)\n                else:\n                    break\n        return None, None\n\n\nclass Option(LeafPattern):\n\n    def __init__(self, short=None, long=None, argcount=0, value=False):\n        assert argcount in (0, 1)\n        self.short, self.long, self.argcount = short, long, argcount\n        self.value = None if value is False and argcount else value\n\n    @classmethod\n    def parse(class_, option_description):\n        short, long, argcount, value = None, None, 0, False\n        options, _, description = option_description.strip().partition('  ')\n        options = options.replace(',', ' ').replace('=', ' ')\n        for s in options.split():\n            if s.startswith('--'):\n                long = s\n            elif s.startswith('-'):\n                short = s\n            else:\n                argcount = 1\n        if argcount:\n            matched = re.findall('\\[default: (.*)\\]', description, flags=re.I)\n            value = matched[0] if matched else None\n        return class_(short, long, argcount, value)\n\n    def single_match(self, left):\n        for n, pattern in enumerate(left):\n            if self.name == pattern.name:\n                return n, pattern\n        return None, None\n\n    @property\n    def name(self):\n        return self.long or self.short\n\n    def __repr__(self):\n        return 'Option(%r, %r, %r, %r)' % (self.short, self.long,\n                                           self.argcount, self.value)\n\n\nclass Required(BranchPattern):\n\n    def match(self, left, collected=None):\n        collected = [] if collected is None else collected\n        l = left\n        c = collected\n        for pattern in self.children:\n            matched, l, c = pattern.match(l, c)\n            if not matched:\n                return False, left, collected\n        return True, l, c\n\n\nclass Optional(BranchPattern):\n\n    def match(self, left, collected=None):\n        collected = [] if collected is None else collected\n        for pattern in self.children:\n            m, left, collected = pattern.match(left, collected)\n        return True, left, collected\n\n\nclass OptionsShortcut(Optional):\n\n    \"\"\"Marker/placeholder for [options] shortcut.\"\"\"\n\n\nclass OneOrMore(BranchPattern):\n\n    def match(self, left, collected=None):\n        assert len(self.children) == 1\n        collected = [] if collected is None else collected\n        l = left\n        c = collected\n        l_ = None\n        matched = True\n        times = 0\n        while matched:\n            # could it be that something didn't match but changed l or c?\n            matched, l, c = self.children[0].match(l, c)\n            times += 1 if matched else 0\n            if l_ == l:\n                break\n            l_ = l\n        if times >= 1:\n            return True, l, c\n        return False, left, collected\n\n\nclass Either(BranchPattern):\n\n    def match(self, left, collected=None):\n        collected = [] if collected is None else collected\n        outcomes = []\n        for pattern in self.children:\n            matched, _, _ = outcome = pattern.match(left, collected)\n            if matched:\n                outcomes.append(outcome)\n        if outcomes:\n            return min(outcomes, key=lambda outcome: len(outcome[1]))\n        return False, left, collected\n\n\nclass Tokens(list):\n\n    def __init__(self, source, error=DocoptExit):\n        self += source.split() if hasattr(source, 'split') else source\n        self.error = error\n\n    @staticmethod\n    def from_pattern(source):\n        source = re.sub(r'([\\[\\]\\(\\)\\|]|\\.\\.\\.)', r' \\1 ', source)\n        source = [s for s in re.split('\\s+|(\\S*<.*?>)', source) if s]\n        return Tokens(source, error=DocoptLanguageError)\n\n    def move(self):\n        return self.pop(0) if len(self) else None\n\n    def current(self):\n        return self[0] if len(self) else None\n\n\ndef parse_long(tokens, options):\n    \"\"\"long ::= '--' chars [ ( ' ' | '=' ) chars ] ;\"\"\"\n    long, eq, value = tokens.move().partition('=')\n    assert long.startswith('--')\n    value = None if eq == value == '' else value\n    similar = [o for o in options if o.long == long]\n    if tokens.error is DocoptExit and similar == []:  # if no exact match\n        similar = [o for o in options if o.long and o.long.startswith(long)]\n    if len(similar) > 1:  # might be simply specified ambiguously 2+ times?\n        raise tokens.error('%s is not a unique prefix: %s?' %\n                           (long, ', '.join(o.long for o in similar)))\n    elif len(similar) < 1:\n        argcount = 1 if eq == '=' else 0\n        o = Option(None, long, argcount)\n        options.append(o)\n        if tokens.error is DocoptExit:\n            o = Option(None, long, argcount, value if argcount else True)\n    else:\n        o = Option(similar[0].short, similar[0].long,\n                   similar[0].argcount, similar[0].value)\n        if o.argcount == 0:\n            if value is not None:\n                raise tokens.error('%s must not have an argument' % o.long)\n        else:\n            if value is None:\n                if tokens.current() in [None, '--']:\n                    raise tokens.error('%s requires argument' % o.long)\n                value = tokens.move()\n        if tokens.error is DocoptExit:\n            o.value = value if value is not None else True\n    return [o]\n\n\ndef parse_shorts(tokens, options):\n    \"\"\"shorts ::= '-' ( chars )* [ [ ' ' ] chars ] ;\"\"\"\n    token = tokens.move()\n    assert token.startswith('-') and not token.startswith('--')\n    left = token.lstrip('-')\n    parsed = []\n    while left != '':\n        short, left = '-' + left[0], left[1:]\n        similar = [o for o in options if o.short == short]\n        if len(similar) > 1:\n            raise tokens.error('%s is specified ambiguously %d times' %\n                               (short, len(similar)))\n        elif len(similar) < 1:\n            o = Option(short, None, 0)\n            options.append(o)\n            if tokens.error is DocoptExit:\n                o = Option(short, None, 0, True)\n        else:  # why copying is necessary here?\n            o = Option(short, similar[0].long,\n                       similar[0].argcount, similar[0].value)\n            value = None\n            if o.argcount != 0:\n                if left == '':\n                    if tokens.current() in [None, '--']:\n                        raise tokens.error('%s requires argument' % short)\n                    value = tokens.move()\n                else:\n                    value = left\n                    left = ''\n            if tokens.error is DocoptExit:\n                o.value = value if value is not None else True\n        parsed.append(o)\n    return parsed\n\n\ndef parse_pattern(source, options):\n    tokens = Tokens.from_pattern(source)\n    result = parse_expr(tokens, options)\n    if tokens.current() is not None:\n        raise tokens.error('unexpected ending: %r' % ' '.join(tokens))\n    return Required(*result)\n\n\ndef parse_expr(tokens, options):\n    \"\"\"expr ::= seq ( '|' seq )* ;\"\"\"\n    seq = parse_seq(tokens, options)\n    if tokens.current() != '|':\n        return seq\n    result = [Required(*seq)] if len(seq) > 1 else seq\n    while tokens.current() == '|':\n        tokens.move()\n        seq = parse_seq(tokens, options)\n        result += [Required(*seq)] if len(seq) > 1 else seq\n    return [Either(*result)] if len(result) > 1 else result\n\n\ndef parse_seq(tokens, options):\n    \"\"\"seq ::= ( atom [ '...' ] )* ;\"\"\"\n    result = []\n    while tokens.current() not in [None, ']', ')', '|']:\n        atom = parse_atom(tokens, options)\n        if tokens.current() == '...':\n            atom = [OneOrMore(*atom)]\n            tokens.move()\n        result += atom\n    return result\n\n\ndef parse_atom(tokens, options):\n    \"\"\"atom ::= '(' expr ')' | '[' expr ']' | 'options'\n             | long | shorts | argument | command ;\n    \"\"\"\n    token = tokens.current()\n    result = []\n    if token in '([':\n        tokens.move()\n        matching, pattern = {'(': [')', Required], '[': [']', Optional]}[token]\n        result = pattern(*parse_expr(tokens, options))\n        if tokens.move() != matching:\n            raise tokens.error(\"unmatched '%s'\" % token)\n        return [result]\n    elif token == 'options':\n        tokens.move()\n        return [OptionsShortcut()]\n    elif token.startswith('--') and token != '--':\n        return parse_long(tokens, options)\n    elif token.startswith('-') and token not in ('-', '--'):\n        return parse_shorts(tokens, options)\n    elif token.startswith('<') and token.endswith('>') or token.isupper():\n        return [Argument(tokens.move())]\n    else:\n        return [Command(tokens.move())]\n\n\ndef parse_argv(tokens, options, options_first=False):\n    \"\"\"Parse command-line argument vector.\n\n    If options_first:\n        argv ::= [ long | shorts ]* [ argument ]* [ '--' [ argument ]* ] ;\n    else:\n        argv ::= [ long | shorts | argument ]* [ '--' [ argument ]* ] ;\n\n    \"\"\"\n    parsed = []\n    while tokens.current() is not None:\n        if tokens.current() == '--':\n            return parsed + [Argument(None, v) for v in tokens]\n        elif tokens.current().startswith('--'):\n            parsed += parse_long(tokens, options)\n        elif tokens.current().startswith('-') and tokens.current() != '-':\n            parsed += parse_shorts(tokens, options)\n        elif options_first:\n            return parsed + [Argument(None, v) for v in tokens]\n        else:\n            parsed.append(Argument(None, tokens.move()))\n    return parsed\n\n\ndef parse_defaults(doc):\n    defaults = []\n    for s in parse_section('options:', doc):\n        # FIXME corner case \"bla: options: --foo\"\n        _, _, s = s.partition(':')  # get rid of \"options:\"\n        split = re.split('\\n[ \\t]*(-\\S+?)', '\\n' + s)[1:]\n        split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])]\n        options = [Option.parse(s) for s in split if s.startswith('-')]\n        defaults += options\n    return defaults\n\n\ndef parse_section(name, source):\n    pattern = re.compile('^([^\\n]*' + name + '[^\\n]*\\n?(?:[ \\t].*?(?:\\n|$))*)',\n                         re.IGNORECASE | re.MULTILINE)\n    return [s.strip() for s in pattern.findall(source)]\n\n\ndef formal_usage(section):\n    _, _, section = section.partition(':')  # drop \"usage:\"\n    pu = section.split()\n    return '( ' + ' '.join(') | (' if s == pu[0] else s for s in pu[1:]) + ' )'\n\n\ndef extras(help, version, options, doc):\n    if help and any((o.name in ('-h', '--help')) and o.value for o in options):\n        print(doc.strip(\"\\n\"))\n        sys.exit()\n    if version and any(o.name == '--version' and o.value for o in options):\n        print(version)\n        sys.exit()\n\n\nclass Dict(dict):\n    def __repr__(self):\n        return '{%s}' % ',\\n '.join('%r: %r' % i for i in sorted(self.items()))\n\n\ndef docopt(doc, argv=None, help=True, version=None, options_first=False):\n    \"\"\"Parse `argv` based on command-line interface described in `doc`.\n\n    `docopt` creates your command-line interface based on its\n    description that you pass as `doc`. Such description can contain\n    --options, <positional-argument>, commands, which could be\n    [optional], (required), (mutually | exclusive) or repeated...\n\n    Parameters\n    ----------\n    doc : str\n        Description of your command-line interface.\n    argv : list of str, optional\n        Argument vector to be parsed. sys.argv[1:] is used if not\n        provided.\n    help : bool (default: True)\n        Set to False to disable automatic help on -h or --help\n        options.\n    version : any object\n        If passed, the object will be printed if --version is in\n        `argv`.\n    options_first : bool (default: False)\n        Set to True to require options precede positional arguments,\n        i.e. to forbid options and positional arguments intermix.\n\n    Returns\n    -------\n    args : dict\n        A dictionary, where keys are names of command-line elements\n        such as e.g. \"--verbose\" and \"<path>\", and values are the\n        parsed values of those elements.\n\n    Example\n    -------\n    >>> from docopt import docopt\n    >>> doc = '''\n    ... Usage:\n    ...     my_program tcp <host> <port> [--timeout=<seconds>]\n    ...     my_program serial <port> [--baud=<n>] [--timeout=<seconds>]\n    ...     my_program (-h | --help | --version)\n    ...\n    ... Options:\n    ...     -h, --help  Show this screen and exit.\n    ...     --baud=<n>  Baudrate [default: 9600]\n    ... '''\n    >>> argv = ['tcp', '127.0.0.1', '80', '--timeout', '30']\n    >>> docopt(doc, argv)\n    {'--baud': '9600',\n     '--help': False,\n     '--timeout': '30',\n     '--version': False,\n     '<host>': '127.0.0.1',\n     '<port>': '80',\n     'serial': False,\n     'tcp': True}\n\n    See also\n    --------\n    * For video introduction see http://docopt.org\n    * Full documentation is available in README.rst as well as online\n      at https://github.com/docopt/docopt#readme\n\n    \"\"\"\n    argv = sys.argv[1:] if argv is None else argv\n\n    usage_sections = parse_section('usage:', doc)\n    if len(usage_sections) == 0:\n        raise DocoptLanguageError('\"usage:\" (case-insensitive) not found.')\n    if len(usage_sections) > 1:\n        raise DocoptLanguageError('More than one \"usage:\" (case-insensitive).')\n    DocoptExit.usage = usage_sections[0]\n\n    options = parse_defaults(doc)\n    pattern = parse_pattern(formal_usage(DocoptExit.usage), options)\n    # [default] syntax for argument is disabled\n    #for a in pattern.flat(Argument):\n    #    same_name = [d for d in arguments if d.name == a.name]\n    #    if same_name:\n    #        a.value = same_name[0].value\n    argv = parse_argv(Tokens(argv), list(options), options_first)\n    pattern_options = set(pattern.flat(Option))\n    for options_shortcut in pattern.flat(OptionsShortcut):\n        doc_options = parse_defaults(doc)\n        options_shortcut.children = list(set(doc_options) - pattern_options)\n        #if any_options:\n        #    options_shortcut.children += [Option(o.short, o.long, o.argcount)\n        #                    for o in argv if type(o) is Option]\n    extras(help, version, argv, doc)\n    matched, left, collected = pattern.fix().match(argv)\n    if matched and left == []:  # better error message if left?\n        return Dict((a.name, a.value) for a in (pattern.flat() + collected))\n    raise DocoptExit()\n"
  },
  {
    "path": "support/gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\n# This downloads Gradle 9.3 automatically.\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-9.3.0-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "support/gradle.properties",
    "content": "# Required for modern Android builds (AGP 8.0+)\nandroid.useAndroidX=true\n\n# Improves build performance\nandroid.nonTransitiveRClass=true\n\n# Memory settings for the build process\norg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g\n"
  },
  {
    "path": "support/mkdocs",
    "content": "#!/usr/bin/env python3\n# A script to invoke mkdocs with the correct environment.\n# Additionally supports deploying via mike:\n#   ./mkdocs deploy [mike-deploy-options]\n# For example:\n#   ./mkdocs deploy <version>\n# This will checkout the website to fmt/build/fmt.dev and deploy documentation\n# <version> there.\n\nimport errno, os, shutil, sys\nfrom subprocess import call\n\nsupport_dir = os.path.dirname(os.path.normpath(__file__))\nbuild_dir = os.path.join(os.path.dirname(support_dir), 'build')\n\n# Set PYTHONPATH for the mkdocstrings handler.\nenv = os.environ.copy()\npath = env.get('PYTHONPATH')\nenv['PYTHONPATH'] = \\\n  (path + ':' if path else '') + os.path.join(support_dir, 'python')\n\nredirect_page = \\\n'''<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <title>Redirecting</title>\n  <noscript>\n    <meta http-equiv=\"refresh\" content=\"1; url=11.0/\" />\n  </noscript>\n  <script>\n    window.location.replace(\n      \"api/\" + window.location.search + window.location.hash\n    );\n  </script>\n</head>\n<body>\n  Redirecting to <a href=\"api/\">api</a>...\n</body>\n</html>\n'''\n\nconfig_path = os.path.join(support_dir, 'mkdocs.yml')\nargs = sys.argv[1:]\nif len(args) > 0:\n  command = args[0]\n  if command == 'deploy' or command == 'set-default':\n    git_url = 'https://github.com/' if 'CI' in os.environ else 'git@github.com:'\n    site_repo = git_url + 'fmtlib/fmt.dev.git'\n\n    site_dir = os.path.join(build_dir, 'fmt.dev')\n    try:\n      shutil.rmtree(site_dir)\n    except OSError as e:\n      if e.errno == errno.ENOENT:\n        pass\n    ret = call(['git', 'clone', '--depth=1', site_repo, site_dir])\n    if ret != 0:\n      sys.exit(ret)\n\n    # Copy the config to the build dir because the site is built relative to it.\n    config_build_path = os.path.join(build_dir, 'mkdocs.yml')\n    shutil.copyfile(config_path, config_build_path)\n\n    version = args[1]\n    ret = call(['mike'] + args + ['--config-file', config_build_path,\n               '--branch', 'master'], cwd=site_dir, env=env)\n    if ret != 0 or version == 'dev':\n      sys.exit(ret)\n    current_doc_path = os.path.join(site_dir, version)\n    # mike stages files added by deploy for deletion for unclear reason,\n    # undo it.\n    ret = call(['git', 'reset', '--hard'], cwd=site_dir)\n    if False:\n      os.makedirs(current_doc_path, exist_ok=True)\n      redirect_page_path = os.path.join(current_doc_path, 'api.html')\n      with open(redirect_page_path, \"w\") as file:\n        file.write(redirect_page)\n      ret = call(['git', 'add', redirect_page_path], cwd=site_dir)\n      if ret != 0:\n        sys.exit(ret)\n      ret = call(['git', 'commit', '--amend', '--no-edit'], cwd=site_dir)\n    sys.exit(ret)\n  elif not command.startswith('-'):\n    args += ['-f', config_path]\nsys.exit(call(['mkdocs'] + args, env=env))\n"
  },
  {
    "path": "support/mkdocs.yml",
    "content": "site_name: '{fmt}'\n\ndocs_dir: ../doc\n\nrepo_url: https://github.com/fmtlib/fmt\n\ntheme:\n  name: material\n  features:\n    - navigation.tabs\n    - navigation.top\n    - toc.integrate\n\nextra_javascript:\n  - https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js\n  - fmt.js\n\nextra_css:\n  - https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css\n  - fmt.css\n\nmarkdown_extensions:\n  - pymdownx.highlight:\n      # Use JavaScript syntax highlighter instead of Pygments because it\n      # automatically applies to code blocks extracted through Doxygen.\n      use_pygments: false\n      anchor_linenums: true\n      line_spans: __span\n      pygments_lang_class: true\n  - pymdownx.inlinehilite\n  - pymdownx.snippets\n\nplugins:\n  - search\n  - mkdocstrings:\n      default_handler: cxx\nnav:\n  - Home: index.md\n  - Get Started: get-started.md\n  - API: api.md\n  - Syntax: syntax.md\n\nexclude_docs: ChangeLog-old.md\n\nextra:\n  version:\n    provider: mike\n  generator: false\n"
  },
  {
    "path": "support/printable.py",
    "content": "#!/usr/bin/env python3\n\n# This script is based on\n# https://github.com/rust-lang/rust/blob/master/library/core/src/unicode/printable.py\n# distributed under https://github.com/rust-lang/rust/blob/master/LICENSE-MIT.\n\n# This script uses the following Unicode tables:\n# - UnicodeData.txt\n\n\nfrom collections import namedtuple\nimport csv\nimport os\nimport subprocess\n\nNUM_CODEPOINTS=0x110000\n\ndef to_ranges(iter):\n    current = None\n    for i in iter:\n        if current is None or i != current[1] or i in (0x10000, 0x20000):\n            if current is not None:\n                yield tuple(current)\n            current = [i, i + 1]\n        else:\n            current[1] += 1\n    if current is not None:\n        yield tuple(current)\n\ndef get_escaped(codepoints):\n    for c in codepoints:\n        if (c.class_ or \"Cn\") in \"Cc Cf Cs Co Cn Zl Zp Zs\".split() and c.value != ord(' '):\n            yield c.value\n\ndef get_file(f):\n    try:\n        return open(os.path.basename(f))\n    except FileNotFoundError:\n        subprocess.run([\"curl\", \"-O\", f], check=True)\n        return open(os.path.basename(f))\n\nCodepoint = namedtuple('Codepoint', 'value class_')\n\ndef get_codepoints(f):\n    r = csv.reader(f, delimiter=\";\")\n    prev_codepoint = 0\n    class_first = None\n    for row in r:\n        codepoint = int(row[0], 16)\n        name = row[1]\n        class_ = row[2]\n\n        if class_first is not None:\n            if not name.endswith(\"Last>\"):\n                raise ValueError(\"Missing Last after First\")\n\n        for c in range(prev_codepoint + 1, codepoint):\n            yield Codepoint(c, class_first)\n\n        class_first = None\n        if name.endswith(\"First>\"):\n            class_first = class_\n\n        yield Codepoint(codepoint, class_)\n        prev_codepoint = codepoint\n\n    if class_first is not None:\n        raise ValueError(\"Missing Last after First\")\n\n    for c in range(prev_codepoint + 1, NUM_CODEPOINTS):\n        yield Codepoint(c, None)\n\ndef compress_singletons(singletons):\n    uppers = [] # (upper, # items in lowers)\n    lowers = []\n\n    for i in singletons:\n        upper = i >> 8\n        lower = i & 0xff\n        if len(uppers) == 0 or uppers[-1][0] != upper:\n            uppers.append((upper, 1))\n        else:\n            upper, count = uppers[-1]\n            uppers[-1] = upper, count + 1\n        lowers.append(lower)\n\n    return uppers, lowers\n\ndef compress_normal(normal):\n    # lengths 0x00..0x7f are encoded as 00, 01, ..., 7e, 7f\n    # lengths 0x80..0x7fff are encoded as 80 80, 80 81, ..., ff fe, ff ff\n    compressed = [] # [truelen, (truelenaux), falselen, (falselenaux)]\n\n    prev_start = 0\n    for start, count in normal:\n        truelen = start - prev_start\n        falselen = count\n        prev_start = start + count\n\n        assert truelen < 0x8000 and falselen < 0x8000\n        entry = []\n        if truelen > 0x7f:\n            entry.append(0x80 | (truelen >> 8))\n            entry.append(truelen & 0xff)\n        else:\n            entry.append(truelen & 0x7f)\n        if falselen > 0x7f:\n            entry.append(0x80 | (falselen >> 8))\n            entry.append(falselen & 0xff)\n        else:\n            entry.append(falselen & 0x7f)\n\n        compressed.append(entry)\n\n    return compressed\n\ndef print_singletons(uppers, lowers, uppersname, lowersname):\n    print(\"  static constexpr singleton {}[] = {{\".format(uppersname))\n    for u, c in uppers:\n        print(\"    {{{:#04x}, {}}},\".format(u, c))\n    print(\"  };\")\n    print(\"  static constexpr unsigned char {}[] = {{\".format(lowersname))\n    for i in range(0, len(lowers), 8):\n        print(\"    {}\".format(\" \".join(\"{:#04x},\".format(l) for l in lowers[i:i+8])))\n    print(\"  };\")\n\ndef print_normal(normal, normalname):\n    print(\"  static constexpr unsigned char {}[] = {{\".format(normalname))\n    for v in normal:\n        print(\"    {}\".format(\" \".join(\"{:#04x},\".format(i) for i in v)))\n    print(\"  };\")\n\ndef main():\n    file = get_file(\"https://www.unicode.org/Public/UNIDATA/UnicodeData.txt\")\n\n    codepoints = get_codepoints(file)\n\n    CUTOFF=0x10000\n    singletons0 = []\n    singletons1 = []\n    normal0 = []\n    normal1 = []\n    extra = []\n\n    for a, b in to_ranges(get_escaped(codepoints)):\n        if a > 2 * CUTOFF:\n            extra.append((a, b - a))\n        elif a == b - 1:\n            if a & CUTOFF:\n                singletons1.append(a & ~CUTOFF)\n            else:\n                singletons0.append(a)\n        elif a == b - 2:\n            if a & CUTOFF:\n                singletons1.append(a & ~CUTOFF)\n                singletons1.append((a + 1) & ~CUTOFF)\n            else:\n                singletons0.append(a)\n                singletons0.append(a + 1)\n        else:\n            if a >= 2 * CUTOFF:\n                extra.append((a, b - a))\n            elif a & CUTOFF:\n                normal1.append((a & ~CUTOFF, b - a))\n            else:\n                normal0.append((a, b - a))\n\n    singletons0u, singletons0l = compress_singletons(singletons0)\n    singletons1u, singletons1l = compress_singletons(singletons1)\n    normal0 = compress_normal(normal0)\n    normal1 = compress_normal(normal1)\n\n    print(\"\"\"\\\nFMT_FUNC auto is_printable(uint32_t cp) -> bool {\\\n\"\"\")\n    print_singletons(singletons0u, singletons0l, 'singletons0', 'singletons0_lower')\n    print_singletons(singletons1u, singletons1l, 'singletons1', 'singletons1_lower')\n    print_normal(normal0, 'normal0')\n    print_normal(normal1, 'normal1')\n    print(\"\"\"\\\n  auto lower = static_cast<uint16_t>(cp);\n  if (cp < 0x10000) {\n    return is_printable(lower, singletons0,\n                        sizeof(singletons0) / sizeof(*singletons0),\n                        singletons0_lower, normal0, sizeof(normal0));\n  }\n  if (cp < 0x20000) {\n    return is_printable(lower, singletons1,\n                        sizeof(singletons1) / sizeof(*singletons1),\n                        singletons1_lower, normal1, sizeof(normal1));\n  }\\\n\"\"\")\n    for a, b in extra:\n        print(\"  if (0x{:x} <= cp && cp < 0x{:x}) return false;\".format(a, a + b))\n    print(\"\"\"\\\n  return cp < 0x{:x};\n}}\\\n\"\"\".format(NUM_CODEPOINTS))\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "support/python/mkdocstrings_handlers/cxx/__init__.py",
    "content": "# A basic mkdocstrings handler for {fmt}.\n# Copyright (c) 2012 - present, Victor Zverovich\n# https://github.com/fmtlib/fmt/blob/master/LICENSE\n\n# pyright: strict\n\nimport os\nimport xml.etree.ElementTree as ET\nfrom pathlib import Path\nfrom subprocess import PIPE, STDOUT, CalledProcessError, Popen\n\nfrom markupsafe import Markup\nfrom mkdocstrings import BaseHandler\nfrom typing_extensions import TYPE_CHECKING, Any, ClassVar, final, override\n\nif TYPE_CHECKING:\n    from collections.abc import Mapping, MutableMapping\n\n    from mkdocs.config.defaults import MkDocsConfig\n    from mkdocstrings import CollectorItem, HandlerOptions\n\n\n@final\nclass Definition:\n    \"\"\"A definition extracted by Doxygen.\"\"\"\n\n    def __init__(\n        self,\n        name: str,\n        kind: \"str | None\" = None,\n        node: \"ET.Element | None\" = None,\n        is_member: bool = False,\n    ):\n        self.name = name\n        self.kind: \"str | None\" = None\n        if kind is not None:\n            self.kind = kind\n        elif node is not None:\n            self.kind = node.get(\"kind\")\n        self.desc: \"list[ET.Element[str]] | None\" = None\n        self.id: \"str | None\" = name if not is_member else None\n        self.members: \"list[Definition] | None\" = None\n        self.params: \"list[Definition] | None\" = None\n        self.template_params: \"list[Definition] | None\" = None\n        self.trailing_return_type: \"str | None\" = None\n        self.type: \"str | None\" = None\n\n\n# A map from Doxygen to HTML tags.\ntag_map = {\n    \"bold\": \"b\",\n    \"emphasis\": \"em\",\n    \"computeroutput\": \"code\",\n    \"para\": \"p\",\n    \"itemizedlist\": \"ul\",\n    \"listitem\": \"li\",\n}\n\n# A map from Doxygen tags to text.\ntag_text_map = {\"codeline\": \"\", \"highlight\": \"\", \"sp\": \" \"}\n\n\ndef escape_html(s: str) -> str:\n    return s.replace(\"<\", \"&lt;\")\n\n\n# Converts a node from doxygen to HTML format.\ndef convert_node(\n    node: ET.Element, tag: str, attrs: \"Mapping[str, str] | None\" = None\n) -> str:\n    if attrs is None:\n        attrs = {}\n\n    out: str = \"<\" + tag\n    for key, value in attrs.items():\n        out += \" \" + key + '=\"' + value + '\"'\n    out += \">\"\n    if node.text:\n        out += escape_html(node.text)\n    out += doxyxml2html(list(node))\n    out += \"</\" + tag + \">\"\n    if node.tail:\n        out += node.tail\n    return out\n\n\ndef doxyxml2html(nodes: \"list[ET.Element]\"):\n    out = \"\"\n    for n in nodes:\n        tag = tag_map.get(n.tag)\n        if tag:\n            out += convert_node(n, tag)\n            continue\n        if n.tag == \"programlisting\" or n.tag == \"verbatim\":\n            out += \"<pre>\"\n            out += convert_node(n, \"code\", {\"class\": \"language-cpp\"})\n            out += \"</pre>\"\n            continue\n        if n.tag == \"ulink\":\n            out += convert_node(n, \"a\", {\"href\": n.attrib[\"url\"]})\n            continue\n        out += tag_text_map[n.tag]\n    return out\n\n\ndef convert_template_params(node: ET.Element) -> \"list[Definition] | None\":\n    template_param_list = node.find(\"templateparamlist\")\n    if template_param_list is None:\n        return None\n    params: \"list[Definition]\" = []\n    for param_node in template_param_list.findall(\"param\"):\n        name = param_node.find(\"declname\")\n        if name is not None:\n            name = name.text\n        if name is None:\n            name = \"\"\n        param = Definition(name, \"param\")\n        param_type = param_node.find(\"type\")\n        if param_type is not None:\n            param.type = param_type.text\n        params.append(param)\n    return params\n\n\ndef get_description(node: ET.Element) -> list[ET.Element]:\n    return node.findall(\"briefdescription/para\") + node.findall(\n        \"detaileddescription/para\"\n    )\n\n\ndef normalize_type(type_: str) -> str:\n    type_ = type_.replace(\"< \", \"<\").replace(\" >\", \">\")\n    return type_.replace(\" &\", \"&\").replace(\" *\", \"*\")\n\n\ndef convert_type(type_: \"ET.Element | None\") -> \"str | None\":\n    if type_ is None:\n        return None\n    result = type_.text if type_.text else \"\"\n    for ref in type_:\n        if ref.text is None:\n            raise ValueError\n        result += ref.text\n        if ref.tail:\n            result += ref.tail\n    if type_.tail is None:\n        raise ValueError\n    result += type_.tail.strip()\n    return normalize_type(result)\n\n\ndef convert_params(func: ET.Element) -> list[Definition]:\n    params: \"list[Definition]\" = []\n    for p in func.findall(\"param\"):\n        declname = p.find(\"declname\")\n        if declname is None or declname.text is None:\n            raise ValueError\n        d = Definition(declname.text, \"param\")\n        d.type = convert_type(p.find(\"type\"))\n        params.append(d)\n    return params\n\n\ndef convert_return_type(d: Definition, node: ET.Element) -> None:\n    d.trailing_return_type = None\n    if d.type == \"auto\" or d.type == \"constexpr auto\":\n        argsstring = node.find(\"argsstring\")\n        if argsstring is None or argsstring.text is None:\n            raise ValueError\n        parts = argsstring.text.split(\" -> \")\n        if len(parts) > 1:\n            d.trailing_return_type = normalize_type(parts[1])\n\n\ndef render_param(param: Definition) -> str:\n    if param.type is None:\n        raise ValueError\n    return param.type + (f\"&nbsp;{param.name}\" if len(param.name) > 0 else \"\")\n\n\ndef render_decl(d: Definition) -> str:\n    text = \"\"\n    if d.id is not None:\n        text += f'<a id=\"{d.id}\">\\n'\n    text += '<pre><code class=\"language-cpp decl\">'\n\n    text += \"<div>\"\n    if d.template_params is not None:\n        text += \"template &lt;\"\n        text += \", \".join([render_param(p) for p in d.template_params])\n        text += \"&gt;\\n\"\n    text += \"</div>\"\n\n    text += \"<div>\"\n    end = \";\"\n    if d.kind is None:\n        raise ValueError\n    if d.kind == \"function\" or d.kind == \"variable\":\n        if d.type is None:\n            raise ValueError\n        text += d.type + \" \" if len(d.type) > 0 else \"\"\n    elif d.kind == \"typedef\":\n        text += \"using \"\n    elif d.kind == \"define\":\n        end = \"\"\n    else:\n        text += d.kind + \" \"\n    text += d.name\n\n    if d.params is not None:\n        params = \", \".join([\n            (p.type + \" \" if p.type else \"\") + p.name for p in d.params\n        ])\n        text += \"(\" + escape_html(params) + \")\"\n        if d.trailing_return_type:\n            text += \" -&NoBreak;>&nbsp;\" + escape_html(d.trailing_return_type)\n    elif d.kind == \"typedef\":\n        if d.type is None:\n            raise ValueError\n        text += \" = \" + escape_html(d.type)\n\n    text += end\n    text += \"</div>\"\n    text += \"</code></pre>\\n\"\n    if d.id is not None:\n        text += \"</a>\\n\"\n    return text\n\n\n@final\nclass CxxHandler(BaseHandler):\n    name: ClassVar[str] = \"cxx\"\n\n    domain: ClassVar[str] = \"cxx\"\n\n    def __init__(\n        self, config: \"Mapping[str, Any]\", base_dir: Path, **kwargs: Any\n    ) -> None:\n        super().__init__(**kwargs)\n\n        self.config = config\n        \"\"\"The handler configuration.\"\"\"\n        self.base_dir = base_dir\n        \"\"\"The base directory of the project.\"\"\"\n\n        headers = [\n            \"args.h\",\n            \"base.h\",\n            \"chrono.h\",\n            \"color.h\",\n            \"compile.h\",\n            \"format.h\",\n            \"os.h\",\n            \"ostream.h\",\n            \"printf.h\",\n            \"ranges.h\",\n            \"std.h\",\n            \"xchar.h\",\n        ]\n\n        # Run doxygen.\n        cmd = [\"doxygen\", \"-\"]\n        support_dir = Path(__file__).parents[3]\n        top_dir = os.path.dirname(support_dir)\n        include_dir = os.path.join(top_dir, \"include\", \"fmt\")\n        self._ns2doxyxml: \"dict[str, ET.ElementTree[ET.Element[str]]]\" = {}\n        build_dir = os.path.join(top_dir, \"build\")\n        os.makedirs(build_dir, exist_ok=True)\n        self._doxyxml_dir = os.path.join(build_dir, \"doxyxml\")\n        p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)\n        _, _ = p.communicate(\n            input=r\"\"\"\n            PROJECT_NAME     = fmt\n            GENERATE_XML     = YES\n            GENERATE_LATEX   = NO\n            GENERATE_HTML    = NO\n            INPUT            = {0}\n            XML_OUTPUT       = {1}\n            QUIET            = YES\n            AUTOLINK_SUPPORT = NO\n            MACRO_EXPANSION  = YES\n            PREDEFINED       = _WIN32=1 \\\n                               __linux__=1 \\\n                               FMT_ENABLE_IF(...)= \\\n                               FMT_USE_USER_LITERALS=1 \\\n                               FMT_USE_ALIAS_TEMPLATES=1 \\\n                               FMT_USE_NONTYPE_TEMPLATE_ARGS=1 \\\n                               FMT_API= \\\n                               \"FMT_BEGIN_NAMESPACE=namespace fmt {{\" \\\n                               \"FMT_END_NAMESPACE=}}\" \\\n                               \"FMT_DOC=1\"\n            \"\"\".format(\n                \" \".join([os.path.join(include_dir, h) for h in headers]),\n                self._doxyxml_dir,\n            ).encode(\"utf-8\")\n        )\n        if p.returncode != 0:\n            raise CalledProcessError(p.returncode, cmd)\n\n        # Merge all file-level XMLs into one to simplify search.\n        self._file_doxyxml: \"ET.ElementTree[ET.Element[str]] | None\" = None\n        for h in headers:\n            filename = h.replace(\".h\", \"_8h.xml\")\n            with open(os.path.join(self._doxyxml_dir, filename)) as f:\n                doxyxml = ET.parse(f)\n                if self._file_doxyxml is None:\n                    self._file_doxyxml = doxyxml\n                    continue\n                root = self._file_doxyxml.getroot()\n                for node in doxyxml.getroot():\n                    root.append(node)\n\n    def collect_compound(self, identifier: str, cls: \"list[ET.Element]\") -> Definition:\n        \"\"\"Collect a compound definition such as a struct.\"\"\"\n        refid = cls[0].get(\"refid\")\n        if refid is None:\n            raise ValueError\n        path = os.path.join(self._doxyxml_dir, refid + \".xml\")\n        with open(path) as f:\n            xml = ET.parse(f)\n            node = xml.find(\"compounddef\")\n            if node is None:\n                raise ValueError\n            d = Definition(identifier, node=node)\n            d.template_params = convert_template_params(node)\n            d.desc = get_description(node)\n            d.members = []\n            for m in node.findall(\n                'sectiondef[@kind=\"public-attrib\"]/memberdef'\n            ) + node.findall('sectiondef[@kind=\"public-func\"]/memberdef'):\n                name = m.find(\"name\")\n                if name is None or name.text is None:\n                    raise ValueError\n                name = name.text\n                # Doxygen incorrectly classifies members of private unnamed unions as\n                # public members of the containing class.\n                if name.endswith(\"_\"):\n                    continue\n                desc = get_description(m)\n                if len(desc) == 0:\n                    continue\n                kind = m.get(\"kind\")\n                member = Definition(name if name else \"\", kind=kind, is_member=True)\n                type_ = m.find(\"type\")\n                if type_ is None:\n                    raise ValueError\n                type_text = type_.text\n                member.type = type_text if type_text else \"\"\n                if kind == \"function\":\n                    member.params = convert_params(m)\n                    convert_return_type(member, m)\n                member.template_params = None\n                member.desc = desc\n                d.members.append(member)\n            return d\n\n    @override\n    def collect(self, identifier: str, options: \"Mapping[str, Any]\") -> Definition:\n        qual_name = \"fmt::\" + identifier\n\n        param_str = None\n        paren = qual_name.find(\"(\")\n        if paren > 0:\n            qual_name, param_str = qual_name[:paren], qual_name[paren + 1 : -1]\n\n        colons = qual_name.rfind(\"::\")\n        namespace, name = qual_name[:colons], qual_name[colons + 2 :]\n\n        # Load XML.\n        doxyxml = self._ns2doxyxml.get(namespace)\n        if doxyxml is None:\n            path = f\"namespace{namespace.replace('::', '_1_1')}.xml\"\n            with open(os.path.join(self._doxyxml_dir, path)) as f:\n                doxyxml = ET.parse(f)\n                self._ns2doxyxml[namespace] = doxyxml\n\n        nodes = doxyxml.findall(f\"compounddef/sectiondef/memberdef/name[.='{name}']/..\")\n        if len(nodes) == 0:\n            if self._file_doxyxml is None:\n                raise ValueError\n            nodes = self._file_doxyxml.findall(\n                f\"compounddef/sectiondef/memberdef/name[.='{name}']/..\"\n            )\n        candidates: \"list[str]\" = []\n        for node in nodes:\n            # Process a function or a typedef.\n            params: \"list[Definition] | None\" = None\n            d = Definition(name, node=node)\n            if d.kind == \"function\":\n                params = convert_params(node)\n                params_type: \"list[str]\" = []\n                for p in params:\n                    if p.type is None:\n                        raise ValueError\n                    else:\n                        params_type.append(p.type)\n                node_param_str = \", \".join(params_type)\n                if param_str and param_str != node_param_str:\n                    candidates.append(f\"{name}({node_param_str})\")\n                    continue\n            elif d.kind == \"define\":\n                params = []\n                for p in node.findall(\"param\"):\n                    defname = p.find(\"defname\")\n                    if defname is None or defname.text is None:\n                        raise ValueError\n                    param = Definition(defname.text, kind=\"param\")\n                    param.type = None\n                    params.append(param)\n            d.type = convert_type(node.find(\"type\"))\n            d.template_params = convert_template_params(node)\n            d.params = params\n            convert_return_type(d, node)\n            d.desc = get_description(node)\n            return d\n\n        cls = doxyxml.findall(f\"compounddef/innerclass[.='{qual_name}']\")\n        if not cls:\n            raise Exception(f\"Cannot find {identifier}. Candidates: {candidates}\")\n        return self.collect_compound(identifier, cls)\n\n    @override\n    def render(\n        self,\n        data: \"CollectorItem\",\n        options: \"HandlerOptions\",\n        *,\n        locale: \"str | None\" = None,\n    ) -> str:\n        d = data\n        if d.id is not None:\n            _ = self.do_heading(Markup(), 0, id=d.id)\n        if d.desc is None:\n            raise ValueError\n        text = '<div class=\"docblock\">\\n'\n        text += render_decl(d)\n        text += '<div class=\"docblock-desc\">\\n'\n        text += doxyxml2html(d.desc)\n        if d.members is not None:\n            for m in d.members:\n                text += self.render(m, options, locale=locale)\n        text += \"</div>\\n\"\n        text += \"</div>\\n\"\n        return text\n\n\ndef get_handler(\n    handler_config: \"MutableMapping[str, Any]\", tool_config: \"MkDocsConfig\", **kwargs: Any\n) -> CxxHandler:\n    \"\"\"Return an instance of `CxxHandler`.\n\n    Arguments:\n        handler_config: The handler configuration.\n        tool_config: The tool (SSG) configuration.\n    \"\"\"\n    base_dir = Path(tool_config.config_file_path or \"./mkdocs.yml\").parent\n    return CxxHandler(config=handler_config, base_dir=base_dir, **kwargs)\n"
  },
  {
    "path": "support/python/mkdocstrings_handlers/cxx/templates/README",
    "content": "mkdocsstrings requires a handler to have a templates directory.\n"
  },
  {
    "path": "support/release.py",
    "content": "#!/usr/bin/env python3\n\n\"\"\"Make a release.\n\nUsage:\n  release.py [<branch>]\n\nFor the release command $FMT_TOKEN should contain a GitHub personal access token\nobtained from https://github.com/settings/tokens.\n\"\"\"\n\nfrom __future__ import print_function\nimport datetime, docopt, errno, fileinput, json, os\nimport re, shutil, sys\nfrom subprocess import check_call\nimport urllib.request\n\n\nclass Git:\n    def __init__(self, dir):\n        self.dir = dir\n\n    def call(self, method, args, **kwargs):\n        return check_call(['git', method] + list(args), **kwargs)\n\n    def add(self, *args):\n        return self.call('add', args, cwd=self.dir)\n\n    def checkout(self, *args):\n        return self.call('checkout', args, cwd=self.dir)\n\n    def clean(self, *args):\n        return self.call('clean', args, cwd=self.dir)\n\n    def clone(self, *args):\n        return self.call('clone', list(args) + [self.dir])\n\n    def commit(self, *args):\n        return self.call('commit', args, cwd=self.dir)\n\n    def pull(self, *args):\n        return self.call('pull', args, cwd=self.dir)\n\n    def push(self, *args):\n        return self.call('push', args, cwd=self.dir)\n\n    def reset(self, *args):\n        return self.call('reset', args, cwd=self.dir)\n\n    def update(self, *args):\n        clone = not os.path.exists(self.dir)\n        if clone:\n            self.clone(*args)\n        return clone\n\n\ndef clean_checkout(repo, branch):\n    repo.clean('-f', '-d')\n    repo.reset('--hard')\n    repo.checkout(branch)\n\n\nclass Runner:\n    def __init__(self, cwd):\n        self.cwd = cwd\n\n    def __call__(self, *args, **kwargs):\n        kwargs['cwd'] = kwargs.get('cwd', self.cwd)\n        check_call(args, **kwargs)\n\n\ndef create_build_env():\n    \"\"\"Create a build environment.\"\"\"\n    class Env:\n        pass\n    env = Env()\n    env.fmt_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n    env.build_dir = 'build'\n    env.fmt_repo = Git(os.path.join(env.build_dir, 'fmt'))\n    return env\n\n\nif __name__ == '__main__':\n    args = docopt.docopt(__doc__)\n    env = create_build_env()\n    fmt_repo = env.fmt_repo\n\n    branch = args.get('<branch>')\n    if branch is None:\n        branch = 'master'\n    if not fmt_repo.update('-b', branch, 'git@github.com:fmtlib/fmt'):\n        clean_checkout(fmt_repo, branch)\n\n    # Update the date in the changelog and extract the version and the first\n    # section content.\n    changelog = 'ChangeLog.md'\n    changelog_path = os.path.join(fmt_repo.dir, changelog)\n    is_first_section = True\n    first_section = []\n    for i, line in enumerate(fileinput.input(changelog_path, inplace=True)):\n        if i == 0:\n            version = re.match(r'# (.*) - TBD', line).group(1)\n            line = '# {} - {}\\n'.format(\n                version, datetime.date.today().isoformat())\n        elif not is_first_section:\n            pass\n        elif line.startswith('#'):\n            is_first_section = False\n        else:\n            first_section.append(line)\n        sys.stdout.write(line)\n    if first_section[0] == '\\n':\n        first_section.pop(0)\n\n    ns_version = None\n    base_h_path = os.path.join(fmt_repo.dir, 'include', 'fmt', 'base.h')\n    for line in fileinput.input(base_h_path):\n        m = re.match(r'\\s*inline namespace v(.*) .*', line)\n        if m:\n            ns_version = m.group(1)\n            break\n    major_version = version.split('.')[0]\n    if not ns_version or ns_version != major_version:\n        raise Exception(f'Version mismatch {ns_version} != {major_version}')\n\n    # Workaround GitHub-flavored Markdown treating newlines as <br>.\n    changes = ''\n    code_block = False\n    stripped = False\n    for line in first_section:\n        if re.match(r'^\\s*```', line):\n            code_block = not code_block\n            changes += line\n            stripped = False\n            continue\n        if code_block:\n            changes += line\n            continue\n        if line == '\\n' or re.match(r'^\\s*\\|.*', line):\n            if stripped:\n                changes += '\\n'\n                stripped = False\n            changes += line\n            continue\n        if stripped:\n            line = ' ' + line.lstrip()\n        changes += line.rstrip()\n        stripped = True\n\n    fmt_repo.checkout('-B', 'release')\n    fmt_repo.add(changelog)\n    fmt_repo.commit('-m', 'Update version')\n\n    # Build the docs and package.\n    run = Runner(fmt_repo.dir)\n    run('cmake', '.')\n    run('make', 'doc', 'package_source')\n\n    # Create a release on GitHub.\n    fmt_repo.push('origin', 'release')\n    auth_headers = {'Authorization': 'token ' + os.getenv('FMT_TOKEN')}\n    req = urllib.request.Request(\n        'https://api.github.com/repos/fmtlib/fmt/releases',\n        data=json.dumps({'tag_name': version,\n                         'target_commitish': 'release',\n                         'body': changes, 'draft': True}).encode('utf-8'),\n        headers=auth_headers, method='POST')\n    with urllib.request.urlopen(req) as response:\n        if response.status != 201:\n            raise Exception(f'Failed to create a release ' +\n                            '{response.status} {response.reason}')\n        response_data = json.loads(response.read().decode('utf-8'))\n        id = response_data['id']\n\n    # Upload the package.\n    uploads_url = 'https://uploads.github.com/repos/fmtlib/fmt/releases'\n    package = 'fmt-{}.zip'.format(version)\n    req = urllib.request.Request(\n        f'{uploads_url}/{id}/assets?name={package}',\n        headers={'Content-Type': 'application/zip'} | auth_headers,\n        data=open('build/fmt/' + package, 'rb').read(), method='POST')\n    with urllib.request.urlopen(req) as response:\n        if response.status != 201:\n            raise Exception(f'Failed to upload an asset '\n                            '{response.status} {response.reason}')\n\n    short_version = '.'.join(version.split('.')[:-1])\n    check_call(['./mkdocs', 'deploy', short_version])\n"
  },
  {
    "path": "test/CMakeLists.txt",
    "content": "add_subdirectory(gtest)\n\nset(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)\nadd_library(test-main STATIC ${TEST_MAIN_SRC})\ntarget_include_directories(\n  test-main PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)\ntarget_link_libraries(test-main gtest fmt)\n\n# Adds a test.\n# Usage: add_fmt_test(name srcs...)\nfunction (add_fmt_test name)\n  cmake_parse_arguments(ADD_FMT_TEST \"HEADER_ONLY;MODULE\" \"\" \"\" ${ARGN})\n\n  set(sources ${name}.cc ${ADD_FMT_TEST_UNPARSED_ARGUMENTS})\n  if (ADD_FMT_TEST_HEADER_ONLY)\n    set(sources ${sources} ${TEST_MAIN_SRC} ../src/os.cc)\n    set(libs gtest fmt-header-only)\n    if (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n      set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables)\n    endif ()\n  elseif (ADD_FMT_TEST_MODULE)\n    set(libs test-main)\n  else ()\n    set(libs test-main fmt)\n  endif ()\n  add_executable(${name} ${sources})\n  target_link_libraries(${name} ${libs})\n\n  if (ADD_FMT_TEST_HEADER_ONLY AND NOT FMT_UNICODE)\n    target_compile_definitions(${name} PUBLIC FMT_UNICODE=0)\n  endif ()\n\n  # Define if certain C++ features can be used.\n  if (FMT_PEDANTIC)\n    target_compile_options(${name} PRIVATE ${PEDANTIC_COMPILE_FLAGS})\n  endif ()\n  if (FMT_WERROR)\n    target_compile_options(${name} PRIVATE ${WERROR_FLAG})\n  endif ()\n  add_test(NAME ${name} COMMAND ${name})\nendfunction ()\n\nadd_fmt_test(args-test)\nadd_fmt_test(base-test)\nadd_fmt_test(assert-test)\nadd_fmt_test(chrono-test)\nadd_fmt_test(color-test)\nadd_fmt_test(gtest-extra-test)\nadd_fmt_test(format-test mock-allocator.h)\nif (MSVC)\n  target_compile_options(format-test PRIVATE /bigobj)\nendif ()\nif (NOT (MSVC AND BUILD_SHARED_LIBS))\n  add_fmt_test(format-impl-test HEADER_ONLY header-only-test.cc)\nendif ()\nadd_fmt_test(ostream-test)\nadd_fmt_test(compile-test)\nadd_fmt_test(printf-test)\nadd_fmt_test(ranges-test ranges-odr-test.cc)\nadd_fmt_test(no-builtin-types-test HEADER_ONLY)\nadd_fmt_test(scan-test HEADER_ONLY)\nadd_fmt_test(std-test)\ntry_compile(\n  compile_result_unused ${CMAKE_CURRENT_BINARY_DIR}\n  SOURCES ${CMAKE_CURRENT_LIST_DIR}/detect-stdfs.cc\n  OUTPUT_VARIABLE RAWOUTPUT)\nstring(REGEX REPLACE \".*libfound \\\"([^\\\"]*)\\\".*\" \"\\\\1\" STDLIBFS \"${RAWOUTPUT}\")\nif (STDLIBFS)\n  target_link_libraries(std-test ${STDLIBFS})\nendif ()\nadd_fmt_test(unicode-test HEADER_ONLY)\nif (MSVC)\n  target_compile_options(unicode-test PRIVATE /utf-8)\nendif ()\nadd_fmt_test(xchar-test)\nadd_fmt_test(enforce-checks-test)\ntarget_compile_definitions(enforce-checks-test\n                           PRIVATE -DFMT_ENFORCE_COMPILE_STRING)\n\nadd_executable(perf-sanity perf-sanity.cc)\ntarget_link_libraries(perf-sanity fmt::fmt)\n\nif (FMT_MODULE)\n  # Module tests are currently disabled.\n  # add_fmt_test(module-test MODULE test-main.cc)\n  # target_link_libraries(module-test fmt-module)\nendif ()\n\nif (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC)\n  foreach (flag_var\n           CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE\n           CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)\n    if (${flag_var} MATCHES \"^(/|-)(MT|MTd)\")\n      set(MSVC_STATIC_RUNTIME ON)\n      break()\n    endif ()\n  endforeach ()\nendif ()\n\nif (NOT MSVC_STATIC_RUNTIME)\n  add_executable(posix-mock-test posix-mock-test.cc ../src/format.cc\n                                 ${TEST_MAIN_SRC})\n  target_include_directories(posix-mock-test\n                             PRIVATE ${PROJECT_SOURCE_DIR}/include)\n  target_link_libraries(posix-mock-test gtest)\n  if (FMT_PEDANTIC)\n    target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})\n  endif ()\n  if (MSVC)\n    target_compile_options(posix-mock-test PRIVATE /utf-8)\n  endif ()\n  add_test(NAME posix-mock-test COMMAND posix-mock-test)\n  add_fmt_test(os-test)\nendif ()\n\nmessage(STATUS \"FMT_PEDANTIC: ${FMT_PEDANTIC}\")\n\nif (FMT_PEDANTIC)\n  # Test that the library can be compiled with exceptions disabled.\n  # -fno-exception is broken in icc: https://github.com/fmtlib/fmt/issues/822.\n  if (NOT CMAKE_CXX_COMPILER_ID STREQUAL \"Intel\")\n    check_cxx_compiler_flag(-fno-exceptions HAVE_FNO_EXCEPTIONS_FLAG)\n  endif ()\n  if (HAVE_FNO_EXCEPTIONS_FLAG)\n    add_library(noexception-test ../src/format.cc noexception-test.cc)\n    target_include_directories(noexception-test\n                               PRIVATE ${PROJECT_SOURCE_DIR}/include)\n    target_compile_options(noexception-test PRIVATE -fno-exceptions)\n    target_compile_options(noexception-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})\n  endif ()\n\n  # Test that the library compiles without locale.\n  add_library(nolocale-test ../src/format.cc)\n  target_include_directories(nolocale-test\n                             PRIVATE ${PROJECT_SOURCE_DIR}/include)\n  target_compile_definitions(nolocale-test\n                             PRIVATE FMT_STATIC_THOUSANDS_SEPARATOR=1)\nendif ()\n\n# These tests are disabled on Windows because they take too long.\n# They are disabled on GCC < 4.9 because it can't parse UDLs without a space\n# after operator\"\" but that is an incorrect syntax for any more modern compiler.\nif (FMT_PEDANTIC\n    AND NOT WIN32\n    AND NOT (CMAKE_CXX_COMPILER_ID MATCHES \"GNU\" AND CMAKE_CXX_COMPILER_VERSION\n                                                     VERSION_LESS 4.9))\n  # Test if incorrect API usages produce compilation error.\n  add_test(\n    compile-error-test\n    ${CMAKE_CTEST_COMMAND}\n    --build-and-test\n    \"${CMAKE_CURRENT_SOURCE_DIR}/compile-error-test\"\n    \"${CMAKE_CURRENT_BINARY_DIR}/compile-error-test\"\n    --build-generator\n    ${CMAKE_GENERATOR}\n    --build-makeprogram\n    ${CMAKE_MAKE_PROGRAM}\n    --build-options\n    \"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\"\n    \"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}\"\n    \"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}\"\n    \"-DCXX_STANDARD_FLAG=${CXX_STANDARD_FLAG}\"\n    \"-DFMT_DIR=${CMAKE_SOURCE_DIR}\")\n\n  # Test if the targets are found from the build directory.\n  add_test(\n    find-package-test\n    ${CMAKE_CTEST_COMMAND}\n    -C\n    ${CMAKE_BUILD_TYPE}\n    --build-and-test\n    \"${CMAKE_CURRENT_SOURCE_DIR}/find-package-test\"\n    \"${CMAKE_CURRENT_BINARY_DIR}/find-package-test\"\n    --build-generator\n    ${CMAKE_GENERATOR}\n    --build-makeprogram\n    ${CMAKE_MAKE_PROGRAM}\n    --build-options\n    \"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\"\n    \"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}\"\n    \"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}\"\n    \"-DFMT_DIR=${PROJECT_BINARY_DIR}\"\n    \"-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}\"\n    \"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}\")\n\n  # Test if the targets are found when add_subdirectory is used.\n  add_test(\n    add-subdirectory-test\n    ${CMAKE_CTEST_COMMAND}\n    -C\n    ${CMAKE_BUILD_TYPE}\n    --build-and-test\n    \"${CMAKE_CURRENT_SOURCE_DIR}/add-subdirectory-test\"\n    \"${CMAKE_CURRENT_BINARY_DIR}/add-subdirectory-test\"\n    --build-generator\n    ${CMAKE_GENERATOR}\n    --build-makeprogram\n    ${CMAKE_MAKE_PROGRAM}\n    --build-options\n    \"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\"\n    \"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}\"\n    \"-DPEDANTIC_COMPILE_FLAGS=${PEDANTIC_COMPILE_FLAGS}\"\n    \"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}\")\nendif ()\n\n# This test is disabled on Windows because it is POSIX-specific.\nif (FMT_PEDANTIC AND NOT WIN32)\n  add_test(\n    static-export-test\n    ${CMAKE_CTEST_COMMAND}\n    -C\n    ${CMAKE_BUILD_TYPE}\n    --build-and-test\n    \"${CMAKE_CURRENT_SOURCE_DIR}/static-export-test\"\n    \"${CMAKE_CURRENT_BINARY_DIR}/static-export-test\"\n    --build-generator\n    ${CMAKE_GENERATOR}\n    --build-makeprogram\n    ${CMAKE_MAKE_PROGRAM}\n    --build-options\n    \"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\"\n    \"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}\"\n    \"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}\")\nendif ()\n\n# Activate optional CUDA tests if CUDA is found. For version selection see\n# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features\nif (FMT_CUDA_TEST)\n  if (${CMAKE_VERSION} VERSION_LESS 3.15)\n    find_package(CUDA 9.0)\n  else ()\n    include(CheckLanguage)\n    check_language(CUDA)\n    if (CMAKE_CUDA_COMPILER)\n      enable_language(CUDA OPTIONAL)\n      set(CUDA_FOUND TRUE)\n    endif ()\n  endif ()\n\n  if (CUDA_FOUND)\n    add_subdirectory(cuda-test)\n    add_test(NAME cuda-test COMMAND fmt-in-cuda-test)\n  endif ()\nendif ()\n\nenable_language(C)\nadd_executable(c-test c-test.c)\ntarget_link_libraries(c-test PRIVATE fmt::fmt-c)\nadd_test(NAME c-test COMMAND c-test)\n"
  },
  {
    "path": "test/add-subdirectory-test/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.8...3.25)\n\nproject(fmt-test CXX)\n\nadd_subdirectory(../.. fmt)\n\nadd_executable(library-test main.cc)\ntarget_include_directories(library-test PUBLIC SYSTEM .)\ntarget_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})\ntarget_link_libraries(library-test fmt::fmt)\n\nif (TARGET fmt::fmt-header-only)\n  add_executable(header-only-test main.cc)\n  target_include_directories(header-only-test PUBLIC SYSTEM .)\n  target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})\n  target_link_libraries(header-only-test fmt::fmt-header-only)\nendif ()\n"
  },
  {
    "path": "test/add-subdirectory-test/main.cc",
    "content": "#include \"fmt/base.h\"\n\nint main(int argc, char** argv) {\n  for (int i = 0; i < argc; ++i) fmt::print(\"{}: {}\\n\", i, argv[i]);\n}\n"
  },
  {
    "path": "test/args-test.cc",
    "content": "// Formatting library for C++ - dynamic argument store tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/args.h\"\n\n#include <memory>\n\n#include \"gtest/gtest.h\"\n\nTEST(args_test, basic) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  store.push_back(42);\n  store.push_back(\"abc1\");\n  store.push_back(1.5f);\n  EXPECT_EQ(\"42 and abc1 and 1.5\", fmt::vformat(\"{} and {} and {}\", store));\n}\n\nTEST(args_test, strings_and_refs) {\n  // Unfortunately the tests are compiled with old ABI so strings use COW.\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  char str[] = \"1234567890\";\n  store.push_back(str);\n  store.push_back(std::cref(str));\n  store.push_back(fmt::string_view{str});\n  str[0] = 'X';\n\n  auto result = fmt::vformat(\"{} and {} and {}\", store);\n  EXPECT_EQ(\"1234567890 and X234567890 and X234567890\", result);\n}\n\nstruct custom_type {\n  int i = 0;\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<custom_type> {\n  auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  template <typename FormatContext>\n  auto format(const custom_type& p, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return fmt::format_to(ctx.out(), \"cust={}\", p.i);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(args_test, custom_format) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  auto c = custom_type();\n  store.push_back(c);\n  ++c.i;\n  store.push_back(c);\n  ++c.i;\n  store.push_back(std::cref(c));\n  ++c.i;\n  auto result = fmt::vformat(\"{} and {} and {}\", store);\n  EXPECT_EQ(\"cust=0 and cust=1 and cust=3\", result);\n}\n\nstruct to_stringable {\n  friend auto to_string_view(to_stringable) -> fmt::string_view { return {}; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<to_stringable> {\n  auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(to_stringable, format_context& ctx) const -> decltype(ctx.out()) {\n    return ctx.out();\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(args_test, to_string_and_formatter) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  auto s = to_stringable();\n  store.push_back(s);\n  store.push_back(std::cref(s));\n  fmt::vformat(\"\", store);\n}\n\nTEST(args_test, named_int) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  store.push_back(fmt::arg(\"a1\", 42));\n  EXPECT_EQ(\"42\", fmt::vformat(\"{a1}\", store));\n}\n\nTEST(args_test, named_strings) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  char str[] = \"1234567890\";\n  store.push_back(fmt::arg(\"a1\", str));\n  store.push_back(fmt::arg(\"a2\", std::cref(str)));\n  str[0] = 'X';\n  EXPECT_EQ(\"1234567890 and X234567890\", fmt::vformat(\"{a1} and {a2}\", store));\n}\n\nTEST(args_test, named_arg_by_ref) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  char band[] = \"Rolling Stones\";\n  store.push_back(fmt::arg(\"band\", std::cref(band)));\n  band[9] = 'c';  // Changing band affects the output.\n  EXPECT_EQ(fmt::vformat(\"{band}\", store), \"Rolling Scones\");\n}\n\nTEST(args_test, named_custom_format) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  auto c = custom_type();\n  store.push_back(fmt::arg(\"c1\", c));\n  ++c.i;\n  store.push_back(fmt::arg(\"c2\", c));\n  ++c.i;\n  store.push_back(fmt::arg(\"c_ref\", std::cref(c)));\n  ++c.i;\n  auto result = fmt::vformat(\"{c1} and {c2} and {c_ref}\", store);\n  EXPECT_EQ(\"cust=0 and cust=1 and cust=3\", result);\n}\n\nTEST(args_test, clear) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  store.push_back(42);\n\n  auto result = fmt::vformat(\"{}\", store);\n  EXPECT_EQ(\"42\", result);\n\n  store.push_back(43);\n  result = fmt::vformat(\"{} and {}\", store);\n  EXPECT_EQ(\"42 and 43\", result);\n\n  store.clear();\n  store.push_back(44);\n  result = fmt::vformat(\"{}\", store);\n  EXPECT_EQ(\"44\", result);\n}\n\nTEST(args_test, reserve) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  store.reserve(2, 1);\n  store.push_back(1.5f);\n  store.push_back(fmt::arg(\"a\", 42));\n  auto result = fmt::vformat(\"{} and {a}\", store);\n  EXPECT_EQ(\"1.5 and 42\", result);\n}\n\nstruct copy_throwable {\n  copy_throwable() {}\n  copy_throwable(const copy_throwable&) { throw \"deal with it\"; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<copy_throwable> {\n  auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n  auto format(copy_throwable, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return ctx.out();\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(args_test, throw_on_copy) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  store.push_back(std::string(\"foo\"));\n  try {\n    store.push_back(copy_throwable());\n  } catch (...) {\n  }\n  EXPECT_EQ(fmt::vformat(\"{}\", store), \"foo\");\n}\n\nTEST(args_test, move_constructor) {\n  using store_type = fmt::dynamic_format_arg_store<fmt::format_context>;\n  auto store = std::unique_ptr<store_type>(new store_type());\n  store->push_back(42);\n  store->push_back(std::string(\"foo\"));\n  store->push_back(fmt::arg(\"a1\", \"foo\"));\n  auto moved_store = std::move(*store);\n  store.reset();\n  EXPECT_EQ(fmt::vformat(\"{} {} {a1}\", moved_store), \"42 foo foo\");\n}\n\nTEST(args_test, size) {\n  fmt::dynamic_format_arg_store<fmt::format_context> store;\n  EXPECT_EQ(store.size(), 0);\n\n  store.push_back(42);\n  EXPECT_EQ(store.size(), 1);\n\n  store.push_back(\"Molybdenum\");\n  EXPECT_EQ(store.size(), 2);\n\n  store.clear();\n  EXPECT_EQ(store.size(), 0);\n}\n"
  },
  {
    "path": "test/assert-test.cc",
    "content": "// Formatting library for C++ - FMT_ASSERT test\n//\n// It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks\n// which are slow on some platforms. In other tests FMT_ASSERT is made to throw\n// an exception which is much faster and easier to check.\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/base.h\"\n#include \"gtest/gtest.h\"\n\nTEST(assert_test, fail) {\n#if GTEST_HAS_DEATH_TEST\n  EXPECT_DEBUG_DEATH(FMT_ASSERT(false, \"don't panic!\"), \"don't panic!\");\n#else\n  fmt::print(\"warning: death tests are not supported\\n\");\n#endif\n}\n\nTEST(assert_test, dangling_else) {\n  bool test_condition = false;\n  bool executed_else = false;\n  if (test_condition)\n    FMT_ASSERT(true, \"\");\n  else\n    executed_else = true;\n  EXPECT_TRUE(executed_else);\n}\n"
  },
  {
    "path": "test/base-test.cc",
    "content": "// Formatting library for C++ - core tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n// Turn assertion failures into exceptions for testing.\n// clang-format off\n#include \"test-assert.h\"\n// clang-format on\n\n// Suppress warnings for pathological types convertible to detail::value.\n#pragma GCC diagnostic ignored \"-Wconversion\"\n\n#include \"fmt/base.h\"\n\n#include <limits.h>  // INT_MAX\n#include <string.h>  // strlen\n\n#include <functional>   // std::equal_to\n#include <iterator>     // std::back_insert_iterator, std::distance\n#include <limits>       // std::numeric_limits\n#include <string>       // std::string\n#include <type_traits>  // std::is_same\n\n#include \"gmock/gmock.h\"\n\n#ifdef FMT_FORMAT_H_\n#  error base-test includes format.h\n#endif\n\nusing testing::_;\nusing testing::Invoke;\nusing testing::Return;\n\nauto copy(fmt::string_view s, fmt::appender out) -> fmt::appender {\n  for (char c : s) *out++ = c;\n  return out;\n}\n\nTEST(string_view_test, value_type) {\n  static_assert(std::is_same<fmt::string_view::value_type, char>::value, \"\");\n}\n\nTEST(string_view_test, ctor) {\n  EXPECT_STREQ(fmt::string_view(\"abc\").data(), \"abc\");\n  EXPECT_EQ(fmt::string_view(\"abc\").size(), 3u);\n\n  EXPECT_STREQ(fmt::string_view(std::string(\"defg\")).data(), \"defg\");\n  EXPECT_EQ(fmt::string_view(std::string(\"defg\")).size(), 4u);\n}\n\nTEST(string_view_test, length) {\n  // Test that string_view::size() returns string length, not buffer size.\n  char str[100] = \"some string\";\n  EXPECT_EQ(fmt::string_view(str).size(), strlen(str));\n  EXPECT_LT(strlen(str), sizeof(str));\n}\n\n// Check string_view's comparison operator.\ntemplate <template <typename> class Op> void check_op() {\n  const char* inputs[] = {\"foo\", \"fop\", \"fo\"};\n  size_t num_inputs = sizeof(inputs) / sizeof(*inputs);\n  for (size_t i = 0; i < num_inputs; ++i) {\n    for (size_t j = 0; j < num_inputs; ++j) {\n      fmt::string_view lhs(inputs[i]), rhs(inputs[j]);\n      EXPECT_EQ(Op<int>()(lhs.compare(rhs), 0),\n                Op<fmt::string_view>()(lhs, rhs));\n    }\n  }\n}\n\nTEST(string_view_test, compare) {\n  using fmt::string_view;\n\n  EXPECT_EQ(string_view(\"foo\").compare(string_view(\"foo\")), 0);\n  EXPECT_GT(string_view(\"fop\").compare(string_view(\"foo\")), 0);\n  EXPECT_LT(string_view(\"foo\").compare(string_view(\"fop\")), 0);\n  EXPECT_GT(string_view(\"foo\").compare(string_view(\"fo\")), 0);\n  EXPECT_LT(string_view(\"fo\").compare(string_view(\"foo\")), 0);\n\n  EXPECT_TRUE(string_view(\"foo\").starts_with('f'));\n  EXPECT_FALSE(string_view(\"foo\").starts_with('o'));\n  EXPECT_FALSE(string_view().starts_with('o'));\n\n  EXPECT_TRUE(string_view(\"foo\").starts_with(\"fo\"));\n  EXPECT_TRUE(string_view(\"foo\").starts_with(\"foo\"));\n  EXPECT_FALSE(string_view(\"foo\").starts_with(\"fooo\"));\n  EXPECT_FALSE(string_view().starts_with(\"fooo\"));\n\n  check_op<std::equal_to>();\n  check_op<std::not_equal_to>();\n  check_op<std::less>();\n  check_op<std::less_equal>();\n  check_op<std::greater>();\n  check_op<std::greater_equal>();\n}\n\n#if FMT_USE_CONSTEVAL\nTEST(string_view_test, from_constexpr_fixed_string) {\n  constexpr int size = 4;\n\n  struct fixed_string {\n    char data[size] = {};\n\n    constexpr fixed_string(const char (&m)[size]) {\n      for (size_t i = 0; i != size; ++i) data[i] = m[i];\n    }\n  };\n\n  static constexpr auto fs = fixed_string(\"foo\");\n  static constexpr auto sv = fmt::string_view(fs.data);\n  EXPECT_EQ(sv, \"foo\");\n}\n#endif  // FMT_USE_CONSTEVAL\n\nTEST(buffer_test, noncopyable) {\n  EXPECT_FALSE(std::is_copy_constructible<fmt::detail::buffer<char>>::value);\n  EXPECT_FALSE(std::is_copy_assignable<fmt::detail::buffer<char>>::value);\n}\n\nTEST(buffer_test, nonmoveable) {\n  EXPECT_FALSE(std::is_move_constructible<fmt::detail::buffer<char>>::value);\n  EXPECT_FALSE(std::is_move_assignable<fmt::detail::buffer<char>>::value);\n}\n\nTEST(buffer_test, indestructible) {\n  static_assert(!std::is_destructible<fmt::detail::buffer<int>>(),\n                \"buffer's destructor is protected\");\n}\n\ntemplate <typename T> struct mock_buffer final : fmt::detail::buffer<T> {\n  MOCK_METHOD(size_t, do_grow, (size_t));\n\n  static void grow(fmt::detail::buffer<T>& buf, size_t capacity) {\n    auto& self = static_cast<mock_buffer&>(buf);\n    self.set(buf.data(), self.do_grow(capacity));\n  }\n\n  mock_buffer(T* data = nullptr, size_t buf_capacity = 0)\n      : fmt::detail::buffer<T>(grow) {\n    this->set(data, buf_capacity);\n    ON_CALL(*this, do_grow(_)).WillByDefault(Invoke([](size_t capacity) {\n      return capacity;\n    }));\n  }\n};\n\nTEST(buffer_test, ctor) {\n  {\n    mock_buffer<int> buffer;\n    EXPECT_EQ(buffer.data(), nullptr);\n    EXPECT_EQ(buffer.size(), 0u);\n    EXPECT_EQ(buffer.capacity(), 0u);\n  }\n  {\n    int data;\n    mock_buffer<int> buffer(&data);\n    EXPECT_EQ(&buffer[0], &data);\n    EXPECT_EQ(buffer.size(), 0u);\n    EXPECT_EQ(buffer.capacity(), 0u);\n  }\n  {\n    int data;\n    size_t capacity = std::numeric_limits<size_t>::max();\n    mock_buffer<int> buffer(&data, capacity);\n    EXPECT_EQ(&buffer[0], &data);\n    EXPECT_EQ(buffer.size(), 0u);\n    EXPECT_EQ(buffer.capacity(), capacity);\n  }\n}\n\nTEST(buffer_test, access) {\n  char data[10];\n  mock_buffer<char> buffer(data, sizeof(data));\n  buffer[0] = 11;\n  EXPECT_EQ(buffer[0], 11);\n  buffer[3] = 42;\n  EXPECT_EQ(*(&buffer[0] + 3), 42);\n  const fmt::detail::buffer<char>& const_buffer = buffer;\n  EXPECT_EQ(const_buffer[3], 42);\n}\n\nTEST(buffer_test, try_resize) {\n  char data[123];\n  mock_buffer<char> buffer(data, sizeof(data));\n  buffer[10] = 42;\n  EXPECT_EQ(buffer[10], 42);\n  buffer.try_resize(20);\n  EXPECT_EQ(buffer.size(), 20u);\n  EXPECT_EQ(buffer.capacity(), 123u);\n  EXPECT_EQ(buffer[10], 42);\n  buffer.try_resize(5);\n  EXPECT_EQ(buffer.size(), 5u);\n  EXPECT_EQ(buffer.capacity(), 123u);\n  EXPECT_EQ(buffer[10], 42);\n  // Check if try_resize calls grow.\n  EXPECT_CALL(buffer, do_grow(124));\n  buffer.try_resize(124);\n  EXPECT_CALL(buffer, do_grow(200));\n  buffer.try_resize(200);\n}\n\nTEST(buffer_test, try_resize_partial) {\n  char data[10];\n  mock_buffer<char> buffer(data, sizeof(data));\n  EXPECT_CALL(buffer, do_grow(20)).WillOnce(Return(15));\n  buffer.try_resize(20);\n  EXPECT_EQ(buffer.capacity(), 15);\n  EXPECT_EQ(buffer.size(), 15);\n}\n\nTEST(buffer_test, clear) {\n  mock_buffer<char> buffer;\n  EXPECT_CALL(buffer, do_grow(20));\n  buffer.try_resize(20);\n  buffer.try_resize(0);\n  EXPECT_EQ(buffer.size(), 0u);\n  EXPECT_EQ(buffer.capacity(), 20u);\n}\n\nTEST(buffer_test, append) {\n  char data[15];\n  mock_buffer<char> buffer(data, 10);\n  auto test = \"test\";\n  buffer.append(test, test + 5);\n  EXPECT_STREQ(&buffer[0], test);\n  EXPECT_EQ(buffer.size(), 5u);\n  buffer.try_resize(10);\n  EXPECT_CALL(buffer, do_grow(12));\n  buffer.append(test, test + 2);\n  EXPECT_EQ(buffer[10], 't');\n  EXPECT_EQ(buffer[11], 'e');\n  EXPECT_EQ(buffer.size(), 12u);\n}\n\nTEST(buffer_test, append_partial) {\n  char data[10];\n  mock_buffer<char> buffer(data, sizeof(data));\n  testing::InSequence seq;\n  EXPECT_CALL(buffer, do_grow(15)).WillOnce(Return(10));\n  EXPECT_CALL(buffer, do_grow(15)).WillOnce(Invoke([&buffer](size_t) {\n    EXPECT_EQ(fmt::string_view(buffer.data(), buffer.size()), \"0123456789\");\n    buffer.clear();\n    return 10;\n  }));\n  auto test = \"0123456789abcde\";\n  buffer.append(test, test + 15);\n}\n\nTEST(buffer_test, append_allocates_enough_storage) {\n  char data[19];\n  mock_buffer<char> buffer(data, 10);\n  auto test = \"abcdefgh\";\n  buffer.try_resize(10);\n  EXPECT_CALL(buffer, do_grow(19));\n  buffer.append(test, test + 9);\n}\n\nTEST(base_test, is_locking) {\n  EXPECT_FALSE(fmt::detail::is_locking<const char(&)[3]>());\n}\n\nTEST(base_test, is_output_iterator) {\n  EXPECT_TRUE((fmt::detail::is_output_iterator<char*, char>::value));\n  EXPECT_FALSE((fmt::detail::is_output_iterator<const char*, char>::value));\n  EXPECT_FALSE((fmt::detail::is_output_iterator<std::string, char>::value));\n  EXPECT_TRUE(\n      (fmt::detail::is_output_iterator<std::back_insert_iterator<std::string>,\n                                       char>::value));\n  EXPECT_TRUE(\n      (fmt::detail::is_output_iterator<std::string::iterator, char>::value));\n  EXPECT_FALSE((fmt::detail::is_output_iterator<std::string::const_iterator,\n                                                char>::value));\n}\n\nTEST(base_test, is_back_insert_iterator) {\n  EXPECT_TRUE(fmt::detail::is_back_insert_iterator<\n              std::back_insert_iterator<std::string>>::value);\n  EXPECT_FALSE(fmt::detail::is_back_insert_iterator<\n               std::front_insert_iterator<std::string>>::value);\n}\n\nTEST(base_test, get_buffer) {\n  mock_buffer<char> buffer;\n  void* buffer_ptr = &buffer;\n  auto&& appender_result = fmt::detail::get_buffer<char>(fmt::appender(buffer));\n  EXPECT_EQ(&appender_result, buffer_ptr);\n  auto&& back_inserter_result =\n      fmt::detail::get_buffer<char>(std::back_inserter(buffer));\n  EXPECT_EQ(&back_inserter_result, buffer_ptr);\n}\n\nstruct test_struct {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <typename Char> struct formatter<test_struct, Char> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(test_struct, format_context& ctx) const -> decltype(ctx.out()) {\n    return copy(\"test\", ctx.out());\n  }\n};\nFMT_END_NAMESPACE\n\n// Use a unique result type to make sure that there are no undesirable\n// conversions.\nstruct test_result {};\n\ntemplate <typename T> struct mock_visitor {\n  template <typename U> struct result {\n    using type = test_result;\n  };\n\n  mock_visitor() {\n    ON_CALL(*this, visit(_)).WillByDefault(Return(test_result()));\n  }\n\n  MOCK_METHOD(test_result, visit, (T));\n  MOCK_METHOD(void, unexpected, ());\n\n  auto operator()(T value) -> test_result { return visit(value); }\n\n  template <typename U> auto operator()(U) -> test_result {\n    unexpected();\n    return test_result();\n  }\n};\n\ntemplate <typename T> struct visit_type {\n  using type = T;\n};\n\n#define VISIT_TYPE(type_, visit_type_)   \\\n  template <> struct visit_type<type_> { \\\n    using type = visit_type_;            \\\n  }\n\nVISIT_TYPE(signed char, int);\nVISIT_TYPE(unsigned char, unsigned);\nVISIT_TYPE(short, int);\nVISIT_TYPE(unsigned short, unsigned);\n\n#if LONG_MAX == INT_MAX\nVISIT_TYPE(long, int);\nVISIT_TYPE(unsigned long, unsigned);\n#else\nVISIT_TYPE(long, long long);\nVISIT_TYPE(unsigned long, unsigned long long);\n#endif\n\n#if FMT_BUILTIN_TYPES\n#  define CHECK_ARG(expected, value)                                  \\\n    {                                                                 \\\n      testing::StrictMock<mock_visitor<decltype(expected)>> visitor;  \\\n      EXPECT_CALL(visitor, visit(expected));                          \\\n      auto var = value;                                               \\\n      fmt::basic_format_arg<fmt::format_context>(var).visit(visitor); \\\n    }\n#else\n#  define CHECK_ARG(expected, value)\n#endif\n\n#define CHECK_ARG_SIMPLE(value)                             \\\n  {                                                         \\\n    using value_type = decltype(value);                     \\\n    typename visit_type<value_type>::type expected = value; \\\n    CHECK_ARG(expected, value)                              \\\n  }\n\nTEST(arg_test, format_args) {\n  auto args = fmt::format_args();\n  EXPECT_FALSE(args.get(1));\n}\n\nTEST(arg_test, char_arg) { CHECK_ARG('a', 'a'); }\n\nTEST(arg_test, string_arg) {\n  char str_data[] = \"test\";\n  char* str = str_data;\n  const char* cstr = str;\n  CHECK_ARG(cstr, str);\n\n  auto sv = fmt::string_view(str);\n  CHECK_ARG(sv, std::string(str));\n}\n\nTEST(arg_test, pointer_arg) {\n  void* p = nullptr;\n  const void* cp = nullptr;\n  CHECK_ARG(cp, p);\n  CHECK_ARG_SIMPLE(cp);\n}\n\nTEST(arg_test, volatile_pointer_arg) {\n  const void* p = nullptr;\n  volatile int* vip = nullptr;\n  const volatile int* cvip = nullptr;\n  CHECK_ARG(p, static_cast<volatile void*>(vip));\n  CHECK_ARG(p, static_cast<const volatile void*>(cvip));\n}\n\nstruct check_custom {\n  auto operator()(fmt::basic_format_arg<fmt::format_context>::handle h) const\n      -> test_result {\n    struct test_buffer final : fmt::detail::buffer<char> {\n      char data[10];\n      test_buffer()\n          : fmt::detail::buffer<char>([](buffer<char>&, size_t) {}, data, 0,\n                                      10) {}\n    } buffer;\n    auto parse_ctx = fmt::format_parse_context(\"\");\n    auto ctx = fmt::format_context(fmt::appender(buffer), fmt::format_args());\n    h.format(parse_ctx, ctx);\n    EXPECT_EQ(std::string(buffer.data, buffer.size()), \"test\");\n    return test_result();\n  }\n};\n\nTEST(arg_test, custom_arg) {\n  auto test = test_struct();\n  using visitor =\n      mock_visitor<fmt::basic_format_arg<fmt::format_context>::handle>;\n  auto&& v = testing::StrictMock<visitor>();\n  EXPECT_CALL(v, visit(_)).WillOnce(Invoke(check_custom()));\n  fmt::basic_format_arg<fmt::format_context>(test).visit(v);\n}\n\nTEST(arg_test, visit_invalid_arg) {\n  auto&& visitor = testing::StrictMock<mock_visitor<fmt::monostate>>();\n  EXPECT_CALL(visitor, visit(_));\n  fmt::basic_format_arg<fmt::format_context>().visit(visitor);\n}\n\ntemplate <typename T> class numeric_arg_test : public testing::Test {};\n\n#if FMT_BUILTIN_TYPES\nusing test_types =\n    testing::Types<bool, signed char, unsigned char, short, unsigned short, int,\n                   unsigned, long, unsigned long, long long, unsigned long long,\n                   float, double, long double>;\n#else\nusing test_types = testing::Types<int>;\n#endif\nTYPED_TEST_SUITE(numeric_arg_test, test_types);\n\ntemplate <typename T, fmt::enable_if_t<std::is_integral<T>::value, int> = 0>\nauto test_value() -> T {\n  return static_cast<T>(42);\n}\n\ntemplate <typename T,\n          fmt::enable_if_t<std::is_floating_point<T>::value, int> = 0>\nauto test_value() -> T {\n  return static_cast<T>(4.2);\n}\n\nTYPED_TEST(numeric_arg_test, make_and_visit) {\n  CHECK_ARG_SIMPLE(test_value<TypeParam>());\n  CHECK_ARG_SIMPLE(std::numeric_limits<TypeParam>::min());\n  CHECK_ARG_SIMPLE(std::numeric_limits<TypeParam>::max());\n}\n\n#if FMT_USE_CONSTEXPR\n\nenum class arg_id_result { none, index, name };\n\nstruct test_arg_id_handler {\n  arg_id_result res = arg_id_result::none;\n  int index = 0;\n  fmt::string_view name;\n\n  constexpr void on_index(int i) {\n    res = arg_id_result::index;\n    index = i;\n  }\n\n  constexpr void on_name(fmt::string_view n) {\n    res = arg_id_result::name;\n    name = n;\n  }\n};\n\ntemplate <size_t N>\nconstexpr auto parse_arg_id(const char (&s)[N]) -> test_arg_id_handler {\n  auto h = test_arg_id_handler();\n  fmt::detail::parse_arg_id(s, s + N, h);\n  return h;\n}\n\nTEST(base_test, constexpr_parse_arg_id) {\n  static_assert(parse_arg_id(\"42:\").res == arg_id_result::index, \"\");\n  static_assert(parse_arg_id(\"42:\").index == 42, \"\");\n  static_assert(parse_arg_id(\"foo:\").res == arg_id_result::name, \"\");\n  static_assert(parse_arg_id(\"foo:\").name.size() == 3, \"\");\n}\n\ntemplate <size_t N> constexpr auto parse_test_specs(const char (&s)[N]) {\n  auto ctx = fmt::detail::compile_parse_context<char>(fmt::string_view(s, N),\n                                                      43, nullptr);\n  auto specs = fmt::detail::dynamic_format_specs<>();\n  fmt::detail::parse_format_specs(s, s + N - 1, specs, ctx,\n                                  fmt::detail::type::float_type);\n  return specs;\n}\n\nTEST(base_test, constexpr_parse_format_specs) {\n  static_assert(parse_test_specs(\"<\").align() == fmt::align::left, \"\");\n  static_assert(parse_test_specs(\"*^\").fill_unit<char>() == '*', \"\");\n  static_assert(parse_test_specs(\"+\").sign() == fmt::sign::plus, \"\");\n  static_assert(parse_test_specs(\"-\").sign() == fmt::sign::none, \"\");\n  static_assert(parse_test_specs(\" \").sign() == fmt::sign::space, \"\");\n  static_assert(parse_test_specs(\"#\").alt(), \"\");\n  static_assert(parse_test_specs(\"0\").align() == fmt::align::numeric, \"\");\n  static_assert(parse_test_specs(\"L\").localized(), \"\");\n  static_assert(parse_test_specs(\"42\").width == 42, \"\");\n  static_assert(parse_test_specs(\"{42}\").width_ref.index == 42, \"\");\n  static_assert(parse_test_specs(\".42\").precision == 42, \"\");\n  static_assert(parse_test_specs(\".{42}\").precision_ref.index == 42, \"\");\n  static_assert(parse_test_specs(\"f\").type() == fmt::presentation_type::fixed,\n                \"\");\n}\n\nstruct test_format_string_handler {\n  constexpr void on_text(const char*, const char*) {}\n\n  constexpr auto on_arg_id() -> int { return 0; }\n\n  template <typename T> constexpr auto on_arg_id(T) -> int { return 0; }\n\n  constexpr void on_replacement_field(int, const char*) {}\n\n  constexpr auto on_format_specs(int, const char* begin, const char*) -> const\n      char* {\n    return begin;\n  }\n\n  constexpr void on_error(const char*) { error = true; }\n\n  bool error = false;\n};\n\ntemplate <size_t N> constexpr auto parse_string(const char (&s)[N]) -> bool {\n  auto h = test_format_string_handler();\n  fmt::detail::parse_format_string(fmt::string_view(s, N - 1), h);\n  return !h.error;\n}\n\nTEST(base_test, constexpr_parse_format_string) {\n  static_assert(parse_string(\"foo\"), \"\");\n  static_assert(!parse_string(\"}\"), \"\");\n  static_assert(parse_string(\"{}\"), \"\");\n  static_assert(parse_string(\"{42}\"), \"\");\n  static_assert(parse_string(\"{foo}\"), \"\");\n  static_assert(parse_string(\"{:}\"), \"\");\n}\n\n#endif  // FMT_USE_CONSTEXPR\n\nstruct enabled_formatter {};\nstruct enabled_ptr_formatter {};\nstruct disabled_formatter {};\nstruct disabled_formatter_convertible {\n  operator int() const { return 42; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<enabled_formatter> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n  auto format(enabled_formatter, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return ctx.out();\n  }\n};\n\ntemplate <> struct formatter<enabled_ptr_formatter*> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n  auto format(enabled_ptr_formatter*, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return ctx.out();\n  }\n};\nFMT_END_NAMESPACE\n\nstruct const_formattable {};\nstruct nonconst_formattable {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<const_formattable> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(const const_formattable&, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return copy(\"test\", ctx.out());\n  }\n};\n\ntemplate <> struct formatter<nonconst_formattable> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(nonconst_formattable&, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return copy(\"test\", ctx.out());\n  }\n};\nFMT_END_NAMESPACE\n\nstruct convertible_to_pointer {\n  operator const int*() const { return nullptr; }\n};\n\nstruct convertible_to_pointer_formattable {\n  operator const int*() const { return nullptr; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<convertible_to_pointer_formattable> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(convertible_to_pointer_formattable, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return copy(\"test\", ctx.out());\n  }\n};\nFMT_END_NAMESPACE\n\nenum class unformattable_scoped_enum {};\n\nTEST(base_test, is_formattable) {\n  EXPECT_FALSE(fmt::is_formattable<void>::value);\n  EXPECT_FALSE(fmt::is_formattable<wchar_t>::value);\n#ifdef __cpp_char8_t\n  EXPECT_FALSE(fmt::is_formattable<char8_t>::value);\n#endif\n  EXPECT_FALSE(fmt::is_formattable<char16_t>::value);\n  EXPECT_FALSE(fmt::is_formattable<char32_t>::value);\n  EXPECT_FALSE(fmt::is_formattable<signed char*>::value);\n  EXPECT_FALSE(fmt::is_formattable<unsigned char*>::value);\n  EXPECT_FALSE(fmt::is_formattable<const signed char*>::value);\n  EXPECT_FALSE(fmt::is_formattable<const unsigned char*>::value);\n  EXPECT_FALSE(fmt::is_formattable<const wchar_t*>::value);\n  EXPECT_FALSE(fmt::is_formattable<const wchar_t[3]>::value);\n  EXPECT_FALSE(fmt::is_formattable<fmt::basic_string_view<wchar_t>>::value);\n  EXPECT_FALSE(fmt::is_formattable<enabled_ptr_formatter*>::value);\n  EXPECT_FALSE(fmt::is_formattable<disabled_formatter>::value);\n  EXPECT_FALSE(fmt::is_formattable<disabled_formatter_convertible>::value);\n\n  EXPECT_TRUE(fmt::is_formattable<enabled_formatter>::value);\n  EXPECT_TRUE(fmt::is_formattable<const_formattable&>::value);\n  EXPECT_TRUE(fmt::is_formattable<const const_formattable&>::value);\n\n  EXPECT_TRUE(fmt::is_formattable<nonconst_formattable&>::value);\n  EXPECT_FALSE(fmt::is_formattable<const nonconst_formattable&>::value);\n\n  EXPECT_FALSE(fmt::is_formattable<convertible_to_pointer>::value);\n  const auto f = convertible_to_pointer_formattable();\n  auto str = std::string();\n  fmt::format_to(std::back_inserter(str), \"{}\", f);\n  EXPECT_EQ(str, \"test\");\n\n  EXPECT_FALSE(fmt::is_formattable<void (*)()>::value);\n\n  struct s;\n  EXPECT_FALSE(fmt::is_formattable<int(s::*)>::value);\n  EXPECT_FALSE(fmt::is_formattable<int (s::*)()>::value);\n  EXPECT_FALSE(fmt::is_formattable<unformattable_scoped_enum>::value);\n  EXPECT_FALSE(fmt::is_formattable<unformattable_scoped_enum>::value);\n}\n\n#ifdef __cpp_concepts\nTEST(base_test, formattable_concept) {\n  static_assert(fmt::formattable<char>);\n  static_assert(fmt::formattable<char&>);\n  static_assert(fmt::formattable<char&&>);\n  static_assert(fmt::formattable<const char>);\n  static_assert(fmt::formattable<const char&>);\n  static_assert(fmt::formattable<const char&&>);\n  static_assert(fmt::formattable<int>);\n  static_assert(!fmt::formattable<wchar_t>);\n}\n#endif\n\nTEST(base_test, format_to) {\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), \"{}\", 42);\n  EXPECT_EQ(s, \"42\");\n}\n\nTEST(base_test, format_to_array) {\n  char buffer[4];\n  auto result = fmt::format_to(buffer, \"{}\", 12345);\n  EXPECT_EQ(std::distance(&buffer[0], result.out), 4);\n  EXPECT_TRUE(result.truncated);\n  EXPECT_EQ(result.out, buffer + 4);\n  EXPECT_EQ(fmt::string_view(buffer, 4), \"1234\");\n\n  char* out = nullptr;\n  EXPECT_THROW(out = result, std::runtime_error);\n  (void)out;\n\n  result = fmt::format_to(buffer, \"{:s}\", \"foobar\");\n  EXPECT_EQ(std::distance(&buffer[0], result.out), 4);\n  EXPECT_TRUE(result.truncated);\n  EXPECT_EQ(result.out, buffer + 4);\n  EXPECT_EQ(fmt::string_view(buffer, 4), \"foob\");\n\n  buffer[0] = 'x';\n  buffer[1] = 'x';\n  buffer[2] = 'x';\n  buffer[3] = 'x';\n  result = fmt::format_to(buffer, \"{}\", 'A');\n  EXPECT_EQ(std::distance(&buffer[0], result.out), 1);\n  EXPECT_FALSE(result.truncated);\n  EXPECT_EQ(result.out, buffer + 1);\n  EXPECT_EQ(fmt::string_view(buffer, 4), \"Axxx\");\n\n  result = fmt::format_to(buffer, \"{}{} \", 'B', 'C');\n  EXPECT_EQ(std::distance(&buffer[0], result.out), 3);\n  EXPECT_FALSE(result.truncated);\n  EXPECT_EQ(result.out, buffer + 3);\n  EXPECT_EQ(fmt::string_view(buffer, 4), \"BC x\");\n\n  result = fmt::format_to(buffer, \"{}\", \"ABCDE\");\n  EXPECT_EQ(std::distance(&buffer[0], result.out), 4);\n  EXPECT_TRUE(result.truncated);\n  EXPECT_EQ(fmt::string_view(buffer, 4), \"ABCD\");\n\n  result = fmt::format_to(buffer, \"{}\", std::string(1000, '*').c_str());\n  EXPECT_EQ(std::distance(&buffer[0], result.out), 4);\n  EXPECT_TRUE(result.truncated);\n  EXPECT_EQ(fmt::string_view(buffer, 4), \"****\");\n}\n\n// Test that check is not found by ADL.\ntemplate <typename T> void check(T);\nTEST(base_test, adl_check) {\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), \"{}\", test_struct());\n  EXPECT_EQ(s, \"test\");\n}\n\nstruct implicitly_convertible_to_string_view {\n  operator fmt::string_view() const { return \"foo\"; }\n};\n\nTEST(base_test, no_implicit_conversion_to_string_view) {\n  EXPECT_FALSE(\n      fmt::is_formattable<implicitly_convertible_to_string_view>::value);\n}\n\nstruct explicitly_convertible_to_string_view {\n  explicit operator fmt::string_view() const { return \"foo\"; }\n};\n\nTEST(base_test, format_explicitly_convertible_to_string_view) {\n  // Types explicitly convertible to string_view are not formattable by\n  // default because it may introduce ODR violations.\n  static_assert(\n      !fmt::is_formattable<explicitly_convertible_to_string_view>::value, \"\");\n}\n\n#if FMT_CPLUSPLUS >= 201703L\nstruct implicitly_convertible_to_std_string_view {\n  operator std::string_view() const { return \"foo\"; }\n};\n\nTEST(base_test, no_implicit_conversion_to_std_string_view) {\n  EXPECT_FALSE(\n      fmt::is_formattable<implicitly_convertible_to_std_string_view>::value);\n}\n\nstruct explicitly_convertible_to_std_string_view {\n  explicit operator std::string_view() const { return \"foo\"; }\n};\n\nTEST(base_test, format_explicitly_convertible_to_std_string_view) {\n  // Types explicitly convertible to string_view are not formattable by\n  // default because it may introduce ODR violations.\n  static_assert(\n      !fmt::is_formattable<explicitly_convertible_to_std_string_view>::value,\n      \"\");\n}\n#endif  // FMT_CPLUSPLUS >= 201703L\n\nTEST(base_test, has_formatter) {\n  EXPECT_TRUE((fmt::detail::has_formatter<const const_formattable, char>()));\n  EXPECT_FALSE(\n      (fmt::detail::has_formatter<const nonconst_formattable, char>()));\n}\n\nTEST(base_test, format_nonconst) {\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), \"{}\", nonconst_formattable());\n  EXPECT_EQ(s, \"test\");\n}\n\nTEST(base_test, throw_in_buffer_dtor) {\n  constexpr int buffer_size = 256;\n\n  struct throwing_iterator {\n    int& count;\n\n    auto operator=(char) -> throwing_iterator& {\n      if (++count > buffer_size) throw std::exception();\n      return *this;\n    }\n    auto operator*() -> throwing_iterator& { return *this; }\n    auto operator++() -> throwing_iterator& { return *this; }\n    auto operator++(int) -> throwing_iterator { return *this; }\n  };\n\n  try {\n    int count = 0;\n    fmt::format_to(throwing_iterator{count}, fmt::runtime(\"{:{}}{\"), \"\",\n                   buffer_size + 1);\n  } catch (const std::exception&) {\n  }\n}\n\nstruct convertible_to_any_type_with_member_x {\n  template <typename T> operator T() const {\n    auto v = T();\n    v.x = 42;\n    return v;\n  }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<convertible_to_any_type_with_member_x> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(convertible_to_any_type_with_member_x, format_context& ctx) const\n      -> decltype(ctx.out()) const {\n    auto out = ctx.out();\n    *out++ = 'x';\n    return out;\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(base_test, promiscuous_conversions) {\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), \"{}\",\n                 convertible_to_any_type_with_member_x());\n  EXPECT_EQ(s, \"x\");\n}\n\nstruct custom_container {\n  char data;\n\n  using value_type = char;\n\n  auto size() const -> size_t { return 0; }\n  void resize(size_t) {}\n\n  void push_back(char) {}\n  auto operator[](size_t) -> char& { return data; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct is_contiguous<custom_container> : std::true_type {};\nFMT_END_NAMESPACE\n\nTEST(base_test, format_to_custom_container) {\n  auto c = custom_container();\n  fmt::format_to(std::back_inserter(c), \"\");\n}\n\nTEST(base_test, no_repeated_format_string_conversions) {\n  struct nondeterministic_format_string {\n    mutable int i = 0;\n    FMT_CONSTEXPR operator fmt::string_view() const {\n      return {\"{}\", i++ != 0 ? 2u : 0u};\n    }\n  };\n\n#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 1200\n  char buf[10];\n  fmt::format_to(buf, nondeterministic_format_string());\n#endif\n}\n\nTEST(base_test, format_context_accessors) {\n  auto copy = [](fmt::appender app, const fmt::format_context& ctx) {\n    return fmt::format_context(app, ctx.args(), ctx.locale());\n  };\n  fmt::detail::ignore_unused(copy);\n}\n"
  },
  {
    "path": "test/c-test.c",
    "content": "// Formatting library for C++ - the C API tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/fmt-c.h\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#define ASSERT_STR_EQ(actual, expected)                                   \\\n  do {                                                                    \\\n    if (strcmp(actual, expected) != 0) {                                  \\\n      fprintf(stderr,                                                     \\\n              \"\\nAssertion failed:\\n  Expected: \\\"%s\\\"\\n  Got: \\\"%s\\\"\\n\", \\\n              expected, actual);                                          \\\n      exit(1);                                                            \\\n    }                                                                     \\\n  } while (0)\n\n#define ASSERT_INT_EQ(actual, expected)                                   \\\n  do {                                                                    \\\n    if ((actual) != (expected)) {                                         \\\n      fprintf(stderr, \"\\nAssertion failed:\\n  Expected: %d\\n  Got: %d\\n\", \\\n              expected, actual);                                          \\\n      exit(1);                                                            \\\n    }                                                                     \\\n  } while (0)\n\nstatic inline int fmt_vformat_cstr(char* buf, size_t size, int result) {\n  if (result >= 0 && (size_t)result < size)\n    buf[result] = '\\0';\n  else if (size > 0)\n    buf[size - 1] = '\\0';\n  return result;\n}\n\n#define fmt_format_cstr(buf, size, ...) \\\n  fmt_vformat_cstr(buf, size, fmt_format(buf, size, __VA_ARGS__))\n\nvoid test_types(void) {\n  char buf[100];\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", 42);\n  ASSERT_STR_EQ(buf, \"42\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", 123u);\n  ASSERT_STR_EQ(buf, \"123\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", (bool)true);\n  ASSERT_STR_EQ(buf, \"true\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", (char)'x');\n  ASSERT_STR_EQ(buf, \"x\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", 1.2f);\n  ASSERT_STR_EQ(buf, \"1.2\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", 3.14159);\n  ASSERT_STR_EQ(buf, \"3.14159\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", 1.2l);\n  ASSERT_STR_EQ(buf, \"1.2\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", \"foo\");\n  ASSERT_STR_EQ(buf, \"foo\");\n\n  fmt_format_cstr(buf, sizeof(buf), \"{}\", (void*)0x12345678);\n  ASSERT_STR_EQ(buf, \"0x12345678\");\n}\n\nvoid test_zero_arguments(void) {\n  char buf[100];\n  int ret = fmt_format_cstr(buf, sizeof(buf), \"No arguments\");\n  ASSERT_STR_EQ(buf, \"No arguments\");\n}\n\nvoid test_buffer_size_query(void) {\n  int size = fmt_format(NULL, 0, \"Test string: {}\", 42);\n  ASSERT_INT_EQ(size, 15);\n}\n\nint main(void) {\n  printf(\"Running C API tests\\n\");\n  test_types();\n  test_zero_arguments();\n  test_buffer_size_query();\n  printf(\"C API tests passed\\n\");\n}\n"
  },
  {
    "path": "test/chrono-test.cc",
    "content": "// Formatting library for C++ - time formatting tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/chrono.h\"\n\n#include <algorithm>\n#include <ctime>\n#include <vector>\n\n#include \"gtest-extra.h\"  // EXPECT_THROW_MSG\n#include \"util.h\"         // get_locale\n\nusing fmt::runtime;\nusing fmt::sys_time;\nusing testing::Contains;\n\n#if defined(__MINGW32__) && !defined(_UCRT)\n// Only C89 conversion specifiers when using MSVCRT instead of UCRT\n#  define FMT_HAS_C99_STRFTIME 0\n#else\n#  define FMT_HAS_C99_STRFTIME 1\n#endif\n\n#if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907L\nusing days = std::chrono::days;\n#else\nusing days = std::chrono::duration<std::chrono::hours::rep, std::ratio<86400>>;\n#endif\n\nauto make_tm() -> std::tm {\n  auto time = std::tm();\n  time.tm_mday = 1;\n  return time;\n}\n\nauto make_hour(int h) -> std::tm {\n  auto time = make_tm();\n  time.tm_hour = h;\n  return time;\n}\n\nauto make_minute(int m) -> std::tm {\n  auto time = make_tm();\n  time.tm_min = m;\n  return time;\n}\n\nauto make_second(int s) -> std::tm {\n  auto time = make_tm();\n  time.tm_sec = s;\n  return time;\n}\n\nauto system_strftime(const std::string& format, const std::tm* timeptr,\n                     std::locale* locptr = nullptr) -> std::string {\n  auto loc = locptr ? *locptr : std::locale::classic();\n  auto& facet = std::use_facet<std::time_put<char>>(loc);\n  std::ostringstream os;\n  os.imbue(loc);\n  facet.put(os, os, ' ', timeptr, format.c_str(),\n            format.c_str() + format.size());\n#ifdef _WIN32\n  // Workaround a bug in older versions of Universal CRT.\n  auto str = os.str();\n  if (str == \"-0000\") str = \"+0000\";\n  return str;\n#else\n  return os.str();\n#endif\n}\n\nFMT_CONSTEXPR auto make_tm(int year, int mon, int mday, int hour, int min,\n                           int sec) -> std::tm {\n  auto tm = std::tm();\n  tm.tm_sec = sec;\n  tm.tm_min = min;\n  tm.tm_hour = hour;\n  tm.tm_mday = mday;\n  tm.tm_mon = mon - 1;\n  tm.tm_year = year - 1900;\n  return tm;\n}\n\nTEST(chrono_test, format_tm) {\n  auto tm = std::tm();\n  tm.tm_year = 116;\n  tm.tm_mon = 3;\n  tm.tm_mday = 25;\n  tm.tm_hour = 11;\n  tm.tm_min = 22;\n  tm.tm_sec = 33;\n  EXPECT_EQ(fmt::format(\"The date is {:%Y-%m-%d %H:%M:%S}.\", tm),\n            \"The date is 2016-04-25 11:22:33.\");\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"2016\");\n  EXPECT_EQ(fmt::format(\"{:%C}\", tm), \"20\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), fmt::format(\"{:%Y}\", tm));\n  EXPECT_EQ(fmt::format(\"{:%e}\", tm), \"25\");\n  EXPECT_EQ(fmt::format(\"{:%D}\", tm), \"04/25/16\");\n  EXPECT_EQ(fmt::format(\"{:%F}\", tm), \"2016-04-25\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", tm), \"11:22:33\");\n\n  // Short year\n  tm.tm_year = 999 - 1900;\n  tm.tm_mon = 0;   // for %G\n  tm.tm_mday = 2;  // for %G\n  tm.tm_wday = 3;  // for %G\n  tm.tm_yday = 1;  // for %G\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"0999\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), \"0999\");\n  EXPECT_EQ(fmt::format(\"{:%G}\", tm), \"0999\");\n\n  tm.tm_year = 27 - 1900;\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"0027\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), \"0027\");\n\n  // Overflow year\n  tm.tm_year = 2147483647;\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"2147485547\");\n\n  tm.tm_year = -2147483648;\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"-2147481748\");\n\n  // for week on the year\n  // https://www.cl.cam.ac.uk/~mgk25/iso-time.html\n  std::vector<std::tm> tm_list = {\n      make_tm(1975, 12, 29, 12, 14, 16),  // W01\n      make_tm(1977, 1, 2, 12, 14, 16),    // W53\n      make_tm(1999, 12, 27, 12, 14, 16),  // W52\n      make_tm(1999, 12, 31, 12, 14, 16),  // W52\n      make_tm(2000, 1, 1, 12, 14, 16),    // W52\n      make_tm(2000, 1, 2, 12, 14, 16),    // W52\n      make_tm(2000, 1, 3, 12, 14, 16)     // W1\n  };\n\n#if !FMT_HAS_C99_STRFTIME\n  GTEST_SKIP() << \"Skip the rest of this test because it relies on strftime() \"\n                  \"conforming to C99, but on this platform, MINGW + MSVCRT, \"\n                  \"the function conforms only to C89.\";\n#endif\n\n  const std::string iso_week_spec = \"%Y-%m-%d: %G %g %V\";\n  for (auto ctm : tm_list) {\n    // Calculate tm_yday, tm_wday, etc.\n    std::time_t t = std::mktime(&ctm);\n    tm = *std::localtime(&t);\n\n    auto fmt_spec = fmt::format(\"{{:{}}}\", iso_week_spec);\n    EXPECT_EQ(system_strftime(iso_week_spec, &tm),\n              fmt::format(fmt::runtime(fmt_spec), tm));\n  }\n\n  // Every day from 1970-01-01\n  std::time_t time_now = std::time(nullptr);\n  for (std::time_t t = 6 * 3600; t < time_now; t += 86400) {\n    tm = *std::localtime(&t);\n\n    auto fmt_spec = fmt::format(\"{{:{}}}\", iso_week_spec);\n    EXPECT_EQ(system_strftime(iso_week_spec, &tm),\n              fmt::format(fmt::runtime(fmt_spec), tm));\n  }\n}\n\n// MSVC:\n//  minkernel\\crts\\ucrt\\src\\appcrt\\time\\wcsftime.cpp(971) : Assertion failed:\n//  timeptr->tm_year >= -1900 && timeptr->tm_year <= 8099\n#ifndef _WIN32\nTEST(chrono_test, format_tm_future) {\n  auto tm = std::tm();\n  tm.tm_year = 10445;  // 10000+ years\n  tm.tm_mon = 3;\n  tm.tm_mday = 25;\n  tm.tm_hour = 11;\n  tm.tm_min = 22;\n  tm.tm_sec = 33;\n  EXPECT_EQ(fmt::format(\"The date is {:%Y-%m-%d %H:%M:%S}.\", tm),\n            \"The date is 12345-04-25 11:22:33.\");\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"12345\");\n  EXPECT_EQ(fmt::format(\"{:%C}\", tm), \"123\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), fmt::format(\"{:%Y}\", tm));\n  EXPECT_EQ(fmt::format(\"{:%D}\", tm), \"04/25/45\");\n  EXPECT_EQ(fmt::format(\"{:%F}\", tm), \"12345-04-25\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", tm), \"11:22:33\");\n}\n\nTEST(chrono_test, format_tm_past) {\n  auto tm = std::tm();\n  tm.tm_year = -2001;\n  tm.tm_mon = 3;\n  tm.tm_mday = 25;\n  tm.tm_hour = 11;\n  tm.tm_min = 22;\n  tm.tm_sec = 33;\n  EXPECT_EQ(fmt::format(\"The date is {:%Y-%m-%d %H:%M:%S}.\", tm),\n            \"The date is -101-04-25 11:22:33.\");\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"-101\");\n\n  // macOS  %C - \"-1\"\n  // Linux  %C - \"-2\"\n  // fmt    %C - \"-1\"\n  EXPECT_EQ(fmt::format(\"{:%C}\", tm), \"-1\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), fmt::format(\"{:%Y}\", tm));\n\n  // macOS  %D - \"04/25/01\" (%y)\n  // Linux  %D - \"04/25/99\" (%y)\n  // fmt    %D - \"04/25/01\" (%y)\n  EXPECT_EQ(fmt::format(\"{:%D}\", tm), \"04/25/01\");\n\n  EXPECT_EQ(fmt::format(\"{:%F}\", tm), \"-101-04-25\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", tm), \"11:22:33\");\n\n  tm.tm_year = -1901;  // -1\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"-001\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), fmt::format(\"{:%Y}\", tm));\n\n  tm.tm_year = -1911;  // -11\n  EXPECT_EQ(fmt::format(\"{:%Y}\", tm), \"-011\");\n  EXPECT_EQ(fmt::format(\"{:%C%y}\", tm), fmt::format(\"{:%Y}\", tm));\n}\n#endif\n\nTEST(chrono_test, grow_buffer) {\n  auto s = std::string(\"{:\");\n  for (int i = 0; i < 30; ++i) s += \"%c\";\n  s += \"}\\n\";\n  auto t = std::time(nullptr);\n  (void)fmt::format(fmt::runtime(s), *std::localtime(&t));\n}\n\nTEST(chrono_test, format_to_empty_container) {\n  auto time = std::tm();\n  time.tm_sec = 42;\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), \"{:%S}\", time);\n  EXPECT_EQ(s, \"42\");\n}\n\nTEST(chrono_test, gmtime) {\n  auto t = std::time(nullptr);\n  auto expected = *std::gmtime(&t);\n  auto actual = fmt::gmtime(t);\n  EXPECT_EQ(actual.tm_sec, expected.tm_sec);\n  EXPECT_EQ(actual.tm_min, expected.tm_min);\n  EXPECT_EQ(actual.tm_hour, expected.tm_hour);\n  EXPECT_EQ(actual.tm_mday, expected.tm_mday);\n  EXPECT_EQ(actual.tm_mon, expected.tm_mon);\n  EXPECT_EQ(actual.tm_year, expected.tm_year);\n  EXPECT_EQ(actual.tm_wday, expected.tm_wday);\n  EXPECT_EQ(actual.tm_yday, expected.tm_yday);\n  EXPECT_EQ(actual.tm_isdst, expected.tm_isdst);\n}\n\ntemplate <typename Time> void test_time(Time time) {\n  EXPECT_EQ(fmt::format(\"{}\", time), \"1979-03-12 12:00:00\");\n  EXPECT_EQ(fmt::format(\"{:}\", time), \"1979-03-12 12:00:00\");\n\n  EXPECT_EQ(fmt::format(\"{:%%}\", time), \"%\");\n  EXPECT_EQ(fmt::format(\"{:%n}\", time), \"\\n\");\n  EXPECT_EQ(fmt::format(\"{:%t}\", time), \"\\t\");\n  EXPECT_EQ(fmt::format(\"{:%Y}\", time), \"1979\");\n  EXPECT_EQ(fmt::format(\"{:%EY}\", time), \"1979\");\n  EXPECT_EQ(fmt::format(\"{:%y}\", time), \"79\");\n  EXPECT_EQ(fmt::format(\"{:%Oy}\", time), \"79\");\n  EXPECT_EQ(fmt::format(\"{:%Ey}\", time), \"79\");\n  EXPECT_EQ(fmt::format(\"{:%C}\", time), \"19\");\n  EXPECT_EQ(fmt::format(\"{:%EC}\", time), \"19\");\n  EXPECT_EQ(fmt::format(\"{:%G}\", time), \"1979\");\n  EXPECT_EQ(fmt::format(\"{:%g}\", time), \"79\");\n  EXPECT_EQ(fmt::format(\"{:%b}\", time), \"Mar\");\n  EXPECT_EQ(fmt::format(\"{:%h}\", time), \"Mar\");\n  EXPECT_EQ(fmt::format(\"{:%B}\", time), \"March\");\n  EXPECT_EQ(fmt::format(\"{:%m}\", time), \"03\");\n  EXPECT_EQ(fmt::format(\"{:%Om}\", time), \"03\");\n  EXPECT_EQ(fmt::format(\"{:%U}\", time), \"10\");\n  EXPECT_EQ(fmt::format(\"{:%OU}\", time), \"10\");\n  EXPECT_EQ(fmt::format(\"{:%W}\", time), \"11\");\n  EXPECT_EQ(fmt::format(\"{:%OW}\", time), \"11\");\n  EXPECT_EQ(fmt::format(\"{:%V}\", time), \"11\");\n  EXPECT_EQ(fmt::format(\"{:%OV}\", time), \"11\");\n  EXPECT_EQ(fmt::format(\"{:%j}\", time), \"071\");\n  EXPECT_EQ(fmt::format(\"{:%d}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%Od}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%e}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%Oe}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%a}\", time), \"Mon\");\n  EXPECT_EQ(fmt::format(\"{:%A}\", time), \"Monday\");\n  EXPECT_EQ(fmt::format(\"{:%w}\", time), \"1\");\n  EXPECT_EQ(fmt::format(\"{:%Ow}\", time), \"1\");\n  EXPECT_EQ(fmt::format(\"{:%u}\", time), \"1\");\n  EXPECT_EQ(fmt::format(\"{:%Ou}\", time), \"1\");\n  EXPECT_EQ(fmt::format(\"{:%H}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%OH}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%I}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%OI}\", time), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%M}\", time), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%OM}\", time), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", time), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%OS}\", time), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%x}\", time), \"03/12/79\");\n  EXPECT_EQ(fmt::format(\"{:%Ex}\", time), \"03/12/79\");\n  EXPECT_EQ(fmt::format(\"{:%X}\", time), \"12:00:00\");\n  EXPECT_EQ(fmt::format(\"{:%EX}\", time), \"12:00:00\");\n  EXPECT_EQ(fmt::format(\"{:%D}\", time), \"03/12/79\");\n  EXPECT_EQ(fmt::format(\"{:%F}\", time), \"1979-03-12\");\n  EXPECT_EQ(fmt::format(\"{:%R}\", time), \"12:00\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", time), \"12:00:00\");\n  EXPECT_EQ(fmt::format(\"{:%p}\", time), \"PM\");\n  EXPECT_EQ(fmt::format(\"{:%c}\", time), \"Mon Mar 12 12:00:00 1979\");\n  EXPECT_EQ(fmt::format(\"{:%Ec}\", time), \"Mon Mar 12 12:00:00 1979\");\n  EXPECT_EQ(fmt::format(\"{:%r}\", time), \"12:00:00 PM\");\n\n  EXPECT_EQ(fmt::format(\"{:%Y-%m-%d %H:%M:%S}\", time), \"1979-03-12 12:00:00\");\n}\n\nTEST(chrono_test, sys_time) {\n  auto time =\n      fmt::sys_time<std::chrono::seconds>(std::chrono::seconds(290088000));\n  test_time(time);\n  EXPECT_EQ(fmt::format(\"{:%z}\", time), \"+0000\");\n  EXPECT_EQ(fmt::format(\"{:%Ez}\", time), \"+00:00\");\n  EXPECT_EQ(fmt::format(\"{:%Oz}\", time), \"+00:00\");\n  EXPECT_EQ(fmt::format(\"{:%Z}\", time), \"UTC\");\n}\n\nTEST(chrono_test, local_time) {\n  auto time =\n      fmt::local_time<std::chrono::seconds>(std::chrono::seconds(290088000));\n  test_time(time);\n  EXPECT_THROW_MSG((void)fmt::format(fmt::runtime(\"{:%z}\"), time),\n                   fmt::format_error, \"no timezone\");\n  EXPECT_THROW_MSG((void)fmt::format(fmt::runtime(\"{:%Z}\"), time),\n                   fmt::format_error, \"no timezone\");\n}\n\ntemplate <typename T, FMT_ENABLE_IF(fmt::detail::has_tm_gmtoff<T>::value)>\nauto set_tm_gmtoff(T& time, long offset) -> bool {\n  time.tm_gmtoff = offset;\n  return true;\n}\ntemplate <typename T, FMT_ENABLE_IF(!fmt::detail::has_tm_gmtoff<T>::value)>\nauto set_tm_gmtoff(T&, long) -> bool {\n  return false;\n}\n\nTEST(chrono_test, tm) {\n  auto time = fmt::gmtime(290088000);\n  test_time(time);\n  if (set_tm_gmtoff(time, -28800)) {\n    EXPECT_EQ(fmt::format(fmt::runtime(\"{:%z}\"), time), \"-0800\");\n    EXPECT_EQ(fmt::format(fmt::runtime(\"{:%Ez}\"), time), \"-08:00\");\n    EXPECT_EQ(fmt::format(fmt::runtime(\"{:%Oz}\"), time), \"-08:00\");\n  } else {\n    EXPECT_THROW_MSG((void)fmt::format(fmt::runtime(\"{:%z}\"), time),\n                     fmt::format_error, \"no timezone\");\n  }\n  char tz[] = \"EET\";\n  if (fmt::detail::set_tm_zone(time, tz)) {\n    EXPECT_EQ(fmt::format(fmt::runtime(\"{:%Z}\"), time), \"EET\");\n  } else {\n    EXPECT_THROW_MSG((void)fmt::format(fmt::runtime(\"{:%Z}\"), time),\n                     fmt::format_error, \"no timezone\");\n  }\n}\n\nTEST(chrono_test, daylight_savings_time_end) {\n  // 2024-10-27 03:05 as the number of seconds since epoch in Europe/Kyiv time.\n  // It is slightly after the DST end and passing it to to_sys will result in\n  // an ambiguous time error:\n  //   2024-10-27 03:05:00 is ambiguous.  It could be\n  //   2024-10-27 03:05:00 EEST == 2024-10-27 00:05:00 UTC or\n  //   2024-10-27 03:05:00 EET == 2024-10-27 01:05:00 UTC\n  auto t =\n      fmt::local_time<std::chrono::seconds>(std::chrono::seconds(1729998300));\n  EXPECT_EQ(fmt::format(\"{}\", t), \"2024-10-27 03:05:00\");\n}\n\nTEST(chrono_test, format_default) {\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::seconds(42)), \"42s\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::atto>(42)),\n            \"42as\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::femto>(42)),\n            \"42fs\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::pico>(42)),\n            \"42ps\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::nanoseconds(42)), \"42ns\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::microseconds(42)), \"42µs\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::milliseconds(42)), \"42ms\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::centi>(42)),\n            \"42cs\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::deci>(42)),\n            \"42ds\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::seconds(42)), \"42s\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::deca>(42)),\n            \"42das\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::hecto>(42)),\n            \"42hs\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::kilo>(42)),\n            \"42ks\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::mega>(42)),\n            \"42Ms\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::giga>(42)),\n            \"42Gs\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::tera>(42)),\n            \"42Ts\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::peta>(42)),\n            \"42Ps\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<int, std::exa>(42)),\n            \"42Es\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::minutes(42)), \"42min\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::hours(42)), \"42h\");\n  EXPECT_EQ(fmt::format(\"{}\", days(42)), \"42d\");\n  EXPECT_EQ(\n      fmt::format(\"{}\", std::chrono::duration<int, std::ratio<15, 1>>(42)),\n      \"42[15]s\");\n  EXPECT_EQ(\n      fmt::format(\"{}\", std::chrono::duration<int, std::ratio<15, 4>>(42)),\n      \"42[15/4]s\");\n}\n\nTEST(chrono_test, duration_align) {\n  auto s = std::chrono::seconds(42);\n  EXPECT_EQ(fmt::format(\"{:5}\", s), \"42s  \");\n  EXPECT_EQ(fmt::format(\"{:{}}\", s, 5), \"42s  \");\n  EXPECT_EQ(fmt::format(\"{:>5}\", s), \"  42s\");\n  EXPECT_EQ(fmt::format(\"{:*^7}\", s), \"**42s**\");\n  EXPECT_EQ(fmt::format(\"{:12%H:%M:%S}\", std::chrono::seconds(12345)),\n            \"03:25:45    \");\n  EXPECT_EQ(fmt::format(\"{:>12%H:%M:%S}\", std::chrono::seconds(12345)),\n            \"    03:25:45\");\n  EXPECT_EQ(fmt::format(\"{:~^12%H:%M:%S}\", std::chrono::seconds(12345)),\n            \"~~03:25:45~~\");\n  EXPECT_EQ(fmt::format(\"{:{}%H:%M:%S}\", std::chrono::seconds(12345), 12),\n            \"03:25:45    \");\n}\n\nTEST(chrono_test, tm_align) {\n  auto t = make_tm(1975, 12, 29, 12, 14, 16);\n  EXPECT_EQ(fmt::format(\"{:%F %T}\", t), \"1975-12-29 12:14:16\");\n  EXPECT_EQ(fmt::format(\"{:30%F %T}\", t), \"1975-12-29 12:14:16           \");\n  EXPECT_EQ(fmt::format(\"{:{}%F %T}\", t, 30), \"1975-12-29 12:14:16           \");\n  EXPECT_EQ(fmt::format(\"{:<30%F %T}\", t), \"1975-12-29 12:14:16           \");\n  EXPECT_EQ(fmt::format(\"{:^30%F %T}\", t), \"     1975-12-29 12:14:16      \");\n  EXPECT_EQ(fmt::format(\"{:>30%F %T}\", t), \"           1975-12-29 12:14:16\");\n\n  EXPECT_EQ(fmt::format(\"{:*<30%F %T}\", t), \"1975-12-29 12:14:16***********\");\n  EXPECT_EQ(fmt::format(\"{:*^30%F %T}\", t), \"*****1975-12-29 12:14:16******\");\n  EXPECT_EQ(fmt::format(\"{:*>30%F %T}\", t), \"***********1975-12-29 12:14:16\");\n}\n\nTEST(chrono_test, tp_align) {\n  auto tp = std::chrono::time_point_cast<std::chrono::microseconds>(\n      std::chrono::system_clock::from_time_t(0));\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", tp), \"00:00.000000\");\n  EXPECT_EQ(fmt::format(\"{:15%M:%S}\", tp), \"00:00.000000   \");\n  EXPECT_EQ(fmt::format(\"{:{}%M:%S}\", tp, 15), \"00:00.000000   \");\n  EXPECT_EQ(fmt::format(\"{:<15%M:%S}\", tp), \"00:00.000000   \");\n  EXPECT_EQ(fmt::format(\"{:^15%M:%S}\", tp), \" 00:00.000000  \");\n  EXPECT_EQ(fmt::format(\"{:>15%M:%S}\", tp), \"   00:00.000000\");\n\n  EXPECT_EQ(fmt::format(\"{:*<15%M:%S}\", tp), \"00:00.000000***\");\n  EXPECT_EQ(fmt::format(\"{:*^15%M:%S}\", tp), \"*00:00.000000**\");\n  EXPECT_EQ(fmt::format(\"{:*>15%M:%S}\", tp), \"***00:00.000000\");\n}\n\nTEST(chrono_test, format_specs) {\n  EXPECT_EQ(fmt::format(\"{:%%}\", std::chrono::seconds(0)), \"%\");\n  EXPECT_EQ(fmt::format(\"{:%n}\", std::chrono::seconds(0)), \"\\n\");\n  EXPECT_EQ(fmt::format(\"{:%t}\", std::chrono::seconds(0)), \"\\t\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::seconds(0)), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::seconds(60)), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::seconds(42)), \"42\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::milliseconds(1234)), \"01.234\");\n  EXPECT_EQ(fmt::format(\"{:%M}\", std::chrono::minutes(0)), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%M}\", std::chrono::minutes(60)), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%M}\", std::chrono::minutes(42)), \"42\");\n  EXPECT_EQ(fmt::format(\"{:%M}\", std::chrono::seconds(61)), \"01\");\n  EXPECT_EQ(fmt::format(\"{:%H}\", std::chrono::hours(0)), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%H}\", std::chrono::hours(24)), \"00\");\n  EXPECT_EQ(fmt::format(\"{:%H}\", std::chrono::hours(14)), \"14\");\n  EXPECT_EQ(fmt::format(\"{:%H}\", std::chrono::minutes(61)), \"01\");\n  EXPECT_EQ(fmt::format(\"{:%I}\", std::chrono::hours(0)), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%I}\", std::chrono::hours(12)), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%I}\", std::chrono::hours(24)), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%I}\", std::chrono::hours(4)), \"04\");\n  EXPECT_EQ(fmt::format(\"{:%I}\", std::chrono::hours(14)), \"02\");\n  EXPECT_EQ(fmt::format(\"{:%j}\", days(12)), \"12\");\n  EXPECT_EQ(fmt::format(\"{:%j}\", days(12345)), \"12345\");\n  EXPECT_EQ(fmt::format(\"{:%j}\", std::chrono::hours(12345 * 24 + 12)), \"12345\");\n  EXPECT_EQ(fmt::format(\"{:%H:%M:%S}\", std::chrono::seconds(12345)),\n            \"03:25:45\");\n  EXPECT_EQ(fmt::format(\"{:%R}\", std::chrono::seconds(12345)), \"03:25\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", std::chrono::seconds(12345)), \"03:25:45\");\n  EXPECT_EQ(fmt::format(\"{:%Q}\", std::chrono::seconds(12345)), \"12345\");\n  EXPECT_EQ(fmt::format(\"{:%q}\", std::chrono::seconds(12345)), \"s\");\n}\n\nTEST(chrono_test, invalid_specs) {\n  auto sec = std::chrono::seconds(0);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%a}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%A}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%c}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%x}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%Ex}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%X}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%EX}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%D}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%F}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%Ec}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%w}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%u}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%b}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%B}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%z}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%Z}\"), sec), fmt::format_error,\n                   \"no date\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%Eq}\"), sec), fmt::format_error,\n                   \"invalid format\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%Oq}\"), sec), fmt::format_error,\n                   \"invalid format\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:abc}\"), sec), fmt::format_error,\n                   \"invalid format\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:.2f}\"), sec), fmt::format_error,\n                   \"invalid format\");\n}\n\nauto format_tm(const std::tm& time, fmt::string_view spec,\n               const std::locale& loc) -> std::string {\n  auto& facet = std::use_facet<std::time_put<char>>(loc);\n  std::ostringstream os;\n  os.imbue(loc);\n  facet.put(os, os, ' ', &time, spec.begin(), spec.end());\n  return os.str();\n}\n\nTEST(chrono_test, locale) {\n  auto loc = get_locale(\"ja_JP.utf8\");\n  if (loc == std::locale::classic()) return;\n#define EXPECT_TIME(spec, time, duration)                     \\\n  {                                                           \\\n    auto jp_loc = std::locale(\"ja_JP.utf8\");                  \\\n    EXPECT_EQ(format_tm(time, spec, jp_loc),                  \\\n              fmt::format(jp_loc, \"{:L\" spec \"}\", duration)); \\\n  }\n  EXPECT_TIME(\"%OH\", make_hour(14), std::chrono::hours(14));\n  EXPECT_TIME(\"%OI\", make_hour(14), std::chrono::hours(14));\n  EXPECT_TIME(\"%OM\", make_minute(42), std::chrono::minutes(42));\n  EXPECT_TIME(\"%OS\", make_second(42), std::chrono::seconds(42));\n  auto time = make_tm();\n  time.tm_hour = 3;\n  time.tm_min = 25;\n  time.tm_sec = 45;\n  auto sec = std::chrono::seconds(12345);\n  EXPECT_TIME(\"%r\", time, sec);\n  EXPECT_TIME(\"%p\", time, sec);\n}\n\nusing dms = std::chrono::duration<double, std::milli>;\n\nTEST(chrono_test, format_default_fp) {\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<float>(1.234)), \"1.234s\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<float, std::milli>(1.234)),\n            \"1.234ms\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<double>(1.234)), \"1.234s\");\n  EXPECT_EQ(fmt::format(\"{}\", dms(1.234)), \"1.234ms\");\n}\n\nTEST(chrono_test, format_precision) {\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{:.2%Q}\"), std::chrono::seconds(42)),\n      fmt::format_error, \"precision not allowed for this argument type\");\n  EXPECT_EQ(fmt::format(\"{:.0}\", dms(1.234)), \"1ms\");\n  EXPECT_EQ(fmt::format(\"{:.1}\", dms(1.234)), \"1.2ms\");\n  EXPECT_EQ(fmt::format(\"{:.{}}\", dms(1.234), 2), \"1.23ms\");\n\n  EXPECT_EQ(fmt::format(\"{:.0}\", dms(12.56)), \"13ms\");\n  EXPECT_EQ(fmt::format(\"{:.1}\", dms(12.56)), \"12.6ms\");\n  EXPECT_EQ(fmt::format(\"{:.2}\", dms(12.56)), \"12.56ms\");\n}\n\nTEST(chrono_test, format_full_specs) {\n  EXPECT_EQ(fmt::format(\"{:6.0}\", dms(1.234)), \"1ms   \");\n  EXPECT_EQ(fmt::format(\"{:6.1}\", dms(1.234)), \"1.2ms \");\n  EXPECT_EQ(fmt::format(\"{:>8.{}}\", dms(1.234), 2), \"  1.23ms\");\n  EXPECT_EQ(fmt::format(\"{:^{}.{}}\", dms(1.234), 7, 1), \" 1.2ms \");\n  EXPECT_EQ(fmt::format(\"{0:^{2}.{1}}\", dms(1.234), 2, 8), \" 1.23ms \");\n  EXPECT_EQ(fmt::format(\"{:=^{}.{}}\", dms(1.234), 9, 3), \"=1.234ms=\");\n  EXPECT_EQ(fmt::format(\"{:*^10.4}\", dms(1.234)), \"*1.2340ms*\");\n\n  EXPECT_EQ(fmt::format(\"{:6.0}\", dms(12.56)), \"13ms  \");\n  EXPECT_EQ(fmt::format(\"{:>8.{}}\", dms(12.56), 0), \"    13ms\");\n  EXPECT_EQ(fmt::format(\"{:^{}.{}}\", dms(12.56), 6, 0), \" 13ms \");\n  EXPECT_EQ(fmt::format(\"{0:^{2}.{1}}\", dms(12.56), 0, 8), \"  13ms  \");\n  EXPECT_EQ(fmt::format(\"{:=^{}.{}}\", dms(12.56), 9, 0), \"==13ms===\");\n  EXPECT_EQ(fmt::format(\"{:*^10.0}\", dms(12.56)), \"***13ms***\");\n}\n\nTEST(chrono_test, format_simple_q) {\n  EXPECT_EQ(fmt::format(\"{:%Q %q}\", std::chrono::duration<float>(1.234)),\n            \"1.234 s\");\n  EXPECT_EQ(\n      fmt::format(\"{:%Q %q}\", std::chrono::duration<float, std::milli>(1.234)),\n      \"1.234 ms\");\n  EXPECT_EQ(fmt::format(\"{:%Q %q}\", std::chrono::duration<double>(1.234)),\n            \"1.234 s\");\n  EXPECT_EQ(fmt::format(\"{:%Q %q}\", dms(1.234)), \"1.234 ms\");\n}\n\nTEST(chrono_test, format_precision_q) {\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{:.2%Q %q}\"), std::chrono::seconds(42)),\n      fmt::format_error, \"precision not allowed for this argument type\");\n  EXPECT_EQ(fmt::format(\"{:.1%Q %q}\", dms(1.234)), \"1.2 ms\");\n  EXPECT_EQ(fmt::format(\"{:.{}%Q %q}\", dms(1.234), 2), \"1.23 ms\");\n}\n\nTEST(chrono_test, format_full_specs_q) {\n  EXPECT_EQ(fmt::format(\"{:7.0%Q %q}\", dms(1.234)), \"1 ms   \");\n  EXPECT_EQ(fmt::format(\"{:7.1%Q %q}\", dms(1.234)), \"1.2 ms \");\n  EXPECT_EQ(fmt::format(\"{:>8.{}%Q %q}\", dms(1.234), 2), \" 1.23 ms\");\n  EXPECT_EQ(fmt::format(\"{:^{}.{}%Q %q}\", dms(1.234), 8, 1), \" 1.2 ms \");\n  EXPECT_EQ(fmt::format(\"{0:^{2}.{1}%Q %q}\", dms(1.234), 2, 9), \" 1.23 ms \");\n  EXPECT_EQ(fmt::format(\"{:=^{}.{}%Q %q}\", dms(1.234), 10, 3), \"=1.234 ms=\");\n  EXPECT_EQ(fmt::format(\"{:*^11.4%Q %q}\", dms(1.234)), \"*1.2340 ms*\");\n\n  EXPECT_EQ(fmt::format(\"{:7.0%Q %q}\", dms(12.56)), \"13 ms  \");\n  EXPECT_EQ(fmt::format(\"{:>8.{}%Q %q}\", dms(12.56), 0), \"   13 ms\");\n  EXPECT_EQ(fmt::format(\"{:^{}.{}%Q %q}\", dms(12.56), 8, 0), \" 13 ms  \");\n  EXPECT_EQ(fmt::format(\"{0:^{2}.{1}%Q %q}\", dms(12.56), 0, 9), \"  13 ms  \");\n  EXPECT_EQ(fmt::format(\"{:=^{}.{}%Q %q}\", dms(12.56), 9, 0), \"==13 ms==\");\n  EXPECT_EQ(fmt::format(\"{:*^11.0%Q %q}\", dms(12.56)), \"***13 ms***\");\n}\n\nTEST(chrono_test, invalid_width_id) {\n  EXPECT_THROW((void)fmt::format(runtime(\"{:{o}\"), std::chrono::seconds(0)),\n               fmt::format_error);\n}\n\nTEST(chrono_test, invalid_colons) {\n  EXPECT_THROW((void)fmt::format(runtime(\"{0}=:{0::\"), std::chrono::seconds(0)),\n               fmt::format_error);\n}\n\nTEST(chrono_test, negative_durations) {\n  EXPECT_EQ(fmt::format(\"{:%Q}\", std::chrono::seconds(-12345)), \"-12345\");\n  EXPECT_EQ(fmt::format(\"{:%H:%M:%S}\", std::chrono::seconds(-12345)),\n            \"-03:25:45\");\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", std::chrono::duration<double>(-1)),\n            \"-00:01\");\n  EXPECT_EQ(fmt::format(\"{:%q}\", std::chrono::seconds(-12345)), \"s\");\n  EXPECT_EQ(fmt::format(\"{:%S}\",\n                        std::chrono::duration<signed char, std::milli>(-127)),\n            \"-00.127\");\n  auto min = std::numeric_limits<int>::min();\n  EXPECT_EQ(fmt::format(\"{}\", min),\n            fmt::format(\"{:%Q}\", std::chrono::duration<int>(min)));\n}\n\nTEST(chrono_test, special_durations) {\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::duration<double>(1e20)), \"40\");\n  auto nan = std::numeric_limits<double>::quiet_NaN();\n  EXPECT_EQ(\n      fmt::format(\"{:%I %H %M %S %R %r}\", std::chrono::duration<double>(nan)),\n      \"nan nan nan nan nan:nan nan\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<float, std::exa>(1)),\n            \"1Es\");\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<float, std::atto>(1)),\n            \"1as\");\n  EXPECT_EQ(fmt::format(\"{:%R}\", std::chrono::duration<char, std::mega>{2}),\n            \"03:33\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", std::chrono::duration<char, std::mega>{2}),\n            \"03:33:20\");\n  EXPECT_EQ(\n      fmt::format(\"{:.3%S}\", std::chrono::duration<float, std::pico>(1.234e12)),\n      \"01.234\");\n}\n\nTEST(chrono_test, unsigned_duration) {\n  EXPECT_EQ(fmt::format(\"{}\", std::chrono::duration<unsigned>(42)), \"42s\");\n}\n\nTEST(chrono_test, weekday) {\n  auto loc = get_locale(\"es_ES.UTF-8\");\n  std::locale::global(loc);\n\n  auto sat = fmt::weekday(6);\n\n  auto tm = std::tm();\n  tm.tm_wday = static_cast<int>(sat.c_encoding());\n\n  EXPECT_EQ(fmt::format(\"{}\", sat), \"Sat\");\n  EXPECT_EQ(fmt::format(\"{:%a}\", sat), \"Sat\");\n  EXPECT_EQ(fmt::format(\"{:%A}\", sat), \"Saturday\");\n  EXPECT_EQ(fmt::format(\"{:%a}\", tm), \"Sat\");\n\n  if (loc != std::locale::classic()) {\n    auto saturdays = std::vector<std::string>{\"sáb\", \"sá.\", \"sáb.\"};\n    EXPECT_THAT(saturdays, Contains(fmt::format(loc, \"{:L}\", sat)));\n    EXPECT_THAT(saturdays, Contains(fmt::format(loc, \"{:L%a}\", sat)));\n    EXPECT_THAT(saturdays, Contains(fmt::format(loc, \"{:L%a}\", tm)));\n  }\n}\n\nTEST(chrono_test, cpp20_duration_subsecond_support) {\n  using attoseconds = std::chrono::duration<long long, std::atto>;\n  // Check that 18 digits of subsecond precision are supported.\n  EXPECT_EQ(fmt::format(\"{:%S}\", attoseconds{999999999999999999}),\n            \"00.999999999999999999\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", attoseconds{673231113420148734}),\n            \"00.673231113420148734\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", attoseconds{-673231113420148734}),\n            \"-00.673231113420148734\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::nanoseconds{13420148734}),\n            \"13.420148734\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::nanoseconds{-13420148734}),\n            \"-13.420148734\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::milliseconds{1234}), \"01.234\");\n  // Check subsecond presision modifier.\n  EXPECT_EQ(fmt::format(\"{:.6%S}\", std::chrono::nanoseconds{1234}),\n            \"00.000001\");\n  EXPECT_EQ(fmt::format(\"{:.18%S}\", std::chrono::nanoseconds{1234}),\n            \"00.000001234000000000\");\n  EXPECT_EQ(fmt::format(\"{:.{}%S}\", std::chrono::nanoseconds{1234}, 6),\n            \"00.000001\");\n  EXPECT_EQ(fmt::format(\"{:.6%S}\", std::chrono::milliseconds{1234}),\n            \"01.234000\");\n  EXPECT_EQ(fmt::format(\"{:.6%S}\", std::chrono::milliseconds{-1234}),\n            \"-01.234000\");\n  EXPECT_EQ(fmt::format(\"{:.2%S}\", std::chrono::milliseconds{12345}), \"12.34\");\n  EXPECT_EQ(fmt::format(\"{:.2%S}\", std::chrono::milliseconds{12375}), \"12.37\");\n  EXPECT_EQ(fmt::format(\"{:.2%S}\", std::chrono::milliseconds{-12375}),\n            \"-12.37\");\n  EXPECT_EQ(fmt::format(\"{:.0%S}\", std::chrono::milliseconds{12054}), \"12\");\n  EXPECT_EQ(fmt::format(\"{:.2%S}\", std::chrono::milliseconds{99999}), \"39.99\");\n  EXPECT_EQ(fmt::format(\"{:.2%S}\", std::chrono::milliseconds{1000}), \"01.00\");\n  EXPECT_EQ(fmt::format(\"{:.3%S}\", std::chrono::milliseconds{1}), \"00.001\");\n  EXPECT_EQ(fmt::format(\"{:.3%S}\", std::chrono::seconds{1234}), \"34.000\");\n  EXPECT_EQ(fmt::format(\"{:.3%S}\", std::chrono::hours{1234}), \"00.000\");\n  EXPECT_EQ(fmt::format(\"{:.5%S}\", dms(1.234)), \"00.00123\");\n  EXPECT_EQ(fmt::format(\"{:.8%S}\", dms(1.234)), \"00.00123400\");\n  {\n    // Check that {:%H:%M:%S} is equivalent to {:%T}.\n    auto dur = std::chrono::milliseconds{3601234};\n    auto formatted_dur = fmt::format(\"{:%T}\", dur);\n    EXPECT_EQ(formatted_dur, \"01:00:01.234\");\n    EXPECT_EQ(fmt::format(\"{:%H:%M:%S}\", dur), formatted_dur);\n    EXPECT_EQ(fmt::format(\"{:.6%H:%M:%S}\", dur), \"01:00:01.234000\");\n  }\n  using nanoseconds_dbl = std::chrono::duration<double, std::nano>;\n  EXPECT_EQ(fmt::format(\"{:%S}\", nanoseconds_dbl(-123456789)), \"-00.123456789\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", nanoseconds_dbl(9123456789)), \"09.123456789\");\n  // Verify that only the seconds part is extracted and printed.\n  EXPECT_EQ(fmt::format(\"{:%S}\", nanoseconds_dbl(99123456789)), \"39.123456789\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", nanoseconds_dbl(99123000000)), \"39.123000000\");\n  {\n    // Now the hour is printed, and we also test if negative doubles work.\n    auto dur = nanoseconds_dbl{-99123456789};\n    auto formatted_dur = fmt::format(\"{:%T}\", dur);\n    EXPECT_EQ(formatted_dur, \"-00:01:39.123456789\");\n    EXPECT_EQ(fmt::format(\"{:%H:%M:%S}\", dur), formatted_dur);\n    EXPECT_EQ(fmt::format(\"{:.3%H:%M:%S}\", dur), \"-00:01:39.123\");\n  }\n  // Check that durations with precision greater than std::chrono::seconds have\n  // fixed precision, and print zeros even if there is no fractional part.\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::microseconds(7000000)),\n            \"07.000000\");\n  EXPECT_EQ(fmt::format(\"{:%S}\",\n                        std::chrono::duration<long long, std::ratio<1, 3>>(1)),\n            \"00.333333\");\n  EXPECT_EQ(fmt::format(\"{:%S}\",\n                        std::chrono::duration<long long, std::ratio<1, 7>>(1)),\n            \"00.142857\");\n\n  EXPECT_EQ(\n      fmt::format(\"{:%S}\",\n                  std::chrono::duration<signed char, std::ratio<1, 100>>(0x80)),\n      \"-01.28\");\n\n  EXPECT_EQ(\n      fmt::format(\"{:%M:%S}\",\n                  std::chrono::duration<short, std::ratio<1, 100>>(0x8000)),\n      \"-05:27.68\");\n\n  // Check that floating point seconds with ratio<1,1> are printed.\n  EXPECT_EQ(fmt::format(\"{:%S}\", std::chrono::duration<double>(1.5)),\n            \"01.500000\");\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", std::chrono::duration<double>(-61.25)),\n            \"-01:01.250000\");\n}\n\n// Disable the utc_clock test for windows, as the icu.dll used for tzdb\n// (time zone database) is not shipped with many windows versions.\n#if FMT_USE_UTC_TIME && !defined(_WIN32)\nTEST(chrono_test, utc_clock) {\n  auto t1 = std::chrono::system_clock::now();\n  auto t1_utc = std::chrono::utc_clock::from_sys(t1);\n  EXPECT_EQ(fmt::format(\"{:%Y-%m-%d %H:%M:%S}\", t1),\n            fmt::format(\"{:%Y-%m-%d %H:%M:%S}\", t1_utc));\n}\n#endif\n\nTEST(chrono_test, timestamp_ratios) {\n  auto t1 =\n      sys_time<std::chrono::milliseconds>(std::chrono::milliseconds(67890));\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", t1), \"01:07.890\");\n\n  auto t2 = sys_time<std::chrono::minutes>(std::chrono::minutes(7));\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", t2), \"07:00\");\n\n  auto t3 = sys_time<std::chrono::duration<int, std::ratio<9>>>(\n      std::chrono::duration<int, std::ratio<9>>(7));\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", t3), \"01:03\");\n\n  auto t4 = sys_time<std::chrono::duration<int, std::ratio<63>>>(\n      std::chrono::duration<int, std::ratio<63>>(1));\n  EXPECT_EQ(fmt::format(\"{:%M:%S}\", t4), \"01:03\");\n\n  if (sizeof(time_t) > 4) {\n    auto tp =\n        sys_time<std::chrono::milliseconds>(std::chrono::seconds(32503680000));\n    EXPECT_EQ(fmt::format(\"{:%Y-%m-%d}\", tp), \"3000-01-01\");\n  }\n\n  if (FMT_SAFE_DURATION_CAST) {\n    using years = std::chrono::duration<std::int64_t, std::ratio<31556952>>;\n    auto tp = sys_time<years>(years(std::numeric_limits<std::int64_t>::max()));\n    EXPECT_THROW_MSG((void)fmt::format(\"{:%Y-%m-%d}\", tp), fmt::format_error,\n                     \"cannot format duration\");\n  }\n}\n\nTEST(chrono_test, timestamp_sub_seconds) {\n  auto t1 = sys_time<std::chrono::duration<long long, std::ratio<1, 3>>>(\n      std::chrono::duration<long long, std::ratio<1, 3>>(4));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t1), \"01.333333\");\n\n  auto t2 = sys_time<std::chrono::duration<double, std::ratio<1, 3>>>(\n      std::chrono::duration<double, std::ratio<1, 3>>(4));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t2), \"01.333333\");\n\n  auto t3 = sys_time<std::chrono::seconds>(std::chrono::seconds(2));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t3), \"02\");\n\n  auto t4 = sys_time<std::chrono::duration<double>>(\n      std::chrono::duration<double, std::ratio<1, 1>>(9.5));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t4), \"09.500000\");\n\n  auto t5 = sys_time<std::chrono::duration<double>>(\n      std::chrono::duration<double, std::ratio<1, 1>>(9));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t5), \"09\");\n\n  auto t6 = sys_time<std::chrono::milliseconds>(std::chrono::seconds(1) +\n                                                std::chrono::milliseconds(120));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t6), \"01.120\");\n\n  auto t7 =\n      sys_time<std::chrono::microseconds>(std::chrono::microseconds(1234567));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t7), \"01.234567\");\n\n  auto t8 =\n      sys_time<std::chrono::nanoseconds>(std::chrono::nanoseconds(123456789));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t8), \"00.123456789\");\n  EXPECT_EQ(fmt::format(\"{:%T}\", t8), \"00:00:00.123456789\");\n\n  auto t9 =\n      sys_time<std::chrono::milliseconds>(std::chrono::milliseconds(2000));\n  EXPECT_EQ(fmt::format(\"{:%S}\", t9), \"02.000\");\n\n  auto epoch = sys_time<std::chrono::milliseconds>();\n  auto d = std::chrono::milliseconds(250);\n  EXPECT_EQ(fmt::format(\"{:%S}\", epoch - d), \"59.750\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", epoch), \"00.000\");\n  EXPECT_EQ(fmt::format(\"{:%S}\", epoch + d), \"00.250\");\n}\n\nTEST(chrono_test, glibc_extensions) {\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%0}\"), std::chrono::seconds()),\n                   fmt::format_error, \"invalid format\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%_}\"), std::chrono::seconds()),\n                   fmt::format_error, \"invalid format\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:%-}\"), std::chrono::seconds()),\n                   fmt::format_error, \"invalid format\");\n\n  {\n    const auto d = std::chrono::hours(1) + std::chrono::minutes(2) +\n                   std::chrono::seconds(3);\n\n    EXPECT_EQ(fmt::format(\"{:%I,%H,%M,%S}\", d), \"01,01,02,03\");\n    EXPECT_EQ(fmt::format(\"{:%_I,%_H,%_M,%_S}\", d), \" 1, 1, 2, 3\");\n    EXPECT_EQ(fmt::format(\"{:%-I,%-H,%-M,%-S}\", d), \"1,1,2,3\");\n    EXPECT_EQ(fmt::format(\"{:%-I,%H,%M,%S}\", d), \"1,01,02,03\");\n\n    EXPECT_EQ(fmt::format(\"{:%OI,%OH,%OM,%OS}\", d), \"01,01,02,03\");\n    EXPECT_EQ(fmt::format(\"{:%_OI,%_OH,%_OM,%_OS}\", d), \" 1, 1, 2, 3\");\n    EXPECT_EQ(fmt::format(\"{:%-OI,%-OH,%-OM,%-OS}\", d), \"1,1,2,3\");\n  }\n\n  {\n    const auto tm = make_tm(1970, 1, 1, 1, 2, 3);\n    EXPECT_EQ(fmt::format(\"{:%I,%H,%M,%S}\", tm), \"01,01,02,03\");\n    EXPECT_EQ(fmt::format(\"{:%_I,%_H,%_M,%_S}\", tm), \" 1, 1, 2, 3\");\n    EXPECT_EQ(fmt::format(\"{:%-I,%-H,%-M,%-S}\", tm), \"1,1,2,3\");\n\n    EXPECT_EQ(fmt::format(\"{:%OI,%OH,%OM,%OS}\", tm), \"01,01,02,03\");\n    EXPECT_EQ(fmt::format(\"{:%_OI,%_OH,%_OM,%_OS}\", tm), \" 1, 1, 2, 3\");\n    EXPECT_EQ(fmt::format(\"{:%-OI,%-OH,%-OM,%-OS}\", tm), \"1,1,2,3\");\n  }\n\n  {\n    const auto d = std::chrono::seconds(3) + std::chrono::milliseconds(140);\n    EXPECT_EQ(fmt::format(\"{:%S}\", d), \"03.140\");\n    EXPECT_EQ(fmt::format(\"{:%_S}\", d), \" 3.140\");\n    EXPECT_EQ(fmt::format(\"{:%-S}\", d), \"3.140\");\n  }\n\n  {\n    auto d = std::chrono::duration<double>(3.14);\n    EXPECT_EQ(fmt::format(\"{:%S}\", d), \"03.140000\");\n    EXPECT_EQ(fmt::format(\"{:%_S}\", d), \" 3.140000\");\n    EXPECT_EQ(fmt::format(\"{:%-S}\", d), \"3.140000\");\n  }\n\n  {\n    auto t = std::tm();\n    t.tm_yday = 7;\n    EXPECT_EQ(fmt::format(\"{:%U,%W,%V}\", t), \"02,01,01\");\n    EXPECT_EQ(fmt::format(\"{:%_U,%_W,%_V}\", t), \" 2, 1, 1\");\n    EXPECT_EQ(fmt::format(\"{:%-U,%-W,%-V}\", t), \"2,1,1\");\n\n    EXPECT_EQ(fmt::format(\"{:%j}\", t), \"008\");\n    EXPECT_EQ(fmt::format(\"{:%_j}\", t), \"  8\");\n    EXPECT_EQ(fmt::format(\"{:%-j}\", t), \"8\");\n  }\n\n  {\n    auto t = std::tm();\n    t.tm_mday = 7;\n    EXPECT_EQ(fmt::format(\"{:%d}\", t), \"07\");\n    EXPECT_EQ(fmt::format(\"{:%_d}\", t), \" 7\");\n    EXPECT_EQ(fmt::format(\"{:%-d}\", t), \"7\");\n\n    EXPECT_EQ(fmt::format(\"{:%e}\", t), \" 7\");\n  }\n\n  {\n    auto t = std::tm();\n    t.tm_year = 7 - 1900;\n    EXPECT_EQ(fmt::format(\"{:%Y}\", t), \"0007\");\n    EXPECT_EQ(fmt::format(\"{:%_Y}\", t), \"   7\");\n    EXPECT_EQ(fmt::format(\"{:%-Y}\", t), \"7\");\n  }\n\n  {\n    auto t = std::tm();\n    t.tm_year = -5 - 1900;\n    EXPECT_EQ(fmt::format(\"{:%Y}\", t), \"-005\");\n    EXPECT_EQ(fmt::format(\"{:%_Y}\", t), \"  -5\");\n    EXPECT_EQ(fmt::format(\"{:%-Y}\", t), \"-5\");\n  }\n\n  {\n    auto t = std::tm();\n    t.tm_mon = 7 - 1;\n    EXPECT_EQ(fmt::format(\"{:%m}\", t), \"07\");\n    EXPECT_EQ(fmt::format(\"{:%_m}\", t), \" 7\");\n    EXPECT_EQ(fmt::format(\"{:%-m}\", t), \"7\");\n  }\n}\n\nTEST(chrono_test, out_of_range) {\n  auto d = std::chrono::duration<unsigned long, std::giga>(538976288);\n  EXPECT_THROW((void)fmt::format(\"{:%j}\", d), fmt::format_error);\n}\n\nTEST(chrono_test, year_month_day) {\n  auto loc = get_locale(\"es_ES.UTF-8\");\n  std::locale::global(loc);\n\n  auto year = fmt::year(2024);\n  auto month = fmt::month(1);\n  auto day = fmt::day(1);\n  auto ymd = fmt::year_month_day(year, month, day);\n\n  EXPECT_EQ(fmt::format(\"{}\", year), \"2024\");\n  EXPECT_EQ(fmt::format(\"{:%Y}\", year), \"2024\");\n  EXPECT_EQ(fmt::format(\"{:%y}\", year), \"24\");\n\n  EXPECT_EQ(fmt::format(\"{}\", month), \"Jan\");\n  EXPECT_EQ(fmt::format(\"{:%m}\", month), \"01\");\n  EXPECT_EQ(fmt::format(\"{:%b}\", month), \"Jan\");\n  EXPECT_EQ(fmt::format(\"{:%B}\", month), \"January\");\n\n  EXPECT_EQ(fmt::format(\"{}\", day), \"01\");\n  EXPECT_EQ(fmt::format(\"{:%d}\", day), \"01\");\n\n  EXPECT_EQ(fmt::format(\"{}\", ymd), \"2024-01-01\");\n  EXPECT_EQ(fmt::format(\"{:%Y-%m-%d}\", ymd), \"2024-01-01\");\n  EXPECT_EQ(fmt::format(\"{:%Y-%b-%d}\", ymd), \"2024-Jan-01\");\n  EXPECT_EQ(fmt::format(\"{:%Y-%B-%d}\", ymd), \"2024-January-01\");\n\n  if (loc != std::locale::classic()) {\n    auto months = std::vector<std::string>{\"ene.\", \"ene\"};\n    EXPECT_THAT(months, Contains(fmt::format(loc, \"{:L}\", month)));\n    EXPECT_THAT(months, Contains(fmt::format(loc, \"{:L%b}\", month)));\n  }\n}\n"
  },
  {
    "path": "test/color-test.cc",
    "content": "// Formatting library for C++ - color tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/color.h\"\n\n#include <iterator>  // std::back_inserter\n\n#include \"gtest-extra.h\"  // EXPECT_WRITE, EXPECT_THROW_MSG\n\nTEST(color_test, text_style) {\n  EXPECT_FALSE(fmt::text_style().has_foreground());\n  EXPECT_FALSE(fmt::text_style().has_background());\n  EXPECT_FALSE(fmt::text_style().has_emphasis());\n\n  EXPECT_TRUE(fg(fmt::rgb(0)).has_foreground());\n  EXPECT_FALSE(fg(fmt::rgb(0)).has_background());\n  EXPECT_FALSE(fg(fmt::rgb(0)).has_emphasis());\n  EXPECT_TRUE(bg(fmt::rgb(0)).has_background());\n  EXPECT_FALSE(bg(fmt::rgb(0)).has_foreground());\n  EXPECT_FALSE(bg(fmt::rgb(0)).has_emphasis());\n\n  EXPECT_TRUE(\n      (fg(fmt::rgb(0xFFFFFF)) | bg(fmt::rgb(0xFFFFFF))).has_foreground());\n  EXPECT_TRUE(\n      (fg(fmt::rgb(0xFFFFFF)) | bg(fmt::rgb(0xFFFFFF))).has_background());\n  EXPECT_FALSE(\n      (fg(fmt::rgb(0xFFFFFF)) | bg(fmt::rgb(0xFFFFFF))).has_emphasis());\n\n  EXPECT_EQ(fg(fmt::rgb(0x000000)) | fg(fmt::rgb(0x000000)),\n            fg(fmt::rgb(0x000000)));\n  EXPECT_EQ(fg(fmt::rgb(0x00000F)) | fg(fmt::rgb(0x00000F)),\n            fg(fmt::rgb(0x00000F)));\n  EXPECT_EQ(fg(fmt::rgb(0xC0F000)) | fg(fmt::rgb(0x000FEE)),\n            fg(fmt::rgb(0xC0FFEE)));\n\n  EXPECT_THROW_MSG(\n      fg(fmt::terminal_color::black) | fg(fmt::terminal_color::black),\n      fmt::format_error, \"can't OR a terminal color\");\n  EXPECT_THROW_MSG(\n      fg(fmt::terminal_color::black) | fg(fmt::terminal_color::white),\n      fmt::format_error, \"can't OR a terminal color\");\n  EXPECT_THROW_MSG(\n      bg(fmt::terminal_color::black) | bg(fmt::terminal_color::black),\n      fmt::format_error, \"can't OR a terminal color\");\n  EXPECT_THROW_MSG(\n      bg(fmt::terminal_color::black) | bg(fmt::terminal_color::white),\n      fmt::format_error, \"can't OR a terminal color\");\n  EXPECT_THROW_MSG(fg(fmt::terminal_color::black) | fg(fmt::color::black),\n                   fmt::format_error, \"can't OR a terminal color\");\n  EXPECT_THROW_MSG(bg(fmt::terminal_color::black) | bg(fmt::color::black),\n                   fmt::format_error, \"can't OR a terminal color\");\n\n  EXPECT_NO_THROW(fg(fmt::terminal_color::white) |\n                  bg(fmt::terminal_color::white));\n  EXPECT_NO_THROW(fg(fmt::terminal_color::white) | bg(fmt::rgb(0xFFFFFF)));\n  EXPECT_NO_THROW(fg(fmt::terminal_color::white) | fmt::text_style());\n  EXPECT_NO_THROW(bg(fmt::terminal_color::white) | fmt::text_style());\n}\n\nTEST(color_test, format) {\n  EXPECT_EQ(fmt::format(fmt::text_style(), \"no style\"), \"no style\");\n  EXPECT_EQ(fmt::format(fg(fmt::rgb(255, 20, 30)), \"rgb(255,20,30)\"),\n            \"\\x1b[38;2;255;020;030mrgb(255,20,30)\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fg(fmt::rgb(255, 0, 0)) | fg(fmt::rgb(0, 20, 30)),\n                        \"rgb(255,20,30)\"),\n            \"\\x1b[38;2;255;020;030mrgb(255,20,30)\\x1b[0m\");\n  EXPECT_EQ(\n      fmt::format(fg(fmt::rgb(0, 0, 0)) | fg(fmt::rgb(0, 0, 0)), \"rgb(0,0,0)\"),\n      \"\\x1b[38;2;000;000;000mrgb(0,0,0)\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fg(fmt::color::blue), \"blue\"),\n            \"\\x1b[38;2;000;000;255mblue\\x1b[0m\");\n  EXPECT_EQ(\n      fmt::format(fg(fmt::color::blue) | bg(fmt::color::red), \"two color\"),\n      \"\\x1b[38;2;000;000;255m\\x1b[48;2;255;000;000mtwo color\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::bold, \"bold\"), \"\\x1b[1mbold\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::faint, \"faint\"), \"\\x1b[2mfaint\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::italic, \"italic\"),\n            \"\\x1b[3mitalic\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::underline, \"underline\"),\n            \"\\x1b[4munderline\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::blink, \"blink\"), \"\\x1b[5mblink\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::reverse, \"reverse\"),\n            \"\\x1b[7mreverse\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::conceal, \"conceal\"),\n            \"\\x1b[8mconceal\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::strikethrough, \"strikethrough\"),\n            \"\\x1b[9mstrikethrough\\x1b[0m\");\n  EXPECT_EQ(\n      fmt::format(fg(fmt::color::blue) | fmt::emphasis::bold, \"blue/bold\"),\n      \"\\x1b[1m\\x1b[38;2;000;000;255mblue/bold\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::emphasis::bold, \"bold error\"),\n            \"\\x1b[1mbold error\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fg(fmt::color::blue), \"blue log\"),\n            \"\\x1b[38;2;000;000;255mblue log\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fmt::text_style(), \"hi\"), \"hi\");\n  EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), \"tred\"),\n            \"\\x1b[31mtred\\x1b[0m\");\n  EXPECT_EQ(fmt::format(bg(fmt::terminal_color::cyan), \"tcyan\"),\n            \"\\x1b[46mtcyan\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fg(fmt::terminal_color::bright_green), \"tbgreen\"),\n            \"\\x1b[92mtbgreen\\x1b[0m\");\n  EXPECT_EQ(fmt::format(bg(fmt::terminal_color::bright_magenta), \"tbmagenta\"),\n            \"\\x1b[105mtbmagenta\\x1b[0m\");\n  EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), \"{}\", \"foo\"),\n            \"\\x1b[31mfoo\\x1b[0m\");\n  EXPECT_EQ(fmt::format(\"{}{}\", fmt::styled(\"red\", fg(fmt::color::red)),\n                        fmt::styled(\"bold\", fmt::emphasis::bold)),\n            \"\\x1b[38;2;255;000;000mred\\x1b[0m\\x1b[1mbold\\x1b[0m\");\n  EXPECT_EQ(fmt::format(\"{}\", fmt::styled(\"bar\", fg(fmt::color::blue) |\n                                                     fmt::emphasis::underline)),\n            \"\\x1b[4m\\x1b[38;2;000;000;255mbar\\x1b[0m\");\n  EXPECT_EQ(\n      fmt::format(\n          \"{}\", fmt::styled(\n                    \"all\", fmt::emphasis::bold | fmt::emphasis::faint |\n                               fmt::emphasis::italic |\n                               fmt::emphasis::underline | fmt::emphasis::blink |\n                               fmt::emphasis::reverse | fmt::emphasis::conceal |\n                               fmt::emphasis::strikethrough)),\n      \"\\x1b[1;2;3;4;5;7;8;9mall\\x1b[0m\");\n}\n\nTEST(color_test, format_to) {\n  auto out = std::string();\n  fmt::format_to(std::back_inserter(out), fg(fmt::rgb(255, 20, 30)),\n                 \"rgb(255,20,30){}{}{}\", 1, 2, 3);\n  EXPECT_EQ(fmt::to_string(out),\n            \"\\x1b[38;2;255;020;030mrgb(255,20,30)123\\x1b[0m\");\n}\n\nTEST(color_test, print) {\n  EXPECT_WRITE(stdout, fmt::print(fg(fmt::rgb(255, 20, 30)), \"rgb(255,20,30)\"),\n               \"\\x1b[38;2;255;020;030mrgb(255,20,30)\\x1b[0m\");\n}\n"
  },
  {
    "path": "test/compile-error-test/CMakeLists.txt",
    "content": "# Test if compile errors are produced where necessary.\n\ncmake_minimum_required(VERSION 3.8...3.25)\nproject(compile-error-test CXX)\n\nset(fmt_headers\n    \"\n  #include <fmt/format.h>\n  #include <fmt/xchar.h>\n  #include <fmt/ostream.h>\n  #include <iostream>\n\")\n\nset(error_test_names \"\")\nset(non_error_test_content \"\")\n\n# For error tests (we expect them to produce compilation error)\n#  * adds a name of test into `error_test_names` list\n#  * generates a single source file (with the same name) for each test\n# For non-error tests (we expect them to compile successfully):\n#  * adds a code segment as separate function to `non_error_test_content`\nfunction (expect_compile name code_fragment)\n  cmake_parse_arguments(EXPECT_COMPILE \"ERROR\" \"\" \"\" ${ARGN})\n  string(MAKE_C_IDENTIFIER \"${name}\" test_name)\n\n  if (EXPECT_COMPILE_ERROR)\n    file(\n      WRITE \"${CMAKE_CURRENT_BINARY_DIR}/test/${test_name}.cc\"\n      \"\n      ${fmt_headers}\n      void ${test_name}() {\n        ${code_fragment}\n      }\n      \")\n    set(error_test_names_copy \"${error_test_names}\")\n    list(APPEND error_test_names_copy \"${test_name}\")\n    set(error_test_names\n        \"${error_test_names_copy}\"\n        PARENT_SCOPE)\n  else ()\n    set(non_error_test_content\n        \"\n        ${non_error_test_content}\n        void ${test_name}() {\n          ${code_fragment}\n        }\"\n        PARENT_SCOPE)\n  endif ()\nendfunction ()\n\n# Generates a source file for non-error test with `non_error_test_content` and\n# CMake project file with all error and single non-error test targets.\nfunction (run_tests)\n  set(cmake_targets \"\")\n  foreach (test_name IN LISTS error_test_names)\n    set(cmake_targets\n        \"\n        ${cmake_targets}\n        add_library(test-${test_name} ${test_name}.cc)\n        target_link_libraries(test-${test_name} PRIVATE fmt::fmt)\n        \")\n  endforeach ()\n\n  file(\n    WRITE \"${CMAKE_CURRENT_BINARY_DIR}/test/non_error_test.cc\"\n    \"\n    ${fmt_headers}\n    ${non_error_test_content}\n    \")\n  set(cmake_targets\n      \"\n      ${cmake_targets}\n      add_library(non-error-test non_error_test.cc)\n      target_link_libraries(non-error-test PRIVATE fmt::fmt)\n      \")\n\n  file(\n    WRITE \"${CMAKE_CURRENT_BINARY_DIR}/test/CMakeLists.txt\"\n    \"\n    cmake_minimum_required(VERSION 3.8...3.25)\n    project(tests CXX)\n    add_subdirectory(${FMT_DIR} fmt)\n    ${cmake_targets}\n    \")\n\n  set(build_directory \"${CMAKE_CURRENT_BINARY_DIR}/test/build\")\n  file(MAKE_DIRECTORY \"${build_directory}\")\n  execute_process(\n    COMMAND\n      \"${CMAKE_COMMAND}\" \"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}\"\n      \"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}\"\n      \"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}\"\n      \"-DCMAKE_GENERATOR=${CMAKE_GENERATOR}\"\n      \"-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}\" \"-DFMT_DIR=${FMT_DIR}\"\n      \"${CMAKE_CURRENT_BINARY_DIR}/test\"\n    WORKING_DIRECTORY \"${build_directory}\"\n    RESULT_VARIABLE result_var\n    OUTPUT_VARIABLE output_var\n    ERROR_VARIABLE output_var)\n  if (NOT result_var EQUAL 0)\n    message(FATAL_ERROR \"Unable to configure:\\n${output_var}\")\n  endif ()\n\n  foreach (test_name IN LISTS error_test_names)\n    execute_process(\n      COMMAND \"${CMAKE_COMMAND}\" --build \"${build_directory}\" --target\n              \"test-${test_name}\"\n      WORKING_DIRECTORY \"${build_directory}\"\n      RESULT_VARIABLE result_var\n      OUTPUT_VARIABLE output_var\n      ERROR_QUIET)\n    if (result_var EQUAL 0)\n      message(\n        SEND_ERROR \"No compile error for \\\"${test_name}\\\":\\n${output_var}\")\n    endif ()\n  endforeach ()\n\n  execute_process(\n    COMMAND \"${CMAKE_COMMAND}\" --build \"${build_directory}\" --target\n            \"non-error-test\"\n    WORKING_DIRECTORY \"${build_directory}\"\n    RESULT_VARIABLE result_var\n    OUTPUT_VARIABLE output_var\n    ERROR_VARIABLE output_var)\n  if (NOT result_var EQUAL 0)\n    message(\n      SEND_ERROR \"Compile error for combined non-error test:\\n${output_var}\")\n  endif ()\nendfunction ()\n\n# Check if the source file skeleton compiles.\nexpect_compile(check \"\")\nexpect_compile(check-error \"compilation_error\" ERROR)\n\n# Formatting a wide character with a narrow format string is forbidden.\nexpect_compile(wide-character-narrow-format-string\n               \"fmt::format(L\\\"{}\\\", L'a');\")\nexpect_compile(wide-character-narrow-format-string-error\n               \"fmt::format(\\\"{}\\\", L'a');\" ERROR)\n\n# Formatting a wide string with a narrow format string is forbidden.\nexpect_compile(wide-string-narrow-format-string\n               \"fmt::format(L\\\"{}\\\", L\\\"foo\\\");\")\nexpect_compile(wide-string-narrow-format-string-error\n               \"fmt::format(\\\"{}\\\", L\\\"foo\\\");\" ERROR)\n\n# Formatting a narrow string with a wide format string is forbidden because\n# mixing UTF-8 with UTF-16/32 can result in an invalid output.\nexpect_compile(narrow-string-wide-format-string\n               \"fmt::format(L\\\"{}\\\", L\\\"foo\\\");\")\nexpect_compile(narrow-string-wide-format-string-error\n               \"fmt::format(L\\\"{}\\\", \\\"foo\\\");\" ERROR)\n\nexpect_compile(\n  cast-to-string\n  \"\n  struct S {\n    operator std::string() const { return std::string(); }\n  };\n  fmt::format(\\\"{}\\\", std::string(S()));\n  \")\nexpect_compile(\n  cast-to-string-error\n  \"\n  struct S {\n    operator std::string() const { return std::string(); }\n  };\n  fmt::format(\\\"{}\\\", S());\n  \"\n  ERROR)\n\n# Formatting a function\nexpect_compile(\n  format-function\n  \"\n  void (*f)();\n  fmt::format(\\\"{}\\\", fmt::ptr(f));\n  \")\nexpect_compile(\n  format-function-error\n  \"\n  void (*f)();\n  fmt::format(\\\"{}\\\", f);\n  \"\n  ERROR)\n\n# Formatting an unformattable argument should always be a compile time error\nexpect_compile(\n  format-lots-of-arguments-with-unformattable\n  \"\n  struct E {};\n  fmt::format(\\\"\\\", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, E());\n  \"\n  ERROR)\nexpect_compile(\n  format-lots-of-arguments-with-function\n  \"\n  void (*f)();\n  fmt::format(\\\"\\\", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, f);\n  \"\n  ERROR)\n\nif (CMAKE_CXX_STANDARD GREATER_EQUAL 20)\n  # Compile-time argument type check\n  expect_compile(\n    format-string-number-spec\n    \"\n    #ifdef FMT_HAS_CONSTEVAL\n      fmt::format(\\\"{:d}\\\", 42);\n    #endif\n    \")\n  expect_compile(\n    format-string-number-spec-error\n    \"\n    #ifdef FMT_HAS_CONSTEVAL\n      fmt::format(\\\"{:d}\\\", \\\"I am not a number\\\");\n    #else\n      #error\n    #endif\n    \"\n    ERROR)\n  expect_compile(\n    print-string-number-spec-error\n    \"\n    #ifdef FMT_HAS_CONSTEVAL\n      fmt::print(\\\"{:d}\\\", \\\"I am not a number\\\");\n    #else\n      #error\n    #endif\n    \"\n    ERROR)\n  expect_compile(\n    print-stream-string-number-spec-error\n    \"\n  #ifdef FMT_HAS_CONSTEVAL\n    fmt::print(std::cout, \\\"{:d}\\\", \\\"I am not a number\\\");\n  #else\n    #error\n  #endif\n    \"\n    ERROR)\n\n  # Compile-time argument name check\n  expect_compile(\n    format-string-name\n    \"\n    #if defined(FMT_HAS_CONSTEVAL) && FMT_USE_NONTYPE_TEMPLATE_ARGS\n      using namespace fmt::literals;\n      fmt::print(\\\"{foo}\\\", \\\"foo\\\"_a=42);\n    #endif\n    \")\n  expect_compile(\n    format-string-name-error\n    \"\n    #if defined(FMT_HAS_CONSTEVAL) && FMT_USE_NONTYPE_TEMPLATE_ARGS\n      using namespace fmt::literals;\n      fmt::print(\\\"{foo}\\\", \\\"bar\\\"_a=42);\n    #else\n      #error\n    #endif\n    \"\n    ERROR)\nendif ()\n\n# Run all tests\nrun_tests()\n"
  },
  {
    "path": "test/compile-test.cc",
    "content": "// Formatting library for C++ - formatting library tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/compile.h\"\n\n#include <iterator>\n#include <list>\n#include <type_traits>\n#include <vector>\n\n#include \"fmt/chrono.h\"\n#include \"fmt/ranges.h\"\n#include \"gmock/gmock.h\"\n#include \"gtest-extra.h\"\n\nTEST(compile_test, compile_fallback) {\n  // FMT_COMPILE should fallback on runtime formatting when `if constexpr` is\n  // not available.\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{}\"), 42));\n}\n\nstruct type_with_get {\n  template <int> friend void get(type_with_get);\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<type_with_get> : formatter<int> {\n  template <typename FormatContext>\n  auto format(type_with_get, FormatContext& ctx) const -> decltype(ctx.out()) {\n    return formatter<int>::format(42, ctx);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(compile_test, compile_type_with_get) {\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{}\"), type_with_get()));\n}\n\n#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)\nstruct test_formattable {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<test_formattable> : formatter<const char*> {\n  char word_spec = 'f';\n  constexpr auto parse(format_parse_context& ctx) {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it == end || *it == '}') return it;\n    if (it != end && (*it == 'f' || *it == 'b')) word_spec = *it++;\n    if (it != end && *it != '}') throw format_error(\"invalid format\");\n    return it;\n  }\n  template <typename FormatContext>\n  constexpr auto format(test_formattable, FormatContext& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<const char*>::format(word_spec == 'f' ? \"foo\" : \"bar\",\n                                          ctx);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(compile_test, format_default) {\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{}\"), 42));\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{}\"), 42u));\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{}\"), 42ll));\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{}\"), 42ull));\n  EXPECT_EQ(\"true\", fmt::format(FMT_COMPILE(\"{}\"), true));\n  EXPECT_EQ(\"x\", fmt::format(FMT_COMPILE(\"{}\"), 'x'));\n  EXPECT_EQ(\"4.2\", fmt::format(FMT_COMPILE(\"{}\"), 4.2));\n  EXPECT_EQ(\"foo\", fmt::format(FMT_COMPILE(\"{}\"), \"foo\"));\n  EXPECT_EQ(\"foo\", fmt::format(FMT_COMPILE(\"{}\"), std::string(\"foo\")));\n  EXPECT_EQ(\"foo\", fmt::format(FMT_COMPILE(\"{}\"), test_formattable()));\n  auto t = std::chrono::system_clock::now();\n  EXPECT_EQ(fmt::format(\"{}\", t), fmt::format(FMT_COMPILE(\"{}\"), t));\n}\n\nTEST(compile_test, format_escape) {\n  EXPECT_EQ(\"\\\"string\\\"\", fmt::format(FMT_COMPILE(\"{:?}\"), \"string\"));\n  EXPECT_EQ(\"prefix \\\"string\\\"\",\n            fmt::format(FMT_COMPILE(\"prefix {:?}\"), \"string\"));\n  EXPECT_EQ(\"\\\"string\\\" suffix\",\n            fmt::format(FMT_COMPILE(\"{:?} suffix\"), \"string\"));\n  EXPECT_EQ(\"\\\"abc\\\"\", fmt::format(FMT_COMPILE(\"{0:<5?}\"), \"abc\"));\n  EXPECT_EQ(\"\\\"abc\\\"  \", fmt::format(FMT_COMPILE(\"{0:<7?}\"), \"abc\"));\n}\n\n\nTEST(compile_test, format_specs) {\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{:x}\"), 0x42));\n  EXPECT_EQ(\"1.2 ms \",\n            fmt::format(FMT_COMPILE(\"{:7.1%Q %q}\"),\n                        std::chrono::duration<double, std::milli>(1.234)));\n}\n\nTEST(compile_test, dynamic_format_specs) {\n  EXPECT_EQ(\"foo  \", fmt::format(FMT_COMPILE(\"{:{}}\"), \"foo\", 5));\n  EXPECT_EQ(\"  3.14\", fmt::format(FMT_COMPILE(\"{:{}.{}f}\"), 3.141592, 6, 2));\n  EXPECT_EQ(\n      \"=1.234ms=\",\n      fmt::format(FMT_COMPILE(\"{:=^{}.{}}\"),\n                  std::chrono::duration<double, std::milli>(1.234), 9, 3));\n}\n\nTEST(compile_test, manual_ordering) {\n  EXPECT_EQ(\"42\", fmt::format(FMT_COMPILE(\"{0}\"), 42));\n  EXPECT_EQ(\" -42\", fmt::format(FMT_COMPILE(\"{0:4}\"), -42));\n  EXPECT_EQ(\"41 43\", fmt::format(FMT_COMPILE(\"{0} {1}\"), 41, 43));\n  EXPECT_EQ(\"41 43\", fmt::format(FMT_COMPILE(\"{1} {0}\"), 43, 41));\n  EXPECT_EQ(\"41 43\", fmt::format(FMT_COMPILE(\"{0} {2}\"), 41, 42, 43));\n  EXPECT_EQ(\"  41   43\", fmt::format(FMT_COMPILE(\"{1:{2}} {0:4}\"), 43, 41, 4));\n  EXPECT_EQ(\"42 1.2 ms \",\n            fmt::format(FMT_COMPILE(\"{0} {1:7.1%Q %q}\"), 42,\n                        std::chrono::duration<double, std::milli>(1.234)));\n  EXPECT_EQ(\n      \"true 42 42 foo 0x1234 foo\",\n      fmt::format(FMT_COMPILE(\"{0} {1} {2} {3} {4} {5}\"), true, 42, 42.0f,\n                  \"foo\", reinterpret_cast<void*>(0x1234), test_formattable()));\n}\n\nTEST(compile_test, named) {\n  auto runtime_named_field_compiled =\n      fmt::detail::compile<decltype(fmt::arg(\"arg\", 42))>(FMT_COMPILE(\"{arg}\"));\n  static_assert(std::is_same_v<decltype(runtime_named_field_compiled),\n                               fmt::detail::runtime_named_field<char>>);\n\n  EXPECT_EQ(\"foobar\",\n            fmt::format(FMT_COMPILE(\"{a0}{a1}\"), fmt::arg(\"a0\", \"foo\"),\n                        fmt::arg(\"a1\", \"bar\")));\n  EXPECT_EQ(\"foobar\", fmt::format(FMT_COMPILE(\"{}{a1}\"), fmt::arg(\"a0\", \"foo\"),\n                                  fmt::arg(\"a1\", \"bar\")));\n  EXPECT_EQ(\"foofoo\", fmt::format(FMT_COMPILE(\"{a0}{}\"), fmt::arg(\"a0\", \"foo\"),\n                                  fmt::arg(\"a1\", \"bar\")));\n  EXPECT_EQ(\"foobar\", fmt::format(FMT_COMPILE(\"{0}{a1}\"), fmt::arg(\"a0\", \"foo\"),\n                                  fmt::arg(\"a1\", \"bar\")));\n  EXPECT_EQ(\"foobar\", fmt::format(FMT_COMPILE(\"{a0}{1}\"), fmt::arg(\"a0\", \"foo\"),\n                                  fmt::arg(\"a1\", \"bar\")));\n\n  EXPECT_EQ(\"foobar\",\n            fmt::format(FMT_COMPILE(\"{}{a1}\"), \"foo\", fmt::arg(\"a1\", \"bar\")));\n  EXPECT_EQ(\"foobar\",\n            fmt::format(FMT_COMPILE(\"{a0}{a1}\"), fmt::arg(\"a1\", \"bar\"),\n                        fmt::arg(\"a2\", \"baz\"), fmt::arg(\"a0\", \"foo\")));\n  EXPECT_EQ(\" bar foo \",\n            fmt::format(FMT_COMPILE(\" {foo} {bar} \"), fmt::arg(\"foo\", \"bar\"),\n                        fmt::arg(\"bar\", \"foo\")));\n\n  EXPECT_THROW(fmt::format(FMT_COMPILE(\"{invalid}\"), fmt::arg(\"valid\", 42)),\n               fmt::format_error);\n\n#  if FMT_USE_NONTYPE_TEMPLATE_ARGS\n  using namespace fmt::literals;\n  auto statically_named_field_compiled =\n      fmt::detail::compile<decltype(\"arg\"_a = 42)>(FMT_COMPILE(\"{arg}\"));\n  static_assert(std::is_same_v<decltype(statically_named_field_compiled),\n                               fmt::detail::field<char, int, 0>>);\n\n  EXPECT_EQ(\"41 43\",\n            fmt::format(FMT_COMPILE(\"{a0} {a1}\"), \"a0\"_a = 41, \"a1\"_a = 43));\n  EXPECT_EQ(\"41 43\",\n            fmt::format(FMT_COMPILE(\"{a1} {a0}\"), \"a0\"_a = 43, \"a1\"_a = 41));\n#  endif\n}\n\nTEST(compile_test, join) {\n  unsigned char data[] = {0x1, 0x2, 0xaf};\n  EXPECT_EQ(\"0102af\", fmt::format(FMT_COMPILE(\"{:02x}\"), fmt::join(data, \"\")));\n}\n\nTEST(compile_test, format_to) {\n  char buf[8];\n  auto end = fmt::format_to(buf, FMT_COMPILE(\"{}\"), 42);\n  *end = '\\0';\n  EXPECT_STREQ(\"42\", buf);\n  end = fmt::format_to(buf, FMT_COMPILE(\"{:x}\"), 42);\n  *end = '\\0';\n  EXPECT_STREQ(\"2a\", buf);\n}\n\nTEST(compile_test, format_to_n) {\n  constexpr auto buffer_size = 8;\n  char buffer[buffer_size];\n  auto res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE(\"{}\"), 42);\n  *res.out = '\\0';\n  EXPECT_STREQ(\"42\", buffer);\n  res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE(\"{:x}\"), 42);\n  *res.out = '\\0';\n  EXPECT_STREQ(\"2a\", buffer);\n}\n\nTEST(compile_test, output_iterators) {\n  std::list<char> out;\n  fmt::format_to(std::back_inserter(out), FMT_COMPILE(\"{}\"), 42);\n  EXPECT_EQ(\"42\", std::string(out.begin(), out.end()));\n\n  std::stringstream s;\n  fmt::format_to(std::ostream_iterator<char>(s), FMT_COMPILE(\"{}\"), 42);\n  EXPECT_EQ(\"42\", s.str());\n\n  std::stringstream s2;\n  fmt::format_to(std::ostreambuf_iterator<char>(s2), FMT_COMPILE(\"{}.{:06d}\"),\n                 42, 43);\n  EXPECT_EQ(\"42.000043\", s2.str());\n}\n\n#  if FMT_USE_CONSTEVAL && (!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1940)\nTEST(compile_test, constexpr_formatted_size) {\n  FMT_CONSTEXPR20 size_t size = fmt::formatted_size(FMT_COMPILE(\"{}\"), 42);\n  EXPECT_EQ(size, 2);\n  FMT_CONSTEXPR20 size_t hex_size =\n      fmt::formatted_size(FMT_COMPILE(\"{:x}\"), 15);\n  EXPECT_EQ(hex_size, 1);\n  FMT_CONSTEXPR20 size_t binary_size =\n      fmt::formatted_size(FMT_COMPILE(\"{:b}\"), 15);\n  EXPECT_EQ(binary_size, 4);\n  FMT_CONSTEXPR20 size_t padded_size =\n      fmt::formatted_size(FMT_COMPILE(\"{:*^6}\"), 42);\n  EXPECT_EQ(padded_size, 6);\n  FMT_CONSTEXPR20 size_t float_size =\n      fmt::formatted_size(FMT_COMPILE(\"{:.3}\"), 12.345);\n  EXPECT_EQ(float_size, 4);\n  FMT_CONSTEXPR20 size_t str_size =\n      fmt::formatted_size(FMT_COMPILE(\"{:s}\"), \"abc\");\n  EXPECT_EQ(str_size, 3);\n}\n\nTEST(compile_test, static_format) {\n  constexpr auto result = FMT_STATIC_FORMAT(\"{}\", 42);\n  EXPECT_STREQ(result.c_str(), \"42\");\n  EXPECT_EQ(result.str(), \"42\");\n}\n#  endif\n\nTEST(compile_test, text_and_arg) {\n  EXPECT_EQ(\">>>42<<<\", fmt::format(FMT_COMPILE(\">>>{}<<<\"), 42));\n  EXPECT_EQ(\"42!\", fmt::format(FMT_COMPILE(\"{}!\"), 42));\n}\n\nTEST(compile_test, unknown_format_fallback) {\n  EXPECT_EQ(\" 42 \",\n            fmt::format(FMT_COMPILE(\"{name:^4}\"), fmt::arg(\"name\", 42)));\n\n  std::vector<char> v1;\n  fmt::format_to(std::back_inserter(v1), FMT_COMPILE(\"{}\"), 42);\n  EXPECT_EQ(\"42\", fmt::string_view(v1.data(), v1.size()));\n\n  std::vector<char> v2;\n  fmt::format_to(std::back_inserter(v2), FMT_COMPILE(\"{name:^4}\"),\n                 fmt::arg(\"name\", 42));\n  EXPECT_EQ(\" 42 \", fmt::string_view(v2.data(), v2.size()));\n\n  char buffer[4];\n  auto result = fmt::format_to_n(buffer, 4, FMT_COMPILE(\"{name:^5}\"),\n                                 fmt::arg(\"name\", 42));\n  EXPECT_EQ(5u, result.size);\n  EXPECT_EQ(buffer + 4, result.out);\n  EXPECT_EQ(\" 42 \", fmt::string_view(buffer, 4));\n}\n\nTEST(compile_test, empty) { EXPECT_EQ(\"\", fmt::format(FMT_COMPILE(\"\"))); }\n\nstruct to_stringable {\n  friend fmt::string_view to_string_view(to_stringable) { return {}; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<to_stringable> {\n  auto parse(format_parse_context& ctx) const -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  template <typename FormatContext>\n  auto format(const to_stringable&, FormatContext& ctx) -> decltype(ctx.out()) {\n    return ctx.out();\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(compile_test, to_string_and_formatter) {\n  fmt::format(FMT_COMPILE(\"{}\"), to_stringable());\n}\n\nstruct std_context_test {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<std_context_test> : formatter<int> {\n  auto format(std_context_test, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return ctx.out();\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(compile_test, print) {\n  EXPECT_WRITE(stdout, fmt::print(FMT_COMPILE(\"Don't {}!\"), \"panic\"),\n               \"Don't panic!\");\n  EXPECT_WRITE(stderr, fmt::print(stderr, FMT_COMPILE(\"Don't {}!\"), \"panic\"),\n               \"Don't panic!\");\n  fmt::print(FMT_COMPILE(\"{}\"), std_context_test());\n}\n#endif\n\n#if FMT_USE_NONTYPE_TEMPLATE_ARGS\nTEST(compile_test, compile_format_string_literal) {\n  using namespace fmt::literals;\n  EXPECT_EQ(\"\", fmt::format(\"\"_cf));\n  EXPECT_EQ(\"42\", fmt::format(\"{}\"_cf, 42));\n}\n#endif\n\n#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)\ntemplate <typename S> auto check_is_compiled_string(const S&) -> bool {\n  return fmt::is_compiled_string<S>::value;\n}\n\nTEST(compile_test, is_compiled_string) {\n  EXPECT_TRUE(check_is_compiled_string(FMT_COMPILE(\"asdf\")));\n  EXPECT_TRUE(check_is_compiled_string(FMT_COMPILE(\"{}\")));\n}\n#endif\n\n// MSVS 2019 19.29.30145.0 - OK\n// MSVS 2022 19.32.31332.0, 19.37.32826.1 - compile-test.cc(362,3): fatal error\n// C1001: Internal compiler error.\n//  (compiler file\n//  'D:\\a\\_work\\1\\s\\src\\vctools\\Compiler\\CxxFE\\sl\\p1\\c\\constexpr\\constexpr.cpp',\n//  line 8635)\n#if FMT_USE_CONSTEVAL &&                                     \\\n    (!FMT_MSC_VERSION ||                                     \\\n     (FMT_MSC_VERSION >= 1928 && FMT_MSC_VERSION < 1930)) && \\\n    defined(__cpp_lib_is_constant_evaluated)\ntemplate <size_t max_string_length, typename Char = char> struct test_string {\n  template <typename T> constexpr auto operator==(const T& rhs) const -> bool {\n    return fmt::basic_string_view<Char>(rhs).compare(buffer) == 0;\n  }\n  Char buffer[max_string_length]{};\n};\n\ntemplate <size_t max_string_length, typename Char = char, typename... Args>\nconsteval auto test_format(auto format, const Args&... args) {\n  test_string<max_string_length, Char> string{};\n  fmt::format_to(string.buffer, format, args...);\n  return string;\n}\n\nTEST(compile_time_formatting_test, bool) {\n  EXPECT_EQ(\"true\", test_format<5>(FMT_COMPILE(\"{}\"), true));\n  EXPECT_EQ(\"false\", test_format<6>(FMT_COMPILE(\"{}\"), false));\n  EXPECT_EQ(\"true \", test_format<6>(FMT_COMPILE(\"{:5}\"), true));\n  EXPECT_EQ(\"1\", test_format<2>(FMT_COMPILE(\"{:d}\"), true));\n}\n\nTEST(compile_time_formatting_test, integer) {\n  EXPECT_EQ(\"42\", test_format<3>(FMT_COMPILE(\"{}\"), 42));\n  EXPECT_EQ(\"420\", test_format<4>(FMT_COMPILE(\"{}\"), 420));\n  EXPECT_EQ(\"42 42\", test_format<6>(FMT_COMPILE(\"{} {}\"), 42, 42));\n  EXPECT_EQ(\"42 42\",\n            test_format<6>(FMT_COMPILE(\"{} {}\"), uint32_t{42}, uint64_t{42}));\n\n  EXPECT_EQ(\"+42\", test_format<4>(FMT_COMPILE(\"{:+}\"), 42));\n  EXPECT_EQ(\"42\", test_format<3>(FMT_COMPILE(\"{:-}\"), 42));\n  EXPECT_EQ(\" 42\", test_format<4>(FMT_COMPILE(\"{: }\"), 42));\n\n  EXPECT_EQ(\"-0042\", test_format<6>(FMT_COMPILE(\"{:05}\"), -42));\n\n  EXPECT_EQ(\"101010\", test_format<7>(FMT_COMPILE(\"{:b}\"), 42));\n  EXPECT_EQ(\"0b101010\", test_format<9>(FMT_COMPILE(\"{:#b}\"), 42));\n  EXPECT_EQ(\"0B101010\", test_format<9>(FMT_COMPILE(\"{:#B}\"), 42));\n  EXPECT_EQ(\"042\", test_format<4>(FMT_COMPILE(\"{:#o}\"), 042));\n  EXPECT_EQ(\"0x4a\", test_format<5>(FMT_COMPILE(\"{:#x}\"), 0x4a));\n  EXPECT_EQ(\"0X4A\", test_format<5>(FMT_COMPILE(\"{:#X}\"), 0x4a));\n\n  EXPECT_EQ(\"   42\", test_format<6>(FMT_COMPILE(\"{:5}\"), 42));\n  EXPECT_EQ(\"   42\", test_format<6>(FMT_COMPILE(\"{:5}\"), 42l));\n  EXPECT_EQ(\"   42\", test_format<6>(FMT_COMPILE(\"{:5}\"), 42ll));\n  EXPECT_EQ(\"   42\", test_format<6>(FMT_COMPILE(\"{:5}\"), 42ull));\n\n  EXPECT_EQ(\"42  \", test_format<5>(FMT_COMPILE(\"{:<4}\"), 42));\n  EXPECT_EQ(\"  42\", test_format<5>(FMT_COMPILE(\"{:>4}\"), 42));\n  EXPECT_EQ(\" 42 \", test_format<5>(FMT_COMPILE(\"{:^4}\"), 42));\n  EXPECT_EQ(\"**-42\", test_format<6>(FMT_COMPILE(\"{:*>5}\"), -42));\n}\n\nTEST(compile_time_formatting_test, char) {\n  EXPECT_EQ(\"c\", test_format<2>(FMT_COMPILE(\"{}\"), 'c'));\n\n  EXPECT_EQ(\"c  \", test_format<4>(FMT_COMPILE(\"{:3}\"), 'c'));\n  EXPECT_EQ(\"99\", test_format<3>(FMT_COMPILE(\"{:d}\"), 'c'));\n}\n\nTEST(compile_time_formatting_test, string) {\n  EXPECT_EQ(\"42\", test_format<3>(FMT_COMPILE(\"{}\"), \"42\"));\n  EXPECT_EQ(\"The answer is 42\",\n            test_format<17>(FMT_COMPILE(\"{} is {}\"), \"The answer\", \"42\"));\n\n  EXPECT_EQ(\"abc**\", test_format<6>(FMT_COMPILE(\"{:*<5}\"), \"abc\"));\n  EXPECT_EQ(\"**🤡**\", test_format<9>(FMT_COMPILE(\"{:*^6}\"), \"🤡\"));\n}\n\nTEST(compile_time_formatting_test, combination) {\n  EXPECT_EQ(\"420, true, answer\",\n            test_format<18>(FMT_COMPILE(\"{}, {}, {}\"), 420, true, \"answer\"));\n\n  EXPECT_EQ(\" -42\", test_format<5>(FMT_COMPILE(\"{:{}}\"), -42, 4));\n}\n\nTEST(compile_time_formatting_test, custom_type) {\n  EXPECT_EQ(\"foo\", test_format<4>(FMT_COMPILE(\"{}\"), test_formattable()));\n  EXPECT_EQ(\"bar\", test_format<4>(FMT_COMPILE(\"{:b}\"), test_formattable()));\n}\n\nTEST(compile_time_formatting_test, multibyte_fill) {\n  EXPECT_EQ(\"жж42\", test_format<8>(FMT_COMPILE(\"{:ж>4}\"), 42));\n}\n\nTEST(compile_time_formatting_test, floating_point) {\n  EXPECT_EQ(\"0\", test_format<2>(FMT_COMPILE(\"{}\"), 0.0f));\n  EXPECT_EQ(\"392.500000\", test_format<11>(FMT_COMPILE(\"{0:f}\"), 392.5f));\n\n  EXPECT_EQ(\"0\", test_format<2>(FMT_COMPILE(\"{:}\"), 0.0));\n  EXPECT_EQ(\"0.000000\", test_format<9>(FMT_COMPILE(\"{:f}\"), 0.0));\n  EXPECT_EQ(\"0\", test_format<2>(FMT_COMPILE(\"{:g}\"), 0.0));\n  EXPECT_EQ(\"392.65\", test_format<7>(FMT_COMPILE(\"{:}\"), 392.65));\n  EXPECT_EQ(\"392.65\", test_format<7>(FMT_COMPILE(\"{:g}\"), 392.65));\n  EXPECT_EQ(\"392.65\", test_format<7>(FMT_COMPILE(\"{:G}\"), 392.65));\n  EXPECT_EQ(\"4.9014e+06\", test_format<11>(FMT_COMPILE(\"{:g}\"), 4.9014e6));\n  EXPECT_EQ(\"-392.650000\", test_format<12>(FMT_COMPILE(\"{:f}\"), -392.65));\n  EXPECT_EQ(\"-392.650000\", test_format<12>(FMT_COMPILE(\"{:F}\"), -392.65));\n\n  EXPECT_EQ(\"3.926500e+02\", test_format<13>(FMT_COMPILE(\"{0:e}\"), 392.65));\n  EXPECT_EQ(\"3.926500E+02\", test_format<13>(FMT_COMPILE(\"{0:E}\"), 392.65));\n  EXPECT_EQ(\"+0000392.6\", test_format<11>(FMT_COMPILE(\"{0:+010.4g}\"), 392.65));\n  EXPECT_EQ(\"9223372036854775808.000000\",\n            test_format<27>(FMT_COMPILE(\"{:f}\"), 9223372036854775807.0));\n\n  constexpr double nan = std::numeric_limits<double>::quiet_NaN();\n  EXPECT_EQ(\"nan\", test_format<4>(FMT_COMPILE(\"{}\"), nan));\n  EXPECT_EQ(\"+nan\", test_format<5>(FMT_COMPILE(\"{:+}\"), nan));\n  if (std::signbit(-nan))\n    EXPECT_EQ(\"-nan\", test_format<5>(FMT_COMPILE(\"{}\"), -nan));\n  else\n    fmt::print(\"Warning: compiler doesn't handle negative NaN correctly\");\n\n  constexpr double inf = std::numeric_limits<double>::infinity();\n  EXPECT_EQ(\"inf\", test_format<4>(FMT_COMPILE(\"{}\"), inf));\n  EXPECT_EQ(\"+inf\", test_format<5>(FMT_COMPILE(\"{:+}\"), inf));\n  EXPECT_EQ(\"-inf\", test_format<5>(FMT_COMPILE(\"{}\"), -inf));\n}\n#endif\n\n#if FMT_USE_CONSTEXPR_STRING\nTEST(compile_test, constexpr_string_format) {\n  constexpr auto result = []() {\n    return fmt::format(FMT_COMPILE(\"{}\"), 42) == \"42\";\n  }();\n  EXPECT_TRUE(result);\n\n  // Test with a larger string to avoid small string optimization.\n  constexpr auto big = []() {\n    return fmt::format(FMT_COMPILE(\"{:100}\"), ' ') == std::string(100, ' ');\n  }();\n  EXPECT_TRUE(big);\n}\n#endif  // FMT_USE_CONSTEXPR_STRING\n"
  },
  {
    "path": "test/cuda-test/CMakeLists.txt",
    "content": "# We can find some usecases which follow the guide of CMake which uses\n# `enable_language(CUDA)` instead of `find_package(CUDA)` and let the CMake\n# built-in functions use NVCC.\n\n# See: https://cmake.org/cmake/help/latest/module/FindCUDA.html#replacement\n#\n# However, this requires CMake version 3.10 or higher and we can't be sure most\n# of the CUDA projects are using those.\n#\n# This test relies on `find_package(CUDA)` in the parent CMake config.\n\n# These can be updated when NVCC becomes ready for C++ 17 features\n# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features\nset(CMAKE_CUDA_STANDARD 14)\nset(CMAKE_CUDA_STANDARD_REQUIRED 14)\n\n# In this test, we assume that the user is going to compile CUDA source code\n# with some libraries (fmt in this case).\n#\n# In addition to that, this test invokes both the C++ host compiler and NVCC by\n# providing another (non-CUDA) C++ source code.\nif (${CMAKE_VERSION} VERSION_LESS 3.15)\n  # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html\n  list(APPEND CUDA_NVCC_FLAGS \"-std=c++14\")\n  if (MSVC)\n    # This is the solution of pytorch:\n    # https://github.com/pytorch/pytorch/pull/7118\n    list(APPEND CUDA_NVCC_FLAGS \"-Xcompiler\" \"/std:c++14\")\n    list(APPEND CUDA_NVCC_FLAGS \"-Xcompiler\" \"/Zc:__cplusplus\")\n    # for the reason of this -Xcompiler options, see below.\n  endif ()\n  cuda_add_executable(fmt-in-cuda-test cuda-cpp14.cu cpp14.cc)\n  target_compile_features(fmt-in-cuda-test PRIVATE cxx_std_14)\n  if (MSVC)\n    # This part is for (non-CUDA) C++ code. MSVC can define incorrect\n    # `__cplusplus` macro. Fix for the issue is to use additional compiler flag.\n    #\n    # See Also:\n    # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/\n    # https://github.com/Microsoft/vscode-cpptools/issues/2595\n    target_compile_options(fmt-in-cuda-test PRIVATE /Zc:__cplusplus\n                                                    /permissive-)\n  endif ()\nelse ()\n  # now using a \"new\" way of handling CUDA\n  add_executable(fmt-in-cuda-test cuda-cpp14.cu cpp14.cc)\n  set_target_properties(fmt-in-cuda-test PROPERTIES CUDA_SEPARABLE_COMPILATION\n                                                    ON)\n  target_compile_features(fmt-in-cuda-test PRIVATE cxx_std_14)\n  if (MSVC)\n    # with MSVC, 'cxx_std_14' will only propagate to the host code (MSVC), but\n    # will not set __cplusplus correctly anyway, while nvcc will ignore it. If\n    # specified for nvcc on the command line as '-std=c++14' nvcc will emit this\n    # message instead: nvcc warning : The -std=c++14 flag is not supported with\n    # the configured host compiler. Flag will be ignored.\n    set_property(\n      SOURCE cuda-cpp14.cu\n      APPEND\n      PROPERTY COMPILE_OPTIONS -Xcompiler /std:c++14 -Xcompiler /Zc:__cplusplus)\n    set_property(\n      SOURCE cpp14.cc\n      APPEND\n      PROPERTY COMPILE_OPTIONS /std:c++14 /Zc:__cplusplus)\n  endif ()\nendif ()\n\nget_target_property(IN_USE_CUDA_STANDARD fmt-in-cuda-test CUDA_STANDARD)\nmessage(STATUS \"cuda_standard:          ${IN_USE_CUDA_STANDARD}\")\n\nget_target_property(IN_USE_CUDA_STANDARD_REQUIRED fmt-in-cuda-test\n                    CUDA_STANDARD_REQUIRED)\nmessage(STATUS \"cuda_standard_required: ${IN_USE_CUDA_STANDARD_REQUIRED}\")\n\n# We don't use PUBLIC or other keyword for reasons explained in the\n# CUDA_LINK_LIBRARIES_KEYWORD section in\n# https://cmake.org/cmake/help/latest/module/FindCUDA.html\ntarget_link_libraries(fmt-in-cuda-test fmt::fmt)\n"
  },
  {
    "path": "test/cuda-test/cpp14.cc",
    "content": "#include <fmt/base.h>\n\n// The purpose of this part is to ensure NVCC's host compiler also supports\n// the standard version. See 'cuda-cpp14.cu'.\n//\n// https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros\nstatic_assert(__cplusplus >= 201402L, \"expect C++ 2014 for host compiler\");\n\nauto make_message_cpp() -> std::string {\n  return fmt::format(\"host compiler \\t: __cplusplus == {}\", __cplusplus);\n}\n"
  },
  {
    "path": "test/cuda-test/cuda-cpp14.cu",
    "content": "//  Direct NVCC command line example:\n//\n//  nvcc ./cuda-cpp14.cu -x cu -I\"../include\" -l\"fmtd\" -L\"../build/Debug\" \\\n//       -std=c++14 -Xcompiler /std:c++14 -Xcompiler /Zc:__cplusplus\n\n// Ensure that we are using the latest C++ standard for NVCC\n// The version is C++14\n//\n// https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#c-cplusplus-language-support\n// https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros\nstatic_assert(__cplusplus >= 201402L, \"expect C++ 2014 for nvcc\");\n\n#include <fmt/base.h>\n\n#include <cuda.h>\n#include <iostream>\n\nextern auto make_message_cpp() -> std::string;\nextern auto make_message_cuda() -> std::string;\n\nint main() {\n  std::cout << make_message_cuda() << std::endl;\n  std::cout << make_message_cpp() << std::endl;\n}\n\nauto make_message_cuda() -> std::string {\n  return fmt::format(\"nvcc compiler \\t: __cplusplus == {}\", __cplusplus);\n}\n"
  },
  {
    "path": "test/detect-stdfs.cc",
    "content": "// Formatting library for C++ - tests of formatters for standard library types\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <exception>  // _GLIBCXX_RELEASE & _LIBCPP_VERSION\n\n#if defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE == 8\n#  error libfound \"stdc++fs\"\n#elif !defined(__apple_build_version__) && defined(_LIBCPP_VERSION) && \\\n    _LIBCPP_VERSION >= 7000 && _LIBCPP_VERSION < 9000\n#  error libfound \"c++fs\"\n#else\n// none if std::filesystem does not require additional libraries\n#  error libfound \"\"\n#endif\n"
  },
  {
    "path": "test/enforce-checks-test.cc",
    "content": "// Formatting library for C++ - formatting library tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <iterator>\n#include <vector>\n\n#define I 42  // simulate https://en.cppreference.com/w/c/numeric/complex/I\n#include \"fmt/chrono.h\"\n#include \"fmt/color.h\"\n#include \"fmt/format.h\"\n#include \"fmt/ostream.h\"\n#include \"fmt/ranges.h\"\n#include \"fmt/xchar.h\"\n#undef I\n\n// Exercise the API to verify that everything we expect to can compile.\nvoid test_format_api() {\n  (void)fmt::format(FMT_STRING(\"{}\"), 42);\n  (void)fmt::format(FMT_STRING(L\"{}\"), 42);\n  (void)fmt::format(FMT_STRING(\"noop\"));\n\n  (void)fmt::to_string(42);\n  (void)fmt::to_wstring(42);\n\n  std::vector<char> out;\n  fmt::format_to(std::back_inserter(out), FMT_STRING(\"{}\"), 42);\n\n  char buffer[4];\n  fmt::format_to_n(buffer, 3, FMT_STRING(\"{}\"), 12345);\n\n  wchar_t wbuffer[4];\n  fmt::format_to_n(wbuffer, 3, FMT_STRING(L\"{}\"), 12345);\n}\n\nvoid test_chrono() {\n  (void)fmt::format(FMT_STRING(\"{}\"), std::chrono::seconds(42));\n  (void)fmt::format(FMT_STRING(L\"{}\"), std::chrono::seconds(42));\n}\n\nvoid test_text_style() {\n  fmt::print(fg(fmt::rgb(255, 20, 30)), FMT_STRING(\"{}\"), \"rgb(255,20,30)\");\n  (void)fmt::format(fg(fmt::rgb(255, 20, 30)), FMT_STRING(\"{}\"),\n                    \"rgb(255,20,30)\");\n\n  fmt::text_style ts = fg(fmt::rgb(255, 20, 30));\n  std::string out;\n  fmt::format_to(std::back_inserter(out), ts,\n                 FMT_STRING(\"rgb(255,20,30){}{}{}\"), 1, 2, 3);\n}\n\nvoid test_range() {\n  std::vector<char> hello = {'h', 'e', 'l', 'l', 'o'};\n  (void)fmt::format(FMT_STRING(\"{}\"), hello);\n}\n\nint main() {\n  test_format_api();\n  test_chrono();\n  test_text_style();\n  test_range();\n}\n"
  },
  {
    "path": "test/find-package-test/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.8...3.25)\n\nproject(fmt-test)\n\nfind_package(FMT REQUIRED)\n\nadd_executable(library-test main.cc)\ntarget_link_libraries(library-test fmt::fmt)\ntarget_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})\ntarget_include_directories(library-test PUBLIC SYSTEM .)\n\nif (TARGET fmt::fmt-header-only)\n  add_executable(header-only-test main.cc)\n  target_link_libraries(header-only-test fmt::fmt-header-only)\n  target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})\n  target_include_directories(header-only-test PUBLIC SYSTEM .)\nendif ()\n"
  },
  {
    "path": "test/find-package-test/main.cc",
    "content": "#include \"fmt/format.h\"\n\nint main(int argc, char** argv) {\n  for (int i = 0; i < argc; ++i) fmt::print(\"{}: {}\\n\", i, argv[i]);\n}\n"
  },
  {
    "path": "test/format-impl-test.cc",
    "content": "// Formatting library for C++ - formatting library implementation tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <algorithm>\n#include <cstring>\n\n// clang-format off\n#include \"test-assert.h\"\n// clang-format on\n\n#include \"fmt/format.h\"\n#include \"gmock/gmock.h\"\n#include \"util.h\"\n\nusing fmt::detail::bigint;\nusing fmt::detail::fp;\nusing fmt::detail::max_value;\n\nstatic_assert(!std::is_copy_constructible<bigint>::value, \"\");\nstatic_assert(!std::is_copy_assignable<bigint>::value, \"\");\n\nTEST(bigint_test, construct) {\n  EXPECT_EQ(fmt::to_string(bigint()), \"\");\n  EXPECT_EQ(fmt::to_string(bigint(0x42)), \"42\");\n  EXPECT_EQ(fmt::to_string(bigint(0x123456789abcedf0)), \"123456789abcedf0\");\n}\n\nTEST(bigint_test, compare) {\n  bigint n1(42);\n  bigint n2(42);\n  EXPECT_EQ(compare(n1, n2), 0);\n  n2 <<= 32;\n  EXPECT_LT(compare(n1, n2), 0);\n  bigint n3(43);\n  EXPECT_LT(compare(n1, n3), 0);\n  EXPECT_GT(compare(n3, n1), 0);\n  bigint n4(42 * 0x100000001);\n  EXPECT_LT(compare(n2, n4), 0);\n  EXPECT_GT(compare(n4, n2), 0);\n}\n\nTEST(bigint_test, add_compare) {\n  EXPECT_LT(\n      add_compare(bigint(0xffffffff), bigint(0xffffffff), bigint(1) <<= 64), 0);\n  EXPECT_LT(add_compare(bigint(1) <<= 32, bigint(1), bigint(1) <<= 96), 0);\n  EXPECT_GT(add_compare(bigint(1) <<= 32, bigint(0), bigint(0xffffffff)), 0);\n  EXPECT_GT(add_compare(bigint(0), bigint(1) <<= 32, bigint(0xffffffff)), 0);\n  EXPECT_GT(add_compare(bigint(42), bigint(1), bigint(42)), 0);\n  EXPECT_GT(add_compare(bigint(0xffffffff), bigint(1), bigint(0xffffffff)), 0);\n  EXPECT_LT(add_compare(bigint(10), bigint(10), bigint(22)), 0);\n  EXPECT_LT(add_compare(bigint(0x100000010), bigint(0x100000010),\n                        bigint(0x300000010)),\n            0);\n  EXPECT_GT(add_compare(bigint(0x1ffffffff), bigint(0x100000002),\n                        bigint(0x300000000)),\n            0);\n  EXPECT_EQ(add_compare(bigint(0x1ffffffff), bigint(0x100000002),\n                        bigint(0x300000001)),\n            0);\n  EXPECT_LT(add_compare(bigint(0x1ffffffff), bigint(0x100000002),\n                        bigint(0x300000002)),\n            0);\n  EXPECT_LT(add_compare(bigint(0x1ffffffff), bigint(0x100000002),\n                        bigint(0x300000003)),\n            0);\n}\n\nTEST(bigint_test, shift_left) {\n  bigint n(0x42);\n  n <<= 0;\n  EXPECT_EQ(fmt::to_string(n), \"42\");\n  n <<= 1;\n  EXPECT_EQ(fmt::to_string(n), \"84\");\n  n <<= 25;\n  EXPECT_EQ(fmt::to_string(n), \"108000000\");\n}\n\nTEST(bigint_test, multiply) {\n  bigint n(0x42);\n  EXPECT_THROW(n *= 0, assertion_failure);\n  n *= 1;\n  EXPECT_EQ(fmt::to_string(n), \"42\");\n\n  n *= 2;\n  EXPECT_EQ(fmt::to_string(n), \"84\");\n  n *= 0x12345678;\n  EXPECT_EQ(fmt::to_string(n), \"962fc95e0\");\n\n  bigint bigmax(max_value<uint32_t>());\n  bigmax *= max_value<uint32_t>();\n  EXPECT_EQ(fmt::to_string(bigmax), \"fffffffe00000001\");\n\n  const auto max64 = max_value<uint64_t>();\n  bigmax = max64;\n  bigmax *= max64;\n  EXPECT_EQ(fmt::to_string(bigmax), \"fffffffffffffffe0000000000000001\");\n\n  const auto max128 = (fmt::detail::uint128_t(max64) << 64) | max64;\n  bigmax = max128;\n  bigmax *= max128;\n  EXPECT_EQ(fmt::to_string(bigmax),\n            \"fffffffffffffffffffffffffffffffe00000000000000000000000000000001\");\n}\n\nTEST(bigint_test, square) {\n  bigint n0(0);\n  n0.square();\n  EXPECT_EQ(fmt::to_string(n0), \"0\");\n  bigint n1(0x100);\n  n1.square();\n  EXPECT_EQ(fmt::to_string(n1), \"10000\");\n  bigint n2(0xfffffffff);\n  n2.square();\n  EXPECT_EQ(fmt::to_string(n2), \"ffffffffe000000001\");\n  bigint n3(max_value<uint64_t>());\n  n3.square();\n  EXPECT_EQ(fmt::to_string(n3), \"fffffffffffffffe0000000000000001\");\n  bigint n4;\n  n4.assign_pow10(10);\n  EXPECT_EQ(fmt::to_string(n4), \"2540be400\");\n}\n\nTEST(bigint_test, divmod_assign_zero_divisor) {\n  bigint zero(0);\n  EXPECT_THROW(bigint(0).divmod_assign(zero), assertion_failure);\n  EXPECT_THROW(bigint(42).divmod_assign(zero), assertion_failure);\n}\n\nTEST(bigint_test, divmod_assign_self) {\n  bigint n(100);\n  EXPECT_THROW(n.divmod_assign(n), assertion_failure);\n}\n\nTEST(bigint_test, divmod_assign_unaligned) {\n  // (42 << 340) / pow(10, 100):\n  bigint n1(42);\n  n1 <<= 340;\n  bigint n2;\n  n2.assign_pow10(100);\n  int result = n1.divmod_assign(n2);\n  EXPECT_EQ(result, 9406);\n  EXPECT_EQ(fmt::to_string(n1),\n            \"10f8353019583bfc29ffc8f564e1b9f9d819dbb4cf783e4507eca1539220p96\");\n}\n\nTEST(bigint_test, divmod_assign) {\n  // 100 / 10:\n  bigint n1(100);\n  int result = n1.divmod_assign(bigint(10));\n  EXPECT_EQ(result, 10);\n  EXPECT_EQ(fmt::to_string(n1), \"0\");\n  // pow(10, 100) / (42 << 320):\n  n1.assign_pow10(100);\n  result = n1.divmod_assign(bigint(42) <<= 320);\n  EXPECT_EQ(result, 111);\n  EXPECT_EQ(fmt::to_string(n1),\n            \"13ad2594c37ceb0b2784c4ce0bf38ace408e211a7caab24308a82e8f10p96\");\n  // 42 / 100:\n  bigint n2(42);\n  n1.assign_pow10(2);\n  result = n2.divmod_assign(n1);\n  EXPECT_EQ(result, 0);\n  EXPECT_EQ(fmt::to_string(n2), \"2a\");\n}\n\ntemplate <bool is_iec559> void run_double_tests() {\n  fmt::print(\"warning: double is not IEC559, skipping FP tests\\n\");\n}\n\ntemplate <> void run_double_tests<true>() {\n  // Construct from double.\n  EXPECT_EQ(fp(1.23), fp(0x13ae147ae147aeu, -52));\n}\n\nTEST(fp_test, double_tests) {\n  run_double_tests<std::numeric_limits<double>::is_iec559>();\n}\n\nTEST(fp_test, normalize) {\n  const auto v = fp(0xbeef, 42);\n  auto normalized = normalize(v);\n  EXPECT_EQ(normalized.f, 0xbeef000000000000);\n  EXPECT_EQ(normalized.e, -6);\n}\n\nTEST(fp_test, multiply) {\n  auto v = fp(123ULL << 32, 4) * fp(56ULL << 32, 7);\n  EXPECT_EQ(v.f, 123u * 56u);\n  EXPECT_EQ(v.e, 4 + 7 + 64);\n  v = fp(123ULL << 32, 4) * fp(567ULL << 31, 8);\n  EXPECT_EQ(v.f, (123 * 567 + 1u) / 2);\n  EXPECT_EQ(v.e, 4 + 8 + 64);\n}\n\nTEST(fp_test, dragonbox_max_k) {\n  using fmt::detail::dragonbox::floor_log10_pow2;\n  using float_info = fmt::detail::dragonbox::float_info<float>;\n  EXPECT_EQ(\n      float_info::max_k,\n      float_info::kappa -\n          floor_log10_pow2(std::numeric_limits<float>::min_exponent -\n                           fmt::detail::num_significand_bits<float>() - 1));\n  using double_info = fmt::detail::dragonbox::float_info<double>;\n  EXPECT_EQ(double_info::max_k,\n            double_info::kappa -\n                floor_log10_pow2(\n                    std::numeric_limits<double>::min_exponent -\n                    2 * fmt::detail::num_significand_bits<double>() - 1));\n}\n\nTEST(format_impl_test, format_error_code) {\n  std::string msg = \"error 42\", sep = \": \";\n  {\n    auto buffer = fmt::memory_buffer();\n    fmt::format_to(fmt::appender(buffer), \"garbage\");\n    fmt::detail::format_error_code(buffer, 42, \"test\");\n    EXPECT_EQ(to_string(buffer), \"test: \" + msg);\n  }\n  {\n    auto buffer = fmt::memory_buffer();\n    auto prefix =\n        std::string(fmt::inline_buffer_size - msg.size() - sep.size() + 1, 'x');\n    fmt::detail::format_error_code(buffer, 42, prefix);\n    EXPECT_EQ(msg, to_string(buffer));\n  }\n  int codes[] = {42, -1};\n  for (size_t i = 0, n = sizeof(codes) / sizeof(*codes); i < n; ++i) {\n    // Test maximum buffer size.\n    msg = fmt::format(\"error {}\", codes[i]);\n    fmt::memory_buffer buffer;\n    auto prefix =\n        std::string(fmt::inline_buffer_size - msg.size() - sep.size(), 'x');\n    fmt::detail::format_error_code(buffer, codes[i], prefix);\n    EXPECT_EQ(prefix + sep + msg, to_string(buffer));\n    size_t size = fmt::inline_buffer_size;\n    EXPECT_EQ(size, buffer.size());\n    buffer.resize(0);\n    // Test with a message that doesn't fit into the buffer.\n    prefix += 'x';\n    fmt::detail::format_error_code(buffer, codes[i], prefix);\n    EXPECT_EQ(to_string(buffer), msg);\n  }\n}\n\n// Tests fmt::detail::count_digits for integer type Int.\ntemplate <typename Int> void test_count_digits() {\n  for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::detail::count_digits(i));\n  for (Int i = 1, n = 1, end = max_value<Int>() / 10; n <= end; ++i) {\n    n *= 10;\n    EXPECT_EQ(fmt::detail::count_digits(n - 1), i);\n    EXPECT_EQ(fmt::detail::count_digits(n), i + 1);\n  }\n}\n\nTEST(format_impl_test, count_digits) {\n  test_count_digits<uint32_t>();\n  test_count_digits<uint64_t>();\n}\n\nTEST(format_impl_test, countl_zero) {\n  constexpr auto num_bits = fmt::detail::num_bits<uint32_t>();\n  uint32_t n = 1u;\n  for (int i = 1; i < num_bits - 1; i++) {\n    n <<= 1;\n    EXPECT_EQ(fmt::detail::countl_zero(n - 1), num_bits - i);\n    EXPECT_EQ(fmt::detail::countl_zero(n), num_bits - i - 1);\n  }\n}\n\n#if FMT_USE_FLOAT128\nTEST(format_impl_test, write_float128) {\n  auto s = std::string();\n  fmt::detail::write<char>(std::back_inserter(s), __float128(42));\n  EXPECT_EQ(s, \"42\");\n}\n#endif\n\nstruct double_double {\n  double a;\n  double b;\n\n  constexpr explicit double_double(double a_val = 0, double b_val = 0)\n      : a(a_val), b(b_val) {}\n\n  operator double() const { return a + b; }\n  auto operator-() const -> double_double { return double_double(-a, -b); }\n};\n\nauto format_as(double_double d) -> double { return d; }\n\nauto operator>=(const double_double& lhs, const double_double& rhs) -> bool {\n  return lhs.a + lhs.b >= rhs.a + rhs.b;\n}\n\nstruct slow_float {\n  float value;\n\n  constexpr explicit slow_float(float val = 0) : value(val) {}\n  operator float() const { return value; }\n  auto operator-() const -> slow_float { return slow_float(-value); }\n};\n\nauto format_as(slow_float f) -> float { return f; }\n\nnamespace std {\ntemplate <> struct numeric_limits<double_double> {\n  // is_iec559 is true for double-double in libstdc++.\n  static constexpr bool is_iec559 = true;\n  static constexpr int digits = 106;\n  static constexpr int digits10 = 33;\n};\n\ntemplate <> struct numeric_limits<slow_float> : numeric_limits<float> {};\n}  // namespace std\n\nFMT_BEGIN_NAMESPACE\nnamespace detail {\ntemplate <> struct is_floating_point<double_double> : std::true_type {};\ntemplate <> struct is_floating_point<slow_float> : std::true_type {};\ntemplate <> struct is_fast_float<slow_float> : std::false_type {};\nnamespace dragonbox {\ntemplate <> struct float_info<slow_float> {\n  using carrier_uint = uint32_t;\n  static const int exponent_bits = 8;\n};\n}  // namespace dragonbox\n}  // namespace detail\nFMT_END_NAMESPACE\n\nTEST(format_impl_test, write_double_double) {\n  auto s = std::string();\n  fmt::detail::write<char>(std::back_inserter(s), double_double(42), {});\n  // Specializing is_floating_point is broken in MSVC.\n  if (!FMT_MSC_VERSION) EXPECT_EQ(s, \"42\");\n}\n\nTEST(format_impl_test, write_dragon_even) {\n  auto s = std::string();\n  fmt::detail::write<char>(std::back_inserter(s), slow_float(33554450.0f), {});\n  // Specializing is_floating_point is broken in MSVC.\n  if (!FMT_MSC_VERSION) EXPECT_EQ(s, \"3.355445e+07\");\n}\n\n#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)\n#  include <windows.h>\n\nTEST(format_impl_test, write_console_signature) {\n  decltype(::WriteConsoleW)* p = fmt::detail::WriteConsoleW;\n  (void)p;\n}\n#endif\n\n// A public domain branchless UTF-8 decoder by Christopher Wellons:\n// https://github.com/skeeto/branchless-utf8\nconstexpr auto unicode_is_surrogate(uint32_t c) -> bool {\n  return c >= 0xD800U && c <= 0xDFFFU;\n}\n\nFMT_CONSTEXPR auto utf8_encode(char* s, uint32_t c) -> char* {\n  if (c >= (1UL << 16)) {\n    s[0] = static_cast<char>(0xf0 | (c >> 18));\n    s[1] = static_cast<char>(0x80 | ((c >> 12) & 0x3f));\n    s[2] = static_cast<char>(0x80 | ((c >> 6) & 0x3f));\n    s[3] = static_cast<char>(0x80 | ((c >> 0) & 0x3f));\n    return s + 4;\n  } else if (c >= (1UL << 11)) {\n    s[0] = static_cast<char>(0xe0 | (c >> 12));\n    s[1] = static_cast<char>(0x80 | ((c >> 6) & 0x3f));\n    s[2] = static_cast<char>(0x80 | ((c >> 0) & 0x3f));\n    return s + 3;\n  } else if (c >= (1UL << 7)) {\n    s[0] = static_cast<char>(0xc0 | (c >> 6));\n    s[1] = static_cast<char>(0x80 | ((c >> 0) & 0x3f));\n    return s + 2;\n  } else {\n    s[0] = static_cast<char>(c);\n    return s + 1;\n  }\n}\n\n// Make sure it can decode every character\nTEST(format_impl_test, utf8_decode_decode_all) {\n  for (uint32_t i = 0; i < 0x10ffff; i++) {\n    if (!unicode_is_surrogate(i)) {\n      int e;\n      uint32_t c;\n      char buf[8] = {0};\n      char* end = utf8_encode(buf, i);\n      const char* res = fmt::detail::utf8_decode(buf, &c, &e);\n      EXPECT_EQ(end, res);\n      EXPECT_EQ(c, i);\n      EXPECT_EQ(e, 0);\n    }\n  }\n}\n\n// Reject everything outside of U+0000..U+10FFFF\nTEST(format_impl_test, utf8_decode_out_of_range) {\n  for (uint32_t i = 0x110000; i < 0x1fffff; i++) {\n    int e;\n    uint32_t c;\n    char buf[8] = {0};\n    utf8_encode(buf, i);\n    const char* end = fmt::detail::utf8_decode(buf, &c, &e);\n    EXPECT_NE(e, 0);\n    EXPECT_EQ(end - buf, 4);\n  }\n}\n\n// Does it reject all surrogate halves?\nTEST(format_impl_test, utf8_decode_surrogate_halves) {\n  for (uint32_t i = 0xd800; i <= 0xdfff; i++) {\n    int e;\n    uint32_t c;\n    char buf[8] = {0};\n    utf8_encode(buf, i);\n    fmt::detail::utf8_decode(buf, &c, &e);\n    EXPECT_NE(e, 0);\n  }\n}\n\n// How about non-canonical encodings?\nTEST(format_impl_test, utf8_decode_non_canonical_encodings) {\n  int e;\n  uint32_t c;\n  const char* end;\n\n  char buf2[8] = {char(0xc0), char(0xA4)};\n  end = fmt::detail::utf8_decode(buf2, &c, &e);\n  EXPECT_NE(e, 0);           // non-canonical len 2\n  EXPECT_EQ(end, buf2 + 2);  // non-canonical recover 2\n\n  char buf3[8] = {char(0xe0), char(0x80), char(0xA4)};\n  end = fmt::detail::utf8_decode(buf3, &c, &e);\n  EXPECT_NE(e, 0);           // non-canonical len 3\n  EXPECT_EQ(end, buf3 + 3);  // non-canonical recover 3\n\n  char buf4[8] = {char(0xf0), char(0x80), char(0x80), char(0xA4)};\n  end = fmt::detail::utf8_decode(buf4, &c, &e);\n  EXPECT_NE(e, 0);           // non-canonical encoding len 4\n  EXPECT_EQ(end, buf4 + 4);  // non-canonical recover 4\n}\n\n// Let's try some bogus byte sequences\nTEST(format_impl_test, utf8_decode_bogus_byte_sequences) {\n  int e;\n  uint32_t c;\n\n  // Invalid first byte\n  char buf0[4] = {char(0xff)};\n  auto len = fmt::detail::utf8_decode(buf0, &c, &e) - buf0;\n  EXPECT_NE(e, 0);    // \"bogus [ff] 0x%02x U+%04lx\", e, (unsigned long)c);\n  EXPECT_EQ(len, 1);  // \"bogus [ff] recovery %d\", len);\n\n  // Invalid first byte\n  char buf1[4] = {char(0x80)};\n  len = fmt::detail::utf8_decode(buf1, &c, &e) - buf1;\n  EXPECT_NE(e, 0);    // \"bogus [80] 0x%02x U+%04lx\", e, (unsigned long)c);\n  EXPECT_EQ(len, 1);  // \"bogus [80] recovery %d\", len);\n\n  // Looks like a two-byte sequence but second byte is wrong\n  char buf2[4] = {char(0xc0), char(0x0a)};\n  len = fmt::detail::utf8_decode(buf2, &c, &e) - buf2;\n  EXPECT_NE(e, 0);    // \"bogus [c0 0a] 0x%02x U+%04lx\", e, (unsigned long)c\n  EXPECT_EQ(len, 2);  // \"bogus [c0 0a] recovery %d\", len);\n}\n\nTEST(format_impl_test, to_utf8) {\n  auto s = std::string(\"ёжик\");\n  auto u = fmt::detail::to_utf8<wchar_t>(L\"\\x0451\\x0436\\x0438\\x043A\");\n  EXPECT_EQ(s, u.str());\n  EXPECT_EQ(s.size(), u.size());\n}\n"
  },
  {
    "path": "test/format-test.cc",
    "content": "// Formatting library for C++ - formatting library tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n// Check if fmt/format.h compiles with windows.h included before it.\n#ifdef _WIN32\n#  include <windows.h>\n#endif\n// clang-format off\n#include \"fmt/format.h\"\n// clang-format on\n\n#include <stdint.h>  // uint32_t\n\n#include <cfenv>               // fegetexceptflag and FE_ALL_EXCEPT\n#include <climits>             // INT_MAX\n#include <cmath>               // std::signbit\n#include <condition_variable>  // std::condition_variable\n#include <cstring>             // std::strlen\n#include <iterator>            // std::back_inserter\n#include <list>                // std::list\n#include <mutex>               // std::mutex\n#include <string>              // std::string\n#include <thread>              // std::thread\n#include <type_traits>         // std::is_default_constructible\n#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<version>)\n#  include <version>\n#endif\n\n#include <limits.h>\n\n#include <limits>\n\n#include \"gtest-extra.h\"\n#include \"mock-allocator.h\"\n#include \"util.h\"\nusing fmt::basic_memory_buffer;\nusing fmt::format_error;\nusing fmt::memory_buffer;\nusing fmt::runtime;\nusing fmt::string_view;\nusing fmt::detail::max_value;\nusing fmt::detail::uint128;\n\nusing testing::Return;\nusing testing::StrictMock;\n\n#ifdef __cpp_lib_concepts\nstatic_assert(std::output_iterator<fmt::appender, char>);\n#endif\n\nenum { buffer_size = 256 };\n\nTEST(uint128_test, ctor) {\n  auto n = uint128();\n  EXPECT_EQ(n, 0);\n  n = uint128(42);\n  EXPECT_EQ(n, 42);\n  EXPECT_EQ(static_cast<uint64_t>(n), 42);\n}\n\nTEST(uint128_test, shift) {\n  auto n = uint128(42);\n  n = n << 64;\n  EXPECT_EQ(static_cast<uint64_t>(n), 0);\n  n = n >> 64;\n  EXPECT_EQ(static_cast<uint64_t>(n), 42);\n  n = n << 62;\n  EXPECT_EQ(static_cast<uint64_t>(n >> 64), 0xa);\n  EXPECT_EQ(static_cast<uint64_t>(n), 0x8000000000000000);\n  n = n >> 62;\n  EXPECT_EQ(static_cast<uint64_t>(n), 42);\n  EXPECT_EQ(uint128(1) << 112, uint128(0x1000000000000, 0));\n  EXPECT_EQ(uint128(0x1000000000000, 0) >> 112, uint128(1));\n}\n\nTEST(uint128_test, minus) {\n  auto n = uint128(42);\n  EXPECT_EQ(n - 2, 40);\n}\n\nTEST(uint128_test, plus_assign) {\n  auto n = uint128(32);\n  n += uint128(10);\n  EXPECT_EQ(n, 42);\n  n = uint128(max_value<uint64_t>());\n  n += uint128(1);\n  EXPECT_EQ(n, uint128(1) << 64);\n}\n\nTEST(uint128_test, multiply) {\n  auto n = uint128(2251799813685247);\n  n = n * 3611864890;\n  EXPECT_EQ(static_cast<uint64_t>(n >> 64), 440901);\n}\n\ntemplate <typename Float> void check_isfinite() {\n  using fmt::detail::isfinite;\n  EXPECT_TRUE(isfinite(Float(0.0)));\n  EXPECT_TRUE(isfinite(Float(42.0)));\n  EXPECT_TRUE(isfinite(Float(-42.0)));\n  EXPECT_TRUE(isfinite(Float(fmt::detail::max_value<double>())));\n  // Use double because std::numeric_limits is broken for __float128.\n  using limits = std::numeric_limits<double>;\n  FMT_CONSTEXPR20 auto result = isfinite(Float(limits::infinity()));\n  EXPECT_FALSE(result);\n  EXPECT_FALSE(isfinite(Float(limits::infinity())));\n  EXPECT_FALSE(isfinite(Float(-limits::infinity())));\n  EXPECT_FALSE(isfinite(Float(limits::quiet_NaN())));\n  EXPECT_FALSE(isfinite(Float(-limits::quiet_NaN())));\n}\n\nTEST(float_test, isfinite) {\n  check_isfinite<double>();\n#if FMT_USE_FLOAT128\n  check_isfinite<fmt::detail::float128>();\n#endif\n}\n\nvoid check_no_fp_exception() {\n  fexcept_t fe;\n  fegetexceptflag(&fe, FE_ALL_EXCEPT);\n\n  // No exception flags should have been set\n  EXPECT_TRUE(fe == 0);\n}\n\ntemplate <typename Float> void check_isnan() {\n  using fmt::detail::isnan;\n  EXPECT_FALSE(isnan(Float(0.0)));\n  EXPECT_FALSE(isnan(Float(42.0)));\n  EXPECT_FALSE(isnan(Float(-42.0)));\n  EXPECT_FALSE(isnan(Float(fmt::detail::max_value<double>())));\n  // Use double because std::numeric_limits is broken for __float128.\n  using limits = std::numeric_limits<double>;\n  EXPECT_FALSE(isnan(Float(limits::infinity())));\n  EXPECT_FALSE(isnan(Float(-limits::infinity())));\n  EXPECT_TRUE(isnan(Float(limits::quiet_NaN())));\n  EXPECT_TRUE(isnan(Float(-limits::quiet_NaN())));\n\n  // Sanity check: make sure no error has occurred before we start\n  check_no_fp_exception();\n\n  // Check that no exception is raised for the non-NaN case\n  isnan(Float(42.0));\n  check_no_fp_exception();\n\n  // Check that no exception is raised for the NaN case\n  isnan(Float(limits::quiet_NaN()));\n  check_no_fp_exception();\n}\n\nTEST(float_test, isnan) {\n  check_isnan<double>();\n#if FMT_USE_FLOAT128\n  check_isnan<fmt::detail::float128>();\n#endif\n}\n\nstruct uint32_pair {\n  uint32_t u[2];\n};\n\nTEST(util_test, bit_cast) {\n  auto s = fmt::detail::bit_cast<uint32_pair>(uint64_t{42});\n  EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), 42ull);\n  s = fmt::detail::bit_cast<uint32_pair>(~uint64_t{0});\n  EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), ~0ull);\n}\n\n// Increment a number in a string.\nvoid increment(char* s) {\n  for (int i = static_cast<int>(std::strlen(s)) - 1; i >= 0; --i) {\n    if (s[i] != '9') {\n      ++s[i];\n      break;\n    }\n    s[i] = '0';\n  }\n}\n\nTEST(util_test, increment) {\n  char s[10] = \"123\";\n  increment(s);\n  EXPECT_STREQ(\"124\", s);\n  s[2] = '8';\n  increment(s);\n  EXPECT_STREQ(\"129\", s);\n  increment(s);\n  EXPECT_STREQ(\"130\", s);\n  s[1] = s[2] = '9';\n  increment(s);\n  EXPECT_STREQ(\"200\", s);\n}\n\nstruct minimal_container {\n  using value_type = char;\n  void push_back(char) {}\n};\n\nTEST(util_test, copy) {\n  minimal_container c;\n  static constexpr char str[] = \"a\";\n  fmt::detail::copy<char>(str, str + 1, std::back_inserter(c));\n}\n\nTEST(util_test, parse_nonnegative_int) {\n  auto s = fmt::string_view(\"10000000000\");\n  auto begin = s.begin(), end = s.end();\n  EXPECT_EQ(fmt::detail::parse_nonnegative_int(begin, end, -1), -1);\n  s = \"2147483649\";\n  begin = s.begin();\n  end = s.end();\n  EXPECT_EQ(fmt::detail::parse_nonnegative_int(begin, end, -1), -1);\n}\n\nTEST(util_test, utf8_to_utf16) {\n  auto u = fmt::detail::utf8_to_utf16(\"лошадка\");\n  EXPECT_EQ(L\"\\x043B\\x043E\\x0448\\x0430\\x0434\\x043A\\x0430\", u.str());\n  EXPECT_EQ(7, u.size());\n  // U+10437 { DESERET SMALL LETTER YEE }\n  EXPECT_EQ(L\"\\xD801\\xDC37\", fmt::detail::utf8_to_utf16(\"𐐷\").str());\n  EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16(\"\\xc3\\x28\"), std::runtime_error,\n                   \"invalid utf8\");\n  EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16(fmt::string_view(\"л\", 1)),\n                   std::runtime_error, \"invalid utf8\");\n  EXPECT_EQ(L\"123456\", fmt::detail::utf8_to_utf16(\"123456\").str());\n}\n\nTEST(util_test, utf8_to_utf16_empty_string) {\n  auto s = std::string();\n  auto u = fmt::detail::utf8_to_utf16(s.c_str());\n  EXPECT_EQ(L\"\", u.str());\n  EXPECT_EQ(s.size(), u.size());\n}\n\nTEST(util_test, allocator_ref) {\n  using test_allocator_ref = allocator_ref<mock_allocator<int>>;\n  auto check_forwarding = [](mock_allocator<int>& alloc,\n                             test_allocator_ref& ref) {\n    int mem;\n    // Check if value_type is properly defined.\n    allocator_ref<mock_allocator<int>>::value_type* ptr = &mem;\n    // Check forwarding.\n    EXPECT_CALL(alloc, allocate(42)).WillOnce(Return(ptr));\n    ref.allocate(42);\n    EXPECT_CALL(alloc, deallocate(ptr, 42));\n    ref.deallocate(ptr, 42);\n  };\n\n  StrictMock<mock_allocator<int>> alloc;\n  auto ref = test_allocator_ref(&alloc);\n  // Check if allocator_ref forwards to the underlying allocator.\n  check_forwarding(alloc, ref);\n  test_allocator_ref ref2(ref);\n  check_forwarding(alloc, ref2);\n  test_allocator_ref ref3;\n  EXPECT_EQ(nullptr, ref3.get());\n  ref3 = ref;\n  check_forwarding(alloc, ref3);\n}\n\nTEST(util_test, format_system_error) {\n  fmt::memory_buffer message;\n  fmt::format_system_error(message, EDOM, \"test\");\n  auto ec = std::error_code(EDOM, std::generic_category());\n  EXPECT_EQ(to_string(message), std::system_error(ec, \"test\").what());\n  message = fmt::memory_buffer();\n\n  // Check if std::allocator throws on allocating max size_t / 2 chars.\n  size_t max_size = max_value<size_t>() / 2;\n  bool throws_on_alloc = false;\n  try {\n    auto alloc = std::allocator<char>();\n    alloc.deallocate(alloc.allocate(max_size), max_size);\n  } catch (const std::bad_alloc&) {\n    throws_on_alloc = true;\n  }\n  if (!throws_on_alloc) {\n    fmt::print(stderr, \"warning: std::allocator allocates {} chars\\n\",\n               max_size);\n    return;\n  }\n}\n\nTEST(util_test, system_error) {\n  auto test_error = fmt::system_error(EDOM, \"test\");\n  auto ec = std::error_code(EDOM, std::generic_category());\n  EXPECT_STREQ(test_error.what(), std::system_error(ec, \"test\").what());\n  EXPECT_EQ(test_error.code(), ec);\n\n  auto error = std::system_error(std::error_code());\n  try {\n    throw fmt::system_error(EDOM, \"test {}\", \"error\");\n  } catch (const std::system_error& e) {\n    error = e;\n  }\n  fmt::memory_buffer message;\n  fmt::format_system_error(message, EDOM, \"test error\");\n  EXPECT_EQ(error.what(), to_string(message));\n  EXPECT_EQ(error.code(), std::error_code(EDOM, std::generic_category()));\n}\n\nTEST(util_test, report_system_error) {\n  fmt::memory_buffer out;\n  fmt::format_system_error(out, EDOM, \"test error\");\n  out.push_back('\\n');\n  EXPECT_WRITE(stderr, fmt::report_system_error(EDOM, \"test error\"),\n               to_string(out));\n}\n\nTEST(memory_buffer_test, ctor) {\n  basic_memory_buffer<char, 123> buffer;\n  EXPECT_EQ(static_cast<size_t>(0), buffer.size());\n  EXPECT_EQ(123u, buffer.capacity());\n}\n\nusing std_allocator = allocator_ref<std::allocator<char>>;\n\nTEST(memory_buffer_test, move_ctor_inline_buffer) {\n  auto check_move_buffer =\n      [](const char* str, basic_memory_buffer<char, 5, std_allocator>& buffer) {\n        std::allocator<char>* alloc = buffer.get_allocator().get();\n        basic_memory_buffer<char, 5, std_allocator> buffer2(std::move(buffer));\n        // Move shouldn't destroy the inline content of the first buffer.\n        EXPECT_EQ(std::string(buffer.data(), buffer.size()), str);\n        EXPECT_EQ(std::string(&buffer2[0], buffer2.size()), str);\n        EXPECT_EQ(buffer2.capacity(), 5u);\n        // Move should transfer allocator.\n        EXPECT_EQ(buffer.get_allocator().get(), nullptr);\n        EXPECT_EQ(buffer2.get_allocator().get(), alloc);\n      };\n\n  auto alloc = std::allocator<char>();\n  basic_memory_buffer<char, 5, std_allocator> buffer((std_allocator(&alloc)));\n  buffer.append(string_view(\"test\"));\n  check_move_buffer(\"test\", buffer);\n  // Adding one more character fills the inline buffer, but doesn't cause\n  // dynamic allocation.\n  buffer.push_back('a');\n  check_move_buffer(\"testa\", buffer);\n}\n\nTEST(memory_buffer_test, move_ctor_dynamic_buffer) {\n  auto alloc = std::allocator<char>();\n  basic_memory_buffer<char, 4, std_allocator> buffer((std_allocator(&alloc)));\n  const char test[] = \"test\";\n  buffer.append(test, test + 4);\n  const char* inline_buffer_ptr = &buffer[0];\n  // Adding one more character causes the content to move from the inline to\n  // a dynamically allocated buffer.\n  buffer.push_back('a');\n  basic_memory_buffer<char, 4, std_allocator> buffer2(std::move(buffer));\n  // Move should rip the guts of the first buffer.\n  EXPECT_EQ(&buffer[0], inline_buffer_ptr);\n  EXPECT_EQ(buffer.size(), 0);\n  EXPECT_EQ(std::string(&buffer2[0], buffer2.size()), \"testa\");\n  EXPECT_GT(buffer2.capacity(), 4u);\n}\n\nusing std_allocator_noprop = allocator_ref<std::allocator<char>, false>;\n\nTEST(memory_buffer_test, move_ctor_inline_buffer_non_propagating) {\n  auto check_move_buffer =\n      [](const char* str,\n         basic_memory_buffer<char, 5, std_allocator_noprop>& buffer) {\n        std::allocator<char>* original_alloc_ptr = buffer.get_allocator().get();\n        const char* original_data_ptr = &buffer[0];\n        basic_memory_buffer<char, 5, std_allocator_noprop> buffer2(\n            std::move(buffer));\n        const char* new_data_ptr = &buffer2[0];\n        EXPECT_NE(new_data_ptr, original_data_ptr);\n        EXPECT_EQ(std::string(buffer.data(), buffer.size()), str);\n        EXPECT_EQ(std::string(buffer2.data(), buffer2.size()), str);\n        EXPECT_EQ(buffer2.capacity(), 5u);\n        // Allocators should NOT be transferred; they remain distinct instances.\n        // The original buffer's allocator pointer should still be valid (not\n        // nullptr).\n        EXPECT_EQ(buffer.get_allocator().get(), original_alloc_ptr);\n        EXPECT_NE(buffer2.get_allocator().get(), original_alloc_ptr);\n      };\n  auto alloc = std::allocator<char>();\n  basic_memory_buffer<char, 5, std_allocator_noprop> buffer(\n      (std_allocator_noprop(&alloc)));\n  buffer.append(string_view(\"test\", 4));\n  check_move_buffer(\"test\", buffer);\n  buffer.push_back('a');\n  check_move_buffer(\"testa\", buffer);\n}\n\nTEST(memory_buffer_test, move_ctor_dynamic_buffer_non_propagating) {\n  auto alloc = std::allocator<char>();\n  basic_memory_buffer<char, 4, std_allocator_noprop> buffer(\n      (std_allocator_noprop(&alloc)));\n  const char test[] = \"test\";\n  buffer.append(test, test + 4);\n  const char* inline_buffer_ptr = &buffer[0];\n  buffer.push_back('a');\n  EXPECT_NE(buffer.data(), inline_buffer_ptr);\n  std::allocator<char>* original_alloc_ptr = buffer.get_allocator().get();\n  basic_memory_buffer<char, 4, std_allocator_noprop> buffer2;\n  buffer2 = std::move(buffer);\n  EXPECT_EQ(std::string(buffer2.data(), buffer2.size()), \"testa\");\n  EXPECT_GT(buffer2.capacity(), 4u);\n  EXPECT_NE(buffer2.data(), inline_buffer_ptr);\n  EXPECT_EQ(buffer.get_allocator().get(), original_alloc_ptr);\n  EXPECT_NE(buffer2.get_allocator().get(), original_alloc_ptr);\n}\n\nvoid check_move_assign_buffer(const char* str,\n                              basic_memory_buffer<char, 5>& buffer) {\n  basic_memory_buffer<char, 5> buffer2;\n  buffer2 = std::move(buffer);\n  // Move shouldn't destroy the inline content of the first buffer.\n  EXPECT_EQ(std::string(&buffer[0], buffer.size()), str);\n  EXPECT_EQ(std::string(&buffer2[0], buffer2.size()), str);\n  EXPECT_EQ(buffer2.capacity(), 5u);\n}\n\nTEST(memory_buffer_test, move_assignment) {\n  basic_memory_buffer<char, 5> buffer;\n  const char test[] = \"test\";\n  buffer.append(test, test + 4);\n  check_move_assign_buffer(\"test\", buffer);\n  // Adding one more character fills the inline buffer, but doesn't cause\n  // dynamic allocation.\n  buffer.push_back('a');\n  check_move_assign_buffer(\"testa\", buffer);\n  const char* inline_buffer_ptr = &buffer[0];\n  // Adding one more character causes the content to move from the inline to\n  // a dynamically allocated buffer.\n  buffer.push_back('b');\n  basic_memory_buffer<char, 5> buffer2;\n  buffer2 = std::move(buffer);\n  // Move should rip the guts of the first buffer.\n  EXPECT_EQ(buffer.data(), inline_buffer_ptr);\n  EXPECT_EQ(std::string(buffer2.data(), buffer2.size()), \"testab\");\n  EXPECT_GT(buffer2.capacity(), 5u);\n}\n\nTEST(memory_buffer_test, grow) {\n  using allocator = allocator_ref<mock_allocator<int>>;\n  mock_allocator<int> alloc;\n  basic_memory_buffer<int, 10, allocator> buffer((allocator(&alloc)));\n  buffer.resize(7);\n  using fmt::detail::to_unsigned;\n  for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i;\n  EXPECT_EQ(10u, buffer.capacity());\n  int mem[20];\n  mem[7] = 0xdead;\n  EXPECT_CALL(alloc, allocate(20)).WillOnce(Return(mem));\n  buffer.try_reserve(20);\n  EXPECT_EQ(20u, buffer.capacity());\n  // Check if size elements have been copied\n  for (int i = 0; i < 7; ++i) EXPECT_EQ(i * i, buffer[to_unsigned(i)]);\n  // and no more than that.\n  EXPECT_EQ(0xdead, buffer[7]);\n  EXPECT_CALL(alloc, deallocate(mem, 20));\n}\n\nTEST(memory_buffer_test, allocator) {\n  using test_allocator = allocator_ref<mock_allocator<char>>;\n  basic_memory_buffer<char, 10, test_allocator> buffer;\n  EXPECT_EQ(nullptr, buffer.get_allocator().get());\n  StrictMock<mock_allocator<char>> alloc;\n  char mem;\n  {\n    basic_memory_buffer<char, 10, test_allocator> buffer2(\n        (test_allocator(&alloc)));\n    EXPECT_EQ(&alloc, buffer2.get_allocator().get());\n    size_t size = 2 * fmt::inline_buffer_size;\n    EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem));\n    buffer2.reserve(size);\n    EXPECT_CALL(alloc, deallocate(&mem, size));\n  }\n}\n\nTEST(memory_buffer_test, exception_in_deallocate) {\n  using test_allocator = allocator_ref<mock_allocator<char>>;\n  StrictMock<mock_allocator<char>> alloc;\n  basic_memory_buffer<char, 10, test_allocator> buffer(\n      (test_allocator(&alloc)));\n  size_t size = 2 * fmt::inline_buffer_size;\n  auto mem = std::vector<char>(size);\n  {\n    EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem[0]));\n    buffer.resize(size);\n    std::fill(&buffer[0], &buffer[0] + size, 'x');\n  }\n  auto mem2 = std::vector<char>(2 * size);\n  {\n    EXPECT_CALL(alloc, allocate(2 * size)).WillOnce(Return(&mem2[0]));\n    auto e = std::exception();\n    EXPECT_CALL(alloc, deallocate(&mem[0], size)).WillOnce(testing::Throw(e));\n    EXPECT_THROW(buffer.reserve(2 * size), std::exception);\n    EXPECT_EQ(&mem2[0], &buffer[0]);\n    // Check that the data has been copied.\n    for (size_t i = 0; i < size; ++i) EXPECT_EQ('x', buffer[i]);\n  }\n  EXPECT_CALL(alloc, deallocate(&mem2[0], 2 * size));\n}\n\ntemplate <typename Allocator, size_t MaxSize>\nclass max_size_allocator : public Allocator {\n public:\n  using typename Allocator::value_type;\n  size_t max_size() const noexcept { return MaxSize; }\n  value_type* allocate(size_t n) {\n    if (n > max_size()) {\n      throw std::length_error(\"size > max_size\");\n    }\n    return std::allocator_traits<Allocator>::allocate(\n        *static_cast<Allocator*>(this), n);\n  }\n  void deallocate(value_type* p, size_t n) {\n    std::allocator_traits<Allocator>::deallocate(*static_cast<Allocator*>(this),\n                                                 p, n);\n  }\n};\n\nTEST(memory_buffer_test, max_size_allocator) {\n  // 160 = 128 + 32\n  using test_allocator = max_size_allocator<std::allocator<char>, 160>;\n  basic_memory_buffer<char, 10, test_allocator> buffer;\n  buffer.resize(128);\n  // new_capacity = 128 + 128/2 = 192 > 160\n  buffer.resize(160);  // Shouldn't throw.\n}\n\nTEST(memory_buffer_test, max_size_allocator_overflow) {\n  using test_allocator = max_size_allocator<std::allocator<char>, 160>;\n  basic_memory_buffer<char, 10, test_allocator> buffer;\n  EXPECT_THROW(buffer.resize(161), std::exception);\n}\n\nTEST(memory_buffer_test, back_insert_iterator) {\n  fmt::memory_buffer buf;\n  using iterator = decltype(std::back_inserter(buf));\n  EXPECT_TRUE(fmt::detail::is_back_insert_iterator<iterator>::value);\n}\n\nTEST(format_test, digits2_alignment) {\n  auto p =\n      fmt::detail::bit_cast<fmt::detail::uintptr_t>(fmt::detail::digits2(0));\n  EXPECT_EQ(p % 2, 0);\n}\n\nTEST(format_test, exception_from_lib) {\n  EXPECT_THROW_MSG(fmt::report_error(\"test\"), format_error, \"test\");\n}\n\nTEST(format_test, escape) {\n  EXPECT_EQ(fmt::format(\"{{\"), \"{\");\n  EXPECT_EQ(fmt::format(\"before {{\"), \"before {\");\n  EXPECT_EQ(fmt::format(\"{{ after\"), \"{ after\");\n  EXPECT_EQ(fmt::format(\"before {{ after\"), \"before { after\");\n\n  EXPECT_EQ(fmt::format(\"}}\"), \"}\");\n  EXPECT_EQ(fmt::format(\"before }}\"), \"before }\");\n  EXPECT_EQ(fmt::format(\"}} after\"), \"} after\");\n  EXPECT_EQ(fmt::format(\"before }} after\"), \"before } after\");\n\n  EXPECT_EQ(fmt::format(\"{{}}\"), \"{}\");\n  EXPECT_EQ(fmt::format(\"{{{0}}}\", 42), \"{42}\");\n}\n\nTEST(format_test, unmatched_braces) {\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{\")), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"}\")), format_error,\n                   \"unmatched '}' in format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0{}\")), format_error,\n                   \"invalid format string\");\n}\n\nTEST(format_test, no_args) { EXPECT_EQ(fmt::format(\"test\"), \"test\"); }\n\nTEST(format_test, args_in_different_positions) {\n  EXPECT_EQ(fmt::format(\"{0}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"before {0}\", 42), \"before 42\");\n  EXPECT_EQ(fmt::format(\"{0} after\", 42), \"42 after\");\n  EXPECT_EQ(fmt::format(\"before {0} after\", 42), \"before 42 after\");\n  EXPECT_EQ(fmt::format(\"{0} = {1}\", \"answer\", 42), \"answer = 42\");\n  EXPECT_EQ(fmt::format(\"{1} is the {0}\", \"answer\", 42), \"42 is the answer\");\n  EXPECT_EQ(fmt::format(\"{0}{1}{0}\", \"abra\", \"cad\"), \"abracadabra\");\n}\n\nTEST(format_test, arg_errors) {\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{\")), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{?}\")), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0\")), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0}\")), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{00}\"), 42), format_error,\n                   \"invalid format string\");\n\n  auto int_max = std::to_string(INT_MAX);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{\" + int_max)), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{\" + int_max + \"}\")),\n                   format_error, \"argument not found\");\n\n  auto int_maxer = std::to_string(INT_MAX + 1u);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{\" + int_maxer)), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{\" + int_maxer + \"}\")),\n                   format_error, \"argument not found\");\n}\n\nTEST(format_test, display_width_precision) {\n  EXPECT_EQ(fmt::format(\"{:.5}\", \"🐱🐱🐱\"), \"🐱🐱\");\n}\n\ntemplate <int N> struct test_format {\n  template <typename... T>\n  static auto format(fmt::string_view fmt, const T&... args) -> std::string {\n    return test_format<N - 1>::format(fmt, N - 1, args...);\n  }\n};\n\ntemplate <> struct test_format<0> {\n  template <typename... T>\n  static auto format(fmt::string_view fmt, const T&... args) -> std::string {\n    return fmt::format(runtime(fmt), args...);\n  }\n};\n\nTEST(format_test, many_args) {\n  EXPECT_EQ(\"19\", test_format<20>::format(\"{19}\"));\n  EXPECT_THROW_MSG(test_format<20>::format(\"{20}\"), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG(test_format<21>::format(\"{21}\"), format_error,\n                   \"argument not found\");\n  using fmt::detail::max_packed_args;\n  std::string format_str = fmt::format(\"{{{}}}\", max_packed_args + 1);\n  EXPECT_THROW_MSG(test_format<max_packed_args>::format(format_str),\n                   format_error, \"argument not found\");\n}\n\nTEST(format_test, named_arg) {\n  EXPECT_EQ(\"1/a/A\", fmt::format(\"{_1}/{a_}/{A_}\", fmt::arg(\"a_\", 'a'),\n                                 fmt::arg(\"A_\", \"A\"), fmt::arg(\"_1\", 1)));\n  EXPECT_EQ(fmt::format(\"{0:{width}}\", -42, fmt::arg(\"width\", 4)), \" -42\");\n  EXPECT_EQ(fmt::format(\"{value:{width}}\", fmt::arg(\"value\", -42),\n                        fmt::arg(\"width\", 4)),\n            \" -42\");\n  EXPECT_EQ(\"st\",\n            fmt::format(\"{0:.{precision}}\", \"str\", fmt::arg(\"precision\", 2)));\n  EXPECT_EQ(fmt::format(\"{} {two}\", 1, fmt::arg(\"two\", 2)), \"1 2\");\n  EXPECT_EQ(\"42\",\n            fmt::format(\"{c}\", fmt::arg(\"a\", 0), fmt::arg(\"b\", 0),\n                        fmt::arg(\"c\", 42), fmt::arg(\"d\", 0), fmt::arg(\"e\", 0),\n                        fmt::arg(\"f\", 0), fmt::arg(\"g\", 0), fmt::arg(\"h\", 0),\n                        fmt::arg(\"i\", 0), fmt::arg(\"j\", 0), fmt::arg(\"k\", 0),\n                        fmt::arg(\"l\", 0), fmt::arg(\"m\", 0), fmt::arg(\"n\", 0),\n                        fmt::arg(\"o\", 0), fmt::arg(\"p\", 0)));\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{a}\")), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{a}\"), 42), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{a} {}\"), fmt::arg(\"a\", 2), 42),\n                   format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(\"{a}\", fmt::arg(\"a\", 1), fmt::arg(\"a\", 10)),\n      format_error, \"duplicate named arg\");\n}\n\nTEST(format_test, auto_arg_index) {\n  EXPECT_EQ(fmt::format(\"{}{}{}\", 'a', 'b', 'c'), \"abc\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0}{}\"), 'a', 'b'), format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{}{0}\"), 'a', 'b'), format_error,\n                   \"cannot switch from automatic to manual argument indexing\");\n  EXPECT_EQ(fmt::format(\"{:.{}}\", 1.2345, 2), \"1.2\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0}:.{}\"), 1.2345, 2),\n                   format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:.{0}}\"), 1.2345, 2),\n                   format_error,\n                   \"cannot switch from automatic to manual argument indexing\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{}\")), format_error,\n                   \"argument not found\");\n}\n\nTEST(format_test, empty_specs) { EXPECT_EQ(fmt::format(\"{0:}\", 42), \"42\"); }\n\nTEST(format_test, left_align) {\n  EXPECT_EQ(fmt::format(\"{0:<4}\", 42), \"42  \");\n  EXPECT_EQ(fmt::format(\"{0:<4o}\", 042), \"42  \");\n  EXPECT_EQ(fmt::format(\"{0:<4x}\", 0x42), \"42  \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", -42), \"-42  \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", 42u), \"42   \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", -42l), \"-42  \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", 42ul), \"42   \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", -42ll), \"-42  \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", 42ull), \"42   \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", -42.0), \"-42  \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", -42.0l), \"-42  \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", 'c'), \"c    \");\n  EXPECT_EQ(fmt::format(\"{0:<5}\", \"abc\"), \"abc  \");\n  EXPECT_EQ(fmt::format(\"{0:<8}\", reinterpret_cast<void*>(0xface)), \"0xface  \");\n}\n\nTEST(format_test, right_align) {\n  EXPECT_EQ(fmt::format(\"{0:>4}\", 42), \"  42\");\n  EXPECT_EQ(fmt::format(\"{0:>4o}\", 042), \"  42\");\n  EXPECT_EQ(fmt::format(\"{0:>4x}\", 0x42), \"  42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", -42), \"  -42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", 42u), \"   42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", -42l), \"  -42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", 42ul), \"   42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", -42ll), \"  -42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", 42ull), \"   42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", -42.0), \"  -42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", -42.0l), \"  -42\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", 'c'), \"    c\");\n  EXPECT_EQ(fmt::format(\"{0:>5}\", \"abc\"), \"  abc\");\n  EXPECT_EQ(fmt::format(\"{0:>8}\", reinterpret_cast<void*>(0xface)), \"  0xface\");\n}\n\nTEST(format_test, center_align) {\n  EXPECT_EQ(fmt::format(\"{0:^5}\", 42), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{0:^5o}\", 042), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{0:^5x}\", 0x42), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", -42), \" -42 \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", 42u), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", -42l), \" -42 \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", 42ul), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", -42ll), \" -42 \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", 42ull), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", -42.0), \" -42 \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", -42.0l), \" -42 \");\n  EXPECT_EQ(fmt::format(\"{0:^5}\", 'c'), \"  c  \");\n  EXPECT_EQ(fmt::format(\"{0:^6}\", \"abc\"), \" abc  \");\n  EXPECT_EQ(fmt::format(\"{0:^8}\", reinterpret_cast<void*>(0xface)), \" 0xface \");\n}\n\nTEST(format_test, fill) {\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{<5}\"), 'c'), format_error,\n                   \"invalid fill character '{'\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{<5}}\"), 'c'), format_error,\n                   \"invalid fill character '{'\");\n  EXPECT_EQ(fmt::format(\"{0:*>4}\", 42), \"**42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", -42), \"**-42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", 42u), \"***42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", -42l), \"**-42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", 42ul), \"***42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", -42ll), \"**-42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", 42ull), \"***42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", -42.0), \"**-42\");\n  EXPECT_EQ(fmt::format(\"{0:*>5}\", -42.0l), \"**-42\");\n  EXPECT_EQ(fmt::format(\"{0:*<5}\", 'c'), \"c****\");\n  EXPECT_EQ(fmt::format(\"{0:*<5}\", \"abc\"), \"abc**\");\n  EXPECT_EQ(\"**0xface\",\n            fmt::format(\"{0:*>8}\", reinterpret_cast<void*>(0xface)));\n  EXPECT_EQ(fmt::format(\"{:}=\", \"foo\"), \"foo=\");\n  EXPECT_EQ(std::string(\"\\0\\0\\0*\", 4),\n            fmt::format(string_view(\"{:\\0>4}\", 6), '*'));\n  EXPECT_EQ(fmt::format(\"{0:ж>4}\", 42), \"жж42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:\\x80\\x80\\x80\\x80\\x80>}\"), 0),\n                   format_error, \"invalid format specifier\");\n}\n\nTEST(format_test, plus_sign) {\n  EXPECT_EQ(fmt::format(\"{0:+}\", 42), \"+42\");\n  EXPECT_EQ(fmt::format(\"{0:+}\", -42), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:+}\", 42), \"+42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:+}\"), 42u), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:+}\", 42l), \"+42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:+}\"), 42ul), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:+}\", 42ll), \"+42\");\n#if FMT_USE_INT128\n  EXPECT_EQ(fmt::format(\"{0:+}\", __int128_t(42)), \"+42\");\n#endif\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:+}\"), 42ull), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:+}\", 42.0), \"+42\");\n  EXPECT_EQ(fmt::format(\"{0:+}\", 42.0l), \"+42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:+}\"), 'c'), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:+}\"), \"abc\"), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0:+}\"), reinterpret_cast<void*>(0x42)),\n      format_error, \"invalid format specifier\");\n}\n\nTEST(format_test, minus_sign) {\n  EXPECT_EQ(fmt::format(\"{0:-}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:-}\", -42), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:-}\", 42), \"42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:-}\"), 42u), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:-}\", 42l), \"42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:-}\"), 42ul), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:-}\", 42ll), \"42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:-}\"), 42ull), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:-}\", 42.0), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:-}\", 42.0l), \"42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:-}\"), 'c'), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:-}\"), \"abc\"), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0:-}\"), reinterpret_cast<void*>(0x42)),\n      format_error, \"invalid format specifier\");\n}\n\nTEST(format_test, space_sign) {\n  EXPECT_EQ(fmt::format(\"{0: }\", 42), \" 42\");\n  EXPECT_EQ(fmt::format(\"{0: }\", -42), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0: }\", 42), \" 42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0: }\"), 42u), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0: }\", 42l), \" 42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0: }\"), 42ul), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0: }\", 42ll), \" 42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0: }\"), 42ull), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0: }\", 42.0), \" 42\");\n  EXPECT_EQ(fmt::format(\"{0: }\", 42.0l), \" 42\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0: }\"), 'c'), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0: }\"), \"abc\"), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0: }\"), reinterpret_cast<void*>(0x42)),\n      format_error, \"invalid format specifier\");\n}\n\nTEST(format_test, hash_flag) {\n  EXPECT_EQ(fmt::format(\"{0:#}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:#}\", -42), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:#b}\", 42), \"0b101010\");\n  EXPECT_EQ(fmt::format(\"{0:#B}\", 42), \"0B101010\");\n  EXPECT_EQ(fmt::format(\"{0:#b}\", -42), \"-0b101010\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", 0x42), \"0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#X}\", 0x42), \"0X42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", -0x42), \"-0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 0), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 042), \"042\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", -042), \"-042\");\n  EXPECT_EQ(fmt::format(\"{0:#}\", 42u), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", 0x42u), \"0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 042u), \"042\");\n\n  EXPECT_EQ(fmt::format(\"{0:#}\", -42l), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", 0x42l), \"0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", -0x42l), \"-0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 042l), \"042\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", -042l), \"-042\");\n  EXPECT_EQ(fmt::format(\"{0:#}\", 42ul), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", 0x42ul), \"0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 042ul), \"042\");\n\n  EXPECT_EQ(fmt::format(\"{0:#}\", -42ll), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", 0x42ll), \"0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", -0x42ll), \"-0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 042ll), \"042\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", -042ll), \"-042\");\n  EXPECT_EQ(fmt::format(\"{0:#}\", 42ull), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:#x}\", 0x42ull), \"0x42\");\n  EXPECT_EQ(fmt::format(\"{0:#o}\", 042ull), \"042\");\n\n  EXPECT_EQ(fmt::format(\"{0:#}\", -42.0), \"-42.\");\n  EXPECT_EQ(fmt::format(\"{0:#}\", -42.0l), \"-42.\");\n  EXPECT_EQ(fmt::format(\"{:#.0e}\", 42.0), \"4.e+01\");\n  EXPECT_EQ(fmt::format(\"{:#.0f}\", 0.01), \"0.\");\n  EXPECT_EQ(fmt::format(\"{:#.2g}\", 0.5), \"0.50\");\n  EXPECT_EQ(fmt::format(\"{:#.0f}\", 0.5), \"0.\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:#\"), 'c'), format_error,\n                   \"invalid format specifier for char\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:#}\"), 'c'), format_error,\n                   \"invalid format specifier for char\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:#}\"), \"abc\"), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0:#}\"), reinterpret_cast<void*>(0x42)),\n      format_error, \"invalid format specifier\");\n}\n\nTEST(format_test, zero_flag) {\n  EXPECT_EQ(fmt::format(\"{0:0}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:05}\", -42), \"-0042\");\n  EXPECT_EQ(fmt::format(\"{0:05}\", 42u), \"00042\");\n  EXPECT_EQ(fmt::format(\"{0:05}\", -42l), \"-0042\");\n  EXPECT_EQ(fmt::format(\"{0:05}\", 42ul), \"00042\");\n  EXPECT_EQ(fmt::format(\"{0:05}\", -42ll), \"-0042\");\n  EXPECT_EQ(fmt::format(\"{0:05}\", 42ull), \"00042\");\n  EXPECT_EQ(fmt::format(\"{0:07}\", -42.0), \"-000042\");\n  EXPECT_EQ(fmt::format(\"{0:07}\", -42.0l), \"-000042\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:0\"), 'c'), format_error,\n                   \"invalid format specifier for char\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:05}\"), 'c'), format_error,\n                   \"invalid format specifier for char\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:05}\"), \"abc\"), format_error,\n                   \"format specifier requires numeric argument\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0:05}\"), reinterpret_cast<void*>(0x42)),\n      format_error, \"format specifier requires numeric argument\");\n}\n\nTEST(format_test, zero_flag_and_align) {\n  // If the 0 character and an align option both appear, the 0 character is\n  // ignored.\n  EXPECT_EQ(fmt::format(\"{:<05}\", 42), \"42   \");\n  EXPECT_EQ(fmt::format(\"{:<05}\", -42), \"-42  \");\n  EXPECT_EQ(fmt::format(\"{:^05}\", 42), \" 42  \");\n  EXPECT_EQ(fmt::format(\"{:^05}\", -42), \" -42 \");\n  EXPECT_EQ(fmt::format(\"{:>05}\", 42), \"   42\");\n  EXPECT_EQ(fmt::format(\"{:>05}\", -42), \"  -42\");\n}\n\nTEST(format_test, width) {\n  auto int_maxer = std::to_string(INT_MAX + 1u);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:\" + int_maxer), 0),\n                   format_error, \"number is too big\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:\" + int_maxer + \"}\"), 0),\n                   format_error, \"number is too big\");\n\n  EXPECT_EQ(fmt::format(\"{:4}\", -42), \" -42\");\n  EXPECT_EQ(fmt::format(\"{:5}\", 42u), \"   42\");\n  EXPECT_EQ(fmt::format(\"{:6}\", -42l), \"   -42\");\n  EXPECT_EQ(fmt::format(\"{:7}\", 42ul), \"     42\");\n  EXPECT_EQ(fmt::format(\"{:6}\", -42ll), \"   -42\");\n  EXPECT_EQ(fmt::format(\"{:7}\", 42ull), \"     42\");\n  EXPECT_EQ(fmt::format(\"{:8}\", -1.23), \"   -1.23\");\n  EXPECT_EQ(fmt::format(\"{:9}\", -1.23l), \"    -1.23\");\n  EXPECT_EQ(fmt::format(\"{:10}\", reinterpret_cast<void*>(0xcafe)),\n            \"    0xcafe\");\n  EXPECT_EQ(fmt::format(\"{:11}\", 'x'), \"x          \");\n  EXPECT_EQ(fmt::format(\"{:12}\", \"str\"), \"str         \");\n  EXPECT_EQ(fmt::format(\"{:*^5}\", \"🤡\"), \"*🤡**\");\n  EXPECT_EQ(fmt::format(\"{:*^6}\", \"🤡\"), \"**🤡**\");\n  EXPECT_EQ(fmt::format(\"{:*^8}\", \"你好\"), \"**你好**\");\n  EXPECT_EQ(fmt::format(\"{:#6}\", 42.0), \"   42.\");\n  EXPECT_EQ(fmt::format(\"{:6c}\", static_cast<int>('x')), \"x     \");\n  EXPECT_EQ(fmt::format(\"{:>06.0f}\", 0.00884311), \"     0\");\n}\n\nTEST(format_test, debug_presentation) {\n  EXPECT_EQ(fmt::format(\"{:?}\", \"\"), R\"(\"\")\");\n\n  EXPECT_EQ(fmt::format(\"{:*<5.0?}\", \"\\n\"), R\"(*****)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.1?}\", \"\\n\"), R\"(\"****)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.2?}\", \"\\n\"), R\"(\"\\***)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.3?}\", \"\\n\"), R\"(\"\\n**)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.4?}\", \"\\n\"), R\"(\"\\n\"*)\");\n\n  EXPECT_EQ(fmt::format(\"{:*<5.1?}\", \"Σ\"), R\"(\"****)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.2?}\", \"Σ\"), R\"(\"Σ***)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.3?}\", \"Σ\"), R\"(\"Σ\"**)\");\n\n  EXPECT_EQ(fmt::format(\"{:*<5.1?}\", \"笑\"), R\"(\"****)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.2?}\", \"笑\"), R\"(\"****)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.3?}\", \"笑\"), R\"(\"笑**)\");\n  EXPECT_EQ(fmt::format(\"{:*<5.4?}\", \"笑\"), R\"(\"笑\"*)\");\n\n  EXPECT_EQ(fmt::format(\"{:*<8?}\", \"туда\"), R\"(\"туда\"**)\");\n  EXPECT_EQ(fmt::format(\"{:*>8?}\", \"сюда\"), R\"(**\"сюда\")\");\n  EXPECT_EQ(fmt::format(\"{:*^8?}\", \"中心\"), R\"(*\"中心\"*)\");\n\n  EXPECT_EQ(fmt::format(\"{:*^14?}\", \"A\\t👈🤯ы猫\"), R\"(*\"A\\t👈🤯ы猫\"*)\");\n}\n\nauto bad_dynamic_spec_msg = FMT_BUILTIN_TYPES\n                                ? \"width/precision is out of range\"\n                                : \"width/precision is not integer\";\n\nTEST(format_test, runtime_width) {\n  auto int_maxer = std::to_string(INT_MAX + 1u);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{\" + int_maxer), 0),\n                   format_error, \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{\" + int_maxer + \"}\"), 0),\n                   format_error, \"argument not found\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{\" + int_maxer + \"}}\"), 0),\n                   format_error, \"argument not found\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{\"), 0), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{}\"), 0), format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{?}}\"), 0), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0), format_error,\n                   \"argument not found\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{0:}}\"), 0), format_error,\n                   \"invalid format string\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, -1), format_error,\n                   \"width/precision is out of range\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, (INT_MAX + 1u)),\n                   format_error, bad_dynamic_spec_msg);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, -1l), format_error,\n                   bad_dynamic_spec_msg);\n  if (sizeof(long) > sizeof(int)) {\n    long value = INT_MAX;\n    EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, (value + 1)),\n                     format_error, bad_dynamic_spec_msg);\n  }\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, (INT_MAX + 1ul)),\n                   format_error, bad_dynamic_spec_msg);\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, '0'), format_error,\n                   \"width/precision is not integer\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:{1}}\"), 0, 0.0), format_error,\n                   \"width/precision is not integer\");\n\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", -42, 4), \" -42\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", 42u, 5), \"   42\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", -42l, 6), \"   -42\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", 42ul, 7), \"     42\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", -42ll, 6), \"   -42\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", 42ull, 7), \"     42\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", -1.23, 8), \"   -1.23\");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", -1.23l, 9), \"    -1.23\");\n  EXPECT_EQ(\"    0xcafe\",\n            fmt::format(\"{0:{1}}\", reinterpret_cast<void*>(0xcafe), 10));\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", 'x', 11), \"x          \");\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", \"str\", 12), \"str         \");\n  EXPECT_EQ(fmt::format(\"{:{}}\", 42, short(4)), \"  42\");\n}\n\nTEST(format_test, exponent_range) {\n  for (int e = -1074; e <= 1023; ++e) (void)fmt::format(\"{}\", std::ldexp(1, e));\n}\n\nTEST(format_test, precision) {\n  char format_str[buffer_size];\n  safe_sprintf(format_str, \"{0:.%u\", UINT_MAX);\n  increment(format_str + 4);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"number is too big\");\n  size_t size = std::strlen(format_str);\n  format_str[size] = '}';\n  format_str[size + 1] = 0;\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"number is too big\");\n\n  safe_sprintf(format_str, \"{0:.%u\", INT_MAX + 1u);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"number is too big\");\n  safe_sprintf(format_str, \"{0:.%u}\", INT_MAX + 1u);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"number is too big\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.\"), 0.0), format_error,\n                   \"invalid precision\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.}\"), 0.0), format_error,\n                   \"invalid format string\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2\"), 0), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2}\"), 42), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2f}\"), 42), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2}\"), 42u), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2f}\"), 42u), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2}\"), 42l), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2f}\"), 42l), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2}\"), 42ul), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2f}\"), 42ul), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2}\"), 42ll), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2f}\"), 42ll), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2}\"), 42ull), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.2f}\"), 42ull), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:3.0}\"), 'x'), format_error,\n                   \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:.2}\", 1.2345), \"1.2\");\n  EXPECT_EQ(fmt::format(\"{0:.2}\", 1.2345l), \"1.2\");\n  EXPECT_EQ(fmt::format(\"{:.2}\", 1.234e56), \"1.2e+56\");\n  EXPECT_EQ(fmt::format(\"{0:.3}\", 1.1), \"1.1\");\n  EXPECT_EQ(fmt::format(\"{:.0e}\", 1.0L), \"1e+00\");\n  EXPECT_EQ(fmt::format(\"{:9.1e}\", 0.0), \"  0.0e+00\");\n  EXPECT_EQ(fmt::format(\"{:.7f}\", 0.0000000000000071054273576010018587L),\n            \"0.0000000\");\n\n  EXPECT_EQ(\n      fmt::format(\"{:.494}\", 4.9406564584124654E-324),\n      \"4.9406564584124654417656879286822137236505980261432476442558568250067550\"\n      \"727020875186529983636163599237979656469544571773092665671035593979639877\"\n      \"479601078187812630071319031140452784581716784898210368871863605699873072\"\n      \"305000638740915356498438731247339727316961514003171538539807412623856559\"\n      \"117102665855668676818703956031062493194527159149245532930545654440112748\"\n      \"012970999954193198940908041656332452475714786901472678015935523861155013\"\n      \"480352649347201937902681071074917033322268447533357208324319361e-324\");\n  EXPECT_EQ(\n      fmt::format(\"{:.1074f}\", 1.1125369292536e-308),\n      \"0.0000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000111253692925360019747947051741965785554081512200979\"\n      \"355021686109411883779182127659725163430929750364498219730822952552570601\"\n      \"152163505899912777129583674906301179059298598412303893909188340988729019\"\n      \"014361467448914817838555156840459458527907308695109202499990850735085304\"\n      \"478476991912072201449236975063640913461919914396877093174125167509869762\"\n      \"482369631100360266123742648159508919592746619553246586039571522788247697\"\n      \"156360766271842991667238355464496455107749716934387136380536472531224398\"\n      \"559833794807213172371254492216255558078524900147957309382830827524104234\"\n      \"530961756787819847850302379672357738807808384667004752163416921762619527\"\n      \"462847642037420991432005657440259928195996762610375541867198059294212446\"\n      \"81962777939941034720757232455434770912461317493580281734466552734375\");\n\n  std::string outputs[] = {\n      \"-0X1.41FE3FFE71C9E000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000P+127\",\n      \"-0XA.0FF1FFF38E4F0000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000000000000000000000000\"\n      \"000000000000000000000000000000000000000000000000000P+124\"};\n  EXPECT_THAT(outputs,\n              testing::Contains(fmt::format(\"{:.838A}\", -2.14001164E+38)));\n\n  if (std::numeric_limits<long double>::digits == 64) {\n    auto ld = (std::numeric_limits<long double>::min)();\n    EXPECT_EQ(fmt::format(\"{:.0}\", ld), \"3e-4932\");\n    EXPECT_EQ(\n        fmt::format(\"{:0g}\", std::numeric_limits<long double>::denorm_min()),\n        \"3.6452e-4951\");\n  }\n\n  EXPECT_EQ(fmt::format(\"{:#.0f}\", 123.0), \"123.\");\n  EXPECT_EQ(fmt::format(\"{:.02f}\", 1.234), \"1.23\");\n  EXPECT_EQ(fmt::format(\"{:.1g}\", 0.001), \"0.001\");\n  EXPECT_EQ(fmt::format(\"{}\", 123456789.0f), \"1.2345679e+08\");\n  EXPECT_EQ(fmt::format(\"{}\", 1019666432.0f), \"1.0196664e+09\");\n  EXPECT_EQ(fmt::format(\"{:.0e}\", 9.5), \"1e+01\");\n  EXPECT_EQ(fmt::format(\"{:.1e}\", 1e-34), \"1.0e-34\");\n\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0:.2}\"), reinterpret_cast<void*>(0xcafe)),\n      format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"{0:.2f}\"), reinterpret_cast<void*>(0xcafe)),\n      format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(\"{:.2147483646f}\", -2.2121295195081227E+304),\n      format_error, \"number is too big\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:.f}\"), 42.0), format_error,\n                   \"invalid format string\");\n\n  EXPECT_EQ(fmt::format(\"{0:.2}\", \"str\"), \"st\");\n  EXPECT_EQ(fmt::format(\"{0:.5}\", \"вожыкі\"), \"вожык\");\n  EXPECT_EQ(fmt::format(\"{0:.6}\", \"123456\\xad\"), \"123456\");\n}\n\nTEST(format_test, large_precision) {\n  // Iterator used to abort the actual output.\n  struct throwing_iterator {\n    auto operator=(char) -> throwing_iterator& {\n      throw std::runtime_error(\"aborted\");\n      return *this;\n    }\n    auto operator*() -> throwing_iterator& { return *this; }\n    auto operator++() -> throwing_iterator& { return *this; }\n    auto operator++(int) -> throwing_iterator { return *this; }\n  };\n  auto it = throwing_iterator();\n\n  EXPECT_THROW_MSG(fmt::format_to(it, fmt::runtime(\"{:#.{}}\"), 1.0,\n                                  fmt::detail::max_value<int>()),\n                   std::runtime_error, \"aborted\");\n\n  EXPECT_THROW_MSG(fmt::format_to(it, fmt::runtime(\"{:#.{}e}\"), 1.0,\n                                  fmt::detail::max_value<int>() - 1),\n                   std::runtime_error, \"aborted\");\n\n  EXPECT_THROW_MSG((void)fmt::format(fmt::runtime(\"{:.{}e}\"), 42.0,\n                                     fmt::detail::max_value<int>()),\n                   format_error, \"number is too big\");\n}\n\nTEST(format_test, utf8_precision) {\n  auto result = fmt::format(\"{:.4}\", \"caf\\u00e9s\");  // cafés\n  EXPECT_EQ(result, \"caf\\u00e9\");\n}\n\nTEST(format_test, runtime_precision) {\n  char format_str[buffer_size];\n  safe_sprintf(format_str, \"{0:.{%u\", UINT_MAX);\n  increment(format_str + 5);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"invalid format string\");\n  size_t size = std::strlen(format_str);\n  format_str[size] = '}';\n  format_str[size + 1] = 0;\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"argument not found\");\n  format_str[size + 1] = '}';\n  format_str[size + 2] = 0;\n  EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), 0.0), format_error,\n                   \"argument not found\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{\"), 0.0), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{}\"), 0.0), format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{?}}\"), 0.0), format_error,\n                   \"invalid format string\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}\"), 0, 0), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0), format_error,\n                   \"argument not found\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{0:}}\"), 0.0), format_error,\n                   \"invalid format string\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, -1),\n                   format_error, \"width/precision is out of range\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, (INT_MAX + 1u)),\n                   format_error, bad_dynamic_spec_msg);\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, -1l),\n                   format_error, bad_dynamic_spec_msg);\n  if (sizeof(long) > sizeof(int)) {\n    long value = INT_MAX;\n    EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, (value + 1)),\n                     format_error, bad_dynamic_spec_msg);\n  }\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, (INT_MAX + 1ul)),\n                   format_error, bad_dynamic_spec_msg);\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, '0'),\n                   format_error, \"width/precision is not integer\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 0.0, 0.0),\n                   format_error, \"width/precision is not integer\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 42, 2), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"), 42, 2), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 42u, 2), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"), 42u, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 42l, 2), format_error,\n                   \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"), 42l, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 42ul, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"), 42ul, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 42ll, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"), 42ll, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"), 42ull, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"), 42ull, 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:3.{1}}\"), 'x', 0),\n                   format_error, \"invalid format specifier\");\n  EXPECT_EQ(fmt::format(\"{0:.{1}}\", 1.2345, 2), \"1.2\");\n  EXPECT_EQ(fmt::format(\"{1:.{0}}\", 2, 1.2345l), \"1.2\");\n\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}}\"),\n                                     reinterpret_cast<void*>(0xcafe), 2),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:.{1}f}\"),\n                                     reinterpret_cast<void*>(0xcafe), 2),\n                   format_error, \"invalid format specifier\");\n\n  EXPECT_EQ(fmt::format(\"{0:.{1}}\", \"str\", 2), \"st\");\n}\n\nTEST(format_test, format_bool) {\n  EXPECT_EQ(fmt::format(\"{}\", true), \"true\");\n  EXPECT_EQ(fmt::format(\"{}\", false), \"false\");\n  EXPECT_EQ(fmt::format(\"{:d}\", true), \"1\");\n  EXPECT_EQ(fmt::format(\"{:5}\", true), \"true \");\n  EXPECT_EQ(fmt::format(\"{:s}\", true), \"true\");\n  EXPECT_EQ(fmt::format(\"{:s}\", false), \"false\");\n  EXPECT_EQ(fmt::format(\"{:6s}\", false), \"false \");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:c}\"), false), format_error,\n                   \"invalid format specifier\");\n}\n\nTEST(format_test, format_short) {\n  short s = 42;\n  EXPECT_EQ(fmt::format(\"{0:d}\", s), \"42\");\n  unsigned short us = 42;\n  EXPECT_EQ(fmt::format(\"{0:d}\", us), \"42\");\n}\n\ntemplate <typename T>\nvoid check_unknown_types(const T& value, const char* types, const char*) {\n  char format_str[buffer_size];\n  const char* special = \".0123456789L?}\";\n  for (int i = CHAR_MIN; i <= CHAR_MAX; ++i) {\n    char c = static_cast<char>(i);\n    if (std::strchr(types, c) || std::strchr(special, c) || !c) continue;\n    safe_sprintf(format_str, \"{0:10%c}\", c);\n    const char* message = \"invalid format specifier\";\n    EXPECT_THROW_MSG((void)fmt::format(runtime(format_str), value),\n                     format_error, message)\n        << format_str << \" \" << message;\n  }\n}\n\nTEST(format_test, format_int) {\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:v\"), 42), format_error,\n                   \"invalid format specifier\");\n  check_unknown_types(42, \"bBdoxXnLc\", \"integer\");\n  EXPECT_EQ(fmt::format(\"{:c}\", static_cast<int>('x')), \"x\");\n}\n\nTEST(format_test, format_bin) {\n  EXPECT_EQ(fmt::format(\"{0:b}\", 0), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:b}\", 42), \"101010\");\n  EXPECT_EQ(fmt::format(\"{0:b}\", 42u), \"101010\");\n  EXPECT_EQ(fmt::format(\"{0:b}\", -42), \"-101010\");\n  EXPECT_EQ(fmt::format(\"{0:b}\", 12345), \"11000000111001\");\n  EXPECT_EQ(fmt::format(\"{0:b}\", 0x12345678), \"10010001101000101011001111000\");\n  EXPECT_EQ(\"10010000101010111100110111101111\",\n            fmt::format(\"{0:b}\", 0x90ABCDEF));\n  EXPECT_EQ(\"11111111111111111111111111111111\",\n            fmt::format(\"{0:b}\", max_value<uint32_t>()));\n}\n\n#if FMT_USE_INT128\nconstexpr auto int128_max = static_cast<__int128_t>(\n    (static_cast<__uint128_t>(1) << ((__SIZEOF_INT128__ * CHAR_BIT) - 1)) - 1);\nconstexpr auto int128_min = -int128_max - 1;\n\nconstexpr auto uint128_max = ~static_cast<__uint128_t>(0);\n#endif\n\nTEST(format_test, format_dec) {\n  EXPECT_EQ(fmt::format(\"{0}\", 0), \"0\");\n  EXPECT_EQ(fmt::format(\"{0}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"{:}>\", 42), \"42>\");\n  EXPECT_EQ(fmt::format(\"{0:d}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"{0}\", 42u), \"42\");\n  EXPECT_EQ(fmt::format(\"{0}\", -42), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0}\", 12345), \"12345\");\n  EXPECT_EQ(fmt::format(\"{0}\", 67890), \"67890\");\n#if FMT_USE_INT128\n  EXPECT_EQ(fmt::format(\"{0}\", static_cast<__int128_t>(0)), \"0\");\n  EXPECT_EQ(fmt::format(\"{0}\", static_cast<__uint128_t>(0)), \"0\");\n  EXPECT_EQ(\"9223372036854775808\",\n            fmt::format(\"{0}\", static_cast<__int128_t>(INT64_MAX) + 1));\n  EXPECT_EQ(\"-9223372036854775809\",\n            fmt::format(\"{0}\", static_cast<__int128_t>(INT64_MIN) - 1));\n  EXPECT_EQ(\"18446744073709551616\",\n            fmt::format(\"{0}\", static_cast<__int128_t>(UINT64_MAX) + 1));\n  EXPECT_EQ(\"170141183460469231731687303715884105727\",\n            fmt::format(\"{0}\", int128_max));\n  EXPECT_EQ(\"-170141183460469231731687303715884105728\",\n            fmt::format(\"{0}\", int128_min));\n  EXPECT_EQ(\"340282366920938463463374607431768211455\",\n            fmt::format(\"{0}\", uint128_max));\n#endif\n\n  char buffer[buffer_size];\n  safe_sprintf(buffer, \"%d\", INT_MIN);\n  EXPECT_EQ(buffer, fmt::format(\"{0}\", INT_MIN));\n  safe_sprintf(buffer, \"%d\", INT_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0}\", INT_MAX));\n  safe_sprintf(buffer, \"%u\", UINT_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0}\", UINT_MAX));\n  safe_sprintf(buffer, \"%ld\", 0 - static_cast<unsigned long>(LONG_MIN));\n  EXPECT_EQ(buffer, fmt::format(\"{0}\", LONG_MIN));\n  safe_sprintf(buffer, \"%ld\", LONG_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0}\", LONG_MAX));\n  safe_sprintf(buffer, \"%lu\", ULONG_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0}\", ULONG_MAX));\n}\n\nTEST(format_test, format_hex) {\n  EXPECT_EQ(fmt::format(\"{0:x}\", 0), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:x}\", 0x42), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:x}\", 0x42u), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:x}\", -0x42), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:x}\", 0x12345678), \"12345678\");\n  EXPECT_EQ(fmt::format(\"{0:x}\", 0x90abcdef), \"90abcdef\");\n  EXPECT_EQ(fmt::format(\"{0:X}\", 0x12345678), \"12345678\");\n  EXPECT_EQ(fmt::format(\"{0:X}\", 0x90ABCDEF), \"90ABCDEF\");\n#if FMT_USE_INT128\n  EXPECT_EQ(fmt::format(\"{0:x}\", static_cast<__int128_t>(0)), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:x}\", static_cast<__uint128_t>(0)), \"0\");\n  EXPECT_EQ(\"8000000000000000\",\n            fmt::format(\"{0:x}\", static_cast<__int128_t>(INT64_MAX) + 1));\n  EXPECT_EQ(\"-8000000000000001\",\n            fmt::format(\"{0:x}\", static_cast<__int128_t>(INT64_MIN) - 1));\n  EXPECT_EQ(\"10000000000000000\",\n            fmt::format(\"{0:x}\", static_cast<__int128_t>(UINT64_MAX) + 1));\n  EXPECT_EQ(\"7fffffffffffffffffffffffffffffff\",\n            fmt::format(\"{0:x}\", int128_max));\n  EXPECT_EQ(\"-80000000000000000000000000000000\",\n            fmt::format(\"{0:x}\", int128_min));\n  EXPECT_EQ(\"ffffffffffffffffffffffffffffffff\",\n            fmt::format(\"{0:x}\", uint128_max));\n#endif\n\n  char buffer[buffer_size];\n  safe_sprintf(buffer, \"-%x\", 0 - static_cast<unsigned>(INT_MIN));\n  EXPECT_EQ(buffer, fmt::format(\"{0:x}\", INT_MIN));\n  safe_sprintf(buffer, \"%x\", INT_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:x}\", INT_MAX));\n  safe_sprintf(buffer, \"%x\", UINT_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:x}\", UINT_MAX));\n  safe_sprintf(buffer, \"-%lx\", 0 - static_cast<unsigned long>(LONG_MIN));\n  EXPECT_EQ(buffer, fmt::format(\"{0:x}\", LONG_MIN));\n  safe_sprintf(buffer, \"%lx\", LONG_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:x}\", LONG_MAX));\n  safe_sprintf(buffer, \"%lx\", ULONG_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:x}\", ULONG_MAX));\n}\n\nTEST(format_test, format_oct) {\n  EXPECT_EQ(fmt::format(\"{0:o}\", 0), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:o}\", 042), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:o}\", 042u), \"42\");\n  EXPECT_EQ(fmt::format(\"{0:o}\", -042), \"-42\");\n  EXPECT_EQ(fmt::format(\"{0:o}\", 012345670), \"12345670\");\n#if FMT_USE_INT128\n  EXPECT_EQ(fmt::format(\"{0:o}\", static_cast<__int128_t>(0)), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:o}\", static_cast<__uint128_t>(0)), \"0\");\n  EXPECT_EQ(\"1000000000000000000000\",\n            fmt::format(\"{0:o}\", static_cast<__int128_t>(INT64_MAX) + 1));\n  EXPECT_EQ(\"-1000000000000000000001\",\n            fmt::format(\"{0:o}\", static_cast<__int128_t>(INT64_MIN) - 1));\n  EXPECT_EQ(\"2000000000000000000000\",\n            fmt::format(\"{0:o}\", static_cast<__int128_t>(UINT64_MAX) + 1));\n  EXPECT_EQ(\"1777777777777777777777777777777777777777777\",\n            fmt::format(\"{0:o}\", int128_max));\n  EXPECT_EQ(\"-2000000000000000000000000000000000000000000\",\n            fmt::format(\"{0:o}\", int128_min));\n  EXPECT_EQ(\"3777777777777777777777777777777777777777777\",\n            fmt::format(\"{0:o}\", uint128_max));\n#endif\n\n  char buffer[buffer_size];\n  safe_sprintf(buffer, \"-%o\", 0 - static_cast<unsigned>(INT_MIN));\n  EXPECT_EQ(buffer, fmt::format(\"{0:o}\", INT_MIN));\n  safe_sprintf(buffer, \"%o\", INT_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:o}\", INT_MAX));\n  safe_sprintf(buffer, \"%o\", UINT_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:o}\", UINT_MAX));\n  safe_sprintf(buffer, \"-%lo\", 0 - static_cast<unsigned long>(LONG_MIN));\n  EXPECT_EQ(buffer, fmt::format(\"{0:o}\", LONG_MIN));\n  safe_sprintf(buffer, \"%lo\", LONG_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:o}\", LONG_MAX));\n  safe_sprintf(buffer, \"%lo\", ULONG_MAX);\n  EXPECT_EQ(buffer, fmt::format(\"{0:o}\", ULONG_MAX));\n}\n\nTEST(format_test, format_int_locale) {\n  EXPECT_EQ(fmt::format(\"{:L}\", 1234), \"1234\");\n}\n\nTEST(format_test, format_float) {\n  EXPECT_EQ(fmt::format(\"{}\", 0.0f), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:f}\", 392.5f), \"392.500000\");\n}\n\nTEST(format_test, format_double) {\n  EXPECT_EQ(fmt::format(\"{}\", 0.0), \"0\");\n  check_unknown_types(1.2, \"eEfFgGaAnL%\", \"double\");\n  EXPECT_EQ(fmt::format(\"{:}\", 0.0), \"0\");\n  EXPECT_EQ(fmt::format(\"{:f}\", 0.0), \"0.000000\");\n  EXPECT_EQ(fmt::format(\"{:g}\", 0.0), \"0\");\n  EXPECT_EQ(fmt::format(\"{:}\", 392.65), \"392.65\");\n  EXPECT_EQ(fmt::format(\"{:g}\", 392.65), \"392.65\");\n  EXPECT_EQ(fmt::format(\"{:G}\", 392.65), \"392.65\");\n  EXPECT_EQ(fmt::format(\"{:g}\", 4.9014e6), \"4.9014e+06\");\n  EXPECT_EQ(fmt::format(\"{:f}\", 392.65), \"392.650000\");\n  EXPECT_EQ(fmt::format(\"{:F}\", 392.65), \"392.650000\");\n  EXPECT_EQ(fmt::format(\"{:L}\", 42.0), \"42\");\n  EXPECT_EQ(fmt::format(\"{:24a}\", 4.2f), \"           0x1.0cccccp+2\");\n  EXPECT_EQ(fmt::format(\"{:24a}\", 4.2), \"    0x1.0cccccccccccdp+2\");\n  EXPECT_EQ(fmt::format(\"{:<24a}\", 4.2), \"0x1.0cccccccccccdp+2    \");\n  EXPECT_EQ(fmt::format(\"{0:e}\", 392.65), \"3.926500e+02\");\n  EXPECT_EQ(fmt::format(\"{0:E}\", 392.65), \"3.926500E+02\");\n  EXPECT_EQ(fmt::format(\"{0:+010.4g}\", 392.65), \"+0000392.6\");\n\n#if FMT_CPLUSPLUS >= 201703L\n  double xd = 0x1.ffffffffffp+2;\n  EXPECT_EQ(fmt::format(\"{:.10a}\", xd), \"0x1.ffffffffffp+2\");\n  EXPECT_EQ(fmt::format(\"{:.9a}\", xd), \"0x2.000000000p+2\");\n\n  if (std::numeric_limits<long double>::digits == 64) {\n    auto ld = 0xf.ffffffffffp-3l;\n    EXPECT_EQ(fmt::format(\"{:a}\", ld), \"0xf.ffffffffffp-3\");\n    EXPECT_EQ(fmt::format(\"{:.10a}\", ld), \"0xf.ffffffffffp-3\");\n    EXPECT_EQ(fmt::format(\"{:.9a}\", ld), \"0x1.000000000p+1\");\n  }\n#endif\n\n  if (std::numeric_limits<double>::is_iec559) {\n    double d = (std::numeric_limits<double>::min)();\n    EXPECT_EQ(fmt::format(\"{:a}\", d), \"0x1p-1022\");\n    EXPECT_EQ(fmt::format(\"{:#a}\", d), \"0x1.p-1022\");\n\n    d = (std::numeric_limits<double>::max)();\n    EXPECT_EQ(fmt::format(\"{:a}\", d), \"0x1.fffffffffffffp+1023\");\n\n    d = std::numeric_limits<double>::denorm_min();\n    EXPECT_EQ(fmt::format(\"{:a}\", d), \"0x0.0000000000001p-1022\");\n  }\n\n  if (std::numeric_limits<long double>::digits == 64) {\n    auto ld = (std::numeric_limits<long double>::min)();\n    EXPECT_EQ(fmt::format(\"{:a}\", ld), \"0x8p-16385\");\n\n    ld = (std::numeric_limits<long double>::max)();\n    EXPECT_EQ(fmt::format(\"{:a}\", ld), \"0xf.fffffffffffffffp+16380\");\n\n    ld = std::numeric_limits<long double>::denorm_min();\n    EXPECT_EQ(fmt::format(\"{:a}\", ld), \"0x0.000000000000001p-16382\");\n  }\n\n  EXPECT_EQ(fmt::format(\"{:.10a}\", 4.2), \"0x1.0ccccccccdp+2\");\n\n  EXPECT_EQ(fmt::format(\"{:a}\", -42.0), \"-0x1.5p+5\");\n  EXPECT_EQ(fmt::format(\"{:A}\", -42.0), \"-0X1.5P+5\");\n\n  EXPECT_EQ(fmt::format(\"{:f}\", 9223372036854775807.0),\n            \"9223372036854775808.000000\");\n}\n\nTEST(format_test, precision_rounding) {\n  EXPECT_EQ(fmt::format(\"{:.0f}\", 0.0), \"0\");\n  EXPECT_EQ(fmt::format(\"{:.0f}\", 0.01), \"0\");\n  EXPECT_EQ(fmt::format(\"{:.0f}\", 0.1), \"0\");\n  EXPECT_EQ(fmt::format(\"{:.3f}\", 0.00049), \"0.000\");\n  EXPECT_EQ(fmt::format(\"{:.3f}\", 0.0005), \"0.001\");\n  EXPECT_EQ(fmt::format(\"{:.3f}\", 0.00149), \"0.001\");\n  EXPECT_EQ(fmt::format(\"{:.3f}\", 0.0015), \"0.002\");\n  EXPECT_EQ(fmt::format(\"{:.3f}\", 0.9999), \"1.000\");\n  EXPECT_EQ(fmt::format(\"{:.3}\", 0.00123), \"0.00123\");\n  EXPECT_EQ(fmt::format(\"{:.16g}\", 0.1), \"0.1\");\n  EXPECT_EQ(fmt::format(\"{:.0}\", 1.0), \"1\");\n  EXPECT_EQ(\"225.51575035152063720\",\n            fmt::format(\"{:.17f}\", 225.51575035152064));\n  EXPECT_EQ(fmt::format(\"{:.1f}\", -761519619559038.2), \"-761519619559038.2\");\n  EXPECT_EQ(\"1.9156918820264798e-56\",\n            fmt::format(\"{}\", 1.9156918820264798e-56));\n  EXPECT_EQ(fmt::format(\"{:.4f}\", 7.2809479766055470e-15), \"0.0000\");\n}\n\nTEST(format_test, prettify_float) {\n  EXPECT_EQ(fmt::format(\"{}\", 1e-4), \"0.0001\");\n  EXPECT_EQ(fmt::format(\"{}\", 1e-5), \"1e-05\");\n  EXPECT_EQ(fmt::format(\"{}\", 1e15), \"1000000000000000\");\n  EXPECT_EQ(fmt::format(\"{}\", 1e16), \"1e+16\");\n  EXPECT_EQ(fmt::format(\"{}\", 9.999e-5), \"9.999e-05\");\n  EXPECT_EQ(fmt::format(\"{}\", 1e10), \"10000000000\");\n  EXPECT_EQ(fmt::format(\"{}\", 1e11), \"100000000000\");\n  EXPECT_EQ(fmt::format(\"{}\", 1234e7), \"12340000000\");\n  EXPECT_EQ(fmt::format(\"{}\", 1234e-2), \"12.34\");\n  EXPECT_EQ(fmt::format(\"{}\", 1234e-6), \"0.001234\");\n  EXPECT_EQ(fmt::format(\"{}\", 0.1f), \"0.1\");\n  EXPECT_EQ(fmt::format(\"{}\", 1.35631564e-19f), \"1.3563156e-19\");\n}\n\nTEST(format_test, format_nan) {\n  double nan = std::numeric_limits<double>::quiet_NaN();\n  EXPECT_EQ(fmt::format(\"{}\", nan), \"nan\");\n  EXPECT_EQ(fmt::format(\"{:+}\", nan), \"+nan\");\n  EXPECT_EQ(fmt::format(\"{:+06}\", nan), \"  +nan\");\n  EXPECT_EQ(fmt::format(\"{:<+06}\", nan), \"+nan  \");\n  EXPECT_EQ(fmt::format(\"{:^+06}\", nan), \" +nan \");\n  EXPECT_EQ(fmt::format(\"{:>+06}\", nan), \"  +nan\");\n  if (std::signbit(-nan)) {\n    EXPECT_EQ(fmt::format(\"{}\", -nan), \"-nan\");\n    EXPECT_EQ(fmt::format(\"{:+06}\", -nan), \"  -nan\");\n  } else {\n    fmt::print(\"Warning: compiler doesn't handle negative NaN correctly\");\n  }\n  EXPECT_EQ(fmt::format(\"{: }\", nan), \" nan\");\n  EXPECT_EQ(fmt::format(\"{:F}\", nan), \"NAN\");\n  EXPECT_EQ(fmt::format(\"{:<7}\", nan), \"nan    \");\n  EXPECT_EQ(fmt::format(\"{:^7}\", nan), \"  nan  \");\n  EXPECT_EQ(fmt::format(\"{:>7}\", nan), \"    nan\");\n}\n\nTEST(format_test, format_infinity) {\n  double inf = std::numeric_limits<double>::infinity();\n  EXPECT_EQ(fmt::format(\"{}\", inf), \"inf\");\n  EXPECT_EQ(fmt::format(\"{:+}\", inf), \"+inf\");\n  EXPECT_EQ(fmt::format(\"{}\", -inf), \"-inf\");\n  EXPECT_EQ(fmt::format(\"{:+06}\", inf), \"  +inf\");\n  EXPECT_EQ(fmt::format(\"{:+06}\", -inf), \"  -inf\");\n  EXPECT_EQ(fmt::format(\"{:<+06}\", inf), \"+inf  \");\n  EXPECT_EQ(fmt::format(\"{:^+06}\", inf), \" +inf \");\n  EXPECT_EQ(fmt::format(\"{:>+06}\", inf), \"  +inf\");\n  EXPECT_EQ(fmt::format(\"{: }\", inf), \" inf\");\n  EXPECT_EQ(fmt::format(\"{:F}\", inf), \"INF\");\n  EXPECT_EQ(fmt::format(\"{:<7}\", inf), \"inf    \");\n  EXPECT_EQ(fmt::format(\"{:^7}\", inf), \"  inf  \");\n  EXPECT_EQ(fmt::format(\"{:>7}\", inf), \"    inf\");\n}\n\nTEST(format_test, format_long_double) {\n  EXPECT_EQ(fmt::format(\"{0:}\", 0.0l), \"0\");\n  EXPECT_EQ(fmt::format(\"{0:f}\", 0.0l), \"0.000000\");\n  EXPECT_EQ(fmt::format(\"{:.1f}\", 0.000000001l), \"0.0\");\n  EXPECT_EQ(fmt::format(\"{:.2f}\", 0.099l), \"0.10\");\n  EXPECT_EQ(fmt::format(\"{0:}\", 392.65l), \"392.65\");\n  EXPECT_EQ(fmt::format(\"{0:g}\", 392.65l), \"392.65\");\n  EXPECT_EQ(fmt::format(\"{0:G}\", 392.65l), \"392.65\");\n  EXPECT_EQ(fmt::format(\"{0:f}\", 392.65l), \"392.650000\");\n  EXPECT_EQ(fmt::format(\"{0:F}\", 392.65l), \"392.650000\");\n  char buffer[buffer_size];\n  safe_sprintf(buffer, \"%Le\", 392.65l);\n  EXPECT_EQ(buffer, fmt::format(\"{0:e}\", 392.65l));\n  EXPECT_EQ(fmt::format(\"{0:+010.4g}\", 392.64l), \"+0000392.6\");\n\n  auto ld = 3.31l;\n  if (fmt::detail::is_double_double<decltype(ld)>::value) {\n    safe_sprintf(buffer, \"%a\", static_cast<double>(ld));\n    EXPECT_EQ(buffer, fmt::format(\"{:a}\", ld));\n  } else if (std::numeric_limits<long double>::digits == 64) {\n    EXPECT_EQ(fmt::format(\"{:a}\", ld), \"0xd.3d70a3d70a3d70ap-2\");\n  }\n}\n\nTEST(format_test, format_char) {\n  const char types[] = \"cbBdoxX\";\n  check_unknown_types('a', types, \"char\");\n  EXPECT_EQ(fmt::format(\"{0}\", 'a'), \"a\");\n  EXPECT_EQ(fmt::format(\"{0:c}\", 'z'), \"z\");\n  int n = 'x';\n  for (const char* type = types + 1; *type; ++type) {\n    std::string format_str = fmt::format(\"{{:{}}}\", *type);\n    EXPECT_EQ(fmt::format(runtime(format_str), n),\n              fmt::format(runtime(format_str), 'x'))\n        << format_str;\n  }\n  EXPECT_EQ(fmt::format(\"{:02X}\", n), fmt::format(\"{:02X}\", 'x'));\n\n  EXPECT_EQ(fmt::format(\"{}\", '\\n'), \"\\n\");\n  EXPECT_EQ(fmt::format(\"{:?}\", '\\n'), \"'\\\\n'\");\n  EXPECT_EQ(fmt::format(\"{:x}\", '\\xff'), \"ff\");\n}\n\nTEST(format_test, format_volatile_char) {\n  volatile char c = 'x';\n  EXPECT_EQ(fmt::format(\"{}\", c), \"x\");\n}\n\nTEST(format_test, format_unsigned_char) {\n  EXPECT_EQ(fmt::format(\"{}\", static_cast<unsigned char>(42)), \"42\");\n  EXPECT_EQ(fmt::format(\"{}\", static_cast<uint8_t>(42)), \"42\");\n}\n\nTEST(format_test, format_cstring) {\n  check_unknown_types(\"test\", \"sp\", \"string\");\n  EXPECT_EQ(fmt::format(\"{0}\", \"test\"), \"test\");\n  EXPECT_EQ(fmt::format(\"{0:s}\", \"test\"), \"test\");\n  char nonconst[] = \"nonconst\";\n  EXPECT_EQ(fmt::format(\"{0}\", nonconst), \"nonconst\");\n  auto nullstr = static_cast<const char*>(nullptr);\n  EXPECT_THROW_MSG((void)fmt::format(\"{}\", nullstr), format_error,\n                   \"string pointer is null\");\n  EXPECT_THROW_MSG((void)fmt::format(\"{:s}\", nullstr), format_error,\n                   \"string pointer is null\");\n}\n\nvoid function_pointer_test(int, double, std::string) {}\n\nTEST(format_test, format_pointer) {\n  check_unknown_types(reinterpret_cast<void*>(0x1234), \"p\", \"pointer\");\n  EXPECT_EQ(fmt::format(\"{0}\", static_cast<void*>(nullptr)), \"0x0\");\n  EXPECT_EQ(fmt::format(\"{0}\", reinterpret_cast<void*>(0x1234)), \"0x1234\");\n  EXPECT_EQ(fmt::format(\"{0:p}\", reinterpret_cast<void*>(0x1234)), \"0x1234\");\n  // On CHERI (or other fat-pointer) systems, the size of a pointer is greater\n  // than the size an integer that can hold a virtual address.  There is no\n  // portable address-as-an-integer type (yet) in C++, so we use `size_t` as\n  // the closest equivalent for now.\n  EXPECT_EQ(\"0x\" + std::string(sizeof(size_t) * CHAR_BIT / 4, 'f'),\n            fmt::format(\"{0}\", reinterpret_cast<void*>(~uintptr_t())));\n  EXPECT_EQ(\"0x1234\",\n            fmt::format(\"{}\", fmt::ptr(reinterpret_cast<int*>(0x1234))));\n  EXPECT_EQ(fmt::format(\"{}\", fmt::detail::bit_cast<const void*>(\n                                  &function_pointer_test)),\n            fmt::format(\"{}\", fmt::ptr(function_pointer_test)));\n  EXPECT_EQ(fmt::format(\"{}\", nullptr), \"0x0\");\n}\n\nTEST(format_test, write_uintptr_fallback) {\n  // Test that formatting a pointer by converting it to uint128 works.\n  // This is needed to support systems without uintptr_t.\n  auto s = std::string();\n  fmt::detail::write_ptr<char>(std::back_inserter(s),\n                               fmt::detail::bit_cast<fmt::detail::uint128>(\n                                   reinterpret_cast<void*>(0xface)),\n                               nullptr);\n  EXPECT_EQ(s, \"0xface\");\n}\n\nenum class color { red, green, blue };\n\nnamespace test_ns {\nenum class color { red, green, blue };\nusing fmt::enums::format_as;\n}  // namespace test_ns\n\nTEST(format_test, format_enum_class) {\n  EXPECT_EQ(fmt::format(\"{}\", fmt::underlying(color::red)), \"0\");\n  EXPECT_EQ(fmt::format(\"{}\", test_ns::color::red), \"0\");\n}\n\nTEST(format_test, format_string) {\n  EXPECT_EQ(fmt::format(\"{0}\", std::string(\"test\")), \"test\");\n  EXPECT_EQ(fmt::format(\"{0}\", std::string(\"test\")), \"test\");\n  EXPECT_EQ(fmt::format(\"{:?}\", std::string(\"test\")), \"\\\"test\\\"\");\n  EXPECT_EQ(fmt::format(\"{:*^10?}\", std::string(\"test\")), \"**\\\"test\\\"**\");\n  EXPECT_EQ(fmt::format(\"{:?}\", std::string(\"\\test\")), \"\\\"\\\\test\\\"\");\n  EXPECT_THROW((void)fmt::format(fmt::runtime(\"{:x}\"), std::string(\"test\")),\n               fmt::format_error);\n}\n\nTEST(format_test, format_string_view) {\n  EXPECT_EQ(fmt::format(\"{}\", string_view(\"test\")), \"test\");\n  EXPECT_EQ(fmt::format(\"{:?}\", string_view(\"t\\nst\")), \"\\\"t\\\\nst\\\"\");\n  EXPECT_EQ(fmt::format(\"{}\", string_view()), \"\");\n}\n\n#ifdef FMT_USE_STRING_VIEW\nstruct string_viewable {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<string_viewable> : formatter<std::string_view> {\n  auto format(string_viewable, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<std::string_view>::format(\"foo\", ctx);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, format_std_string_view) {\n  EXPECT_EQ(fmt::format(\"{}\", std::string_view(\"test\")), \"test\");\n  EXPECT_EQ(fmt::format(\"{}\", string_viewable()), \"foo\");\n}\n\nstruct explicitly_convertible_to_std_string_view {\n  explicit operator std::string_view() const { return \"foo\"; }\n};\n\ntemplate <>\nstruct fmt::formatter<explicitly_convertible_to_std_string_view>\n    : formatter<std::string_view> {\n  auto format(explicitly_convertible_to_std_string_view v,\n              format_context& ctx) const -> decltype(ctx.out()) {\n    return fmt::format_to(ctx.out(), \"'{}'\", std::string_view(v));\n  }\n};\n\nTEST(format_test, format_explicitly_convertible_to_std_string_view) {\n  EXPECT_EQ(\"'foo'\",\n            fmt::format(\"{}\", explicitly_convertible_to_std_string_view()));\n}\n\nstruct convertible_to_std_string_view {\n  operator std::string_view() const noexcept { return \"Hi there\"; }\n};\nFMT_BEGIN_NAMESPACE\ntemplate <>\nclass formatter<convertible_to_std_string_view>\n    : public formatter<std::string_view> {};\nFMT_END_NAMESPACE\n\nTEST(format_test, format_implicitly_convertible_and_inherits_string_view) {\n  static_assert(fmt::is_formattable<convertible_to_std_string_view>{}, \"\");\n  EXPECT_EQ(\"Hi there\", fmt::format(\"{}\", convertible_to_std_string_view{}));\n}\n#endif\n\nclass Answer {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<date> {\n  template <typename ParseContext>\n  FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {\n    auto it = ctx.begin();\n    if (it != ctx.end() && *it == 'd') ++it;\n    return it;\n  }\n\n  auto format(const date& d, format_context& ctx) const -> decltype(ctx.out()) {\n    // Namespace-qualify to avoid ambiguity with std::format_to.\n    fmt::format_to(ctx.out(), \"{}-{}-{}\", d.year(), d.month(), d.day());\n    return ctx.out();\n  }\n};\n\ntemplate <> struct formatter<Answer> : formatter<int> {\n  template <typename FormatContext>\n  auto format(Answer, FormatContext& ctx) const -> decltype(ctx.out()) {\n    return formatter<int>::format(42, ctx);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, format_custom) {\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{:s}\"), date(2012, 12, 9)),\n                   format_error, \"unknown format specifier\");\n  EXPECT_EQ(fmt::format(\"{0}\", Answer()), \"42\");\n  EXPECT_EQ(fmt::format(\"{:04}\", Answer()), \"0042\");\n}\n\nTEST(format_test, format_to_custom) {\n  char buf[10] = {};\n  auto end = fmt::format_to(buf, \"{}\", Answer());\n  EXPECT_EQ(end, buf + 2);\n  EXPECT_STREQ(buf, \"42\");\n}\n\nTEST(format_test, format_string_from_speed_test) {\n  EXPECT_EQ(\"1.2340000000:0042:+3.13:str:0x3e8:X:%\",\n            fmt::format(\"{0:0.10f}:{1:04}:{2:+g}:{3}:{4}:{5}:%\", 1.234, 42,\n                        3.13, \"str\", reinterpret_cast<void*>(1000), 'X'));\n}\n\nTEST(format_test, format_examples) {\n  std::string message = fmt::format(\"The answer is {}\", 42);\n  EXPECT_EQ(\"The answer is 42\", message);\n\n  EXPECT_EQ(fmt::format(\"{}\", 42), \"42\");\n\n  memory_buffer out;\n  fmt::format_to(std::back_inserter(out), \"The answer is {}.\", 42);\n  EXPECT_EQ(\"The answer is 42.\", to_string(out));\n\n  EXPECT_THROW(\n      {\n        const char* filename = \"madeup\";\n        FILE* file = fopen(filename, \"r\");\n        if (!file)\n          throw fmt::system_error(errno, \"cannot open file '{}'\", filename);\n        fclose(file);\n      },\n      std::system_error);\n\n  EXPECT_EQ(\"First, thou shalt count to three\",\n            fmt::format(\"First, thou shalt count to {0}\", \"three\"));\n  EXPECT_EQ(fmt::format(\"Bring me a {}\", \"shrubbery\"), \"Bring me a shrubbery\");\n  EXPECT_EQ(fmt::format(\"From {} to {}\", 1, 3), \"From 1 to 3\");\n\n  char buffer[buffer_size];\n  safe_sprintf(buffer, \"%03.2f\", -1.2);\n  EXPECT_EQ(buffer, fmt::format(\"{:03.2f}\", -1.2));\n\n  EXPECT_EQ(fmt::format(\"{0}, {1}, {2}\", 'a', 'b', 'c'), \"a, b, c\");\n  EXPECT_EQ(fmt::format(\"{}, {}, {}\", 'a', 'b', 'c'), \"a, b, c\");\n  EXPECT_EQ(fmt::format(\"{2}, {1}, {0}\", 'a', 'b', 'c'), \"c, b, a\");\n  EXPECT_EQ(fmt::format(\"{0}{1}{0}\", \"abra\", \"cad\"), \"abracadabra\");\n\n  EXPECT_EQ(\"left aligned                  \",\n            fmt::format(\"{:<30}\", \"left aligned\"));\n  EXPECT_EQ(\"                 right aligned\",\n            fmt::format(\"{:>30}\", \"right aligned\"));\n  EXPECT_EQ(\"           centered           \",\n            fmt::format(\"{:^30}\", \"centered\"));\n  EXPECT_EQ(\"***********centered***********\",\n            fmt::format(\"{:*^30}\", \"centered\"));\n\n  EXPECT_EQ(fmt::format(\"{:+f}; {:+f}\", 3.14, -3.14), \"+3.140000; -3.140000\");\n  EXPECT_EQ(fmt::format(\"{: f}; {: f}\", 3.14, -3.14), \" 3.140000; -3.140000\");\n  EXPECT_EQ(fmt::format(\"{:-f}; {:-f}\", 3.14, -3.14), \"3.140000; -3.140000\");\n\n  EXPECT_EQ(\"int: 42;  hex: 2a;  oct: 52\",\n            fmt::format(\"int: {0:d};  hex: {0:x};  oct: {0:o}\", 42));\n  EXPECT_EQ(\"int: 42;  hex: 0x2a;  oct: 052\",\n            fmt::format(\"int: {0:d};  hex: {0:#x};  oct: {0:#o}\", 42));\n\n  EXPECT_EQ(fmt::format(\"The answer is {}\", 42), \"The answer is 42\");\n  EXPECT_THROW_MSG(\n      (void)fmt::format(runtime(\"The answer is {:d}\"), \"forty-two\"),\n      format_error, \"invalid format specifier\");\n\n  EXPECT_WRITE(\n      stdout, fmt::print(\"{}\", std::numeric_limits<double>::infinity()), \"inf\");\n}\n\nTEST(format_test, print) {\n  EXPECT_WRITE(stdout, fmt::print(\"Don't {}!\", \"panic\"), \"Don't panic!\");\n  EXPECT_WRITE(stderr, fmt::print(stderr, \"Don't {}!\", \"panic\"),\n               \"Don't panic!\");\n  EXPECT_WRITE(stdout, fmt::println(\"Don't {}!\", \"panic\"), \"Don't panic!\\n\");\n  EXPECT_WRITE(stderr, fmt::println(stderr, \"Don't {}!\", \"panic\"),\n               \"Don't panic!\\n\");\n}\n\nTEST(format_test, big_print) {\n  enum { count = 5000 };\n  auto big_print = []() {\n    for (int i = 0; i < count / 5; ++i) fmt::print(\"xxxxx\");\n  };\n  EXPECT_WRITE(stdout, big_print(), std::string(count, 'x'));\n}\n\nstruct deadlockable {\n  int value = 0;\n  mutable std::mutex mutex;\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<deadlockable> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  auto format(const deadlockable& d, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    std::lock_guard<std::mutex> lock(d.mutex);\n    return format_to(ctx.out(), \"{}\", d.value);\n  }\n};\n\ntemplate <> struct locking<deadlockable> : std::true_type {};\nFMT_END_NAMESPACE\n\nTEST(format_test, locking_formatter) {\n  auto f = fmt::buffered_file();\n  try {\n    f = fmt::buffered_file(\"/dev/null\", \"w\");\n  } catch (const std::system_error&) {\n    fmt::print(stderr, \"warning: /dev/null is not supported\\n\");\n    return;\n  }\n  deadlockable d;\n  auto t = std::thread([&]() {\n    fmt::print(f.get(), \"start t\\n\");\n    std::lock_guard<std::mutex> lock(d.mutex);\n    for (int i = 0; i < 1000000; ++i) d.value += 10;\n    fmt::print(f.get(), \"done\\n\");\n  });\n  for (int i = 0; i < 100; ++i) fmt::print(f.get(), \"{}\", d);\n  t.join();\n}\n\nTEST(format_test, variadic) {\n  EXPECT_EQ(fmt::format(\"{}c{}\", \"ab\", 1), \"abc1\");\n}\n\nTEST(format_test, bytes) {\n  auto s = fmt::format(\"{:10}\", fmt::bytes(\"ёжик\"));\n  EXPECT_EQ(\"ёжик  \", s);\n  EXPECT_EQ(10, s.size());\n}\n\nTEST(format_test, group_digits_view) {\n  EXPECT_EQ(fmt::format(\"{}\", fmt::group_digits(10000000)), \"10,000,000\");\n  EXPECT_EQ(fmt::format(\"{:8}\", fmt::group_digits(1000)), \"   1,000\");\n  EXPECT_EQ(fmt::format(\"{}\", fmt::group_digits(-10000000)), \"-10,000,000\");\n  EXPECT_EQ(fmt::format(\"{:8}\", fmt::group_digits(-1000)), \"  -1,000\");\n  EXPECT_EQ(fmt::format(\"{:8}\", fmt::group_digits(-100)), \"    -100\");\n}\n\n#ifdef __cpp_generic_lambdas\nstruct point {\n  double x, y;\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<point> : nested_formatter<double> {\n  auto format(point p, format_context& ctx) const -> decltype(ctx.out()) {\n    return write_padded(ctx, [this, p](auto out) -> decltype(out) {\n      return fmt::format_to(out, \"({}, {})\", this->nested(p.x),\n                            this->nested(p.y));\n    });\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, nested_formatter) {\n  EXPECT_EQ(fmt::format(\"{:>16.2f}\", point{1, 2}), \"    (1.00, 2.00)\");\n}\n#endif  // __cpp_generic_lambdas\n\nenum test_enum { foo, bar };\nauto format_as(test_enum e) -> int { return e; }\n\nstd::string vformat_message(int id, const char* format, fmt::format_args args) {\n  auto buffer = fmt::memory_buffer();\n  fmt::format_to(fmt::appender(buffer), \"[{}] \", id);\n  vformat_to(fmt::appender(buffer), format, args);\n  return to_string(buffer);\n}\n\ntemplate <typename... Args>\nstd::string format_message(int id, const char* format, const Args&... args) {\n  auto va = fmt::make_format_args(args...);\n  return vformat_message(id, format, va);\n}\n\nTEST(format_test, format_message_example) {\n  EXPECT_EQ(\"[42] something happened\",\n            format_message(42, \"{} happened\", \"something\"));\n}\n\ntemplate <typename... Args>\nvoid print_error(const char* file, int line, const char* format,\n                 const Args&... args) {\n  fmt::print(\"{}: {}: \", file, line);\n  fmt::print(format, args...);\n}\n\nTEST(format_test, unpacked_args) {\n  EXPECT_EQ(\"0123456789abcdefg\",\n            fmt::format(\"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}\", 0, 1, 2, 3, 4, 5,\n                        6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g'));\n}\n\nTEST(format_test, compile_time_string) {\n  EXPECT_EQ(fmt::format(FMT_STRING(\"foo\")), \"foo\");\n  EXPECT_EQ(fmt::format(FMT_STRING(\"{}\"), 42), \"42\");\n\n#if FMT_USE_NONTYPE_TEMPLATE_ARGS\n  using namespace fmt::literals;\n  EXPECT_EQ(\"foobar\", fmt::format(FMT_STRING(\"{foo}{bar}\"), \"bar\"_a = \"bar\",\n                                  \"foo\"_a = \"foo\"));\n  EXPECT_EQ(fmt::format(FMT_STRING(\"\")), \"\");\n  EXPECT_EQ(fmt::format(FMT_STRING(\"\"), \"arg\"_a = 42), \"\");\n  EXPECT_EQ(fmt::format(FMT_STRING(\"{answer}\"), \"answer\"_a = Answer()), \"42\");\n  EXPECT_EQ(fmt::format(FMT_STRING(\"{} {two}\"), 1, \"two\"_a = 2), \"1 2\");\n#endif\n\n  static constexpr char format_str[3] = {'{', '}', '\\0'};\n  (void)format_str;\n#ifndef _MSC_VER\n  EXPECT_EQ(fmt::format(FMT_STRING(format_str), 42), \"42\");\n#endif\n\n#if defined(FMT_USE_STRING_VIEW) && FMT_CPLUSPLUS >= 201703L\n  EXPECT_EQ(fmt::format(FMT_STRING(std::string_view(\"{}\")), 42), \"42\");\n#endif\n}\n\nTEST(format_test, custom_format_compile_time_string) {\n  EXPECT_EQ(fmt::format(FMT_STRING(\"{}\"), Answer()), \"42\");\n  auto answer = Answer();\n  EXPECT_EQ(fmt::format(FMT_STRING(\"{}\"), answer), \"42\");\n  char buf[10] = {};\n  fmt::format_to(buf, FMT_STRING(\"{}\"), answer);\n  const Answer const_answer = Answer();\n  EXPECT_EQ(fmt::format(FMT_STRING(\"{}\"), const_answer), \"42\");\n}\n\nTEST(format_test, named_arg_udl) {\n  using namespace fmt::literals;\n  auto udl_a = fmt::format(\"{first}{second}{first}{third}\", \"first\"_a = \"abra\",\n                           \"second\"_a = \"cad\", \"third\"_a = 99);\n  EXPECT_EQ(\n      fmt::format(\"{first}{second}{first}{third}\", fmt::arg(\"first\", \"abra\"),\n                  fmt::arg(\"second\", \"cad\"), fmt::arg(\"third\", 99)),\n      udl_a);\n\n  EXPECT_EQ(fmt::format(\"{answer}\", \"answer\"_a = Answer()), \"42\");\n}\n\nTEST(format_test, enum) { EXPECT_EQ(fmt::format(\"{}\", foo), \"0\"); }\n\nTEST(format_test, formatter_not_specialized) {\n  static_assert(!fmt::is_formattable<fmt::formatter<test_enum>,\n                                     fmt::format_context>::value,\n                \"\");\n}\n\n#if FMT_HAS_FEATURE(cxx_strong_enums)\nenum big_enum : unsigned long long { big_enum_value = 5000000000ULL };\nauto format_as(big_enum e) -> unsigned long long { return e; }\n\nTEST(format_test, strong_enum) {\n  auto arg = fmt::basic_format_arg<fmt::context>(big_enum_value);\n  EXPECT_EQ(arg.type(), fmt::detail::type::ulong_long_type);\n  EXPECT_EQ(fmt::format(\"{}\", big_enum_value), \"5000000000\");\n}\n#endif\n\nTEST(format_test, non_null_terminated_format_string) {\n  EXPECT_EQ(fmt::format(string_view(\"{}foo\", 2), 42), \"42\");\n}\n\nnamespace adl_test {\nnamespace fmt {\nnamespace detail {\nstruct foo {};\ntemplate <typename, typename OutputIt> void write(OutputIt, foo) = delete;\n}  // namespace detail\n}  // namespace fmt\n}  // namespace adl_test\n\nFMT_BEGIN_NAMESPACE\ntemplate <>\nstruct formatter<adl_test::fmt::detail::foo> : formatter<std::string> {\n  auto format(adl_test::fmt::detail::foo, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<std::string>::format(\"foo\", ctx);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, to_string) {\n  EXPECT_EQ(fmt::to_string(42), \"42\");\n  EXPECT_EQ(fmt::to_string(reinterpret_cast<void*>(0x1234)), \"0x1234\");\n  EXPECT_EQ(fmt::to_string(adl_test::fmt::detail::foo()), \"foo\");\n  EXPECT_EQ(fmt::to_string(foo), \"0\");\n\n#if FMT_USE_FLOAT128\n  EXPECT_EQ(fmt::to_string(__float128(0.5)), \"0.5\");\n#endif\n\n#if defined(FMT_USE_STRING_VIEW) && FMT_CPLUSPLUS >= 201703L\n  EXPECT_EQ(fmt::to_string(std::string_view()), \"\");\n#endif\n}\n\nTEST(format_test, output_iterators) {\n  std::list<char> out;\n  fmt::format_to(std::back_inserter(out), \"{}\", 42);\n  EXPECT_EQ(\"42\", std::string(out.begin(), out.end()));\n  std::stringstream s;\n  fmt::format_to(std::ostream_iterator<char>(s), \"{}\", 42);\n  EXPECT_EQ(\"42\", s.str());\n\n  std::stringstream s2;\n  fmt::format_to(std::ostreambuf_iterator<char>(s2), \"{}.{:06d}\", 42, 43);\n  EXPECT_EQ(\"42.000043\", s2.str());\n}\n\nTEST(format_test, fill_via_appender) {\n  fmt::memory_buffer buf;\n  auto it = fmt::appender(buf);\n  std::fill_n(it, 3, '~');\n  EXPECT_EQ(fmt::to_string(buf), \"~~~\");\n}\n\nTEST(format_test, formatted_size) {\n  EXPECT_EQ(2u, fmt::formatted_size(\"{}\", 42));\n  EXPECT_EQ(2u, fmt::formatted_size(std::locale(), \"{}\", 42));\n}\n\nTEST(format_test, format_to_no_args) {\n  std::string s;\n  fmt::format_to(std::back_inserter(s), \"test\");\n  EXPECT_EQ(\"test\", s);\n}\n\nTEST(format_test, format_to) {\n  std::string s;\n  fmt::format_to(std::back_inserter(s), \"part{0}\", 1);\n  EXPECT_EQ(\"part1\", s);\n  fmt::format_to(std::back_inserter(s), \"part{0}\", 2);\n  EXPECT_EQ(\"part1part2\", s);\n}\n\nTEST(format_test, format_to_memory_buffer) {\n  auto buf = fmt::basic_memory_buffer<char, 100>();\n  fmt::format_to(fmt::appender(buf), \"{}\", \"foo\");\n  EXPECT_EQ(\"foo\", to_string(buf));\n}\n\nTEST(format_test, format_to_vector) {\n  std::vector<char> v;\n  fmt::format_to(std::back_inserter(v), \"{}\", \"foo\");\n  EXPECT_EQ(string_view(v.data(), v.size()), \"foo\");\n}\n\nstruct nongrowing_container {\n  using value_type = char;\n  void push_back(char) { throw std::runtime_error(\"can't take it any more\"); }\n};\n\nTEST(format_test, format_to_propagates_exceptions) {\n  auto c = nongrowing_container();\n  EXPECT_THROW(fmt::format_to(std::back_inserter(c), \"{}\", 42),\n               std::runtime_error);\n}\n\nTEST(format_test, format_to_n) {\n  char buffer[4];\n  buffer[3] = 'x';\n  auto result = fmt::format_to_n(buffer, 3, \"{}\", 12345);\n  EXPECT_EQ(5u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(\"123x\", fmt::string_view(buffer, 4));\n\n  result = fmt::format_to_n(buffer, 3, \"{:s}\", \"foobar\");\n  EXPECT_EQ(6u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(\"foox\", fmt::string_view(buffer, 4));\n\n  buffer[0] = 'x';\n  buffer[1] = 'x';\n  buffer[2] = 'x';\n  result = fmt::format_to_n(buffer, 3, \"{}\", 'A');\n  EXPECT_EQ(1u, result.size);\n  EXPECT_EQ(buffer + 1, result.out);\n  EXPECT_EQ(\"Axxx\", fmt::string_view(buffer, 4));\n\n  result = fmt::format_to_n(buffer, 3, \"{}{} \", 'B', 'C');\n  EXPECT_EQ(3u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(\"BC x\", fmt::string_view(buffer, 4));\n\n  result = fmt::format_to_n(buffer, 4, \"{}\", \"ABCDE\");\n  EXPECT_EQ(5u, result.size);\n  EXPECT_EQ(\"ABCD\", fmt::string_view(buffer, 4));\n\n  buffer[3] = 'x';\n  result = fmt::format_to_n(buffer, 3, \"{}\", std::string(1000, '*'));\n  EXPECT_EQ(1000u, result.size);\n  EXPECT_EQ(\"***x\", fmt::string_view(buffer, 4));\n}\n\nstruct test_output_iterator {\n  char* data;\n\n  using iterator_category = std::output_iterator_tag;\n  using value_type = void;\n  using difference_type = void;\n  using pointer = void;\n  using reference = void;\n\n  auto operator++() -> test_output_iterator& {\n    ++data;\n    return *this;\n  }\n  auto operator++(int) -> test_output_iterator {\n    auto tmp = *this;\n    ++data;\n    return tmp;\n  }\n  auto operator*() -> char& { return *data; }\n};\n\nTEST(format_test, format_to_n_output_iterator) {\n  char buf[10] = {};\n  fmt::format_to_n(test_output_iterator{buf}, 10, \"{}\", 42);\n  EXPECT_STREQ(buf, \"42\");\n}\n\nTEST(format_test, vformat_to) {\n  using context = fmt::format_context;\n  int n = 42;\n  auto args = fmt::make_format_args<context>(n);\n  auto s = std::string();\n  fmt::vformat_to(std::back_inserter(s), \"{}\", args);\n  EXPECT_EQ(s, \"42\");\n  s.clear();\n  fmt::vformat_to(std::back_inserter(s), \"{}\", args);\n  EXPECT_EQ(s, \"42\");\n}\n\nTEST(format_test, char_traits_not_ambiguous) {\n  // Test that we don't inject detail names into the std namespace.\n  using namespace std;\n  auto c = char_traits<char>::char_type();\n  (void)c;\n#if FMT_CPLUSPLUS >= 201103L\n  auto s = std::string();\n  auto lval = begin(s);\n  (void)lval;\n#endif\n}\n\nstruct check_back_appender {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<check_back_appender> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n\n  template <typename Context>\n  auto format(check_back_appender, Context& ctx) const -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    static_assert(std::is_same<decltype(++out), decltype(out)&>::value,\n                  \"needs to satisfy weakly_incrementable\");\n    *out = 'y';\n    return ++out;\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, back_insert_slicing) {\n  EXPECT_EQ(fmt::format(\"{}\", check_back_appender{}), \"y\");\n}\n\nnamespace test {\nenum class scoped_enum_as_int {};\nauto format_as(scoped_enum_as_int) -> int { return 42; }\n\nenum class scoped_enum_as_string_view {};\nauto format_as(scoped_enum_as_string_view) -> fmt::string_view { return \"foo\"; }\n\nenum class scoped_enum_as_string {};\nauto format_as(scoped_enum_as_string) -> std::string { return \"foo\"; }\n\nstruct struct_as_int {};\nauto format_as(struct_as_int) -> int { return 42; }\n\nstruct struct_as_const_reference {\n  const std::string name = \"foo\";\n};\nauto format_as(const struct_as_const_reference& s) -> const std::string& {\n  return s.name;\n}\n}  // namespace test\n\nTEST(format_test, format_as) {\n  EXPECT_EQ(fmt::format(\"{}\", test::scoped_enum_as_int()), \"42\");\n  EXPECT_EQ(fmt::format(\"{}\", test::scoped_enum_as_string_view()), \"foo\");\n  EXPECT_EQ(fmt::format(\"{}\", test::scoped_enum_as_string()), \"foo\");\n  EXPECT_EQ(fmt::format(\"{}\", test::struct_as_int()), \"42\");\n  EXPECT_EQ(fmt::format(\"{}\", test::struct_as_const_reference()), \"foo\");\n}\n\nTEST(format_test, format_as_to_string) {\n  EXPECT_EQ(fmt::to_string(test::scoped_enum_as_int()), \"42\");\n  EXPECT_EQ(fmt::to_string(test::scoped_enum_as_string_view()), \"foo\");\n  EXPECT_EQ(fmt::to_string(test::scoped_enum_as_string()), \"foo\");\n  EXPECT_EQ(fmt::to_string(test::struct_as_int()), \"42\");\n}\n\ntemplate <typename Char, typename T> auto check_enabled_formatter() -> bool {\n  static_assert(std::is_default_constructible<fmt::formatter<T, Char>>::value,\n                \"\");\n  return true;\n}\n\ntemplate <typename Char, typename... T> void check_enabled_formatters() {\n  auto dummy = {check_enabled_formatter<Char, T>()...};\n  (void)dummy;\n}\n\nTEST(format_test, test_formatters_enabled) {\n  using custom_string =\n      std::basic_string<char, std::char_traits<char>, mock_allocator<char>>;\n  using custom_wstring = std::basic_string<wchar_t, std::char_traits<wchar_t>,\n                                           mock_allocator<wchar_t>>;\n\n  check_enabled_formatters<char, bool, char, signed char, unsigned char, short,\n                           unsigned short, int, unsigned, long, unsigned long,\n                           long long, unsigned long long, float, double,\n                           long double, void*, const void*, char*, const char*,\n                           std::string, custom_string, std::nullptr_t>();\n  check_enabled_formatters<\n      wchar_t, bool, wchar_t, signed char, unsigned char, short, unsigned short,\n      int, unsigned, long, unsigned long, long long, unsigned long long, float,\n      double, long double, void*, const void*, wchar_t*, const wchar_t*,\n      std::wstring, custom_wstring, std::nullptr_t>();\n}\n\nTEST(format_int_test, data) {\n  fmt::format_int format_int(42);\n  EXPECT_EQ(std::string(format_int.data(), format_int.size()), \"42\");\n}\n\nTEST(format_int_test, format_int) {\n  EXPECT_EQ(fmt::format_int(42).str(), \"42\");\n  EXPECT_EQ(fmt::format_int(42).size(), 2u);\n  EXPECT_EQ(fmt::format_int(-42).str(), \"-42\");\n  EXPECT_EQ(fmt::format_int(-42).size(), 3u);\n  EXPECT_EQ(fmt::format_int(42ul).str(), \"42\");\n  EXPECT_EQ(fmt::format_int(-42l).str(), \"-42\");\n  EXPECT_EQ(fmt::format_int(42ull).str(), \"42\");\n  EXPECT_EQ(fmt::format_int(-42ll).str(), \"-42\");\n  EXPECT_EQ(fmt::format_int(max_value<int64_t>()).str(),\n            std::to_string(max_value<int64_t>()));\n}\n\n#ifndef FMT_STATIC_THOUSANDS_SEPARATOR\n\n#  include <locale>\n\nclass format_facet : public fmt::format_facet<std::locale> {\n protected:\n  struct int_formatter {\n    fmt::appender out;\n\n    template <typename T, FMT_ENABLE_IF(fmt::detail::is_integer<T>::value)>\n    auto operator()(T value) -> bool {\n      fmt::format_to(out, \"[{}]\", value);\n      return true;\n    }\n\n    template <typename T, FMT_ENABLE_IF(!fmt::detail::is_integer<T>::value)>\n    auto operator()(T) -> bool {\n      return false;\n    }\n  };\n\n  auto do_put(fmt::appender out, fmt::loc_value val,\n              const fmt::format_specs&) const -> bool override;\n};\n\nauto format_facet::do_put(fmt::appender out, fmt::loc_value val,\n                          const fmt::format_specs&) const -> bool {\n  return val.visit(int_formatter{out});\n}\n\nTEST(format_test, format_facet) {\n  auto loc = std::locale(std::locale(), new format_facet());\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", 42), \"[42]\");\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", -42), \"[-42]\");\n}\n\nTEST(format_test, format_facet_separator) {\n  // U+2019 RIGHT SINGLE QUOTATION MARK is a digit separator in the de_CH\n  // locale.\n  auto loc =\n      std::locale({}, new fmt::format_facet<std::locale>(\"\\xe2\\x80\\x99\"));\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", 1000),\n            \"1\\xe2\\x80\\x99\"\n            \"000\");\n}\n\nTEST(format_test, format_facet_grouping) {\n  auto loc =\n      std::locale({}, new fmt::format_facet<std::locale>(\",\", {1, 2, 3}));\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", 1234567890), \"1,234,567,89,0\");\n}\n\nTEST(format_test, format_named_arg_with_locale) {\n  EXPECT_EQ(fmt::format(std::locale(), \"{answer}\", fmt::arg(\"answer\", 42)),\n            \"42\");\n}\n\nTEST(format_test, format_locale) {\n  auto loc = std::locale({}, new fmt::format_facet<std::locale>(\",\"));\n  EXPECT_EQ(fmt::format(loc, \"{:Lx}\", 123456789), \"7,5bc,d15\");\n  EXPECT_EQ(fmt::format(loc, \"{:#Lb}\", -123456789),\n            \"-0b111,010,110,111,100,110,100,010,101\");\n  EXPECT_EQ(fmt::format(loc, \"{:10Lo}\", 12345), \"    30,071\");\n}\n\n#endif  // FMT_STATIC_THOUSANDS_SEPARATOR\n\nstruct convertible_to_nonconst_cstring {\n  operator char*() const {\n    static char c[] = \"bar\";\n    return c;\n  }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <>\nstruct formatter<convertible_to_nonconst_cstring> : formatter<char*> {};\nFMT_END_NAMESPACE\n\nTEST(format_test, formatter_nonconst_char) {\n  EXPECT_EQ(fmt::format(\"{}\", convertible_to_nonconst_cstring()), \"bar\");\n}\n\nnamespace adl_test {\ntemplate <typename... T> void make_format_args(const T&...) = delete;\n\nstruct string : std::string {};\nauto format_as(const string& s) -> std::string { return s; }\n}  // namespace adl_test\n\n// Test that formatting functions compile when make_format_args is found by ADL.\nTEST(format_test, adl) {\n  // Only check compilation and don't run the code to avoid polluting the output\n  // and since the output is tested elsewhere.\n  if (true) return;\n  auto s = adl_test::string();\n  char buf[10];\n  (void)fmt::format(\"{}\", s);\n  fmt::format_to(buf, \"{}\", s);\n  fmt::format_to_n(buf, 10, \"{}\", s);\n  (void)fmt::formatted_size(\"{}\", s);\n  fmt::print(\"{}\", s);\n  fmt::print(stdout, \"{}\", s);\n}\n\nstruct convertible_to_int {\n  operator int() const { return 42; }\n};\n\nstruct convertible_to_cstring {\n  operator const char*() const { return \"foo\"; }\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<convertible_to_int> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n  auto format(convertible_to_int, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    *out++ = 'x';\n    return out;\n  }\n};\n\ntemplate <> struct formatter<convertible_to_cstring> {\n  FMT_CONSTEXPR auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {\n    return ctx.begin();\n  }\n  auto format(convertible_to_cstring, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    auto out = ctx.out();\n    *out++ = 'y';\n    return out;\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, formatter_overrides_implicit_conversion) {\n  EXPECT_EQ(fmt::format(\"{}\", convertible_to_int()), \"x\");\n  EXPECT_EQ(fmt::format(\"{}\", convertible_to_cstring()), \"y\");\n}\n\nstruct ustring {\n  using value_type = unsigned;\n\n  auto find_first_of(value_type, size_t) const -> size_t;\n\n  auto data() const -> const char*;\n  auto size() const -> size_t;\n};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<ustring> : formatter<std::string> {\n  auto format(const ustring&, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<std::string>::format(\"ustring\", ctx);\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(format_test, ustring) {\n  EXPECT_EQ(fmt::format(\"{}\", ustring()), \"ustring\");\n}\n\nTEST(format_test, writer) {\n  auto write_to_stdout = []() {\n    auto w = fmt::writer(stdout);\n    w.print(\"{}\", 42);\n  };\n  EXPECT_WRITE(stdout, write_to_stdout(), \"42\");\n\n#if FMT_USE_FCNTL\n  auto pipe = fmt::pipe();\n  auto write_end = pipe.write_end.fdopen(\"w\");\n  fmt::writer(write_end.get()).print(\"42\");\n  write_end.close();\n  auto read_end = pipe.read_end.fdopen(\"r\");\n  int n = 0;\n  int result = fscanf(read_end.get(), \"%d\", &n);\n  (void)result;\n  EXPECT_EQ(n, 42);\n#endif\n\n  auto s = fmt::string_buffer();\n  fmt::writer(s).print(\"foo\");\n  EXPECT_EQ(s.str(), \"foo\");\n}\n\n#if FMT_USE_FCNTL && !defined(_WIN32)\nTEST(format_test, invalid_glibc_buffer) {\n  auto pipe = fmt::pipe();\n  auto write_end = pipe.write_end.fdopen(\"w\");\n  auto file = write_end.get();\n\n  // This results in _IO_write_ptr < _IO_write_end.\n  fprintf(file, \"111\\n\");\n  setvbuf(file, nullptr, _IOLBF, 0);\n\n  fmt::print(file, \"------\\n\");\n}\n#endif  // FMT_USE_FCNTL\n\n// Only defined after the test case.\nstruct incomplete_type;\nextern const incomplete_type& external_instance;\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<incomplete_type> : formatter<int> {\n  auto format(const incomplete_type& x, context& ctx) const -> appender;\n};\nFMT_END_NAMESPACE\n\nTEST(incomplete_type_test, format) {\n  EXPECT_EQ(fmt::format(\"{}\", external_instance), \"42\");\n}\n\nstruct incomplete_type {};\nconst incomplete_type& external_instance = {};\n\nauto fmt::formatter<incomplete_type>::format(const incomplete_type&,\n                                             fmt::context& ctx) const\n    -> fmt::appender {\n  return formatter<int>::format(42, ctx);\n}\n"
  },
  {
    "path": "test/fuzzing/.gitignore",
    "content": "# ignore artifacts from the build.sh script\nbuild-*/\n\n"
  },
  {
    "path": "test/fuzzing/CMakeLists.txt",
    "content": "# Copyright (c) 2019, Paul Dreik\n\n# Link in the main function. Useful for reproducing, kcov, gdb, afl, valgrind.\n# (Note that libFuzzer can also reproduce, just pass it the files.)\noption(FMT_FUZZ_LINKMAIN \"Enables the reproduce mode, instead of libFuzzer\" On)\n\n# For oss-fuzz - insert $LIB_FUZZING_ENGINE into the link flags, but only for\n# the fuzz targets, otherwise the CMake configuration step fails.\nset(FMT_FUZZ_LDFLAGS\n    \"\"\n    CACHE STRING \"LDFLAGS for the fuzz targets\")\n\n# Adds a binary for reproducing, i.e. no fuzzing, just enables replaying data\n# through the fuzzers.\nfunction (add_fuzzer source)\n  get_filename_component(basename ${source} NAME_WE)\n  set(name ${basename}-fuzzer)\n  add_executable(${name} ${source} fuzzer-common.h)\n  if (FMT_FUZZ_LINKMAIN)\n    target_sources(${name} PRIVATE main.cc)\n  endif ()\n  target_link_libraries(${name} PRIVATE fmt)\n  if (FMT_FUZZ_LDFLAGS)\n    target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS})\n  endif ()\n  target_compile_features(${name} PRIVATE cxx_std_14)\nendfunction ()\n\nforeach (source chrono-duration.cc chrono-timepoint.cc float.cc named-arg.cc\n                one-arg.cc two-args.cc)\n  add_fuzzer(${source})\nendforeach ()\n"
  },
  {
    "path": "test/fuzzing/README.md",
    "content": "# Running the fuzzers locally\n\nThere is a [helper script](build.sh) to build the fuzzers, which has only been\ntested on Debian and Ubuntu linux so far. There should be no problems fuzzing on\nWindows (using clang>=8) or on Mac, but the script will probably not work out of\nthe box.\n\nSomething along\n```sh\nmkdir build\ncd build\nexport CXX=clang++\nexport CXXFLAGS=\"-fsanitize=fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION= -g\"\ncmake .. -DFMT_SAFE_DURATION_CAST=On -DFMT_FUZZ=On -DFMT_FUZZ_LINKMAIN=Off -DFMT_FUZZ_LDFLAGS=\"-fsanitize=fuzzer\"\ncmake --build .\n```\nshould work to build the fuzzers for all platforms which clang supports.\n\nExecute a fuzzer with for instance\n```sh\ncd build\nexport UBSAN_OPTIONS=halt_on_error=1\nmkdir out_chrono\nbin/fuzzer_chrono_duration out_chrono\n```\n"
  },
  {
    "path": "test/fuzzing/build.sh",
    "content": "#!/bin/sh\n#\n# Creates fuzzer builds of various kinds\n# - oss-fuzz emulated mode (makes sure a simulated invocation by oss-fuzz works)\n# - libFuzzer build (you will need clang)\n# - afl build (you will need afl)\n#\n#\n# Copyright (c) 2019 Paul Dreik\n#\n# For the license information refer to format.h.\n\nset -e\nme=$(basename $0)\nroot=$(readlink -f \"$(dirname \"$0\")/../..\")\n\n\necho $me: root=$root\n\nhere=$(pwd)\n\nCXXFLAGSALL=\"-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION= -g\"\nCMAKEFLAGSALL=\"$root -GNinja -DCMAKE_BUILD_TYPE=Debug -DFMT_DOC=Off -DFMT_TEST=Off -DFMT_FUZZ=On -DCMAKE_CXX_STANDARD=17\"\n\nCLANG=clang++-11\n\n# For performance analysis of the fuzzers.\nbuilddir=$here/build-fuzzers-perfanalysis\nmkdir -p $builddir\ncd $builddir\nCXX=\"ccache g++\" CXXFLAGS=\"$CXXFLAGSALL -g\" cmake \\\n$CMAKEFLAGSALL \\\n-DFMT_FUZZ_LINKMAIN=On \\\n-DCMAKE_BUILD_TYPE=Release\n\ncmake --build $builddir\n\n# Builds the fuzzers as oss-fuzz does.\nbuilddir=$here/build-fuzzers-ossfuzz\nmkdir -p $builddir\ncd $builddir\nCXX=$CLANG \\\nCXXFLAGS=\"$CXXFLAGSALL -fsanitize=fuzzer-no-link\" cmake \\\ncmake $CMAKEFLAGSALL \\\n-DFMT_FUZZ_LINKMAIN=Off \\\n-DFMT_FUZZ_LDFLAGS=\"-fsanitize=fuzzer\"\n\ncmake --build $builddir\n\n\n# Builds fuzzers for local fuzzing with libfuzzer with asan+usan.\nbuilddir=$here/build-fuzzers-libfuzzer\nmkdir -p $builddir\ncd $builddir\nCXX=$CLANG \\\nCXXFLAGS=\"$CXXFLAGSALL -fsanitize=fuzzer-no-link,address,undefined\" cmake \\\ncmake $CMAKEFLAGSALL \\\n-DFMT_FUZZ_LINKMAIN=Off \\\n-DFMT_FUZZ_LDFLAGS=\"-fsanitize=fuzzer\"\n\ncmake --build $builddir\n\n# Builds a fast fuzzer for making coverage fast.\nbuilddir=$here/build-fuzzers-fast\nmkdir -p $builddir\ncd $builddir\nCXX=$CLANG \\\nCXXFLAGS=\"$CXXFLAGSALL -fsanitize=fuzzer-no-link -O3\" cmake \\\ncmake $CMAKEFLAGSALL \\\n-DFMT_FUZZ_LINKMAIN=Off \\\n-DFMT_FUZZ_LDFLAGS=\"-fsanitize=fuzzer\" \\\n -DCMAKE_BUILD_TYPE=Release\n\ncmake --build $builddir\n\n\n# Builds fuzzers for local fuzzing with afl.\nbuilddir=$here/build-fuzzers-afl\nmkdir -p $builddir\ncd $builddir\nCXX=\"afl-g++\" \\\nCXXFLAGS=\"$CXXFLAGSALL -fsanitize=address,undefined\" \\\ncmake $CMAKEFLAGSALL \\\n-DFMT_FUZZ_LINKMAIN=On\n\ncmake --build $builddir\n\n\necho $me: all good\n\n"
  },
  {
    "path": "test/fuzzing/chrono-duration.cc",
    "content": "// Copyright (c) 2019, Paul Dreik\n// For the license information refer to format.h.\n\n#include <fmt/chrono.h>\n\n#include <cstdint>\n\n#include \"fuzzer-common.h\"\n\ntemplate <typename Period, typename Rep>\nvoid invoke_inner(fmt::string_view format_str, Rep rep) {\n  auto value = std::chrono::duration<Rep, Period>(rep);\n  try {\n#if FMT_FUZZ_FORMAT_TO_STRING\n    std::string message = fmt::format(fmt::runtime(format_str), value);\n#else\n    auto buf = fmt::memory_buffer();\n    fmt::format_to(std::back_inserter(buf), fmt::runtime(format_str), value);\n#endif\n  } catch (std::exception&) {\n  }\n}\n\n// Rep is a duration's representation type.\ntemplate <typename Rep>\nvoid invoke_outer(const uint8_t* data, size_t size, int period) {\n  // Always use a fixed location of the data.\n  static_assert(sizeof(Rep) <= fixed_size, \"fixed size is too small\");\n  if (size <= fixed_size + 1) return;\n\n  const Rep rep = assign_from_buf<Rep>(data);\n  data += fixed_size;\n  size -= fixed_size;\n\n  // data is already allocated separately in libFuzzer so reading past the end\n  // will most likely be detected anyway.\n  const auto format_str = fmt::string_view(as_chars(data), size);\n\n  // yocto, zepto, zetta and yotta are not handled.\n  switch (period) {\n  case 1:\n    invoke_inner<std::atto>(format_str, rep);\n    break;\n  case 2:\n    invoke_inner<std::femto>(format_str, rep);\n    break;\n  case 3:\n    invoke_inner<std::pico>(format_str, rep);\n    break;\n  case 4:\n    invoke_inner<std::nano>(format_str, rep);\n    break;\n  case 5:\n    invoke_inner<std::micro>(format_str, rep);\n    break;\n  case 6:\n    invoke_inner<std::milli>(format_str, rep);\n    break;\n  case 7:\n    invoke_inner<std::centi>(format_str, rep);\n    break;\n  case 8:\n    invoke_inner<std::deci>(format_str, rep);\n    break;\n  case 9:\n    invoke_inner<std::deca>(format_str, rep);\n    break;\n  case 10:\n    invoke_inner<std::kilo>(format_str, rep);\n    break;\n  case 11:\n    invoke_inner<std::mega>(format_str, rep);\n    break;\n  case 12:\n    invoke_inner<std::giga>(format_str, rep);\n    break;\n  case 13:\n    invoke_inner<std::tera>(format_str, rep);\n    break;\n  case 14:\n    invoke_inner<std::peta>(format_str, rep);\n    break;\n  case 15:\n    invoke_inner<std::exa>(format_str, rep);\n    break;\n  }\n}\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  if (size <= 4) return 0;\n\n  const auto representation = data[0];\n  const auto period = data[1];\n  data += 2;\n  size -= 2;\n\n  switch (representation) {\n  case 1:\n    invoke_outer<char>(data, size, period);\n    break;\n  case 2:\n    invoke_outer<signed char>(data, size, period);\n    break;\n  case 3:\n    invoke_outer<unsigned char>(data, size, period);\n    break;\n  case 4:\n    invoke_outer<short>(data, size, period);\n    break;\n  case 5:\n    invoke_outer<unsigned short>(data, size, period);\n    break;\n  case 6:\n    invoke_outer<int>(data, size, period);\n    break;\n  case 7:\n    invoke_outer<unsigned int>(data, size, period);\n    break;\n  case 8:\n    invoke_outer<long>(data, size, period);\n    break;\n  case 9:\n    invoke_outer<unsigned long>(data, size, period);\n    break;\n  case 10:\n    invoke_outer<float>(data, size, period);\n    break;\n  case 11:\n    invoke_outer<double>(data, size, period);\n    break;\n  case 12:\n    invoke_outer<long double>(data, size, period);\n    break;\n  }\n  return 0;\n}\n"
  },
  {
    "path": "test/fuzzing/chrono-timepoint.cc",
    "content": "// Copyright (c) 2021, Paul Dreik\n// For license information refer to format.h.\n#include <fmt/chrono.h>\n\n#include \"fuzzer-common.h\"\n\n/*\n * a fuzzer for the chrono timepoints formatters\n * C is a clock (std::chrono::system_clock etc)\n */\ntemplate <typename C> void doit(const uint8_t* data, size_t size) {\n  using Rep = typename C::time_point::rep;\n  constexpr auto N = sizeof(Rep);\n  if (size < N) return;\n\n  const auto x = assign_from_buf<Rep>(data);\n  typename C::duration dur{x};\n  typename C::time_point timepoint{dur};\n  data += N;\n  size -= N;\n  data_to_string format_str(data, size);\n\n  std::string message = fmt::format(format_str.get(), timepoint);\n}\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  try {\n    doit<std::chrono::system_clock>(data, size);\n  } catch (...) {\n  }\n  return 0;\n}\n"
  },
  {
    "path": "test/fuzzing/float.cc",
    "content": "// A fuzzer for floating-point formatter.\n// For the license information refer to format.h.\n\n#include <fmt/format.h>\n\n#include <cstdint>\n#include <cstdlib>\n#include <limits>\n#include <stdexcept>\n\n#include \"fuzzer-common.h\"\n\nvoid check_round_trip(fmt::string_view format_str, double value) {\n  auto buffer = fmt::memory_buffer();\n  fmt::format_to(std::back_inserter(buffer), format_str, value);\n\n  if (std::isnan(value)) {\n    auto nan = std::signbit(value) ? \"-nan\" : \"nan\";\n    if (fmt::string_view(buffer.data(), buffer.size()) != nan)\n      throw std::runtime_error(\"round trip failure\");\n    return;\n  }\n\n  buffer.push_back('\\0');\n  char* ptr = nullptr;\n  if (std::strtod(buffer.data(), &ptr) != value)\n    throw std::runtime_error(\"round trip failure\");\n  if (ptr + 1 != buffer.end()) throw std::runtime_error(\"unparsed output\");\n}\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  if (size <= sizeof(double) || !std::numeric_limits<double>::is_iec559)\n    return 0;\n  check_round_trip(\"{}\", assign_from_buf<double>(data));\n  // A larger than necessary precision is used to trigger the fallback\n  // formatter.\n  check_round_trip(\"{:.50g}\", assign_from_buf<double>(data));\n  return 0;\n}\n"
  },
  {
    "path": "test/fuzzing/fuzzer-common.h",
    "content": "// Copyright (c) 2019, Paul Dreik\n// For the license information refer to format.h.\n\n#ifndef FUZZER_COMMON_H\n#define FUZZER_COMMON_H\n\n#include <fmt/base.h>\n\n#include <cstdint>  // std::uint8_t\n#include <cstring>  // memcpy\n#include <vector>\n\n// One can format to either a string, or a buffer. The latter is faster, but\n// one may be interested in formatting to a string instead to verify it works\n// as intended. To avoid a combinatoric explosion, select this at compile time\n// instead of dynamically from the fuzz data.\n#define FMT_FUZZ_FORMAT_TO_STRING 0\n\n// If {fmt} is given a buffer that is separately allocated, chances that address\n// sanitizer detects out of bound reads is much higher. However, it slows down\n// the fuzzing.\n#define FMT_FUZZ_SEPARATE_ALLOCATION 1\n\n// The size of the largest possible type in use.\n// To let the fuzzer mutation be efficient at cross pollinating between\n// different types, use a fixed size format. The same bit pattern, interpreted\n// as another type, is likely interesting.\nconstexpr auto fixed_size = 16;\n\n// Casts data to a char pointer.\ntemplate <typename T> inline const char* as_chars(const T* data) {\n  return reinterpret_cast<const char*>(data);\n}\n\n// Casts data to a byte pointer.\ntemplate <typename T> inline const std::uint8_t* as_bytes(const T* data) {\n  return reinterpret_cast<const std::uint8_t*>(data);\n}\n\n// Blits bytes from data to form an (assumed trivially constructible) object\n// of type Item.\ntemplate <class Item> inline Item assign_from_buf(const std::uint8_t* data) {\n  auto item = Item();\n  std::memcpy(&item, data, sizeof(Item));\n  return item;\n}\n\n// Reads a boolean value by looking at the first byte from data.\ntemplate <> inline bool assign_from_buf<bool>(const std::uint8_t* data) {\n  return *data != 0;\n}\n\nstruct data_to_string {\n#if FMT_FUZZ_SEPARATE_ALLOCATION\n  std::vector<char> buffer;\n\n  data_to_string(const uint8_t* data, size_t size, bool add_terminator = false)\n      : buffer(size + (add_terminator ? 1 : 0)) {\n    if (size) {\n      std::memcpy(buffer.data(), data, size);\n    }\n  }\n\n  fmt::string_view get() const { return {buffer.data(), buffer.size()}; }\n#else\n  fmt::string_view sv;\n\n  data_to_string(const uint8_t* data, size_t size, bool = false)\n      : str(as_chars(data), size) {}\n\n  fmt::string_view get() const { return sv; }\n#endif\n\n  const char* data() const { return get().data(); }\n};\n\n#endif  // FUZZER_COMMON_H\n"
  },
  {
    "path": "test/fuzzing/main.cc",
    "content": "#include <cassert>\n#include <fstream>\n#include <vector>\n\n#include \"fuzzer-common.h\"\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);\n\nint main(int argc, char** argv) {\n  for (int i = 1; i < argc; ++i) {\n    std::ifstream in(argv[i]);\n    assert(in);\n    in.seekg(0, std::ios_base::end);\n    const auto size = in.tellg();\n    assert(size >= 0);\n    in.seekg(0, std::ios_base::beg);\n    std::vector<char> buf(static_cast<size_t>(size));\n    in.read(buf.data(), size);\n    assert(in.gcount() == size);\n    LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size());\n  }\n}\n"
  },
  {
    "path": "test/fuzzing/named-arg.cc",
    "content": "// Copyright (c) 2019, Paul Dreik\n// For the license information refer to format.h.\n\n#include <fmt/chrono.h>\n\n#include <cstdint>\n#include <type_traits>\n#include <vector>\n\n#include \"fuzzer-common.h\"\n\ntemplate <typename T>\nvoid invoke_fmt(const uint8_t* data, size_t size, unsigned arg_name_size) {\n  static_assert(sizeof(T) <= fixed_size, \"fixed_size too small\");\n  if (size <= fixed_size) return;\n  const T value = assign_from_buf<T>(data);\n  data += fixed_size;\n  size -= fixed_size;\n\n  if (arg_name_size <= 0 || arg_name_size >= size) return;\n  data_to_string arg_name(data, arg_name_size, true);\n  data += arg_name_size;\n  size -= arg_name_size;\n\n  data_to_string format_str(data, size);\n  try {\n#if FMT_FUZZ_FORMAT_TO_STRING\n    std::string message =\n        fmt::format(format_str.get(), fmt::arg(arg_name.data(), value));\n#else\n    fmt::memory_buffer out;\n    fmt::format_to(std::back_inserter(out), format_str.get(),\n                   fmt::arg(arg_name.data(), value));\n#endif\n  } catch (std::exception&) {\n  }\n}\n\n// For dynamic dispatching to an explicit instantiation.\ntemplate <typename Callback> void invoke(int type, Callback callback) {\n  switch (type) {\n  case 0:\n    callback(bool());\n    break;\n  case 1:\n    callback(char());\n    break;\n  case 2:\n    using sc = signed char;\n    callback(sc());\n    break;\n  case 3:\n    using uc = unsigned char;\n    callback(uc());\n    break;\n  case 4:\n    callback(short());\n    break;\n  case 5:\n    using us = unsigned short;\n    callback(us());\n    break;\n  case 6:\n    callback(int());\n    break;\n  case 7:\n    callback(unsigned());\n    break;\n  case 8:\n    callback(long());\n    break;\n  case 9:\n    using ul = unsigned long;\n    callback(ul());\n    break;\n  case 10:\n    callback(float());\n    break;\n  case 11:\n    callback(double());\n    break;\n  case 12:\n    using LD = long double;\n    callback(LD());\n    break;\n  }\n}\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  if (size <= 3) return 0;\n\n  // Switch types depending on the first byte of the input.\n  const auto type = data[0] & 0x0F;\n  const unsigned arg_name_size = (data[0] & 0xF0) >> 4;\n  data++;\n  size--;\n\n  invoke(type, [=](auto arg) {\n    invoke_fmt<decltype(arg)>(data, size, arg_name_size);\n  });\n  return 0;\n}\n"
  },
  {
    "path": "test/fuzzing/one-arg.cc",
    "content": "// Copyright (c) 2019, Paul Dreik\n// For the license information refer to format.h.\n\n#include <fmt/chrono.h>\n\n#include <cstdint>\n#include <exception>\n\n#include \"fuzzer-common.h\"\n\ntemplate <typename T, typename Repr> const T* from_repr(const Repr& r) {\n  return &r;\n}\n\ntemplate <> const std::tm* from_repr<std::tm>(const std::time_t& t) {\n  return std::localtime(&t);\n}\n\ntemplate <typename T, typename Repr = T>\nvoid invoke_fmt(const uint8_t* data, size_t size) {\n  static_assert(sizeof(Repr) <= fixed_size, \"Nfixed is too small\");\n  if (size <= fixed_size) return;\n  auto repr = assign_from_buf<Repr>(data);\n  const T* value = from_repr<T>(repr);\n  if (!value) return;\n  data += fixed_size;\n  size -= fixed_size;\n  data_to_string format_str(data, size);\n  try {\n#if FMT_FUZZ_FORMAT_TO_STRING\n    std::string message = fmt::format(format_str.get(), *value);\n#else\n    auto buf = fmt::memory_buffer();\n    fmt::format_to(std::back_inserter(buf), format_str.get(), *value);\n#endif\n  } catch (std::exception&) {\n  }\n}\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  if (size <= 3) return 0;\n\n  const auto first = data[0];\n  data++;\n  size--;\n\n  switch (first) {\n  case 0:\n    invoke_fmt<bool>(data, size);\n    break;\n  case 1:\n    invoke_fmt<char>(data, size);\n    break;\n  case 2:\n    invoke_fmt<unsigned char>(data, size);\n    break;\n  case 3:\n    invoke_fmt<signed char>(data, size);\n    break;\n  case 4:\n    invoke_fmt<short>(data, size);\n    break;\n  case 5:\n    invoke_fmt<unsigned short>(data, size);\n    break;\n  case 6:\n    invoke_fmt<int>(data, size);\n    break;\n  case 7:\n    invoke_fmt<unsigned int>(data, size);\n    break;\n  case 8:\n    invoke_fmt<long>(data, size);\n    break;\n  case 9:\n    invoke_fmt<unsigned long>(data, size);\n    break;\n  case 10:\n    invoke_fmt<float>(data, size);\n    break;\n  case 11:\n    invoke_fmt<double>(data, size);\n    break;\n  case 12:\n    invoke_fmt<long double>(data, size);\n    break;\n  case 13:\n    invoke_fmt<std::tm, std::time_t>(data, size);\n    break;\n  }\n  return 0;\n}\n"
  },
  {
    "path": "test/fuzzing/two-args.cc",
    "content": "// Copyright (c) 2019, Paul Dreik\n// For the license information refer to format.h.\n\n#include <fmt/format.h>\n\n#include <cstdint>\n#include <exception>\n#include <string>\n\n#include \"fuzzer-common.h\"\n\ntemplate <typename Item1, typename Item2>\nvoid invoke_fmt(const uint8_t* data, size_t size) {\n  static_assert(sizeof(Item1) <= fixed_size, \"size1 exceeded\");\n  static_assert(sizeof(Item2) <= fixed_size, \"size2 exceeded\");\n  if (size <= fixed_size + fixed_size) return;\n\n  const Item1 item1 = assign_from_buf<Item1>(data);\n  data += fixed_size;\n  size -= fixed_size;\n\n  const Item2 item2 = assign_from_buf<Item2>(data);\n  data += fixed_size;\n  size -= fixed_size;\n\n  auto format_str = fmt::string_view(as_chars(data), size);\n#if FMT_FUZZ_FORMAT_TO_STRING\n  std::string message = fmt::format(format_str, item1, item2);\n#else\n  auto buf = fmt::memory_buffer();\n  fmt::format_to(std::back_inserter(buf), format_str, item1, item2);\n#endif\n}\n\n// For dynamic dispatching to an explicit instantiation.\ntemplate <typename Callback> void invoke(int index, Callback callback) {\n  switch (index) {\n  case 0:\n    callback(bool());\n    break;\n  case 1:\n    callback(char());\n    break;\n  case 2:\n    using sc = signed char;\n    callback(sc());\n    break;\n  case 3:\n    using uc = unsigned char;\n    callback(uc());\n    break;\n  case 4:\n    callback(short());\n    break;\n  case 5:\n    using us = unsigned short;\n    callback(us());\n    break;\n  case 6:\n    callback(int());\n    break;\n  case 7:\n    callback(unsigned());\n    break;\n  case 8:\n    callback(long());\n    break;\n  case 9:\n    using ul = unsigned long;\n    callback(ul());\n    break;\n  case 10:\n    callback(float());\n    break;\n  case 11:\n    callback(double());\n    break;\n  case 12:\n    using LD = long double;\n    callback(LD());\n    break;\n  case 13:\n    using ptr = void*;\n    callback(ptr());\n    break;\n  }\n}\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  if (size <= 3) return 0;\n\n  // Switch types depending on the first byte of the input.\n  const auto type1 = data[0] & 0x0F;\n  const auto type2 = (data[0] & 0xF0) >> 4;\n  data++;\n  size--;\n  try {\n    invoke(type1, [=](auto param1) {\n      invoke(type2, [=](auto param2) {\n        invoke_fmt<decltype(param1), decltype(param2)>(data, size);\n      });\n    });\n  } catch (std::exception&) {\n  }\n  return 0;\n}\n"
  },
  {
    "path": "test/gtest/.clang-format",
    "content": "# Disable clang-format here\nDisableFormat: true\nSortIncludes: Never\n"
  },
  {
    "path": "test/gtest/CMakeLists.txt",
    "content": "# Compile Google Test ourselves instead of using pre-compiled libraries. See the\n# Google Test FAQ \"Why is it not recommended to install a pre-compiled copy of\n# Google Test (for example, into /usr/local)?\" at\n# http://code.google.com/p/googletest/wiki/FAQ for more details.\n\nadd_library(gtest STATIC gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h\n                         gtest/gtest-spi.h)\ntarget_compile_definitions(gtest PUBLIC GTEST_HAS_STD_WSTRING=1)\ntarget_include_directories(gtest SYSTEM PUBLIC .)\ntarget_compile_features(gtest PUBLIC cxx_std_11)\n\nfind_package(Threads)\nif (Threads_FOUND)\n  target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})\nelse ()\n  target_compile_definitions(gtest PUBLIC GTEST_HAS_PTHREAD=0)\nendif ()\n\nif (MSVC)\n  # Disable MSVC warnings about _CRT_INSECURE_DEPRECATE functions.\n  target_compile_definitions(gtest PRIVATE _CRT_SECURE_NO_WARNINGS)\n  if (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n    # Disable MSVC warnings about POSIX functions.\n    target_compile_options(gtest PUBLIC -Wno-deprecated-declarations)\n  endif ()\nendif ()\n"
  },
  {
    "path": "test/gtest/gmock/gmock.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This is the main header file a user should include.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_\n\n// This file implements the following syntax:\n//\n//   ON_CALL(mock_object, Method(...))\n//     .With(...) ?\n//     .WillByDefault(...);\n//\n// where With() is optional and WillByDefault() must appear exactly\n// once.\n//\n//   EXPECT_CALL(mock_object, Method(...))\n//     .With(...) ?\n//     .Times(...) ?\n//     .InSequence(...) *\n//     .WillOnce(...) *\n//     .WillRepeatedly(...) ?\n//     .RetiresOnSaturation() ? ;\n//\n// where all clauses are optional and WillOnce() can be repeated.\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// The ACTION* family of macros can be used in a namespace scope to\n// define custom actions easily.  The syntax:\n//\n//   ACTION(name) { statements; }\n//\n// will define an action with the given name that executes the\n// statements.  The value returned by the statements will be used as\n// the return value of the action.  Inside the statements, you can\n// refer to the K-th (0-based) argument of the mock function by\n// 'argK', and refer to its type by 'argK_type'.  For example:\n//\n//   ACTION(IncrementArg1) {\n//     arg1_type temp = arg1;\n//     return ++(*temp);\n//   }\n//\n// allows you to write\n//\n//   ...WillOnce(IncrementArg1());\n//\n// You can also refer to the entire argument tuple and its type by\n// 'args' and 'args_type', and refer to the mock function type and its\n// return type by 'function_type' and 'return_type'.\n//\n// Note that you don't need to specify the types of the mock function\n// arguments.  However rest assured that your code is still type-safe:\n// you'll get a compiler error if *arg1 doesn't support the ++\n// operator, or if the type of ++(*arg1) isn't compatible with the\n// mock function's return type, for example.\n//\n// Sometimes you'll want to parameterize the action.   For that you can use\n// another macro:\n//\n//   ACTION_P(name, param_name) { statements; }\n//\n// For example:\n//\n//   ACTION_P(Add, n) { return arg0 + n; }\n//\n// will allow you to write:\n//\n//   ...WillOnce(Add(5));\n//\n// Note that you don't need to provide the type of the parameter\n// either.  If you need to reference the type of a parameter named\n// 'foo', you can write 'foo_type'.  For example, in the body of\n// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type\n// of 'n'.\n//\n// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support\n// multi-parameter actions.\n//\n// For the purpose of typing, you can view\n//\n//   ACTION_Pk(Foo, p1, ..., pk) { ... }\n//\n// as shorthand for\n//\n//   template <typename p1_type, ..., typename pk_type>\n//   FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }\n//\n// In particular, you can provide the template type arguments\n// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);\n// although usually you can rely on the compiler to infer the types\n// for you automatically.  You can assign the result of expression\n// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,\n// pk_type>.  This can be useful when composing actions.\n//\n// You can also overload actions with different numbers of parameters:\n//\n//   ACTION_P(Plus, a) { ... }\n//   ACTION_P2(Plus, a, b) { ... }\n//\n// While it's tempting to always use the ACTION* macros when defining\n// a new action, you should also consider implementing ActionInterface\n// or using MakePolymorphicAction() instead, especially if you need to\n// use the action a lot.  While these approaches require more work,\n// they give you more control on the types of the mock function\n// arguments and the action parameters, which in general leads to\n// better compiler error messages that pay off in the long run.  They\n// also allow overloading actions based on parameter types (as opposed\n// to just based on the number of parameters).\n//\n// CAVEAT:\n//\n// ACTION*() can only be used in a namespace scope as templates cannot be\n// declared inside of a local class.\n// Users can, however, define any local functors (e.g. a lambda) that\n// can be used as actions.\n//\n// MORE INFORMATION:\n//\n// To learn more about using these macros, please search for 'ACTION' on\n// https://github.com/google/googletest/blob/master/docs/gmock_cook_book.md\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_\n\n#ifndef _WIN32_WCE\n# include <errno.h>\n#endif\n\n#include <algorithm>\n#include <functional>\n#include <memory>\n#include <string>\n#include <tuple>\n#include <type_traits>\n#include <utility>\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file defines some utilities useful for implementing Google\n// Mock.  They are subject to change without notice, so please DO NOT\n// USE THEM IN USER CODE.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_\n\n#include <stdio.h>\n#include <ostream>  // NOLINT\n#include <string>\n#include <type_traits>\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// Low-level types and utilities for porting Google Mock to various\n// platforms.  All macros ending with _ and symbols defined in an\n// internal namespace are subject to change without notice.  Code\n// outside Google Mock MUST NOT USE THEM DIRECTLY.  Macros that don't\n// end with _ are part of Google Mock's public API and can be used by\n// code outside Google Mock.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_\n\n#include <assert.h>\n#include <stdlib.h>\n#include <cstdint>\n#include <iostream>\n\n// Most of the utilities needed for porting Google Mock are also\n// required for Google Test and are defined in gtest-port.h.\n//\n// Note to maintainers: to reduce code duplication, prefer adding\n// portability utilities to Google Test's gtest-port.h instead of\n// here, as Google Mock depends on Google Test.  Only add a utility\n// here if it's truly specific to Google Mock.\n\n#include \"gtest/gtest.h\"\n// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Injection point for custom user configurations. See README for details\n//\n// ** Custom implementation starts here **\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_\n\n// For MS Visual C++, check the compiler version. At least VS 2015 is\n// required to compile Google Mock.\n#if defined(_MSC_VER) && _MSC_VER < 1900\n# error \"At least Visual C++ 2015 (14.0) is required to compile Google Mock.\"\n#endif\n\n// Macro for referencing flags.  This is public as we want the user to\n// use this syntax to reference Google Mock flags.\n#define GMOCK_FLAG(name) FLAGS_gmock_##name\n\n#if !defined(GMOCK_DECLARE_bool_)\n\n// Macros for declaring flags.\n# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)\n# define GMOCK_DECLARE_int32_(name) extern GTEST_API_ int32_t GMOCK_FLAG(name)\n# define GMOCK_DECLARE_string_(name) \\\n    extern GTEST_API_ ::std::string GMOCK_FLAG(name)\n\n// Macros for defining flags.\n# define GMOCK_DEFINE_bool_(name, default_val, doc) \\\n    GTEST_API_ bool GMOCK_FLAG(name) = (default_val)\n# define GMOCK_DEFINE_int32_(name, default_val, doc) \\\n    GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val)\n# define GMOCK_DEFINE_string_(name, default_val, doc) \\\n    GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)\n\n#endif  // !defined(GMOCK_DECLARE_bool_)\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_\n\nnamespace testing {\n\ntemplate <typename>\nclass Matcher;\n\nnamespace internal {\n\n// Silence MSVC C4100 (unreferenced formal parameter) and\n// C4805('==': unsafe mix of type 'const int' and type 'const bool')\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n# pragma warning(disable:4805)\n#endif\n\n// Joins a vector of strings as if they are fields of a tuple; returns\n// the joined string.\nGTEST_API_ std::string JoinAsTuple(const Strings& fields);\n\n// Converts an identifier name to a space-separated list of lower-case\n// words.  Each maximum substring of the form [A-Za-z][a-z]*|\\d+ is\n// treated as one word.  For example, both \"FooBar123\" and\n// \"foo_bar_123\" are converted to \"foo bar 123\".\nGTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name);\n\n// GetRawPointer(p) returns the raw pointer underlying p when p is a\n// smart pointer, or returns p itself when p is already a raw pointer.\n// The following default implementation is for the smart pointer case.\ntemplate <typename Pointer>\ninline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {\n  return p.get();\n}\n// This overloaded version is for the raw pointer case.\ntemplate <typename Element>\ninline Element* GetRawPointer(Element* p) { return p; }\n\n// MSVC treats wchar_t as a native type usually, but treats it as the\n// same as unsigned short when the compiler option /Zc:wchar_t- is\n// specified.  It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t\n// is a native type.\n#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)\n// wchar_t is a typedef.\n#else\n# define GMOCK_WCHAR_T_IS_NATIVE_ 1\n#endif\n\n// In what follows, we use the term \"kind\" to indicate whether a type\n// is bool, an integer type (excluding bool), a floating-point type,\n// or none of them.  This categorization is useful for determining\n// when a matcher argument type can be safely converted to another\n// type in the implementation of SafeMatcherCast.\nenum TypeKind {\n  kBool, kInteger, kFloatingPoint, kOther\n};\n\n// KindOf<T>::value is the kind of type T.\ntemplate <typename T> struct KindOf {\n  enum { value = kOther };  // The default kind.\n};\n\n// This macro declares that the kind of 'type' is 'kind'.\n#define GMOCK_DECLARE_KIND_(type, kind) \\\n  template <> struct KindOf<type> { enum { value = kind }; }\n\nGMOCK_DECLARE_KIND_(bool, kBool);\n\n// All standard integer types.\nGMOCK_DECLARE_KIND_(char, kInteger);\nGMOCK_DECLARE_KIND_(signed char, kInteger);\nGMOCK_DECLARE_KIND_(unsigned char, kInteger);\nGMOCK_DECLARE_KIND_(short, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(unsigned short, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(int, kInteger);\nGMOCK_DECLARE_KIND_(unsigned int, kInteger);\nGMOCK_DECLARE_KIND_(long, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(unsigned long, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(long long, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(unsigned long long, kInteger);  // NOLINT\n\n#if GMOCK_WCHAR_T_IS_NATIVE_\nGMOCK_DECLARE_KIND_(wchar_t, kInteger);\n#endif\n\n// All standard floating-point types.\nGMOCK_DECLARE_KIND_(float, kFloatingPoint);\nGMOCK_DECLARE_KIND_(double, kFloatingPoint);\nGMOCK_DECLARE_KIND_(long double, kFloatingPoint);\n\n#undef GMOCK_DECLARE_KIND_\n\n// Evaluates to the kind of 'type'.\n#define GMOCK_KIND_OF_(type) \\\n  static_cast< ::testing::internal::TypeKind>( \\\n      ::testing::internal::KindOf<type>::value)\n\n// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value\n// is true if and only if arithmetic type From can be losslessly converted to\n// arithmetic type To.\n//\n// It's the user's responsibility to ensure that both From and To are\n// raw (i.e. has no CV modifier, is not a pointer, and is not a\n// reference) built-in arithmetic types, kFromKind is the kind of\n// From, and kToKind is the kind of To; the value is\n// implementation-defined when the above pre-condition is violated.\ntemplate <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>\nusing LosslessArithmeticConvertibleImpl = std::integral_constant<\n    bool,\n    // clang-format off\n      // Converting from bool is always lossless\n      (kFromKind == kBool) ? true\n      // Converting between any other type kinds will be lossy if the type\n      // kinds are not the same.\n    : (kFromKind != kToKind) ? false\n    : (kFromKind == kInteger &&\n       // Converting between integers of different widths is allowed so long\n       // as the conversion does not go from signed to unsigned.\n      (((sizeof(From) < sizeof(To)) &&\n        !(std::is_signed<From>::value && !std::is_signed<To>::value)) ||\n       // Converting between integers of the same width only requires the\n       // two types to have the same signedness.\n       ((sizeof(From) == sizeof(To)) &&\n        (std::is_signed<From>::value == std::is_signed<To>::value)))\n       ) ? true\n      // Floating point conversions are lossless if and only if `To` is at least\n      // as wide as `From`.\n    : (kFromKind == kFloatingPoint && (sizeof(From) <= sizeof(To))) ? true\n    : false\n    // clang-format on\n    >;\n\n// LosslessArithmeticConvertible<From, To>::value is true if and only if\n// arithmetic type From can be losslessly converted to arithmetic type To.\n//\n// It's the user's responsibility to ensure that both From and To are\n// raw (i.e. has no CV modifier, is not a pointer, and is not a\n// reference) built-in arithmetic types; the value is\n// implementation-defined when the above pre-condition is violated.\ntemplate <typename From, typename To>\nusing LosslessArithmeticConvertible =\n    LosslessArithmeticConvertibleImpl<GMOCK_KIND_OF_(From), From,\n                                      GMOCK_KIND_OF_(To), To>;\n\n// This interface knows how to report a Google Mock failure (either\n// non-fatal or fatal).\nclass FailureReporterInterface {\n public:\n  // The type of a failure (either non-fatal or fatal).\n  enum FailureType {\n    kNonfatal, kFatal\n  };\n\n  virtual ~FailureReporterInterface() {}\n\n  // Reports a failure that occurred at the given source file location.\n  virtual void ReportFailure(FailureType type, const char* file, int line,\n                             const std::string& message) = 0;\n};\n\n// Returns the failure reporter used by Google Mock.\nGTEST_API_ FailureReporterInterface* GetFailureReporter();\n\n// Asserts that condition is true; aborts the process with the given\n// message if condition is false.  We cannot use LOG(FATAL) or CHECK()\n// as Google Mock might be used to mock the log sink itself.  We\n// inline this function to prevent it from showing up in the stack\n// trace.\ninline void Assert(bool condition, const char* file, int line,\n                   const std::string& msg) {\n  if (!condition) {\n    GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,\n                                        file, line, msg);\n  }\n}\ninline void Assert(bool condition, const char* file, int line) {\n  Assert(condition, file, line, \"Assertion failed.\");\n}\n\n// Verifies that condition is true; generates a non-fatal failure if\n// condition is false.\ninline void Expect(bool condition, const char* file, int line,\n                   const std::string& msg) {\n  if (!condition) {\n    GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,\n                                        file, line, msg);\n  }\n}\ninline void Expect(bool condition, const char* file, int line) {\n  Expect(condition, file, line, \"Expectation failed.\");\n}\n\n// Severity level of a log.\nenum LogSeverity {\n  kInfo = 0,\n  kWarning = 1\n};\n\n// Valid values for the --gmock_verbose flag.\n\n// All logs (informational and warnings) are printed.\nconst char kInfoVerbosity[] = \"info\";\n// Only warnings are printed.\nconst char kWarningVerbosity[] = \"warning\";\n// No logs are printed.\nconst char kErrorVerbosity[] = \"error\";\n\n// Returns true if and only if a log with the given severity is visible\n// according to the --gmock_verbose flag.\nGTEST_API_ bool LogIsVisible(LogSeverity severity);\n\n// Prints the given message to stdout if and only if 'severity' >= the level\n// specified by the --gmock_verbose flag.  If stack_frames_to_skip >=\n// 0, also prints the stack trace excluding the top\n// stack_frames_to_skip frames.  In opt mode, any positive\n// stack_frames_to_skip is treated as 0, since we don't know which\n// function calls will be inlined by the compiler and need to be\n// conservative.\nGTEST_API_ void Log(LogSeverity severity, const std::string& message,\n                    int stack_frames_to_skip);\n\n// A marker class that is used to resolve parameterless expectations to the\n// correct overload. This must not be instantiable, to prevent client code from\n// accidentally resolving to the overload; for example:\n//\n//    ON_CALL(mock, Method({}, nullptr))...\n//\nclass WithoutMatchers {\n private:\n  WithoutMatchers() {}\n  friend GTEST_API_ WithoutMatchers GetWithoutMatchers();\n};\n\n// Internal use only: access the singleton instance of WithoutMatchers.\nGTEST_API_ WithoutMatchers GetWithoutMatchers();\n\n// Disable MSVC warnings for infinite recursion, since in this case the\n// the recursion is unreachable.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4717)\n#endif\n\n// Invalid<T>() is usable as an expression of type T, but will terminate\n// the program with an assertion failure if actually run.  This is useful\n// when a value of type T is needed for compilation, but the statement\n// will not really be executed (or we don't care if the statement\n// crashes).\ntemplate <typename T>\ninline T Invalid() {\n  Assert(false, \"\", -1, \"Internal error: attempt to return invalid value\");\n  // This statement is unreachable, and would never terminate even if it\n  // could be reached. It is provided only to placate compiler warnings\n  // about missing return statements.\n  return Invalid<T>();\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n// Given a raw type (i.e. having no top-level reference or const\n// modifier) RawContainer that's either an STL-style container or a\n// native array, class StlContainerView<RawContainer> has the\n// following members:\n//\n//   - type is a type that provides an STL-style container view to\n//     (i.e. implements the STL container concept for) RawContainer;\n//   - const_reference is a type that provides a reference to a const\n//     RawContainer;\n//   - ConstReference(raw_container) returns a const reference to an STL-style\n//     container view to raw_container, which is a RawContainer.\n//   - Copy(raw_container) returns an STL-style container view of a\n//     copy of raw_container, which is a RawContainer.\n//\n// This generic version is used when RawContainer itself is already an\n// STL-style container.\ntemplate <class RawContainer>\nclass StlContainerView {\n public:\n  typedef RawContainer type;\n  typedef const type& const_reference;\n\n  static const_reference ConstReference(const RawContainer& container) {\n    static_assert(!std::is_const<RawContainer>::value,\n                  \"RawContainer type must not be const\");\n    return container;\n  }\n  static type Copy(const RawContainer& container) { return container; }\n};\n\n// This specialization is used when RawContainer is a native array type.\ntemplate <typename Element, size_t N>\nclass StlContainerView<Element[N]> {\n public:\n  typedef typename std::remove_const<Element>::type RawElement;\n  typedef internal::NativeArray<RawElement> type;\n  // NativeArray<T> can represent a native array either by value or by\n  // reference (selected by a constructor argument), so 'const type'\n  // can be used to reference a const native array.  We cannot\n  // 'typedef const type& const_reference' here, as that would mean\n  // ConstReference() has to return a reference to a local variable.\n  typedef const type const_reference;\n\n  static const_reference ConstReference(const Element (&array)[N]) {\n    static_assert(std::is_same<Element, RawElement>::value,\n                  \"Element type must not be const\");\n    return type(array, N, RelationToSourceReference());\n  }\n  static type Copy(const Element (&array)[N]) {\n    return type(array, N, RelationToSourceCopy());\n  }\n};\n\n// This specialization is used when RawContainer is a native array\n// represented as a (pointer, size) tuple.\ntemplate <typename ElementPointer, typename Size>\nclass StlContainerView< ::std::tuple<ElementPointer, Size> > {\n public:\n  typedef typename std::remove_const<\n      typename std::pointer_traits<ElementPointer>::element_type>::type\n      RawElement;\n  typedef internal::NativeArray<RawElement> type;\n  typedef const type const_reference;\n\n  static const_reference ConstReference(\n      const ::std::tuple<ElementPointer, Size>& array) {\n    return type(std::get<0>(array), std::get<1>(array),\n                RelationToSourceReference());\n  }\n  static type Copy(const ::std::tuple<ElementPointer, Size>& array) {\n    return type(std::get<0>(array), std::get<1>(array), RelationToSourceCopy());\n  }\n};\n\n// The following specialization prevents the user from instantiating\n// StlContainer with a reference type.\ntemplate <typename T> class StlContainerView<T&>;\n\n// A type transform to remove constness from the first part of a pair.\n// Pairs like that are used as the value_type of associative containers,\n// and this transform produces a similar but assignable pair.\ntemplate <typename T>\nstruct RemoveConstFromKey {\n  typedef T type;\n};\n\n// Partially specialized to remove constness from std::pair<const K, V>.\ntemplate <typename K, typename V>\nstruct RemoveConstFromKey<std::pair<const K, V> > {\n  typedef std::pair<K, V> type;\n};\n\n// Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to\n// reduce code size.\nGTEST_API_ void IllegalDoDefault(const char* file, int line);\n\ntemplate <typename F, typename Tuple, size_t... Idx>\nauto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype(\n    std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) {\n  return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);\n}\n\n// Apply the function to a tuple of arguments.\ntemplate <typename F, typename Tuple>\nauto Apply(F&& f, Tuple&& args) -> decltype(\n    ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),\n              MakeIndexSequence<std::tuple_size<\n                  typename std::remove_reference<Tuple>::type>::value>())) {\n  return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),\n                   MakeIndexSequence<std::tuple_size<\n                       typename std::remove_reference<Tuple>::type>::value>());\n}\n\n// Template struct Function<F>, where F must be a function type, contains\n// the following typedefs:\n//\n//   Result:               the function's return type.\n//   Arg<N>:               the type of the N-th argument, where N starts with 0.\n//   ArgumentTuple:        the tuple type consisting of all parameters of F.\n//   ArgumentMatcherTuple: the tuple type consisting of Matchers for all\n//                         parameters of F.\n//   MakeResultVoid:       the function type obtained by substituting void\n//                         for the return type of F.\n//   MakeResultIgnoredValue:\n//                         the function type obtained by substituting Something\n//                         for the return type of F.\ntemplate <typename T>\nstruct Function;\n\ntemplate <typename R, typename... Args>\nstruct Function<R(Args...)> {\n  using Result = R;\n  static constexpr size_t ArgumentCount = sizeof...(Args);\n  template <size_t I>\n  using Arg = ElemFromList<I, Args...>;\n  using ArgumentTuple = std::tuple<Args...>;\n  using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;\n  using MakeResultVoid = void(Args...);\n  using MakeResultIgnoredValue = IgnoredValue(Args...);\n};\n\ntemplate <typename R, typename... Args>\nconstexpr size_t Function<R(Args...)>::ArgumentCount;\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_\n\n// Expands and concatenates the arguments. Constructed macros reevaluate.\n#define GMOCK_PP_CAT(_1, _2) GMOCK_PP_INTERNAL_CAT(_1, _2)\n\n// Expands and stringifies the only argument.\n#define GMOCK_PP_STRINGIZE(...) GMOCK_PP_INTERNAL_STRINGIZE(__VA_ARGS__)\n\n// Returns empty. Given a variadic number of arguments.\n#define GMOCK_PP_EMPTY(...)\n\n// Returns a comma. Given a variadic number of arguments.\n#define GMOCK_PP_COMMA(...) ,\n\n// Returns the only argument.\n#define GMOCK_PP_IDENTITY(_1) _1\n\n// Evaluates to the number of arguments after expansion.\n//\n//   #define PAIR x, y\n//\n//   GMOCK_PP_NARG() => 1\n//   GMOCK_PP_NARG(x) => 1\n//   GMOCK_PP_NARG(x, y) => 2\n//   GMOCK_PP_NARG(PAIR) => 2\n//\n// Requires: the number of arguments after expansion is at most 15.\n#define GMOCK_PP_NARG(...) \\\n  GMOCK_PP_INTERNAL_16TH(  \\\n      (__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))\n\n// Returns 1 if the expansion of arguments has an unprotected comma. Otherwise\n// returns 0. Requires no more than 15 unprotected commas.\n#define GMOCK_PP_HAS_COMMA(...) \\\n  GMOCK_PP_INTERNAL_16TH(       \\\n      (__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0))\n\n// Returns the first argument.\n#define GMOCK_PP_HEAD(...) GMOCK_PP_INTERNAL_HEAD((__VA_ARGS__, unusedArg))\n\n// Returns the tail. A variadic list of all arguments minus the first. Requires\n// at least one argument.\n#define GMOCK_PP_TAIL(...) GMOCK_PP_INTERNAL_TAIL((__VA_ARGS__))\n\n// Calls CAT(_Macro, NARG(__VA_ARGS__))(__VA_ARGS__)\n#define GMOCK_PP_VARIADIC_CALL(_Macro, ...) \\\n  GMOCK_PP_IDENTITY(                        \\\n      GMOCK_PP_CAT(_Macro, GMOCK_PP_NARG(__VA_ARGS__))(__VA_ARGS__))\n\n// If the arguments after expansion have no tokens, evaluates to `1`. Otherwise\n// evaluates to `0`.\n//\n// Requires: * the number of arguments after expansion is at most 15.\n//           * If the argument is a macro, it must be able to be called with one\n//             argument.\n//\n// Implementation details:\n//\n// There is one case when it generates a compile error: if the argument is macro\n// that cannot be called with one argument.\n//\n//   #define M(a, b)  // it doesn't matter what it expands to\n//\n//   // Expected: expands to `0`.\n//   // Actual: compile error.\n//   GMOCK_PP_IS_EMPTY(M)\n//\n// There are 4 cases tested:\n//\n// * __VA_ARGS__ possible expansion has no unparen'd commas. Expected 0.\n// * __VA_ARGS__ possible expansion is not enclosed in parenthesis. Expected 0.\n// * __VA_ARGS__ possible expansion is not a macro that ()-evaluates to a comma.\n//   Expected 0\n// * __VA_ARGS__ is empty, or has unparen'd commas, or is enclosed in\n//   parenthesis, or is a macro that ()-evaluates to comma. Expected 1.\n//\n// We trigger detection on '0001', i.e. on empty.\n#define GMOCK_PP_IS_EMPTY(...)                                               \\\n  GMOCK_PP_INTERNAL_IS_EMPTY(GMOCK_PP_HAS_COMMA(__VA_ARGS__),                \\\n                             GMOCK_PP_HAS_COMMA(GMOCK_PP_COMMA __VA_ARGS__), \\\n                             GMOCK_PP_HAS_COMMA(__VA_ARGS__()),              \\\n                             GMOCK_PP_HAS_COMMA(GMOCK_PP_COMMA __VA_ARGS__()))\n\n// Evaluates to _Then if _Cond is 1 and _Else if _Cond is 0.\n#define GMOCK_PP_IF(_Cond, _Then, _Else) \\\n  GMOCK_PP_CAT(GMOCK_PP_INTERNAL_IF_, _Cond)(_Then, _Else)\n\n// Similar to GMOCK_PP_IF but takes _Then and _Else in parentheses.\n//\n// GMOCK_PP_GENERIC_IF(1, (a, b, c), (d, e, f)) => a, b, c\n// GMOCK_PP_GENERIC_IF(0, (a, b, c), (d, e, f)) => d, e, f\n//\n#define GMOCK_PP_GENERIC_IF(_Cond, _Then, _Else) \\\n  GMOCK_PP_REMOVE_PARENS(GMOCK_PP_IF(_Cond, _Then, _Else))\n\n// Evaluates to the number of arguments after expansion. Identifies 'empty' as\n// 0.\n//\n//   #define PAIR x, y\n//\n//   GMOCK_PP_NARG0() => 0\n//   GMOCK_PP_NARG0(x) => 1\n//   GMOCK_PP_NARG0(x, y) => 2\n//   GMOCK_PP_NARG0(PAIR) => 2\n//\n// Requires: * the number of arguments after expansion is at most 15.\n//           * If the argument is a macro, it must be able to be called with one\n//             argument.\n#define GMOCK_PP_NARG0(...) \\\n  GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(__VA_ARGS__), 0, GMOCK_PP_NARG(__VA_ARGS__))\n\n// Expands to 1 if the first argument starts with something in parentheses,\n// otherwise to 0.\n#define GMOCK_PP_IS_BEGIN_PARENS(...)                              \\\n  GMOCK_PP_HEAD(GMOCK_PP_CAT(GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_, \\\n                             GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C __VA_ARGS__))\n\n// Expands to 1 is there is only one argument and it is enclosed in parentheses.\n#define GMOCK_PP_IS_ENCLOSED_PARENS(...)             \\\n  GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(__VA_ARGS__), \\\n              GMOCK_PP_IS_EMPTY(GMOCK_PP_EMPTY __VA_ARGS__), 0)\n\n// Remove the parens, requires GMOCK_PP_IS_ENCLOSED_PARENS(args) => 1.\n#define GMOCK_PP_REMOVE_PARENS(...) GMOCK_PP_INTERNAL_REMOVE_PARENS __VA_ARGS__\n\n// Expands to _Macro(0, _Data, e1) _Macro(1, _Data, e2) ... _Macro(K -1, _Data,\n// eK) as many of GMOCK_INTERNAL_NARG0 _Tuple.\n// Requires: * |_Macro| can be called with 3 arguments.\n//           * |_Tuple| expansion has no more than 15 elements.\n#define GMOCK_PP_FOR_EACH(_Macro, _Data, _Tuple)                        \\\n  GMOCK_PP_CAT(GMOCK_PP_INTERNAL_FOR_EACH_IMPL_, GMOCK_PP_NARG0 _Tuple) \\\n  (0, _Macro, _Data, _Tuple)\n\n// Expands to _Macro(0, _Data, ) _Macro(1, _Data, ) ... _Macro(K - 1, _Data, )\n// Empty if _K = 0.\n// Requires: * |_Macro| can be called with 3 arguments.\n//           * |_K| literal between 0 and 15\n#define GMOCK_PP_REPEAT(_Macro, _Data, _N)           \\\n  GMOCK_PP_CAT(GMOCK_PP_INTERNAL_FOR_EACH_IMPL_, _N) \\\n  (0, _Macro, _Data, GMOCK_PP_INTENRAL_EMPTY_TUPLE)\n\n// Increments the argument, requires the argument to be between 0 and 15.\n#define GMOCK_PP_INC(_i) GMOCK_PP_CAT(GMOCK_PP_INTERNAL_INC_, _i)\n\n// Returns comma if _i != 0. Requires _i to be between 0 and 15.\n#define GMOCK_PP_COMMA_IF(_i) GMOCK_PP_CAT(GMOCK_PP_INTERNAL_COMMA_IF_, _i)\n\n// Internal details follow. Do not use any of these symbols outside of this\n// file or we will break your code.\n#define GMOCK_PP_INTENRAL_EMPTY_TUPLE (, , , , , , , , , , , , , , , )\n#define GMOCK_PP_INTERNAL_CAT(_1, _2) _1##_2\n#define GMOCK_PP_INTERNAL_STRINGIZE(...) #__VA_ARGS__\n#define GMOCK_PP_INTERNAL_CAT_5(_1, _2, _3, _4, _5) _1##_2##_3##_4##_5\n#define GMOCK_PP_INTERNAL_IS_EMPTY(_1, _2, _3, _4)                             \\\n  GMOCK_PP_HAS_COMMA(GMOCK_PP_INTERNAL_CAT_5(GMOCK_PP_INTERNAL_IS_EMPTY_CASE_, \\\n                                             _1, _2, _3, _4))\n#define GMOCK_PP_INTERNAL_IS_EMPTY_CASE_0001 ,\n#define GMOCK_PP_INTERNAL_IF_1(_Then, _Else) _Then\n#define GMOCK_PP_INTERNAL_IF_0(_Then, _Else) _Else\n\n// Because of MSVC treating a token with a comma in it as a single token when\n// passed to another macro, we need to force it to evaluate it as multiple\n// tokens. We do that by using a \"IDENTITY(MACRO PARENTHESIZED_ARGS)\" macro. We\n// define one per possible macro that relies on this behavior. Note \"_Args\" must\n// be parenthesized.\n#define GMOCK_PP_INTERNAL_INTERNAL_16TH(_1, _2, _3, _4, _5, _6, _7, _8, _9, \\\n                                        _10, _11, _12, _13, _14, _15, _16,  \\\n                                        ...)                                \\\n  _16\n#define GMOCK_PP_INTERNAL_16TH(_Args) \\\n  GMOCK_PP_IDENTITY(GMOCK_PP_INTERNAL_INTERNAL_16TH _Args)\n#define GMOCK_PP_INTERNAL_INTERNAL_HEAD(_1, ...) _1\n#define GMOCK_PP_INTERNAL_HEAD(_Args) \\\n  GMOCK_PP_IDENTITY(GMOCK_PP_INTERNAL_INTERNAL_HEAD _Args)\n#define GMOCK_PP_INTERNAL_INTERNAL_TAIL(_1, ...) __VA_ARGS__\n#define GMOCK_PP_INTERNAL_TAIL(_Args) \\\n  GMOCK_PP_IDENTITY(GMOCK_PP_INTERNAL_INTERNAL_TAIL _Args)\n\n#define GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C(...) 1 _\n#define GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_1 1,\n#define GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C \\\n  0,\n#define GMOCK_PP_INTERNAL_REMOVE_PARENS(...) __VA_ARGS__\n#define GMOCK_PP_INTERNAL_INC_0 1\n#define GMOCK_PP_INTERNAL_INC_1 2\n#define GMOCK_PP_INTERNAL_INC_2 3\n#define GMOCK_PP_INTERNAL_INC_3 4\n#define GMOCK_PP_INTERNAL_INC_4 5\n#define GMOCK_PP_INTERNAL_INC_5 6\n#define GMOCK_PP_INTERNAL_INC_6 7\n#define GMOCK_PP_INTERNAL_INC_7 8\n#define GMOCK_PP_INTERNAL_INC_8 9\n#define GMOCK_PP_INTERNAL_INC_9 10\n#define GMOCK_PP_INTERNAL_INC_10 11\n#define GMOCK_PP_INTERNAL_INC_11 12\n#define GMOCK_PP_INTERNAL_INC_12 13\n#define GMOCK_PP_INTERNAL_INC_13 14\n#define GMOCK_PP_INTERNAL_INC_14 15\n#define GMOCK_PP_INTERNAL_INC_15 16\n#define GMOCK_PP_INTERNAL_COMMA_IF_0\n#define GMOCK_PP_INTERNAL_COMMA_IF_1 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_2 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_3 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_4 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_5 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_6 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_7 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_8 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_9 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_10 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_11 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_12 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_13 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_14 ,\n#define GMOCK_PP_INTERNAL_COMMA_IF_15 ,\n#define GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, _element) \\\n  _Macro(_i, _Data, _element)\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_0(_i, _Macro, _Data, _Tuple)\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_1(_i, _Macro, _Data, _Tuple) \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple)\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_2(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_1(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_3(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_2(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_4(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_3(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_5(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_4(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_6(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_5(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_7(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_6(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_8(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_7(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_9(_i, _Macro, _Data, _Tuple)    \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_8(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_10(_i, _Macro, _Data, _Tuple)   \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_9(GMOCK_PP_INC(_i), _Macro, _Data,    \\\n                                    (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_11(_i, _Macro, _Data, _Tuple)   \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_10(GMOCK_PP_INC(_i), _Macro, _Data,   \\\n                                     (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_12(_i, _Macro, _Data, _Tuple)   \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_11(GMOCK_PP_INC(_i), _Macro, _Data,   \\\n                                     (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_13(_i, _Macro, _Data, _Tuple)   \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_12(GMOCK_PP_INC(_i), _Macro, _Data,   \\\n                                     (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(_i, _Macro, _Data, _Tuple)   \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_13(GMOCK_PP_INC(_i), _Macro, _Data,   \\\n                                     (GMOCK_PP_TAIL _Tuple))\n#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_15(_i, _Macro, _Data, _Tuple)   \\\n  GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \\\n  GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(GMOCK_PP_INC(_i), _Macro, _Data,   \\\n                                     (GMOCK_PP_TAIL _Tuple))\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_\n\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\nnamespace testing {\n\n// To implement an action Foo, define:\n//   1. a class FooAction that implements the ActionInterface interface, and\n//   2. a factory function that creates an Action object from a\n//      const FooAction*.\n//\n// The two-level delegation design follows that of Matcher, providing\n// consistency for extension developers.  It also eases ownership\n// management as Action objects can now be copied like plain values.\n\nnamespace internal {\n\n// BuiltInDefaultValueGetter<T, true>::Get() returns a\n// default-constructed T value.  BuiltInDefaultValueGetter<T,\n// false>::Get() crashes with an error.\n//\n// This primary template is used when kDefaultConstructible is true.\ntemplate <typename T, bool kDefaultConstructible>\nstruct BuiltInDefaultValueGetter {\n  static T Get() { return T(); }\n};\ntemplate <typename T>\nstruct BuiltInDefaultValueGetter<T, false> {\n  static T Get() {\n    Assert(false, __FILE__, __LINE__,\n           \"Default action undefined for the function return type.\");\n    return internal::Invalid<T>();\n    // The above statement will never be reached, but is required in\n    // order for this function to compile.\n  }\n};\n\n// BuiltInDefaultValue<T>::Get() returns the \"built-in\" default value\n// for type T, which is NULL when T is a raw pointer type, 0 when T is\n// a numeric type, false when T is bool, or \"\" when T is string or\n// std::string.  In addition, in C++11 and above, it turns a\n// default-constructed T value if T is default constructible.  For any\n// other type T, the built-in default T value is undefined, and the\n// function will abort the process.\ntemplate <typename T>\nclass BuiltInDefaultValue {\n public:\n  // This function returns true if and only if type T has a built-in default\n  // value.\n  static bool Exists() {\n    return ::std::is_default_constructible<T>::value;\n  }\n\n  static T Get() {\n    return BuiltInDefaultValueGetter<\n        T, ::std::is_default_constructible<T>::value>::Get();\n  }\n};\n\n// This partial specialization says that we use the same built-in\n// default value for T and const T.\ntemplate <typename T>\nclass BuiltInDefaultValue<const T> {\n public:\n  static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }\n  static T Get() { return BuiltInDefaultValue<T>::Get(); }\n};\n\n// This partial specialization defines the default values for pointer\n// types.\ntemplate <typename T>\nclass BuiltInDefaultValue<T*> {\n public:\n  static bool Exists() { return true; }\n  static T* Get() { return nullptr; }\n};\n\n// The following specializations define the default values for\n// specific types we care about.\n#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \\\n  template <> \\\n  class BuiltInDefaultValue<type> { \\\n   public: \\\n    static bool Exists() { return true; } \\\n    static type Get() { return value; } \\\n  }\n\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, );  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, \"\");\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\\0');\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\\0');\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\\0');\n\n// There's no need for a default action for signed wchar_t, as that\n// type is the same as wchar_t for gcc, and invalid for MSVC.\n//\n// There's also no need for a default action for unsigned wchar_t, as\n// that type is the same as unsigned int for gcc, and invalid for\n// MSVC.\n#if GMOCK_WCHAR_T_IS_NATIVE_\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U);  // NOLINT\n#endif\n\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U);  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0);     // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL);  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L);     // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long long, 0);  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long long, 0);  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);\n\n#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_\n\n// Simple two-arg form of std::disjunction.\ntemplate <typename P, typename Q>\nusing disjunction = typename ::std::conditional<P::value, P, Q>::type;\n\n}  // namespace internal\n\n// When an unexpected function call is encountered, Google Mock will\n// let it return a default value if the user has specified one for its\n// return type, or if the return type has a built-in default value;\n// otherwise Google Mock won't know what value to return and will have\n// to abort the process.\n//\n// The DefaultValue<T> class allows a user to specify the\n// default value for a type T that is both copyable and publicly\n// destructible (i.e. anything that can be used as a function return\n// type).  The usage is:\n//\n//   // Sets the default value for type T to be foo.\n//   DefaultValue<T>::Set(foo);\ntemplate <typename T>\nclass DefaultValue {\n public:\n  // Sets the default value for type T; requires T to be\n  // copy-constructable and have a public destructor.\n  static void Set(T x) {\n    delete producer_;\n    producer_ = new FixedValueProducer(x);\n  }\n\n  // Provides a factory function to be called to generate the default value.\n  // This method can be used even if T is only move-constructible, but it is not\n  // limited to that case.\n  typedef T (*FactoryFunction)();\n  static void SetFactory(FactoryFunction factory) {\n    delete producer_;\n    producer_ = new FactoryValueProducer(factory);\n  }\n\n  // Unsets the default value for type T.\n  static void Clear() {\n    delete producer_;\n    producer_ = nullptr;\n  }\n\n  // Returns true if and only if the user has set the default value for type T.\n  static bool IsSet() { return producer_ != nullptr; }\n\n  // Returns true if T has a default return value set by the user or there\n  // exists a built-in default value.\n  static bool Exists() {\n    return IsSet() || internal::BuiltInDefaultValue<T>::Exists();\n  }\n\n  // Returns the default value for type T if the user has set one;\n  // otherwise returns the built-in default value. Requires that Exists()\n  // is true, which ensures that the return value is well-defined.\n  static T Get() {\n    return producer_ == nullptr ? internal::BuiltInDefaultValue<T>::Get()\n                                : producer_->Produce();\n  }\n\n private:\n  class ValueProducer {\n   public:\n    virtual ~ValueProducer() {}\n    virtual T Produce() = 0;\n  };\n\n  class FixedValueProducer : public ValueProducer {\n   public:\n    explicit FixedValueProducer(T value) : value_(value) {}\n    T Produce() override { return value_; }\n\n   private:\n    const T value_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(FixedValueProducer);\n  };\n\n  class FactoryValueProducer : public ValueProducer {\n   public:\n    explicit FactoryValueProducer(FactoryFunction factory)\n        : factory_(factory) {}\n    T Produce() override { return factory_(); }\n\n   private:\n    const FactoryFunction factory_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(FactoryValueProducer);\n  };\n\n  static ValueProducer* producer_;\n};\n\n// This partial specialization allows a user to set default values for\n// reference types.\ntemplate <typename T>\nclass DefaultValue<T&> {\n public:\n  // Sets the default value for type T&.\n  static void Set(T& x) {  // NOLINT\n    address_ = &x;\n  }\n\n  // Unsets the default value for type T&.\n  static void Clear() { address_ = nullptr; }\n\n  // Returns true if and only if the user has set the default value for type T&.\n  static bool IsSet() { return address_ != nullptr; }\n\n  // Returns true if T has a default return value set by the user or there\n  // exists a built-in default value.\n  static bool Exists() {\n    return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();\n  }\n\n  // Returns the default value for type T& if the user has set one;\n  // otherwise returns the built-in default value if there is one;\n  // otherwise aborts the process.\n  static T& Get() {\n    return address_ == nullptr ? internal::BuiltInDefaultValue<T&>::Get()\n                               : *address_;\n  }\n\n private:\n  static T* address_;\n};\n\n// This specialization allows DefaultValue<void>::Get() to\n// compile.\ntemplate <>\nclass DefaultValue<void> {\n public:\n  static bool Exists() { return true; }\n  static void Get() {}\n};\n\n// Points to the user-set default value for type T.\ntemplate <typename T>\ntypename DefaultValue<T>::ValueProducer* DefaultValue<T>::producer_ = nullptr;\n\n// Points to the user-set default value for type T&.\ntemplate <typename T>\nT* DefaultValue<T&>::address_ = nullptr;\n\n// Implement this interface to define an action for function type F.\ntemplate <typename F>\nclass ActionInterface {\n public:\n  typedef typename internal::Function<F>::Result Result;\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  ActionInterface() {}\n  virtual ~ActionInterface() {}\n\n  // Performs the action.  This method is not const, as in general an\n  // action can have side effects and be stateful.  For example, a\n  // get-the-next-element-from-the-collection action will need to\n  // remember the current element.\n  virtual Result Perform(const ArgumentTuple& args) = 0;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);\n};\n\n// An Action<F> is a copyable and IMMUTABLE (except by assignment)\n// object that represents an action to be taken when a mock function\n// of type F is called.  The implementation of Action<T> is just a\n// std::shared_ptr to const ActionInterface<T>. Don't inherit from Action!\n// You can view an object implementing ActionInterface<F> as a\n// concrete action (including its current state), and an Action<F>\n// object as a handle to it.\ntemplate <typename F>\nclass Action {\n  // Adapter class to allow constructing Action from a legacy ActionInterface.\n  // New code should create Actions from functors instead.\n  struct ActionAdapter {\n    // Adapter must be copyable to satisfy std::function requirements.\n    ::std::shared_ptr<ActionInterface<F>> impl_;\n\n    template <typename... Args>\n    typename internal::Function<F>::Result operator()(Args&&... args) {\n      return impl_->Perform(\n          ::std::forward_as_tuple(::std::forward<Args>(args)...));\n    }\n  };\n\n  template <typename G>\n  using IsCompatibleFunctor = std::is_constructible<std::function<F>, G>;\n\n public:\n  typedef typename internal::Function<F>::Result Result;\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  // Constructs a null Action.  Needed for storing Action objects in\n  // STL containers.\n  Action() {}\n\n  // Construct an Action from a specified callable.\n  // This cannot take std::function directly, because then Action would not be\n  // directly constructible from lambda (it would require two conversions).\n  template <\n      typename G,\n      typename = typename std::enable_if<internal::disjunction<\n          IsCompatibleFunctor<G>, std::is_constructible<std::function<Result()>,\n                                                        G>>::value>::type>\n  Action(G&& fun) {  // NOLINT\n    Init(::std::forward<G>(fun), IsCompatibleFunctor<G>());\n  }\n\n  // Constructs an Action from its implementation.\n  explicit Action(ActionInterface<F>* impl)\n      : fun_(ActionAdapter{::std::shared_ptr<ActionInterface<F>>(impl)}) {}\n\n  // This constructor allows us to turn an Action<Func> object into an\n  // Action<F>, as long as F's arguments can be implicitly converted\n  // to Func's and Func's return type can be implicitly converted to F's.\n  template <typename Func>\n  explicit Action(const Action<Func>& action) : fun_(action.fun_) {}\n\n  // Returns true if and only if this is the DoDefault() action.\n  bool IsDoDefault() const { return fun_ == nullptr; }\n\n  // Performs the action.  Note that this method is const even though\n  // the corresponding method in ActionInterface is not.  The reason\n  // is that a const Action<F> means that it cannot be re-bound to\n  // another concrete action, not that the concrete action it binds to\n  // cannot change state.  (Think of the difference between a const\n  // pointer and a pointer to const.)\n  Result Perform(ArgumentTuple args) const {\n    if (IsDoDefault()) {\n      internal::IllegalDoDefault(__FILE__, __LINE__);\n    }\n    return internal::Apply(fun_, ::std::move(args));\n  }\n\n private:\n  template <typename G>\n  friend class Action;\n\n  template <typename G>\n  void Init(G&& g, ::std::true_type) {\n    fun_ = ::std::forward<G>(g);\n  }\n\n  template <typename G>\n  void Init(G&& g, ::std::false_type) {\n    fun_ = IgnoreArgs<typename ::std::decay<G>::type>{::std::forward<G>(g)};\n  }\n\n  template <typename FunctionImpl>\n  struct IgnoreArgs {\n    template <typename... Args>\n    Result operator()(const Args&...) const {\n      return function_impl();\n    }\n\n    FunctionImpl function_impl;\n  };\n\n  // fun_ is an empty function if and only if this is the DoDefault() action.\n  ::std::function<F> fun_;\n};\n\n// The PolymorphicAction class template makes it easy to implement a\n// polymorphic action (i.e. an action that can be used in mock\n// functions of than one type, e.g. Return()).\n//\n// To define a polymorphic action, a user first provides a COPYABLE\n// implementation class that has a Perform() method template:\n//\n//   class FooAction {\n//    public:\n//     template <typename Result, typename ArgumentTuple>\n//     Result Perform(const ArgumentTuple& args) const {\n//       // Processes the arguments and returns a result, using\n//       // std::get<N>(args) to get the N-th (0-based) argument in the tuple.\n//     }\n//     ...\n//   };\n//\n// Then the user creates the polymorphic action using\n// MakePolymorphicAction(object) where object has type FooAction.  See\n// the definition of Return(void) and SetArgumentPointee<N>(value) for\n// complete examples.\ntemplate <typename Impl>\nclass PolymorphicAction {\n public:\n  explicit PolymorphicAction(const Impl& impl) : impl_(impl) {}\n\n  template <typename F>\n  operator Action<F>() const {\n    return Action<F>(new MonomorphicImpl<F>(impl_));\n  }\n\n private:\n  template <typename F>\n  class MonomorphicImpl : public ActionInterface<F> {\n   public:\n    typedef typename internal::Function<F>::Result Result;\n    typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}\n\n    Result Perform(const ArgumentTuple& args) override {\n      return impl_.template Perform<Result>(args);\n    }\n\n   private:\n    Impl impl_;\n  };\n\n  Impl impl_;\n};\n\n// Creates an Action from its implementation and returns it.  The\n// created Action object owns the implementation.\ntemplate <typename F>\nAction<F> MakeAction(ActionInterface<F>* impl) {\n  return Action<F>(impl);\n}\n\n// Creates a polymorphic action from its implementation.  This is\n// easier to use than the PolymorphicAction<Impl> constructor as it\n// doesn't require you to explicitly write the template argument, e.g.\n//\n//   MakePolymorphicAction(foo);\n// vs\n//   PolymorphicAction<TypeOfFoo>(foo);\ntemplate <typename Impl>\ninline PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl) {\n  return PolymorphicAction<Impl>(impl);\n}\n\nnamespace internal {\n\n// Helper struct to specialize ReturnAction to execute a move instead of a copy\n// on return. Useful for move-only types, but could be used on any type.\ntemplate <typename T>\nstruct ByMoveWrapper {\n  explicit ByMoveWrapper(T value) : payload(std::move(value)) {}\n  T payload;\n};\n\n// Implements the polymorphic Return(x) action, which can be used in\n// any function that returns the type of x, regardless of the argument\n// types.\n//\n// Note: The value passed into Return must be converted into\n// Function<F>::Result when this action is cast to Action<F> rather than\n// when that action is performed. This is important in scenarios like\n//\n// MOCK_METHOD1(Method, T(U));\n// ...\n// {\n//   Foo foo;\n//   X x(&foo);\n//   EXPECT_CALL(mock, Method(_)).WillOnce(Return(x));\n// }\n//\n// In the example above the variable x holds reference to foo which leaves\n// scope and gets destroyed.  If copying X just copies a reference to foo,\n// that copy will be left with a hanging reference.  If conversion to T\n// makes a copy of foo, the above code is safe. To support that scenario, we\n// need to make sure that the type conversion happens inside the EXPECT_CALL\n// statement, and conversion of the result of Return to Action<T(U)> is a\n// good place for that.\n//\n// The real life example of the above scenario happens when an invocation\n// of gtl::Container() is passed into Return.\n//\ntemplate <typename R>\nclass ReturnAction {\n public:\n  // Constructs a ReturnAction object from the value to be returned.\n  // 'value' is passed by value instead of by const reference in order\n  // to allow Return(\"string literal\") to compile.\n  explicit ReturnAction(R value) : value_(new R(std::move(value))) {}\n\n  // This template type conversion operator allows Return(x) to be\n  // used in ANY function that returns x's type.\n  template <typename F>\n  operator Action<F>() const {  // NOLINT\n    // Assert statement belongs here because this is the best place to verify\n    // conditions on F. It produces the clearest error messages\n    // in most compilers.\n    // Impl really belongs in this scope as a local class but can't\n    // because MSVC produces duplicate symbols in different translation units\n    // in this case. Until MS fixes that bug we put Impl into the class scope\n    // and put the typedef both here (for use in assert statement) and\n    // in the Impl class. But both definitions must be the same.\n    typedef typename Function<F>::Result Result;\n    GTEST_COMPILE_ASSERT_(\n        !std::is_reference<Result>::value,\n        use_ReturnRef_instead_of_Return_to_return_a_reference);\n    static_assert(!std::is_void<Result>::value,\n                  \"Can't use Return() on an action expected to return `void`.\");\n    return Action<F>(new Impl<R, F>(value_));\n  }\n\n private:\n  // Implements the Return(x) action for a particular function type F.\n  template <typename R_, typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    // The implicit cast is necessary when Result has more than one\n    // single-argument constructor (e.g. Result is std::vector<int>) and R\n    // has a type conversion operator template.  In that case, value_(value)\n    // won't compile as the compiler doesn't known which constructor of\n    // Result to call.  ImplicitCast_ forces the compiler to convert R to\n    // Result without considering explicit constructors, thus resolving the\n    // ambiguity. value_ is then initialized using its copy constructor.\n    explicit Impl(const std::shared_ptr<R>& value)\n        : value_before_cast_(*value),\n          value_(ImplicitCast_<Result>(value_before_cast_)) {}\n\n    Result Perform(const ArgumentTuple&) override { return value_; }\n\n   private:\n    GTEST_COMPILE_ASSERT_(!std::is_reference<Result>::value,\n                          Result_cannot_be_a_reference_type);\n    // We save the value before casting just in case it is being cast to a\n    // wrapper type.\n    R value_before_cast_;\n    Result value_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);\n  };\n\n  // Partially specialize for ByMoveWrapper. This version of ReturnAction will\n  // move its contents instead.\n  template <typename R_, typename F>\n  class Impl<ByMoveWrapper<R_>, F> : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const std::shared_ptr<R>& wrapper)\n        : performed_(false), wrapper_(wrapper) {}\n\n    Result Perform(const ArgumentTuple&) override {\n      GTEST_CHECK_(!performed_)\n          << \"A ByMove() action should only be performed once.\";\n      performed_ = true;\n      return std::move(wrapper_->payload);\n    }\n\n   private:\n    bool performed_;\n    const std::shared_ptr<R> wrapper_;\n  };\n\n  const std::shared_ptr<R> value_;\n};\n\n// Implements the ReturnNull() action.\nclass ReturnNullAction {\n public:\n  // Allows ReturnNull() to be used in any pointer-returning function. In C++11\n  // this is enforced by returning nullptr, and in non-C++11 by asserting a\n  // pointer type on compile time.\n  template <typename Result, typename ArgumentTuple>\n  static Result Perform(const ArgumentTuple&) {\n    return nullptr;\n  }\n};\n\n// Implements the Return() action.\nclass ReturnVoidAction {\n public:\n  // Allows Return() to be used in any void-returning function.\n  template <typename Result, typename ArgumentTuple>\n  static void Perform(const ArgumentTuple&) {\n    static_assert(std::is_void<Result>::value, \"Result should be void.\");\n  }\n};\n\n// Implements the polymorphic ReturnRef(x) action, which can be used\n// in any function that returns a reference to the type of x,\n// regardless of the argument types.\ntemplate <typename T>\nclass ReturnRefAction {\n public:\n  // Constructs a ReturnRefAction object from the reference to be returned.\n  explicit ReturnRefAction(T& ref) : ref_(ref) {}  // NOLINT\n\n  // This template type conversion operator allows ReturnRef(x) to be\n  // used in ANY function that returns a reference to x's type.\n  template <typename F>\n  operator Action<F>() const {\n    typedef typename Function<F>::Result Result;\n    // Asserts that the function return type is a reference.  This\n    // catches the user error of using ReturnRef(x) when Return(x)\n    // should be used, and generates some helpful error message.\n    GTEST_COMPILE_ASSERT_(std::is_reference<Result>::value,\n                          use_Return_instead_of_ReturnRef_to_return_a_value);\n    return Action<F>(new Impl<F>(ref_));\n  }\n\n private:\n  // Implements the ReturnRef(x) action for a particular function type F.\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(T& ref) : ref_(ref) {}  // NOLINT\n\n    Result Perform(const ArgumentTuple&) override { return ref_; }\n\n   private:\n    T& ref_;\n  };\n\n  T& ref_;\n};\n\n// Implements the polymorphic ReturnRefOfCopy(x) action, which can be\n// used in any function that returns a reference to the type of x,\n// regardless of the argument types.\ntemplate <typename T>\nclass ReturnRefOfCopyAction {\n public:\n  // Constructs a ReturnRefOfCopyAction object from the reference to\n  // be returned.\n  explicit ReturnRefOfCopyAction(const T& value) : value_(value) {}  // NOLINT\n\n  // This template type conversion operator allows ReturnRefOfCopy(x) to be\n  // used in ANY function that returns a reference to x's type.\n  template <typename F>\n  operator Action<F>() const {\n    typedef typename Function<F>::Result Result;\n    // Asserts that the function return type is a reference.  This\n    // catches the user error of using ReturnRefOfCopy(x) when Return(x)\n    // should be used, and generates some helpful error message.\n    GTEST_COMPILE_ASSERT_(\n        std::is_reference<Result>::value,\n        use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);\n    return Action<F>(new Impl<F>(value_));\n  }\n\n private:\n  // Implements the ReturnRefOfCopy(x) action for a particular function type F.\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const T& value) : value_(value) {}  // NOLINT\n\n    Result Perform(const ArgumentTuple&) override { return value_; }\n\n   private:\n    T value_;\n  };\n\n  const T value_;\n};\n\n// Implements the polymorphic ReturnRoundRobin(v) action, which can be\n// used in any function that returns the element_type of v.\ntemplate <typename T>\nclass ReturnRoundRobinAction {\n public:\n  explicit ReturnRoundRobinAction(std::vector<T> values) {\n    GTEST_CHECK_(!values.empty())\n        << \"ReturnRoundRobin requires at least one element.\";\n    state_->values = std::move(values);\n  }\n\n  template <typename... Args>\n  T operator()(Args&&...) const {\n     return state_->Next();\n  }\n\n private:\n  struct State {\n    T Next() {\n      T ret_val = values[i++];\n      if (i == values.size()) i = 0;\n      return ret_val;\n    }\n\n    std::vector<T> values;\n    size_t i = 0;\n  };\n  std::shared_ptr<State> state_ = std::make_shared<State>();\n};\n\n// Implements the polymorphic DoDefault() action.\nclass DoDefaultAction {\n public:\n  // This template type conversion operator allows DoDefault() to be\n  // used in any function.\n  template <typename F>\n  operator Action<F>() const { return Action<F>(); }  // NOLINT\n};\n\n// Implements the Assign action to set a given pointer referent to a\n// particular value.\ntemplate <typename T1, typename T2>\nclass AssignAction {\n public:\n  AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}\n\n  template <typename Result, typename ArgumentTuple>\n  void Perform(const ArgumentTuple& /* args */) const {\n    *ptr_ = value_;\n  }\n\n private:\n  T1* const ptr_;\n  const T2 value_;\n};\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\n// Implements the SetErrnoAndReturn action to simulate return from\n// various system calls and libc functions.\ntemplate <typename T>\nclass SetErrnoAndReturnAction {\n public:\n  SetErrnoAndReturnAction(int errno_value, T result)\n      : errno_(errno_value),\n        result_(result) {}\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple& /* args */) const {\n    errno = errno_;\n    return result_;\n  }\n\n private:\n  const int errno_;\n  const T result_;\n};\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Implements the SetArgumentPointee<N>(x) action for any function\n// whose N-th argument (0-based) is a pointer to x's type.\ntemplate <size_t N, typename A, typename = void>\nstruct SetArgumentPointeeAction {\n  A value;\n\n  template <typename... Args>\n  void operator()(const Args&... args) const {\n    *::std::get<N>(std::tie(args...)) = value;\n  }\n};\n\n// Implements the Invoke(object_ptr, &Class::Method) action.\ntemplate <class Class, typename MethodPtr>\nstruct InvokeMethodAction {\n  Class* const obj_ptr;\n  const MethodPtr method_ptr;\n\n  template <typename... Args>\n  auto operator()(Args&&... args) const\n      -> decltype((obj_ptr->*method_ptr)(std::forward<Args>(args)...)) {\n    return (obj_ptr->*method_ptr)(std::forward<Args>(args)...);\n  }\n};\n\n// Implements the InvokeWithoutArgs(f) action.  The template argument\n// FunctionImpl is the implementation type of f, which can be either a\n// function pointer or a functor.  InvokeWithoutArgs(f) can be used as an\n// Action<F> as long as f's type is compatible with F.\ntemplate <typename FunctionImpl>\nstruct InvokeWithoutArgsAction {\n  FunctionImpl function_impl;\n\n  // Allows InvokeWithoutArgs(f) to be used as any action whose type is\n  // compatible with f.\n  template <typename... Args>\n  auto operator()(const Args&...) -> decltype(function_impl()) {\n    return function_impl();\n  }\n};\n\n// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.\ntemplate <class Class, typename MethodPtr>\nstruct InvokeMethodWithoutArgsAction {\n  Class* const obj_ptr;\n  const MethodPtr method_ptr;\n\n  using ReturnType =\n      decltype((std::declval<Class*>()->*std::declval<MethodPtr>())());\n\n  template <typename... Args>\n  ReturnType operator()(const Args&...) const {\n    return (obj_ptr->*method_ptr)();\n  }\n};\n\n// Implements the IgnoreResult(action) action.\ntemplate <typename A>\nclass IgnoreResultAction {\n public:\n  explicit IgnoreResultAction(const A& action) : action_(action) {}\n\n  template <typename F>\n  operator Action<F>() const {\n    // Assert statement belongs here because this is the best place to verify\n    // conditions on F. It produces the clearest error messages\n    // in most compilers.\n    // Impl really belongs in this scope as a local class but can't\n    // because MSVC produces duplicate symbols in different translation units\n    // in this case. Until MS fixes that bug we put Impl into the class scope\n    // and put the typedef both here (for use in assert statement) and\n    // in the Impl class. But both definitions must be the same.\n    typedef typename internal::Function<F>::Result Result;\n\n    // Asserts at compile time that F returns void.\n    static_assert(std::is_void<Result>::value, \"Result type should be void.\");\n\n    return Action<F>(new Impl<F>(action_));\n  }\n\n private:\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename internal::Function<F>::Result Result;\n    typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const A& action) : action_(action) {}\n\n    void Perform(const ArgumentTuple& args) override {\n      // Performs the action and ignores its result.\n      action_.Perform(args);\n    }\n\n   private:\n    // Type OriginalFunction is the same as F except that its return\n    // type is IgnoredValue.\n    typedef typename internal::Function<F>::MakeResultIgnoredValue\n        OriginalFunction;\n\n    const Action<OriginalFunction> action_;\n  };\n\n  const A action_;\n};\n\ntemplate <typename InnerAction, size_t... I>\nstruct WithArgsAction {\n  InnerAction action;\n\n  // The inner action could be anything convertible to Action<X>.\n  // We use the conversion operator to detect the signature of the inner Action.\n  template <typename R, typename... Args>\n  operator Action<R(Args...)>() const {  // NOLINT\n    using TupleType = std::tuple<Args...>;\n    Action<R(typename std::tuple_element<I, TupleType>::type...)>\n        converted(action);\n\n    return [converted](Args... args) -> R {\n      return converted.Perform(std::forward_as_tuple(\n        std::get<I>(std::forward_as_tuple(std::forward<Args>(args)...))...));\n    };\n  }\n};\n\ntemplate <typename... Actions>\nstruct DoAllAction {\n private:\n  template <typename T>\n  using NonFinalType =\n      typename std::conditional<std::is_scalar<T>::value, T, const T&>::type;\n\n  template <typename ActionT, size_t... I>\n  std::vector<ActionT> Convert(IndexSequence<I...>) const {\n    return {ActionT(std::get<I>(actions))...};\n  }\n\n public:\n  std::tuple<Actions...> actions;\n\n  template <typename R, typename... Args>\n  operator Action<R(Args...)>() const {  // NOLINT\n    struct Op {\n      std::vector<Action<void(NonFinalType<Args>...)>> converted;\n      Action<R(Args...)> last;\n      R operator()(Args... args) const {\n        auto tuple_args = std::forward_as_tuple(std::forward<Args>(args)...);\n        for (auto& a : converted) {\n          a.Perform(tuple_args);\n        }\n        return last.Perform(std::move(tuple_args));\n      }\n    };\n    return Op{Convert<Action<void(NonFinalType<Args>...)>>(\n                  MakeIndexSequence<sizeof...(Actions) - 1>()),\n              std::get<sizeof...(Actions) - 1>(actions)};\n  }\n};\n\ntemplate <typename T, typename... Params>\nstruct ReturnNewAction {\n  T* operator()() const {\n    return internal::Apply(\n        [](const Params&... unpacked_params) {\n          return new T(unpacked_params...);\n        },\n        params);\n  }\n  std::tuple<Params...> params;\n};\n\ntemplate <size_t k>\nstruct ReturnArgAction {\n  template <typename... Args>\n  auto operator()(const Args&... args) const ->\n      typename std::tuple_element<k, std::tuple<Args...>>::type {\n    return std::get<k>(std::tie(args...));\n  }\n};\n\ntemplate <size_t k, typename Ptr>\nstruct SaveArgAction {\n  Ptr pointer;\n\n  template <typename... Args>\n  void operator()(const Args&... args) const {\n    *pointer = std::get<k>(std::tie(args...));\n  }\n};\n\ntemplate <size_t k, typename Ptr>\nstruct SaveArgPointeeAction {\n  Ptr pointer;\n\n  template <typename... Args>\n  void operator()(const Args&... args) const {\n    *pointer = *std::get<k>(std::tie(args...));\n  }\n};\n\ntemplate <size_t k, typename T>\nstruct SetArgRefereeAction {\n  T value;\n\n  template <typename... Args>\n  void operator()(Args&&... args) const {\n    using argk_type =\n        typename ::std::tuple_element<k, std::tuple<Args...>>::type;\n    static_assert(std::is_lvalue_reference<argk_type>::value,\n                  \"Argument must be a reference type.\");\n    std::get<k>(std::tie(args...)) = value;\n  }\n};\n\ntemplate <size_t k, typename I1, typename I2>\nstruct SetArrayArgumentAction {\n  I1 first;\n  I2 last;\n\n  template <typename... Args>\n  void operator()(const Args&... args) const {\n    auto value = std::get<k>(std::tie(args...));\n    for (auto it = first; it != last; ++it, (void)++value) {\n      *value = *it;\n    }\n  }\n};\n\ntemplate <size_t k>\nstruct DeleteArgAction {\n  template <typename... Args>\n  void operator()(const Args&... args) const {\n    delete std::get<k>(std::tie(args...));\n  }\n};\n\ntemplate <typename Ptr>\nstruct ReturnPointeeAction {\n  Ptr pointer;\n  template <typename... Args>\n  auto operator()(const Args&...) const -> decltype(*pointer) {\n    return *pointer;\n  }\n};\n\n#if GTEST_HAS_EXCEPTIONS\ntemplate <typename T>\nstruct ThrowAction {\n  T exception;\n  // We use a conversion operator to adapt to any return type.\n  template <typename R, typename... Args>\n  operator Action<R(Args...)>() const {  // NOLINT\n    T copy = exception;\n    return [copy](Args...) -> R { throw copy; };\n  }\n};\n#endif  // GTEST_HAS_EXCEPTIONS\n\n}  // namespace internal\n\n// An Unused object can be implicitly constructed from ANY value.\n// This is handy when defining actions that ignore some or all of the\n// mock function arguments.  For example, given\n//\n//   MOCK_METHOD3(Foo, double(const string& label, double x, double y));\n//   MOCK_METHOD3(Bar, double(int index, double x, double y));\n//\n// instead of\n//\n//   double DistanceToOriginWithLabel(const string& label, double x, double y) {\n//     return sqrt(x*x + y*y);\n//   }\n//   double DistanceToOriginWithIndex(int index, double x, double y) {\n//     return sqrt(x*x + y*y);\n//   }\n//   ...\n//   EXPECT_CALL(mock, Foo(\"abc\", _, _))\n//       .WillOnce(Invoke(DistanceToOriginWithLabel));\n//   EXPECT_CALL(mock, Bar(5, _, _))\n//       .WillOnce(Invoke(DistanceToOriginWithIndex));\n//\n// you could write\n//\n//   // We can declare any uninteresting argument as Unused.\n//   double DistanceToOrigin(Unused, double x, double y) {\n//     return sqrt(x*x + y*y);\n//   }\n//   ...\n//   EXPECT_CALL(mock, Foo(\"abc\", _, _)).WillOnce(Invoke(DistanceToOrigin));\n//   EXPECT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));\ntypedef internal::IgnoredValue Unused;\n\n// Creates an action that does actions a1, a2, ..., sequentially in\n// each invocation. All but the last action will have a readonly view of the\n// arguments.\ntemplate <typename... Action>\ninternal::DoAllAction<typename std::decay<Action>::type...> DoAll(\n    Action&&... action) {\n  return {std::forward_as_tuple(std::forward<Action>(action)...)};\n}\n\n// WithArg<k>(an_action) creates an action that passes the k-th\n// (0-based) argument of the mock function to an_action and performs\n// it.  It adapts an action accepting one argument to one that accepts\n// multiple arguments.  For convenience, we also provide\n// WithArgs<k>(an_action) (defined below) as a synonym.\ntemplate <size_t k, typename InnerAction>\ninternal::WithArgsAction<typename std::decay<InnerAction>::type, k>\nWithArg(InnerAction&& action) {\n  return {std::forward<InnerAction>(action)};\n}\n\n// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes\n// the selected arguments of the mock function to an_action and\n// performs it.  It serves as an adaptor between actions with\n// different argument lists.\ntemplate <size_t k, size_t... ks, typename InnerAction>\ninternal::WithArgsAction<typename std::decay<InnerAction>::type, k, ks...>\nWithArgs(InnerAction&& action) {\n  return {std::forward<InnerAction>(action)};\n}\n\n// WithoutArgs(inner_action) can be used in a mock function with a\n// non-empty argument list to perform inner_action, which takes no\n// argument.  In other words, it adapts an action accepting no\n// argument to one that accepts (and ignores) arguments.\ntemplate <typename InnerAction>\ninternal::WithArgsAction<typename std::decay<InnerAction>::type>\nWithoutArgs(InnerAction&& action) {\n  return {std::forward<InnerAction>(action)};\n}\n\n// Creates an action that returns 'value'.  'value' is passed by value\n// instead of const reference - otherwise Return(\"string literal\")\n// will trigger a compiler error about using array as initializer.\ntemplate <typename R>\ninternal::ReturnAction<R> Return(R value) {\n  return internal::ReturnAction<R>(std::move(value));\n}\n\n// Creates an action that returns NULL.\ninline PolymorphicAction<internal::ReturnNullAction> ReturnNull() {\n  return MakePolymorphicAction(internal::ReturnNullAction());\n}\n\n// Creates an action that returns from a void function.\ninline PolymorphicAction<internal::ReturnVoidAction> Return() {\n  return MakePolymorphicAction(internal::ReturnVoidAction());\n}\n\n// Creates an action that returns the reference to a variable.\ntemplate <typename R>\ninline internal::ReturnRefAction<R> ReturnRef(R& x) {  // NOLINT\n  return internal::ReturnRefAction<R>(x);\n}\n\n// Prevent using ReturnRef on reference to temporary.\ntemplate <typename R, R* = nullptr>\ninternal::ReturnRefAction<R> ReturnRef(R&&) = delete;\n\n// Creates an action that returns the reference to a copy of the\n// argument.  The copy is created when the action is constructed and\n// lives as long as the action.\ntemplate <typename R>\ninline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {\n  return internal::ReturnRefOfCopyAction<R>(x);\n}\n\n// Modifies the parent action (a Return() action) to perform a move of the\n// argument instead of a copy.\n// Return(ByMove()) actions can only be executed once and will assert this\n// invariant.\ntemplate <typename R>\ninternal::ByMoveWrapper<R> ByMove(R x) {\n  return internal::ByMoveWrapper<R>(std::move(x));\n}\n\n// Creates an action that returns an element of `vals`. Calling this action will\n// repeatedly return the next value from `vals` until it reaches the end and\n// will restart from the beginning.\ntemplate <typename T>\ninternal::ReturnRoundRobinAction<T> ReturnRoundRobin(std::vector<T> vals) {\n  return internal::ReturnRoundRobinAction<T>(std::move(vals));\n}\n\n// Creates an action that returns an element of `vals`. Calling this action will\n// repeatedly return the next value from `vals` until it reaches the end and\n// will restart from the beginning.\ntemplate <typename T>\ninternal::ReturnRoundRobinAction<T> ReturnRoundRobin(\n    std::initializer_list<T> vals) {\n  return internal::ReturnRoundRobinAction<T>(std::vector<T>(vals));\n}\n\n// Creates an action that does the default action for the give mock function.\ninline internal::DoDefaultAction DoDefault() {\n  return internal::DoDefaultAction();\n}\n\n// Creates an action that sets the variable pointed by the N-th\n// (0-based) function argument to 'value'.\ntemplate <size_t N, typename T>\ninternal::SetArgumentPointeeAction<N, T> SetArgPointee(T value) {\n  return {std::move(value)};\n}\n\n// The following version is DEPRECATED.\ntemplate <size_t N, typename T>\ninternal::SetArgumentPointeeAction<N, T> SetArgumentPointee(T value) {\n  return {std::move(value)};\n}\n\n// Creates an action that sets a pointer referent to a given value.\ntemplate <typename T1, typename T2>\nPolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {\n  return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));\n}\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\n// Creates an action that sets errno and returns the appropriate error.\ntemplate <typename T>\nPolymorphicAction<internal::SetErrnoAndReturnAction<T> >\nSetErrnoAndReturn(int errval, T result) {\n  return MakePolymorphicAction(\n      internal::SetErrnoAndReturnAction<T>(errval, result));\n}\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Various overloads for Invoke().\n\n// Legacy function.\n// Actions can now be implicitly constructed from callables. No need to create\n// wrapper objects.\n// This function exists for backwards compatibility.\ntemplate <typename FunctionImpl>\ntypename std::decay<FunctionImpl>::type Invoke(FunctionImpl&& function_impl) {\n  return std::forward<FunctionImpl>(function_impl);\n}\n\n// Creates an action that invokes the given method on the given object\n// with the mock function's arguments.\ntemplate <class Class, typename MethodPtr>\ninternal::InvokeMethodAction<Class, MethodPtr> Invoke(Class* obj_ptr,\n                                                      MethodPtr method_ptr) {\n  return {obj_ptr, method_ptr};\n}\n\n// Creates an action that invokes 'function_impl' with no argument.\ntemplate <typename FunctionImpl>\ninternal::InvokeWithoutArgsAction<typename std::decay<FunctionImpl>::type>\nInvokeWithoutArgs(FunctionImpl function_impl) {\n  return {std::move(function_impl)};\n}\n\n// Creates an action that invokes the given method on the given object\n// with no argument.\ntemplate <class Class, typename MethodPtr>\ninternal::InvokeMethodWithoutArgsAction<Class, MethodPtr> InvokeWithoutArgs(\n    Class* obj_ptr, MethodPtr method_ptr) {\n  return {obj_ptr, method_ptr};\n}\n\n// Creates an action that performs an_action and throws away its\n// result.  In other words, it changes the return type of an_action to\n// void.  an_action MUST NOT return void, or the code won't compile.\ntemplate <typename A>\ninline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {\n  return internal::IgnoreResultAction<A>(an_action);\n}\n\n// Creates a reference wrapper for the given L-value.  If necessary,\n// you can explicitly specify the type of the reference.  For example,\n// suppose 'derived' is an object of type Derived, ByRef(derived)\n// would wrap a Derived&.  If you want to wrap a const Base& instead,\n// where Base is a base class of Derived, just write:\n//\n//   ByRef<const Base>(derived)\n//\n// N.B. ByRef is redundant with std::ref, std::cref and std::reference_wrapper.\n// However, it may still be used for consistency with ByMove().\ntemplate <typename T>\ninline ::std::reference_wrapper<T> ByRef(T& l_value) {  // NOLINT\n  return ::std::reference_wrapper<T>(l_value);\n}\n\n// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new\n// instance of type T, constructed on the heap with constructor arguments\n// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.\ntemplate <typename T, typename... Params>\ninternal::ReturnNewAction<T, typename std::decay<Params>::type...> ReturnNew(\n    Params&&... params) {\n  return {std::forward_as_tuple(std::forward<Params>(params)...)};\n}\n\n// Action ReturnArg<k>() returns the k-th argument of the mock function.\ntemplate <size_t k>\ninternal::ReturnArgAction<k> ReturnArg() {\n  return {};\n}\n\n// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the\n// mock function to *pointer.\ntemplate <size_t k, typename Ptr>\ninternal::SaveArgAction<k, Ptr> SaveArg(Ptr pointer) {\n  return {pointer};\n}\n\n// Action SaveArgPointee<k>(pointer) saves the value pointed to\n// by the k-th (0-based) argument of the mock function to *pointer.\ntemplate <size_t k, typename Ptr>\ninternal::SaveArgPointeeAction<k, Ptr> SaveArgPointee(Ptr pointer) {\n  return {pointer};\n}\n\n// Action SetArgReferee<k>(value) assigns 'value' to the variable\n// referenced by the k-th (0-based) argument of the mock function.\ntemplate <size_t k, typename T>\ninternal::SetArgRefereeAction<k, typename std::decay<T>::type> SetArgReferee(\n    T&& value) {\n  return {std::forward<T>(value)};\n}\n\n// Action SetArrayArgument<k>(first, last) copies the elements in\n// source range [first, last) to the array pointed to by the k-th\n// (0-based) argument, which can be either a pointer or an\n// iterator. The action does not take ownership of the elements in the\n// source range.\ntemplate <size_t k, typename I1, typename I2>\ninternal::SetArrayArgumentAction<k, I1, I2> SetArrayArgument(I1 first,\n                                                             I2 last) {\n  return {first, last};\n}\n\n// Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock\n// function.\ntemplate <size_t k>\ninternal::DeleteArgAction<k> DeleteArg() {\n  return {};\n}\n\n// This action returns the value pointed to by 'pointer'.\ntemplate <typename Ptr>\ninternal::ReturnPointeeAction<Ptr> ReturnPointee(Ptr pointer) {\n  return {pointer};\n}\n\n// Action Throw(exception) can be used in a mock function of any type\n// to throw the given exception.  Any copyable value can be thrown.\n#if GTEST_HAS_EXCEPTIONS\ntemplate <typename T>\ninternal::ThrowAction<typename std::decay<T>::type> Throw(T&& exception) {\n  return {std::forward<T>(exception)};\n}\n#endif  // GTEST_HAS_EXCEPTIONS\n\nnamespace internal {\n\n// A macro from the ACTION* family (defined later in gmock-generated-actions.h)\n// defines an action that can be used in a mock function.  Typically,\n// these actions only care about a subset of the arguments of the mock\n// function.  For example, if such an action only uses the second\n// argument, it can be used in any mock function that takes >= 2\n// arguments where the type of the second argument is compatible.\n//\n// Therefore, the action implementation must be prepared to take more\n// arguments than it needs.  The ExcessiveArg type is used to\n// represent those excessive arguments.  In order to keep the compiler\n// error messages tractable, we define it in the testing namespace\n// instead of testing::internal.  However, this is an INTERNAL TYPE\n// and subject to change without notice, so a user MUST NOT USE THIS\n// TYPE DIRECTLY.\nstruct ExcessiveArg {};\n\n// Builds an implementation of an Action<> for some particular signature, using\n// a class defined by an ACTION* macro.\ntemplate <typename F, typename Impl> struct ActionImpl;\n\ntemplate <typename Impl>\nstruct ImplBase {\n  struct Holder {\n    // Allows each copy of the Action<> to get to the Impl.\n    explicit operator const Impl&() const { return *ptr; }\n    std::shared_ptr<Impl> ptr;\n  };\n  using type = typename std::conditional<std::is_constructible<Impl>::value,\n                                         Impl, Holder>::type;\n};\n\ntemplate <typename R, typename... Args, typename Impl>\nstruct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {\n  using Base = typename ImplBase<Impl>::type;\n  using function_type = R(Args...);\n  using args_type = std::tuple<Args...>;\n\n  ActionImpl() = default;  // Only defined if appropriate for Base.\n  explicit ActionImpl(std::shared_ptr<Impl> impl) : Base{std::move(impl)} { }\n\n  R operator()(Args&&... arg) const {\n    static constexpr size_t kMaxArgs =\n        sizeof...(Args) <= 10 ? sizeof...(Args) : 10;\n    return Apply(MakeIndexSequence<kMaxArgs>{},\n                 MakeIndexSequence<10 - kMaxArgs>{},\n                 args_type{std::forward<Args>(arg)...});\n  }\n\n  template <std::size_t... arg_id, std::size_t... excess_id>\n  R Apply(IndexSequence<arg_id...>, IndexSequence<excess_id...>,\n          const args_type& args) const {\n    // Impl need not be specific to the signature of action being implemented;\n    // only the implementing function body needs to have all of the specific\n    // types instantiated.  Up to 10 of the args that are provided by the\n    // args_type get passed, followed by a dummy of unspecified type for the\n    // remainder up to 10 explicit args.\n    static constexpr ExcessiveArg kExcessArg{};\n    return static_cast<const Impl&>(*this).template gmock_PerformImpl<\n        /*function_type=*/function_type, /*return_type=*/R,\n        /*args_type=*/args_type,\n        /*argN_type=*/typename std::tuple_element<arg_id, args_type>::type...>(\n        /*args=*/args, std::get<arg_id>(args)...,\n        ((void)excess_id, kExcessArg)...);\n  }\n};\n\n// Stores a default-constructed Impl as part of the Action<>'s\n// std::function<>. The Impl should be trivial to copy.\ntemplate <typename F, typename Impl>\n::testing::Action<F> MakeAction() {\n  return ::testing::Action<F>(ActionImpl<F, Impl>());\n}\n\n// Stores just the one given instance of Impl.\ntemplate <typename F, typename Impl>\n::testing::Action<F> MakeAction(std::shared_ptr<Impl> impl) {\n  return ::testing::Action<F>(ActionImpl<F, Impl>(std::move(impl)));\n}\n\n#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \\\n  , const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_\n#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_           \\\n  const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \\\n      GMOCK_INTERNAL_ARG_UNUSED, , 10)\n\n#define GMOCK_INTERNAL_ARG(i, data, el) , const arg##i##_type& arg##i\n#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_ \\\n  const args_type& args GMOCK_PP_REPEAT(GMOCK_INTERNAL_ARG, , 10)\n\n#define GMOCK_INTERNAL_TEMPLATE_ARG(i, data, el) , typename arg##i##_type\n#define GMOCK_ACTION_TEMPLATE_ARGS_NAMES_ \\\n  GMOCK_PP_TAIL(GMOCK_PP_REPEAT(GMOCK_INTERNAL_TEMPLATE_ARG, , 10))\n\n#define GMOCK_INTERNAL_TYPENAME_PARAM(i, data, param) , typename param##_type\n#define GMOCK_ACTION_TYPENAME_PARAMS_(params) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_TYPENAME_PARAM, , params))\n\n#define GMOCK_INTERNAL_TYPE_PARAM(i, data, param) , param##_type\n#define GMOCK_ACTION_TYPE_PARAMS_(params) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_TYPE_PARAM, , params))\n\n#define GMOCK_INTERNAL_TYPE_GVALUE_PARAM(i, data, param) \\\n  , param##_type gmock_p##i\n#define GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_TYPE_GVALUE_PARAM, , params))\n\n#define GMOCK_INTERNAL_GVALUE_PARAM(i, data, param) \\\n  , std::forward<param##_type>(gmock_p##i)\n#define GMOCK_ACTION_GVALUE_PARAMS_(params) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GVALUE_PARAM, , params))\n\n#define GMOCK_INTERNAL_INIT_PARAM(i, data, param) \\\n  , param(::std::forward<param##_type>(gmock_p##i))\n#define GMOCK_ACTION_INIT_PARAMS_(params) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_INIT_PARAM, , params))\n\n#define GMOCK_INTERNAL_FIELD_PARAM(i, data, param) param##_type param;\n#define GMOCK_ACTION_FIELD_PARAMS_(params) \\\n  GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_FIELD_PARAM, , params)\n\n#define GMOCK_INTERNAL_ACTION(name, full_name, params)                        \\\n  template <GMOCK_ACTION_TYPENAME_PARAMS_(params)>                            \\\n  class full_name {                                                           \\\n   public:                                                                    \\\n    explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params))              \\\n        : impl_(std::make_shared<gmock_Impl>(                                 \\\n                GMOCK_ACTION_GVALUE_PARAMS_(params))) { }                     \\\n    full_name(const full_name&) = default;                                    \\\n    full_name(full_name&&) noexcept = default;                                \\\n    template <typename F>                                                     \\\n    operator ::testing::Action<F>() const {                                   \\\n      return ::testing::internal::MakeAction<F>(impl_);                       \\\n    }                                                                         \\\n   private:                                                                   \\\n    class gmock_Impl {                                                        \\\n     public:                                                                  \\\n      explicit gmock_Impl(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params))           \\\n          : GMOCK_ACTION_INIT_PARAMS_(params) {}                              \\\n      template <typename function_type, typename return_type,                 \\\n                typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>        \\\n      return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \\\n      GMOCK_ACTION_FIELD_PARAMS_(params)                                      \\\n    };                                                                        \\\n    std::shared_ptr<const gmock_Impl> impl_;                                  \\\n  };                                                                          \\\n  template <GMOCK_ACTION_TYPENAME_PARAMS_(params)>                            \\\n  inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name(                   \\\n      GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) {                             \\\n    return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>(                      \\\n        GMOCK_ACTION_GVALUE_PARAMS_(params));                                 \\\n  }                                                                           \\\n  template <GMOCK_ACTION_TYPENAME_PARAMS_(params)>                            \\\n  template <typename function_type, typename return_type, typename args_type, \\\n            GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>                                \\\n  return_type full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl::      \\\n  gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n}  // namespace internal\n\n// Similar to GMOCK_INTERNAL_ACTION, but no bound parameters are stored.\n#define ACTION(name)                                                          \\\n  class name##Action {                                                        \\\n   public:                                                                    \\\n   explicit name##Action() noexcept {}                                        \\\n   name##Action(const name##Action&) noexcept {}                              \\\n    template <typename F>                                                     \\\n    operator ::testing::Action<F>() const {                                   \\\n      return ::testing::internal::MakeAction<F, gmock_Impl>();                \\\n    }                                                                         \\\n   private:                                                                   \\\n    class gmock_Impl {                                                        \\\n     public:                                                                  \\\n      template <typename function_type, typename return_type,                 \\\n                typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>        \\\n      return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \\\n    };                                                                        \\\n  };                                                                          \\\n  inline name##Action name() GTEST_MUST_USE_RESULT_;                          \\\n  inline name##Action name() { return name##Action(); }                       \\\n  template <typename function_type, typename return_type, typename args_type, \\\n            GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>                                \\\n  return_type name##Action::gmock_Impl::gmock_PerformImpl(                    \\\n      GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP, (__VA_ARGS__))\n\n#define ACTION_P2(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP2, (__VA_ARGS__))\n\n#define ACTION_P3(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP3, (__VA_ARGS__))\n\n#define ACTION_P4(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP4, (__VA_ARGS__))\n\n#define ACTION_P5(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP5, (__VA_ARGS__))\n\n#define ACTION_P6(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP6, (__VA_ARGS__))\n\n#define ACTION_P7(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP7, (__VA_ARGS__))\n\n#define ACTION_P8(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP8, (__VA_ARGS__))\n\n#define ACTION_P9(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP9, (__VA_ARGS__))\n\n#define ACTION_P10(name, ...) \\\n  GMOCK_INTERNAL_ACTION(name, name##ActionP10, (__VA_ARGS__))\n\n}  // namespace testing\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used cardinalities.  More\n// cardinalities can be defined by the user implementing the\n// CardinalityInterface interface if necessary.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_\n\n#include <limits.h>\n#include <memory>\n#include <ostream>  // NOLINT\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// To implement a cardinality Foo, define:\n//   1. a class FooCardinality that implements the\n//      CardinalityInterface interface, and\n//   2. a factory function that creates a Cardinality object from a\n//      const FooCardinality*.\n//\n// The two-level delegation design follows that of Matcher, providing\n// consistency for extension developers.  It also eases ownership\n// management as Cardinality objects can now be copied like plain values.\n\n// The implementation of a cardinality.\nclass CardinalityInterface {\n public:\n  virtual ~CardinalityInterface() {}\n\n  // Conservative estimate on the lower/upper bound of the number of\n  // calls allowed.\n  virtual int ConservativeLowerBound() const { return 0; }\n  virtual int ConservativeUpperBound() const { return INT_MAX; }\n\n  // Returns true if and only if call_count calls will satisfy this\n  // cardinality.\n  virtual bool IsSatisfiedByCallCount(int call_count) const = 0;\n\n  // Returns true if and only if call_count calls will saturate this\n  // cardinality.\n  virtual bool IsSaturatedByCallCount(int call_count) const = 0;\n\n  // Describes self to an ostream.\n  virtual void DescribeTo(::std::ostream* os) const = 0;\n};\n\n// A Cardinality is a copyable and IMMUTABLE (except by assignment)\n// object that specifies how many times a mock function is expected to\n// be called.  The implementation of Cardinality is just a std::shared_ptr\n// to const CardinalityInterface. Don't inherit from Cardinality!\nclass GTEST_API_ Cardinality {\n public:\n  // Constructs a null cardinality.  Needed for storing Cardinality\n  // objects in STL containers.\n  Cardinality() {}\n\n  // Constructs a Cardinality from its implementation.\n  explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}\n\n  // Conservative estimate on the lower/upper bound of the number of\n  // calls allowed.\n  int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }\n  int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }\n\n  // Returns true if and only if call_count calls will satisfy this\n  // cardinality.\n  bool IsSatisfiedByCallCount(int call_count) const {\n    return impl_->IsSatisfiedByCallCount(call_count);\n  }\n\n  // Returns true if and only if call_count calls will saturate this\n  // cardinality.\n  bool IsSaturatedByCallCount(int call_count) const {\n    return impl_->IsSaturatedByCallCount(call_count);\n  }\n\n  // Returns true if and only if call_count calls will over-saturate this\n  // cardinality, i.e. exceed the maximum number of allowed calls.\n  bool IsOverSaturatedByCallCount(int call_count) const {\n    return impl_->IsSaturatedByCallCount(call_count) &&\n        !impl_->IsSatisfiedByCallCount(call_count);\n  }\n\n  // Describes self to an ostream\n  void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }\n\n  // Describes the given actual call count to an ostream.\n  static void DescribeActualCallCountTo(int actual_call_count,\n                                        ::std::ostream* os);\n\n private:\n  std::shared_ptr<const CardinalityInterface> impl_;\n};\n\n// Creates a cardinality that allows at least n calls.\nGTEST_API_ Cardinality AtLeast(int n);\n\n// Creates a cardinality that allows at most n calls.\nGTEST_API_ Cardinality AtMost(int n);\n\n// Creates a cardinality that allows any number of calls.\nGTEST_API_ Cardinality AnyNumber();\n\n// Creates a cardinality that allows between min and max calls.\nGTEST_API_ Cardinality Between(int min, int max);\n\n// Creates a cardinality that allows exactly n calls.\nGTEST_API_ Cardinality Exactly(int n);\n\n// Creates a cardinality from its implementation.\ninline Cardinality MakeCardinality(const CardinalityInterface* c) {\n  return Cardinality(c);\n}\n\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements MOCK_METHOD.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_  // NOLINT\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_  // NOLINT\n\n#include <type_traits>  // IWYU pragma: keep\n#include <utility>      // IWYU pragma: keep\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements the ON_CALL() and EXPECT_CALL() macros.\n//\n// A user can use the ON_CALL() macro to specify the default action of\n// a mock method.  The syntax is:\n//\n//   ON_CALL(mock_object, Method(argument-matchers))\n//       .With(multi-argument-matcher)\n//       .WillByDefault(action);\n//\n//  where the .With() clause is optional.\n//\n// A user can use the EXPECT_CALL() macro to specify an expectation on\n// a mock method.  The syntax is:\n//\n//   EXPECT_CALL(mock_object, Method(argument-matchers))\n//       .With(multi-argument-matchers)\n//       .Times(cardinality)\n//       .InSequence(sequences)\n//       .After(expectations)\n//       .WillOnce(action)\n//       .WillRepeatedly(action)\n//       .RetiresOnSaturation();\n//\n// where all clauses are optional, and .InSequence()/.After()/\n// .WillOnce() can appear any number of times.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_\n\n#include <cstdint>\n#include <functional>\n#include <map>\n#include <memory>\n#include <set>\n#include <sstream>\n#include <string>\n#include <type_traits>\n#include <utility>\n#include <vector>\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// The MATCHER* family of macros can be used in a namespace scope to\n// define custom matchers easily.\n//\n// Basic Usage\n// ===========\n//\n// The syntax\n//\n//   MATCHER(name, description_string) { statements; }\n//\n// defines a matcher with the given name that executes the statements,\n// which must return a bool to indicate if the match succeeds.  Inside\n// the statements, you can refer to the value being matched by 'arg',\n// and refer to its type by 'arg_type'.\n//\n// The description string documents what the matcher does, and is used\n// to generate the failure message when the match fails.  Since a\n// MATCHER() is usually defined in a header file shared by multiple\n// C++ source files, we require the description to be a C-string\n// literal to avoid possible side effects.  It can be empty, in which\n// case we'll use the sequence of words in the matcher name as the\n// description.\n//\n// For example:\n//\n//   MATCHER(IsEven, \"\") { return (arg % 2) == 0; }\n//\n// allows you to write\n//\n//   // Expects mock_foo.Bar(n) to be called where n is even.\n//   EXPECT_CALL(mock_foo, Bar(IsEven()));\n//\n// or,\n//\n//   // Verifies that the value of some_expression is even.\n//   EXPECT_THAT(some_expression, IsEven());\n//\n// If the above assertion fails, it will print something like:\n//\n//   Value of: some_expression\n//   Expected: is even\n//     Actual: 7\n//\n// where the description \"is even\" is automatically calculated from the\n// matcher name IsEven.\n//\n// Argument Type\n// =============\n//\n// Note that the type of the value being matched (arg_type) is\n// determined by the context in which you use the matcher and is\n// supplied to you by the compiler, so you don't need to worry about\n// declaring it (nor can you).  This allows the matcher to be\n// polymorphic.  For example, IsEven() can be used to match any type\n// where the value of \"(arg % 2) == 0\" can be implicitly converted to\n// a bool.  In the \"Bar(IsEven())\" example above, if method Bar()\n// takes an int, 'arg_type' will be int; if it takes an unsigned long,\n// 'arg_type' will be unsigned long; and so on.\n//\n// Parameterizing Matchers\n// =======================\n//\n// Sometimes you'll want to parameterize the matcher.  For that you\n// can use another macro:\n//\n//   MATCHER_P(name, param_name, description_string) { statements; }\n//\n// For example:\n//\n//   MATCHER_P(HasAbsoluteValue, value, \"\") { return abs(arg) == value; }\n//\n// will allow you to write:\n//\n//   EXPECT_THAT(Blah(\"a\"), HasAbsoluteValue(n));\n//\n// which may lead to this message (assuming n is 10):\n//\n//   Value of: Blah(\"a\")\n//   Expected: has absolute value 10\n//     Actual: -9\n//\n// Note that both the matcher description and its parameter are\n// printed, making the message human-friendly.\n//\n// In the matcher definition body, you can write 'foo_type' to\n// reference the type of a parameter named 'foo'.  For example, in the\n// body of MATCHER_P(HasAbsoluteValue, value) above, you can write\n// 'value_type' to refer to the type of 'value'.\n//\n// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P$n to\n// support multi-parameter matchers.\n//\n// Describing Parameterized Matchers\n// =================================\n//\n// The last argument to MATCHER*() is a string-typed expression.  The\n// expression can reference all of the matcher's parameters and a\n// special bool-typed variable named 'negation'.  When 'negation' is\n// false, the expression should evaluate to the matcher's description;\n// otherwise it should evaluate to the description of the negation of\n// the matcher.  For example,\n//\n//   using testing::PrintToString;\n//\n//   MATCHER_P2(InClosedRange, low, hi,\n//       std::string(negation ? \"is not\" : \"is\") + \" in range [\" +\n//       PrintToString(low) + \", \" + PrintToString(hi) + \"]\") {\n//     return low <= arg && arg <= hi;\n//   }\n//   ...\n//   EXPECT_THAT(3, InClosedRange(4, 6));\n//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));\n//\n// would generate two failures that contain the text:\n//\n//   Expected: is in range [4, 6]\n//   ...\n//   Expected: is not in range [2, 4]\n//\n// If you specify \"\" as the description, the failure message will\n// contain the sequence of words in the matcher name followed by the\n// parameter values printed as a tuple.  For example,\n//\n//   MATCHER_P2(InClosedRange, low, hi, \"\") { ... }\n//   ...\n//   EXPECT_THAT(3, InClosedRange(4, 6));\n//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));\n//\n// would generate two failures that contain the text:\n//\n//   Expected: in closed range (4, 6)\n//   ...\n//   Expected: not (in closed range (2, 4))\n//\n// Types of Matcher Parameters\n// ===========================\n//\n// For the purpose of typing, you can view\n//\n//   MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }\n//\n// as shorthand for\n//\n//   template <typename p1_type, ..., typename pk_type>\n//   FooMatcherPk<p1_type, ..., pk_type>\n//   Foo(p1_type p1, ..., pk_type pk) { ... }\n//\n// When you write Foo(v1, ..., vk), the compiler infers the types of\n// the parameters v1, ..., and vk for you.  If you are not happy with\n// the result of the type inference, you can specify the types by\n// explicitly instantiating the template, as in Foo<long, bool>(5,\n// false).  As said earlier, you don't get to (or need to) specify\n// 'arg_type' as that's determined by the context in which the matcher\n// is used.  You can assign the result of expression Foo(p1, ..., pk)\n// to a variable of type FooMatcherPk<p1_type, ..., pk_type>.  This\n// can be useful when composing matchers.\n//\n// While you can instantiate a matcher template with reference types,\n// passing the parameters by pointer usually makes your code more\n// readable.  If, however, you still want to pass a parameter by\n// reference, be aware that in the failure message generated by the\n// matcher you will see the value of the referenced object but not its\n// address.\n//\n// Explaining Match Results\n// ========================\n//\n// Sometimes the matcher description alone isn't enough to explain why\n// the match has failed or succeeded.  For example, when expecting a\n// long string, it can be very helpful to also print the diff between\n// the expected string and the actual one.  To achieve that, you can\n// optionally stream additional information to a special variable\n// named result_listener, whose type is a pointer to class\n// MatchResultListener:\n//\n//   MATCHER_P(EqualsLongString, str, \"\") {\n//     if (arg == str) return true;\n//\n//     *result_listener << \"the difference: \"\n///                     << DiffStrings(str, arg);\n//     return false;\n//   }\n//\n// Overloading Matchers\n// ====================\n//\n// You can overload matchers with different numbers of parameters:\n//\n//   MATCHER_P(Blah, a, description_string1) { ... }\n//   MATCHER_P2(Blah, a, b, description_string2) { ... }\n//\n// Caveats\n// =======\n//\n// When defining a new matcher, you should also consider implementing\n// MatcherInterface or using MakePolymorphicMatcher().  These\n// approaches require more work than the MATCHER* macros, but also\n// give you more control on the types of the value being matched and\n// the matcher parameters, which may leads to better compiler error\n// messages when the matcher is used wrong.  They also allow\n// overloading matchers based on parameter types (as opposed to just\n// based on the number of parameters).\n//\n// MATCHER*() can only be used in a namespace scope as templates cannot be\n// declared inside of a local class.\n//\n// More Information\n// ================\n//\n// To learn more about using these macros, please search for 'MATCHER'\n// on\n// https://github.com/google/googletest/blob/master/docs/gmock_cook_book.md\n//\n// This file also implements some commonly used argument matchers.  More\n// matchers can be defined by the user implementing the\n// MatcherInterface<T> interface if necessary.\n//\n// See googletest/include/gtest/gtest-matchers.h for the definition of class\n// Matcher, class MatcherInterface, and others.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_\n\n#include <algorithm>\n#include <cmath>\n#include <initializer_list>\n#include <iterator>\n#include <limits>\n#include <memory>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n#include <type_traits>\n#include <utility>\n#include <vector>\n\n\n// MSVC warning C5046 is new as of VS2017 version 15.8.\n#if defined(_MSC_VER) && _MSC_VER >= 1915\n#define GMOCK_MAYBE_5046_ 5046\n#else\n#define GMOCK_MAYBE_5046_\n#endif\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(\n    4251 GMOCK_MAYBE_5046_ /* class A needs to have dll-interface to be used by\n                              clients of class B */\n    /* Symbol involving type with internal linkage not defined */)\n\nnamespace testing {\n\n// To implement a matcher Foo for type T, define:\n//   1. a class FooMatcherImpl that implements the\n//      MatcherInterface<T> interface, and\n//   2. a factory function that creates a Matcher<T> object from a\n//      FooMatcherImpl*.\n//\n// The two-level delegation design makes it possible to allow a user\n// to write \"v\" instead of \"Eq(v)\" where a Matcher is expected, which\n// is impossible if we pass matchers by pointers.  It also eases\n// ownership management as Matcher objects can now be copied like\n// plain values.\n\n// A match result listener that stores the explanation in a string.\nclass StringMatchResultListener : public MatchResultListener {\n public:\n  StringMatchResultListener() : MatchResultListener(&ss_) {}\n\n  // Returns the explanation accumulated so far.\n  std::string str() const { return ss_.str(); }\n\n  // Clears the explanation accumulated so far.\n  void Clear() { ss_.str(\"\"); }\n\n private:\n  ::std::stringstream ss_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);\n};\n\n// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION\n// and MUST NOT BE USED IN USER CODE!!!\nnamespace internal {\n\n// The MatcherCastImpl class template is a helper for implementing\n// MatcherCast().  We need this helper in order to partially\n// specialize the implementation of MatcherCast() (C++ allows\n// class/struct templates to be partially specialized, but not\n// function templates.).\n\n// This general version is used when MatcherCast()'s argument is a\n// polymorphic matcher (i.e. something that can be converted to a\n// Matcher but is not one yet; for example, Eq(value)) or a value (for\n// example, \"hello\").\ntemplate <typename T, typename M>\nclass MatcherCastImpl {\n public:\n  static Matcher<T> Cast(const M& polymorphic_matcher_or_value) {\n    // M can be a polymorphic matcher, in which case we want to use\n    // its conversion operator to create Matcher<T>.  Or it can be a value\n    // that should be passed to the Matcher<T>'s constructor.\n    //\n    // We can't call Matcher<T>(polymorphic_matcher_or_value) when M is a\n    // polymorphic matcher because it'll be ambiguous if T has an implicit\n    // constructor from M (this usually happens when T has an implicit\n    // constructor from any type).\n    //\n    // It won't work to unconditionally implicit_cast\n    // polymorphic_matcher_or_value to Matcher<T> because it won't trigger\n    // a user-defined conversion from M to T if one exists (assuming M is\n    // a value).\n    return CastImpl(polymorphic_matcher_or_value,\n                    std::is_convertible<M, Matcher<T>>{},\n                    std::is_convertible<M, T>{});\n  }\n\n private:\n  template <bool Ignore>\n  static Matcher<T> CastImpl(const M& polymorphic_matcher_or_value,\n                             std::true_type /* convertible_to_matcher */,\n                             std::integral_constant<bool, Ignore>) {\n    // M is implicitly convertible to Matcher<T>, which means that either\n    // M is a polymorphic matcher or Matcher<T> has an implicit constructor\n    // from M.  In both cases using the implicit conversion will produce a\n    // matcher.\n    //\n    // Even if T has an implicit constructor from M, it won't be called because\n    // creating Matcher<T> would require a chain of two user-defined conversions\n    // (first to create T from M and then to create Matcher<T> from T).\n    return polymorphic_matcher_or_value;\n  }\n\n  // M can't be implicitly converted to Matcher<T>, so M isn't a polymorphic\n  // matcher. It's a value of a type implicitly convertible to T. Use direct\n  // initialization to create a matcher.\n  static Matcher<T> CastImpl(const M& value,\n                             std::false_type /* convertible_to_matcher */,\n                             std::true_type /* convertible_to_T */) {\n    return Matcher<T>(ImplicitCast_<T>(value));\n  }\n\n  // M can't be implicitly converted to either Matcher<T> or T. Attempt to use\n  // polymorphic matcher Eq(value) in this case.\n  //\n  // Note that we first attempt to perform an implicit cast on the value and\n  // only fall back to the polymorphic Eq() matcher afterwards because the\n  // latter calls bool operator==(const Lhs& lhs, const Rhs& rhs) in the end\n  // which might be undefined even when Rhs is implicitly convertible to Lhs\n  // (e.g. std::pair<const int, int> vs. std::pair<int, int>).\n  //\n  // We don't define this method inline as we need the declaration of Eq().\n  static Matcher<T> CastImpl(const M& value,\n                             std::false_type /* convertible_to_matcher */,\n                             std::false_type /* convertible_to_T */);\n};\n\n// This more specialized version is used when MatcherCast()'s argument\n// is already a Matcher.  This only compiles when type T can be\n// statically converted to type U.\ntemplate <typename T, typename U>\nclass MatcherCastImpl<T, Matcher<U> > {\n public:\n  static Matcher<T> Cast(const Matcher<U>& source_matcher) {\n    return Matcher<T>(new Impl(source_matcher));\n  }\n\n private:\n  class Impl : public MatcherInterface<T> {\n   public:\n    explicit Impl(const Matcher<U>& source_matcher)\n        : source_matcher_(source_matcher) {}\n\n    // We delegate the matching logic to the source matcher.\n    bool MatchAndExplain(T x, MatchResultListener* listener) const override {\n      using FromType = typename std::remove_cv<typename std::remove_pointer<\n          typename std::remove_reference<T>::type>::type>::type;\n      using ToType = typename std::remove_cv<typename std::remove_pointer<\n          typename std::remove_reference<U>::type>::type>::type;\n      // Do not allow implicitly converting base*/& to derived*/&.\n      static_assert(\n          // Do not trigger if only one of them is a pointer. That implies a\n          // regular conversion and not a down_cast.\n          (std::is_pointer<typename std::remove_reference<T>::type>::value !=\n           std::is_pointer<typename std::remove_reference<U>::type>::value) ||\n              std::is_same<FromType, ToType>::value ||\n              !std::is_base_of<FromType, ToType>::value,\n          \"Can't implicitly convert from <base> to <derived>\");\n\n      // Do the cast to `U` explicitly if necessary.\n      // Otherwise, let implicit conversions do the trick.\n      using CastType =\n          typename std::conditional<std::is_convertible<T&, const U&>::value,\n                                    T&, U>::type;\n\n      return source_matcher_.MatchAndExplain(static_cast<CastType>(x),\n                                             listener);\n    }\n\n    void DescribeTo(::std::ostream* os) const override {\n      source_matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      source_matcher_.DescribeNegationTo(os);\n    }\n\n   private:\n    const Matcher<U> source_matcher_;\n  };\n};\n\n// This even more specialized version is used for efficiently casting\n// a matcher to its own type.\ntemplate <typename T>\nclass MatcherCastImpl<T, Matcher<T> > {\n public:\n  static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }\n};\n\n// Template specialization for parameterless Matcher.\ntemplate <typename Derived>\nclass MatcherBaseImpl {\n public:\n  MatcherBaseImpl() = default;\n\n  template <typename T>\n  operator ::testing::Matcher<T>() const {  // NOLINT(runtime/explicit)\n    return ::testing::Matcher<T>(new\n                                 typename Derived::template gmock_Impl<T>());\n  }\n};\n\n// Template specialization for Matcher with parameters.\ntemplate <template <typename...> class Derived, typename... Ts>\nclass MatcherBaseImpl<Derived<Ts...>> {\n public:\n  // Mark the constructor explicit for single argument T to avoid implicit\n  // conversions.\n  template <typename E = std::enable_if<sizeof...(Ts) == 1>,\n            typename E::type* = nullptr>\n  explicit MatcherBaseImpl(Ts... params)\n      : params_(std::forward<Ts>(params)...) {}\n  template <typename E = std::enable_if<sizeof...(Ts) != 1>,\n            typename = typename E::type>\n  MatcherBaseImpl(Ts... params)  // NOLINT\n      : params_(std::forward<Ts>(params)...) {}\n\n  template <typename F>\n  operator ::testing::Matcher<F>() const {  // NOLINT(runtime/explicit)\n    return Apply<F>(MakeIndexSequence<sizeof...(Ts)>{});\n  }\n\n private:\n  template <typename F, std::size_t... tuple_ids>\n  ::testing::Matcher<F> Apply(IndexSequence<tuple_ids...>) const {\n    return ::testing::Matcher<F>(\n        new typename Derived<Ts...>::template gmock_Impl<F>(\n            std::get<tuple_ids>(params_)...));\n  }\n\n  const std::tuple<Ts...> params_;\n};\n\n}  // namespace internal\n\n// In order to be safe and clear, casting between different matcher\n// types is done explicitly via MatcherCast<T>(m), which takes a\n// matcher m and returns a Matcher<T>.  It compiles only when T can be\n// statically converted to the argument type of m.\ntemplate <typename T, typename M>\ninline Matcher<T> MatcherCast(const M& matcher) {\n  return internal::MatcherCastImpl<T, M>::Cast(matcher);\n}\n\n// This overload handles polymorphic matchers and values only since\n// monomorphic matchers are handled by the next one.\ntemplate <typename T, typename M>\ninline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher_or_value) {\n  return MatcherCast<T>(polymorphic_matcher_or_value);\n}\n\n// This overload handles monomorphic matchers.\n//\n// In general, if type T can be implicitly converted to type U, we can\n// safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is\n// contravariant): just keep a copy of the original Matcher<U>, convert the\n// argument from type T to U, and then pass it to the underlying Matcher<U>.\n// The only exception is when U is a reference and T is not, as the\n// underlying Matcher<U> may be interested in the argument's address, which\n// is not preserved in the conversion from T to U.\ntemplate <typename T, typename U>\ninline Matcher<T> SafeMatcherCast(const Matcher<U>& matcher) {\n  // Enforce that T can be implicitly converted to U.\n  static_assert(std::is_convertible<const T&, const U&>::value,\n                \"T must be implicitly convertible to U\");\n  // Enforce that we are not converting a non-reference type T to a reference\n  // type U.\n  GTEST_COMPILE_ASSERT_(\n      std::is_reference<T>::value || !std::is_reference<U>::value,\n      cannot_convert_non_reference_arg_to_reference);\n  // In case both T and U are arithmetic types, enforce that the\n  // conversion is not lossy.\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;\n  constexpr bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;\n  constexpr bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;\n  GTEST_COMPILE_ASSERT_(\n      kTIsOther || kUIsOther ||\n      (internal::LosslessArithmeticConvertible<RawT, RawU>::value),\n      conversion_of_arithmetic_types_must_be_lossless);\n  return MatcherCast<T>(matcher);\n}\n\n// A<T>() returns a matcher that matches any value of type T.\ntemplate <typename T>\nMatcher<T> A();\n\n// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION\n// and MUST NOT BE USED IN USER CODE!!!\nnamespace internal {\n\n// If the explanation is not empty, prints it to the ostream.\ninline void PrintIfNotEmpty(const std::string& explanation,\n                            ::std::ostream* os) {\n  if (explanation != \"\" && os != nullptr) {\n    *os << \", \" << explanation;\n  }\n}\n\n// Returns true if the given type name is easy to read by a human.\n// This is used to decide whether printing the type of a value might\n// be helpful.\ninline bool IsReadableTypeName(const std::string& type_name) {\n  // We consider a type name readable if it's short or doesn't contain\n  // a template or function type.\n  return (type_name.length() <= 20 ||\n          type_name.find_first_of(\"<(\") == std::string::npos);\n}\n\n// Matches the value against the given matcher, prints the value and explains\n// the match result to the listener. Returns the match result.\n// 'listener' must not be NULL.\n// Value cannot be passed by const reference, because some matchers take a\n// non-const argument.\ntemplate <typename Value, typename T>\nbool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,\n                          MatchResultListener* listener) {\n  if (!listener->IsInterested()) {\n    // If the listener is not interested, we do not need to construct the\n    // inner explanation.\n    return matcher.Matches(value);\n  }\n\n  StringMatchResultListener inner_listener;\n  const bool match = matcher.MatchAndExplain(value, &inner_listener);\n\n  UniversalPrint(value, listener->stream());\n#if GTEST_HAS_RTTI\n  const std::string& type_name = GetTypeName<Value>();\n  if (IsReadableTypeName(type_name))\n    *listener->stream() << \" (of type \" << type_name << \")\";\n#endif\n  PrintIfNotEmpty(inner_listener.str(), listener->stream());\n\n  return match;\n}\n\n// An internal helper class for doing compile-time loop on a tuple's\n// fields.\ntemplate <size_t N>\nclass TuplePrefix {\n public:\n  // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true\n  // if and only if the first N fields of matcher_tuple matches\n  // the first N fields of value_tuple, respectively.\n  template <typename MatcherTuple, typename ValueTuple>\n  static bool Matches(const MatcherTuple& matcher_tuple,\n                      const ValueTuple& value_tuple) {\n    return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple) &&\n           std::get<N - 1>(matcher_tuple).Matches(std::get<N - 1>(value_tuple));\n  }\n\n  // TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)\n  // describes failures in matching the first N fields of matchers\n  // against the first N fields of values.  If there is no failure,\n  // nothing will be streamed to os.\n  template <typename MatcherTuple, typename ValueTuple>\n  static void ExplainMatchFailuresTo(const MatcherTuple& matchers,\n                                     const ValueTuple& values,\n                                     ::std::ostream* os) {\n    // First, describes failures in the first N - 1 fields.\n    TuplePrefix<N - 1>::ExplainMatchFailuresTo(matchers, values, os);\n\n    // Then describes the failure (if any) in the (N - 1)-th (0-based)\n    // field.\n    typename std::tuple_element<N - 1, MatcherTuple>::type matcher =\n        std::get<N - 1>(matchers);\n    typedef typename std::tuple_element<N - 1, ValueTuple>::type Value;\n    const Value& value = std::get<N - 1>(values);\n    StringMatchResultListener listener;\n    if (!matcher.MatchAndExplain(value, &listener)) {\n      *os << \"  Expected arg #\" << N - 1 << \": \";\n      std::get<N - 1>(matchers).DescribeTo(os);\n      *os << \"\\n           Actual: \";\n      // We remove the reference in type Value to prevent the\n      // universal printer from printing the address of value, which\n      // isn't interesting to the user most of the time.  The\n      // matcher's MatchAndExplain() method handles the case when\n      // the address is interesting.\n      internal::UniversalPrint(value, os);\n      PrintIfNotEmpty(listener.str(), os);\n      *os << \"\\n\";\n    }\n  }\n};\n\n// The base case.\ntemplate <>\nclass TuplePrefix<0> {\n public:\n  template <typename MatcherTuple, typename ValueTuple>\n  static bool Matches(const MatcherTuple& /* matcher_tuple */,\n                      const ValueTuple& /* value_tuple */) {\n    return true;\n  }\n\n  template <typename MatcherTuple, typename ValueTuple>\n  static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */,\n                                     const ValueTuple& /* values */,\n                                     ::std::ostream* /* os */) {}\n};\n\n// TupleMatches(matcher_tuple, value_tuple) returns true if and only if\n// all matchers in matcher_tuple match the corresponding fields in\n// value_tuple.  It is a compiler error if matcher_tuple and\n// value_tuple have different number of fields or incompatible field\n// types.\ntemplate <typename MatcherTuple, typename ValueTuple>\nbool TupleMatches(const MatcherTuple& matcher_tuple,\n                  const ValueTuple& value_tuple) {\n  // Makes sure that matcher_tuple and value_tuple have the same\n  // number of fields.\n  GTEST_COMPILE_ASSERT_(std::tuple_size<MatcherTuple>::value ==\n                            std::tuple_size<ValueTuple>::value,\n                        matcher_and_value_have_different_numbers_of_fields);\n  return TuplePrefix<std::tuple_size<ValueTuple>::value>::Matches(matcher_tuple,\n                                                                  value_tuple);\n}\n\n// Describes failures in matching matchers against values.  If there\n// is no failure, nothing will be streamed to os.\ntemplate <typename MatcherTuple, typename ValueTuple>\nvoid ExplainMatchFailureTupleTo(const MatcherTuple& matchers,\n                                const ValueTuple& values,\n                                ::std::ostream* os) {\n  TuplePrefix<std::tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(\n      matchers, values, os);\n}\n\n// TransformTupleValues and its helper.\n//\n// TransformTupleValuesHelper hides the internal machinery that\n// TransformTupleValues uses to implement a tuple traversal.\ntemplate <typename Tuple, typename Func, typename OutIter>\nclass TransformTupleValuesHelper {\n private:\n  typedef ::std::tuple_size<Tuple> TupleSize;\n\n public:\n  // For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.\n  // Returns the final value of 'out' in case the caller needs it.\n  static OutIter Run(Func f, const Tuple& t, OutIter out) {\n    return IterateOverTuple<Tuple, TupleSize::value>()(f, t, out);\n  }\n\n private:\n  template <typename Tup, size_t kRemainingSize>\n  struct IterateOverTuple {\n    OutIter operator() (Func f, const Tup& t, OutIter out) const {\n      *out++ = f(::std::get<TupleSize::value - kRemainingSize>(t));\n      return IterateOverTuple<Tup, kRemainingSize - 1>()(f, t, out);\n    }\n  };\n  template <typename Tup>\n  struct IterateOverTuple<Tup, 0> {\n    OutIter operator() (Func /* f */, const Tup& /* t */, OutIter out) const {\n      return out;\n    }\n  };\n};\n\n// Successively invokes 'f(element)' on each element of the tuple 't',\n// appending each result to the 'out' iterator. Returns the final value\n// of 'out'.\ntemplate <typename Tuple, typename Func, typename OutIter>\nOutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) {\n  return TransformTupleValuesHelper<Tuple, Func, OutIter>::Run(f, t, out);\n}\n\n// Implements _, a matcher that matches any value of any\n// type.  This is a polymorphic matcher, so we need a template type\n// conversion operator to make it appearing as a Matcher<T> for any\n// type T.\nclass AnythingMatcher {\n public:\n  using is_gtest_matcher = void;\n\n  template <typename T>\n  bool MatchAndExplain(const T& /* x */, std::ostream* /* listener */) const {\n    return true;\n  }\n  void DescribeTo(std::ostream* os) const { *os << \"is anything\"; }\n  void DescribeNegationTo(::std::ostream* os) const {\n    // This is mostly for completeness' sake, as it's not very useful\n    // to write Not(A<bool>()).  However we cannot completely rule out\n    // such a possibility, and it doesn't hurt to be prepared.\n    *os << \"never matches\";\n  }\n};\n\n// Implements the polymorphic IsNull() matcher, which matches any raw or smart\n// pointer that is NULL.\nclass IsNullMatcher {\n public:\n  template <typename Pointer>\n  bool MatchAndExplain(const Pointer& p,\n                       MatchResultListener* /* listener */) const {\n    return p == nullptr;\n  }\n\n  void DescribeTo(::std::ostream* os) const { *os << \"is NULL\"; }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"isn't NULL\";\n  }\n};\n\n// Implements the polymorphic NotNull() matcher, which matches any raw or smart\n// pointer that is not NULL.\nclass NotNullMatcher {\n public:\n  template <typename Pointer>\n  bool MatchAndExplain(const Pointer& p,\n                       MatchResultListener* /* listener */) const {\n    return p != nullptr;\n  }\n\n  void DescribeTo(::std::ostream* os) const { *os << \"isn't NULL\"; }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"is NULL\";\n  }\n};\n\n// Ref(variable) matches any argument that is a reference to\n// 'variable'.  This matcher is polymorphic as it can match any\n// super type of the type of 'variable'.\n//\n// The RefMatcher template class implements Ref(variable).  It can\n// only be instantiated with a reference type.  This prevents a user\n// from mistakenly using Ref(x) to match a non-reference function\n// argument.  For example, the following will righteously cause a\n// compiler error:\n//\n//   int n;\n//   Matcher<int> m1 = Ref(n);   // This won't compile.\n//   Matcher<int&> m2 = Ref(n);  // This will compile.\ntemplate <typename T>\nclass RefMatcher;\n\ntemplate <typename T>\nclass RefMatcher<T&> {\n  // Google Mock is a generic framework and thus needs to support\n  // mocking any function types, including those that take non-const\n  // reference arguments.  Therefore the template parameter T (and\n  // Super below) can be instantiated to either a const type or a\n  // non-const type.\n public:\n  // RefMatcher() takes a T& instead of const T&, as we want the\n  // compiler to catch using Ref(const_value) as a matcher for a\n  // non-const reference.\n  explicit RefMatcher(T& x) : object_(x) {}  // NOLINT\n\n  template <typename Super>\n  operator Matcher<Super&>() const {\n    // By passing object_ (type T&) to Impl(), which expects a Super&,\n    // we make sure that Super is a super type of T.  In particular,\n    // this catches using Ref(const_value) as a matcher for a\n    // non-const reference, as you cannot implicitly convert a const\n    // reference to a non-const reference.\n    return MakeMatcher(new Impl<Super>(object_));\n  }\n\n private:\n  template <typename Super>\n  class Impl : public MatcherInterface<Super&> {\n   public:\n    explicit Impl(Super& x) : object_(x) {}  // NOLINT\n\n    // MatchAndExplain() takes a Super& (as opposed to const Super&)\n    // in order to match the interface MatcherInterface<Super&>.\n    bool MatchAndExplain(Super& x,\n                         MatchResultListener* listener) const override {\n      *listener << \"which is located @\" << static_cast<const void*>(&x);\n      return &x == &object_;\n    }\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"references the variable \";\n      UniversalPrinter<Super&>::Print(object_, os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"does not reference the variable \";\n      UniversalPrinter<Super&>::Print(object_, os);\n    }\n\n   private:\n    const Super& object_;\n  };\n\n  T& object_;\n};\n\n// Polymorphic helper functions for narrow and wide string matchers.\ninline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {\n  return String::CaseInsensitiveCStringEquals(lhs, rhs);\n}\n\ninline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,\n                                         const wchar_t* rhs) {\n  return String::CaseInsensitiveWideCStringEquals(lhs, rhs);\n}\n\n// String comparison for narrow or wide strings that can have embedded NUL\n// characters.\ntemplate <typename StringType>\nbool CaseInsensitiveStringEquals(const StringType& s1,\n                                 const StringType& s2) {\n  // Are the heads equal?\n  if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) {\n    return false;\n  }\n\n  // Skip the equal heads.\n  const typename StringType::value_type nul = 0;\n  const size_t i1 = s1.find(nul), i2 = s2.find(nul);\n\n  // Are we at the end of either s1 or s2?\n  if (i1 == StringType::npos || i2 == StringType::npos) {\n    return i1 == i2;\n  }\n\n  // Are the tails equal?\n  return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));\n}\n\n// String matchers.\n\n// Implements equality-based string matchers like StrEq, StrCaseNe, and etc.\ntemplate <typename StringType>\nclass StrEqualityMatcher {\n public:\n  StrEqualityMatcher(StringType str, bool expect_eq, bool case_sensitive)\n      : string_(std::move(str)),\n        expect_eq_(expect_eq),\n        case_sensitive_(case_sensitive) {}\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n  bool MatchAndExplain(const internal::StringView& s,\n                       MatchResultListener* listener) const {\n    // This should fail to compile if StringView is used with wide\n    // strings.\n    const StringType& str = std::string(s);\n    return MatchAndExplain(str, listener);\n  }\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    if (s == nullptr) {\n      return !expect_eq_;\n    }\n    return MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringView has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType s2(s);\n    const bool eq = case_sensitive_ ? s2 == string_ :\n        CaseInsensitiveStringEquals(s2, string_);\n    return expect_eq_ == eq;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    DescribeToHelper(expect_eq_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    DescribeToHelper(!expect_eq_, os);\n  }\n\n private:\n  void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {\n    *os << (expect_eq ? \"is \" : \"isn't \");\n    *os << \"equal to \";\n    if (!case_sensitive_) {\n      *os << \"(ignoring case) \";\n    }\n    UniversalPrint(string_, os);\n  }\n\n  const StringType string_;\n  const bool expect_eq_;\n  const bool case_sensitive_;\n};\n\n// Implements the polymorphic HasSubstr(substring) matcher, which\n// can be used as a Matcher<T> as long as T can be converted to a\n// string.\ntemplate <typename StringType>\nclass HasSubstrMatcher {\n public:\n  explicit HasSubstrMatcher(const StringType& substring)\n      : substring_(substring) {}\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n  bool MatchAndExplain(const internal::StringView& s,\n                       MatchResultListener* listener) const {\n    // This should fail to compile if StringView is used with wide\n    // strings.\n    const StringType& str = std::string(s);\n    return MatchAndExplain(str, listener);\n  }\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != nullptr && MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringView has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    return StringType(s).find(substring_) != StringType::npos;\n  }\n\n  // Describes what this matcher matches.\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"has substring \";\n    UniversalPrint(substring_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"has no substring \";\n    UniversalPrint(substring_, os);\n  }\n\n private:\n  const StringType substring_;\n};\n\n// Implements the polymorphic StartsWith(substring) matcher, which\n// can be used as a Matcher<T> as long as T can be converted to a\n// string.\ntemplate <typename StringType>\nclass StartsWithMatcher {\n public:\n  explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {\n  }\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n  bool MatchAndExplain(const internal::StringView& s,\n                       MatchResultListener* listener) const {\n    // This should fail to compile if StringView is used with wide\n    // strings.\n    const StringType& str = std::string(s);\n    return MatchAndExplain(str, listener);\n  }\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != nullptr && MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringView has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType& s2(s);\n    return s2.length() >= prefix_.length() &&\n        s2.substr(0, prefix_.length()) == prefix_;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"starts with \";\n    UniversalPrint(prefix_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't start with \";\n    UniversalPrint(prefix_, os);\n  }\n\n private:\n  const StringType prefix_;\n};\n\n// Implements the polymorphic EndsWith(substring) matcher, which\n// can be used as a Matcher<T> as long as T can be converted to a\n// string.\ntemplate <typename StringType>\nclass EndsWithMatcher {\n public:\n  explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n  bool MatchAndExplain(const internal::StringView& s,\n                       MatchResultListener* listener) const {\n    // This should fail to compile if StringView is used with wide\n    // strings.\n    const StringType& str = std::string(s);\n    return MatchAndExplain(str, listener);\n  }\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != nullptr && MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringView has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType& s2(s);\n    return s2.length() >= suffix_.length() &&\n        s2.substr(s2.length() - suffix_.length()) == suffix_;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"ends with \";\n    UniversalPrint(suffix_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't end with \";\n    UniversalPrint(suffix_, os);\n  }\n\n private:\n  const StringType suffix_;\n};\n\n// Implements a matcher that compares the two fields of a 2-tuple\n// using one of the ==, <=, <, etc, operators.  The two fields being\n// compared don't have to have the same type.\n//\n// The matcher defined here is polymorphic (for example, Eq() can be\n// used to match a std::tuple<int, short>, a std::tuple<const long&, double>,\n// etc).  Therefore we use a template type conversion operator in the\n// implementation.\ntemplate <typename D, typename Op>\nclass PairMatchBase {\n public:\n  template <typename T1, typename T2>\n  operator Matcher<::std::tuple<T1, T2>>() const {\n    return Matcher<::std::tuple<T1, T2>>(new Impl<const ::std::tuple<T1, T2>&>);\n  }\n  template <typename T1, typename T2>\n  operator Matcher<const ::std::tuple<T1, T2>&>() const {\n    return MakeMatcher(new Impl<const ::std::tuple<T1, T2>&>);\n  }\n\n private:\n  static ::std::ostream& GetDesc(::std::ostream& os) {  // NOLINT\n    return os << D::Desc();\n  }\n\n  template <typename Tuple>\n  class Impl : public MatcherInterface<Tuple> {\n   public:\n    bool MatchAndExplain(Tuple args,\n                         MatchResultListener* /* listener */) const override {\n      return Op()(::std::get<0>(args), ::std::get<1>(args));\n    }\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"are \" << GetDesc;\n    }\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"aren't \" << GetDesc;\n    }\n  };\n};\n\nclass Eq2Matcher : public PairMatchBase<Eq2Matcher, AnyEq> {\n public:\n  static const char* Desc() { return \"an equal pair\"; }\n};\nclass Ne2Matcher : public PairMatchBase<Ne2Matcher, AnyNe> {\n public:\n  static const char* Desc() { return \"an unequal pair\"; }\n};\nclass Lt2Matcher : public PairMatchBase<Lt2Matcher, AnyLt> {\n public:\n  static const char* Desc() { return \"a pair where the first < the second\"; }\n};\nclass Gt2Matcher : public PairMatchBase<Gt2Matcher, AnyGt> {\n public:\n  static const char* Desc() { return \"a pair where the first > the second\"; }\n};\nclass Le2Matcher : public PairMatchBase<Le2Matcher, AnyLe> {\n public:\n  static const char* Desc() { return \"a pair where the first <= the second\"; }\n};\nclass Ge2Matcher : public PairMatchBase<Ge2Matcher, AnyGe> {\n public:\n  static const char* Desc() { return \"a pair where the first >= the second\"; }\n};\n\n// Implements the Not(...) matcher for a particular argument type T.\n// We do not nest it inside the NotMatcher class template, as that\n// will prevent different instantiations of NotMatcher from sharing\n// the same NotMatcherImpl<T> class.\ntemplate <typename T>\nclass NotMatcherImpl : public MatcherInterface<const T&> {\n public:\n  explicit NotMatcherImpl(const Matcher<T>& matcher)\n      : matcher_(matcher) {}\n\n  bool MatchAndExplain(const T& x,\n                       MatchResultListener* listener) const override {\n    return !matcher_.MatchAndExplain(x, listener);\n  }\n\n  void DescribeTo(::std::ostream* os) const override {\n    matcher_.DescribeNegationTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    matcher_.DescribeTo(os);\n  }\n\n private:\n  const Matcher<T> matcher_;\n};\n\n// Implements the Not(m) matcher, which matches a value that doesn't\n// match matcher m.\ntemplate <typename InnerMatcher>\nclass NotMatcher {\n public:\n  explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}\n\n  // This template type conversion operator allows Not(m) to be used\n  // to match any type m can match.\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));\n  }\n\n private:\n  InnerMatcher matcher_;\n};\n\n// Implements the AllOf(m1, m2) matcher for a particular argument type\n// T. We do not nest it inside the BothOfMatcher class template, as\n// that will prevent different instantiations of BothOfMatcher from\n// sharing the same BothOfMatcherImpl<T> class.\ntemplate <typename T>\nclass AllOfMatcherImpl : public MatcherInterface<const T&> {\n public:\n  explicit AllOfMatcherImpl(std::vector<Matcher<T> > matchers)\n      : matchers_(std::move(matchers)) {}\n\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"(\";\n    for (size_t i = 0; i < matchers_.size(); ++i) {\n      if (i != 0) *os << \") and (\";\n      matchers_[i].DescribeTo(os);\n    }\n    *os << \")\";\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"(\";\n    for (size_t i = 0; i < matchers_.size(); ++i) {\n      if (i != 0) *os << \") or (\";\n      matchers_[i].DescribeNegationTo(os);\n    }\n    *os << \")\";\n  }\n\n  bool MatchAndExplain(const T& x,\n                       MatchResultListener* listener) const override {\n    // If either matcher1_ or matcher2_ doesn't match x, we only need\n    // to explain why one of them fails.\n    std::string all_match_result;\n\n    for (size_t i = 0; i < matchers_.size(); ++i) {\n      StringMatchResultListener slistener;\n      if (matchers_[i].MatchAndExplain(x, &slistener)) {\n        if (all_match_result.empty()) {\n          all_match_result = slistener.str();\n        } else {\n          std::string result = slistener.str();\n          if (!result.empty()) {\n            all_match_result += \", and \";\n            all_match_result += result;\n          }\n        }\n      } else {\n        *listener << slistener.str();\n        return false;\n      }\n    }\n\n    // Otherwise we need to explain why *both* of them match.\n    *listener << all_match_result;\n    return true;\n  }\n\n private:\n  const std::vector<Matcher<T> > matchers_;\n};\n\n// VariadicMatcher is used for the variadic implementation of\n// AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...).\n// CombiningMatcher<T> is used to recursively combine the provided matchers\n// (of type Args...).\ntemplate <template <typename T> class CombiningMatcher, typename... Args>\nclass VariadicMatcher {\n public:\n  VariadicMatcher(const Args&... matchers)  // NOLINT\n      : matchers_(matchers...) {\n    static_assert(sizeof...(Args) > 0, \"Must have at least one matcher.\");\n  }\n\n  VariadicMatcher(const VariadicMatcher&) = default;\n  VariadicMatcher& operator=(const VariadicMatcher&) = delete;\n\n  // This template type conversion operator allows an\n  // VariadicMatcher<Matcher1, Matcher2...> object to match any type that\n  // all of the provided matchers (Matcher1, Matcher2, ...) can match.\n  template <typename T>\n  operator Matcher<T>() const {\n    std::vector<Matcher<T> > values;\n    CreateVariadicMatcher<T>(&values, std::integral_constant<size_t, 0>());\n    return Matcher<T>(new CombiningMatcher<T>(std::move(values)));\n  }\n\n private:\n  template <typename T, size_t I>\n  void CreateVariadicMatcher(std::vector<Matcher<T> >* values,\n                             std::integral_constant<size_t, I>) const {\n    values->push_back(SafeMatcherCast<T>(std::get<I>(matchers_)));\n    CreateVariadicMatcher<T>(values, std::integral_constant<size_t, I + 1>());\n  }\n\n  template <typename T>\n  void CreateVariadicMatcher(\n      std::vector<Matcher<T> >*,\n      std::integral_constant<size_t, sizeof...(Args)>) const {}\n\n  std::tuple<Args...> matchers_;\n};\n\ntemplate <typename... Args>\nusing AllOfMatcher = VariadicMatcher<AllOfMatcherImpl, Args...>;\n\n// Implements the AnyOf(m1, m2) matcher for a particular argument type\n// T.  We do not nest it inside the AnyOfMatcher class template, as\n// that will prevent different instantiations of AnyOfMatcher from\n// sharing the same EitherOfMatcherImpl<T> class.\ntemplate <typename T>\nclass AnyOfMatcherImpl : public MatcherInterface<const T&> {\n public:\n  explicit AnyOfMatcherImpl(std::vector<Matcher<T> > matchers)\n      : matchers_(std::move(matchers)) {}\n\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"(\";\n    for (size_t i = 0; i < matchers_.size(); ++i) {\n      if (i != 0) *os << \") or (\";\n      matchers_[i].DescribeTo(os);\n    }\n    *os << \")\";\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"(\";\n    for (size_t i = 0; i < matchers_.size(); ++i) {\n      if (i != 0) *os << \") and (\";\n      matchers_[i].DescribeNegationTo(os);\n    }\n    *os << \")\";\n  }\n\n  bool MatchAndExplain(const T& x,\n                       MatchResultListener* listener) const override {\n    std::string no_match_result;\n\n    // If either matcher1_ or matcher2_ matches x, we just need to\n    // explain why *one* of them matches.\n    for (size_t i = 0; i < matchers_.size(); ++i) {\n      StringMatchResultListener slistener;\n      if (matchers_[i].MatchAndExplain(x, &slistener)) {\n        *listener << slistener.str();\n        return true;\n      } else {\n        if (no_match_result.empty()) {\n          no_match_result = slistener.str();\n        } else {\n          std::string result = slistener.str();\n          if (!result.empty()) {\n            no_match_result += \", and \";\n            no_match_result += result;\n          }\n        }\n      }\n    }\n\n    // Otherwise we need to explain why *both* of them fail.\n    *listener << no_match_result;\n    return false;\n  }\n\n private:\n  const std::vector<Matcher<T> > matchers_;\n};\n\n// AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).\ntemplate <typename... Args>\nusing AnyOfMatcher = VariadicMatcher<AnyOfMatcherImpl, Args...>;\n\n// Wrapper for implementation of Any/AllOfArray().\ntemplate <template <class> class MatcherImpl, typename T>\nclass SomeOfArrayMatcher {\n public:\n  // Constructs the matcher from a sequence of element values or\n  // element matchers.\n  template <typename Iter>\n  SomeOfArrayMatcher(Iter first, Iter last) : matchers_(first, last) {}\n\n  template <typename U>\n  operator Matcher<U>() const {  // NOLINT\n    using RawU = typename std::decay<U>::type;\n    std::vector<Matcher<RawU>> matchers;\n    for (const auto& matcher : matchers_) {\n      matchers.push_back(MatcherCast<RawU>(matcher));\n    }\n    return Matcher<U>(new MatcherImpl<RawU>(std::move(matchers)));\n  }\n\n private:\n  const ::std::vector<T> matchers_;\n};\n\ntemplate <typename T>\nusing AllOfArrayMatcher = SomeOfArrayMatcher<AllOfMatcherImpl, T>;\n\ntemplate <typename T>\nusing AnyOfArrayMatcher = SomeOfArrayMatcher<AnyOfMatcherImpl, T>;\n\n// Used for implementing Truly(pred), which turns a predicate into a\n// matcher.\ntemplate <typename Predicate>\nclass TrulyMatcher {\n public:\n  explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}\n\n  // This method template allows Truly(pred) to be used as a matcher\n  // for type T where T is the argument type of predicate 'pred'.  The\n  // argument is passed by reference as the predicate may be\n  // interested in the address of the argument.\n  template <typename T>\n  bool MatchAndExplain(T& x,  // NOLINT\n                       MatchResultListener* listener) const {\n    // Without the if-statement, MSVC sometimes warns about converting\n    // a value to bool (warning 4800).\n    //\n    // We cannot write 'return !!predicate_(x);' as that doesn't work\n    // when predicate_(x) returns a class convertible to bool but\n    // having no operator!().\n    if (predicate_(x))\n      return true;\n    *listener << \"didn't satisfy the given predicate\";\n    return false;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"satisfies the given predicate\";\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't satisfy the given predicate\";\n  }\n\n private:\n  Predicate predicate_;\n};\n\n// Used for implementing Matches(matcher), which turns a matcher into\n// a predicate.\ntemplate <typename M>\nclass MatcherAsPredicate {\n public:\n  explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}\n\n  // This template operator() allows Matches(m) to be used as a\n  // predicate on type T where m is a matcher on type T.\n  //\n  // The argument x is passed by reference instead of by value, as\n  // some matcher may be interested in its address (e.g. as in\n  // Matches(Ref(n))(x)).\n  template <typename T>\n  bool operator()(const T& x) const {\n    // We let matcher_ commit to a particular type here instead of\n    // when the MatcherAsPredicate object was constructed.  This\n    // allows us to write Matches(m) where m is a polymorphic matcher\n    // (e.g. Eq(5)).\n    //\n    // If we write Matcher<T>(matcher_).Matches(x) here, it won't\n    // compile when matcher_ has type Matcher<const T&>; if we write\n    // Matcher<const T&>(matcher_).Matches(x) here, it won't compile\n    // when matcher_ has type Matcher<T>; if we just write\n    // matcher_.Matches(x), it won't compile when matcher_ is\n    // polymorphic, e.g. Eq(5).\n    //\n    // MatcherCast<const T&>() is necessary for making the code work\n    // in all of the above situations.\n    return MatcherCast<const T&>(matcher_).Matches(x);\n  }\n\n private:\n  M matcher_;\n};\n\n// For implementing ASSERT_THAT() and EXPECT_THAT().  The template\n// argument M must be a type that can be converted to a matcher.\ntemplate <typename M>\nclass PredicateFormatterFromMatcher {\n public:\n  explicit PredicateFormatterFromMatcher(M m) : matcher_(std::move(m)) {}\n\n  // This template () operator allows a PredicateFormatterFromMatcher\n  // object to act as a predicate-formatter suitable for using with\n  // Google Test's EXPECT_PRED_FORMAT1() macro.\n  template <typename T>\n  AssertionResult operator()(const char* value_text, const T& x) const {\n    // We convert matcher_ to a Matcher<const T&> *now* instead of\n    // when the PredicateFormatterFromMatcher object was constructed,\n    // as matcher_ may be polymorphic (e.g. NotNull()) and we won't\n    // know which type to instantiate it to until we actually see the\n    // type of x here.\n    //\n    // We write SafeMatcherCast<const T&>(matcher_) instead of\n    // Matcher<const T&>(matcher_), as the latter won't compile when\n    // matcher_ has type Matcher<T> (e.g. An<int>()).\n    // We don't write MatcherCast<const T&> either, as that allows\n    // potentially unsafe downcasting of the matcher argument.\n    const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);\n\n    // The expected path here is that the matcher should match (i.e. that most\n    // tests pass) so optimize for this case.\n    if (matcher.Matches(x)) {\n      return AssertionSuccess();\n    }\n\n    ::std::stringstream ss;\n    ss << \"Value of: \" << value_text << \"\\n\"\n       << \"Expected: \";\n    matcher.DescribeTo(&ss);\n\n    // Rerun the matcher to \"PrintAndExplain\" the failure.\n    StringMatchResultListener listener;\n    if (MatchPrintAndExplain(x, matcher, &listener)) {\n      ss << \"\\n  The matcher failed on the initial attempt; but passed when \"\n            \"rerun to generate the explanation.\";\n    }\n    ss << \"\\n  Actual: \" << listener.str();\n    return AssertionFailure() << ss.str();\n  }\n\n private:\n  const M matcher_;\n};\n\n// A helper function for converting a matcher to a predicate-formatter\n// without the user needing to explicitly write the type.  This is\n// used for implementing ASSERT_THAT() and EXPECT_THAT().\n// Implementation detail: 'matcher' is received by-value to force decaying.\ntemplate <typename M>\ninline PredicateFormatterFromMatcher<M>\nMakePredicateFormatterFromMatcher(M matcher) {\n  return PredicateFormatterFromMatcher<M>(std::move(matcher));\n}\n\n// Implements the polymorphic IsNan() matcher, which matches any floating type\n// value that is Nan.\nclass IsNanMatcher {\n public:\n  template <typename FloatType>\n  bool MatchAndExplain(const FloatType& f,\n                       MatchResultListener* /* listener */) const {\n    return (::std::isnan)(f);\n  }\n\n  void DescribeTo(::std::ostream* os) const { *os << \"is NaN\"; }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"isn't NaN\";\n  }\n};\n\n// Implements the polymorphic floating point equality matcher, which matches\n// two float values using ULP-based approximation or, optionally, a\n// user-specified epsilon.  The template is meant to be instantiated with\n// FloatType being either float or double.\ntemplate <typename FloatType>\nclass FloatingEqMatcher {\n public:\n  // Constructor for FloatingEqMatcher.\n  // The matcher's input will be compared with expected.  The matcher treats two\n  // NANs as equal if nan_eq_nan is true.  Otherwise, under IEEE standards,\n  // equality comparisons between NANs will always return false.  We specify a\n  // negative max_abs_error_ term to indicate that ULP-based approximation will\n  // be used for comparison.\n  FloatingEqMatcher(FloatType expected, bool nan_eq_nan) :\n    expected_(expected), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) {\n  }\n\n  // Constructor that supports a user-specified max_abs_error that will be used\n  // for comparison instead of ULP-based approximation.  The max absolute\n  // should be non-negative.\n  FloatingEqMatcher(FloatType expected, bool nan_eq_nan,\n                    FloatType max_abs_error)\n      : expected_(expected),\n        nan_eq_nan_(nan_eq_nan),\n        max_abs_error_(max_abs_error) {\n    GTEST_CHECK_(max_abs_error >= 0)\n        << \", where max_abs_error is\" << max_abs_error;\n  }\n\n  // Implements floating point equality matcher as a Matcher<T>.\n  template <typename T>\n  class Impl : public MatcherInterface<T> {\n   public:\n    Impl(FloatType expected, bool nan_eq_nan, FloatType max_abs_error)\n        : expected_(expected),\n          nan_eq_nan_(nan_eq_nan),\n          max_abs_error_(max_abs_error) {}\n\n    bool MatchAndExplain(T value,\n                         MatchResultListener* listener) const override {\n      const FloatingPoint<FloatType> actual(value), expected(expected_);\n\n      // Compares NaNs first, if nan_eq_nan_ is true.\n      if (actual.is_nan() || expected.is_nan()) {\n        if (actual.is_nan() && expected.is_nan()) {\n          return nan_eq_nan_;\n        }\n        // One is nan; the other is not nan.\n        return false;\n      }\n      if (HasMaxAbsError()) {\n        // We perform an equality check so that inf will match inf, regardless\n        // of error bounds.  If the result of value - expected_ would result in\n        // overflow or if either value is inf, the default result is infinity,\n        // which should only match if max_abs_error_ is also infinity.\n        if (value == expected_) {\n          return true;\n        }\n\n        const FloatType diff = value - expected_;\n        if (::std::fabs(diff) <= max_abs_error_) {\n          return true;\n        }\n\n        if (listener->IsInterested()) {\n          *listener << \"which is \" << diff << \" from \" << expected_;\n        }\n        return false;\n      } else {\n        return actual.AlmostEquals(expected);\n      }\n    }\n\n    void DescribeTo(::std::ostream* os) const override {\n      // os->precision() returns the previously set precision, which we\n      // store to restore the ostream to its original configuration\n      // after outputting.\n      const ::std::streamsize old_precision = os->precision(\n          ::std::numeric_limits<FloatType>::digits10 + 2);\n      if (FloatingPoint<FloatType>(expected_).is_nan()) {\n        if (nan_eq_nan_) {\n          *os << \"is NaN\";\n        } else {\n          *os << \"never matches\";\n        }\n      } else {\n        *os << \"is approximately \" << expected_;\n        if (HasMaxAbsError()) {\n          *os << \" (absolute error <= \" << max_abs_error_ << \")\";\n        }\n      }\n      os->precision(old_precision);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      // As before, get original precision.\n      const ::std::streamsize old_precision = os->precision(\n          ::std::numeric_limits<FloatType>::digits10 + 2);\n      if (FloatingPoint<FloatType>(expected_).is_nan()) {\n        if (nan_eq_nan_) {\n          *os << \"isn't NaN\";\n        } else {\n          *os << \"is anything\";\n        }\n      } else {\n        *os << \"isn't approximately \" << expected_;\n        if (HasMaxAbsError()) {\n          *os << \" (absolute error > \" << max_abs_error_ << \")\";\n        }\n      }\n      // Restore original precision.\n      os->precision(old_precision);\n    }\n\n   private:\n    bool HasMaxAbsError() const {\n      return max_abs_error_ >= 0;\n    }\n\n    const FloatType expected_;\n    const bool nan_eq_nan_;\n    // max_abs_error will be used for value comparison when >= 0.\n    const FloatType max_abs_error_;\n  };\n\n  // The following 3 type conversion operators allow FloatEq(expected) and\n  // NanSensitiveFloatEq(expected) to be used as a Matcher<float>, a\n  // Matcher<const float&>, or a Matcher<float&>, but nothing else.\n  operator Matcher<FloatType>() const {\n    return MakeMatcher(\n        new Impl<FloatType>(expected_, nan_eq_nan_, max_abs_error_));\n  }\n\n  operator Matcher<const FloatType&>() const {\n    return MakeMatcher(\n        new Impl<const FloatType&>(expected_, nan_eq_nan_, max_abs_error_));\n  }\n\n  operator Matcher<FloatType&>() const {\n    return MakeMatcher(\n        new Impl<FloatType&>(expected_, nan_eq_nan_, max_abs_error_));\n  }\n\n private:\n  const FloatType expected_;\n  const bool nan_eq_nan_;\n  // max_abs_error will be used for value comparison when >= 0.\n  const FloatType max_abs_error_;\n};\n\n// A 2-tuple (\"binary\") wrapper around FloatingEqMatcher:\n// FloatingEq2Matcher() matches (x, y) by matching FloatingEqMatcher(x, false)\n// against y, and FloatingEq2Matcher(e) matches FloatingEqMatcher(x, false, e)\n// against y. The former implements \"Eq\", the latter \"Near\". At present, there\n// is no version that compares NaNs as equal.\ntemplate <typename FloatType>\nclass FloatingEq2Matcher {\n public:\n  FloatingEq2Matcher() { Init(-1, false); }\n\n  explicit FloatingEq2Matcher(bool nan_eq_nan) { Init(-1, nan_eq_nan); }\n\n  explicit FloatingEq2Matcher(FloatType max_abs_error) {\n    Init(max_abs_error, false);\n  }\n\n  FloatingEq2Matcher(FloatType max_abs_error, bool nan_eq_nan) {\n    Init(max_abs_error, nan_eq_nan);\n  }\n\n  template <typename T1, typename T2>\n  operator Matcher<::std::tuple<T1, T2>>() const {\n    return MakeMatcher(\n        new Impl<::std::tuple<T1, T2>>(max_abs_error_, nan_eq_nan_));\n  }\n  template <typename T1, typename T2>\n  operator Matcher<const ::std::tuple<T1, T2>&>() const {\n    return MakeMatcher(\n        new Impl<const ::std::tuple<T1, T2>&>(max_abs_error_, nan_eq_nan_));\n  }\n\n private:\n  static ::std::ostream& GetDesc(::std::ostream& os) {  // NOLINT\n    return os << \"an almost-equal pair\";\n  }\n\n  template <typename Tuple>\n  class Impl : public MatcherInterface<Tuple> {\n   public:\n    Impl(FloatType max_abs_error, bool nan_eq_nan) :\n        max_abs_error_(max_abs_error),\n        nan_eq_nan_(nan_eq_nan) {}\n\n    bool MatchAndExplain(Tuple args,\n                         MatchResultListener* listener) const override {\n      if (max_abs_error_ == -1) {\n        FloatingEqMatcher<FloatType> fm(::std::get<0>(args), nan_eq_nan_);\n        return static_cast<Matcher<FloatType>>(fm).MatchAndExplain(\n            ::std::get<1>(args), listener);\n      } else {\n        FloatingEqMatcher<FloatType> fm(::std::get<0>(args), nan_eq_nan_,\n                                        max_abs_error_);\n        return static_cast<Matcher<FloatType>>(fm).MatchAndExplain(\n            ::std::get<1>(args), listener);\n      }\n    }\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"are \" << GetDesc;\n    }\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"aren't \" << GetDesc;\n    }\n\n   private:\n    FloatType max_abs_error_;\n    const bool nan_eq_nan_;\n  };\n\n  void Init(FloatType max_abs_error_val, bool nan_eq_nan_val) {\n    max_abs_error_ = max_abs_error_val;\n    nan_eq_nan_ = nan_eq_nan_val;\n  }\n  FloatType max_abs_error_;\n  bool nan_eq_nan_;\n};\n\n// Implements the Pointee(m) matcher for matching a pointer whose\n// pointee matches matcher m.  The pointer can be either raw or smart.\ntemplate <typename InnerMatcher>\nclass PointeeMatcher {\n public:\n  explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}\n\n  // This type conversion operator template allows Pointee(m) to be\n  // used as a matcher for any pointer type whose pointee type is\n  // compatible with the inner matcher, where type Pointer can be\n  // either a raw pointer or a smart pointer.\n  //\n  // The reason we do this instead of relying on\n  // MakePolymorphicMatcher() is that the latter is not flexible\n  // enough for implementing the DescribeTo() method of Pointee().\n  template <typename Pointer>\n  operator Matcher<Pointer>() const {\n    return Matcher<Pointer>(new Impl<const Pointer&>(matcher_));\n  }\n\n private:\n  // The monomorphic implementation that works for a particular pointer type.\n  template <typename Pointer>\n  class Impl : public MatcherInterface<Pointer> {\n   public:\n    using Pointee =\n        typename std::pointer_traits<GTEST_REMOVE_REFERENCE_AND_CONST_(\n            Pointer)>::element_type;\n\n    explicit Impl(const InnerMatcher& matcher)\n        : matcher_(MatcherCast<const Pointee&>(matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"points to a value that \";\n      matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"does not point to a value that \";\n      matcher_.DescribeTo(os);\n    }\n\n    bool MatchAndExplain(Pointer pointer,\n                         MatchResultListener* listener) const override {\n      if (GetRawPointer(pointer) == nullptr) return false;\n\n      *listener << \"which points to \";\n      return MatchPrintAndExplain(*pointer, matcher_, listener);\n    }\n\n   private:\n    const Matcher<const Pointee&> matcher_;\n  };\n\n  const InnerMatcher matcher_;\n};\n\n// Implements the Pointer(m) matcher\n// Implements the Pointer(m) matcher for matching a pointer that matches matcher\n// m.  The pointer can be either raw or smart, and will match `m` against the\n// raw pointer.\ntemplate <typename InnerMatcher>\nclass PointerMatcher {\n public:\n  explicit PointerMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}\n\n  // This type conversion operator template allows Pointer(m) to be\n  // used as a matcher for any pointer type whose pointer type is\n  // compatible with the inner matcher, where type PointerType can be\n  // either a raw pointer or a smart pointer.\n  //\n  // The reason we do this instead of relying on\n  // MakePolymorphicMatcher() is that the latter is not flexible\n  // enough for implementing the DescribeTo() method of Pointer().\n  template <typename PointerType>\n  operator Matcher<PointerType>() const {  // NOLINT\n    return Matcher<PointerType>(new Impl<const PointerType&>(matcher_));\n  }\n\n private:\n  // The monomorphic implementation that works for a particular pointer type.\n  template <typename PointerType>\n  class Impl : public MatcherInterface<PointerType> {\n   public:\n    using Pointer =\n        const typename std::pointer_traits<GTEST_REMOVE_REFERENCE_AND_CONST_(\n            PointerType)>::element_type*;\n\n    explicit Impl(const InnerMatcher& matcher)\n        : matcher_(MatcherCast<Pointer>(matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"is a pointer that \";\n      matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"is not a pointer that \";\n      matcher_.DescribeTo(os);\n    }\n\n    bool MatchAndExplain(PointerType pointer,\n                         MatchResultListener* listener) const override {\n      *listener << \"which is a pointer that \";\n      Pointer p = GetRawPointer(pointer);\n      return MatchPrintAndExplain(p, matcher_, listener);\n    }\n\n   private:\n    Matcher<Pointer> matcher_;\n  };\n\n  const InnerMatcher matcher_;\n};\n\n#if GTEST_HAS_RTTI\n// Implements the WhenDynamicCastTo<T>(m) matcher that matches a pointer or\n// reference that matches inner_matcher when dynamic_cast<T> is applied.\n// The result of dynamic_cast<To> is forwarded to the inner matcher.\n// If To is a pointer and the cast fails, the inner matcher will receive NULL.\n// If To is a reference and the cast fails, this matcher returns false\n// immediately.\ntemplate <typename To>\nclass WhenDynamicCastToMatcherBase {\n public:\n  explicit WhenDynamicCastToMatcherBase(const Matcher<To>& matcher)\n      : matcher_(matcher) {}\n\n  void DescribeTo(::std::ostream* os) const {\n    GetCastTypeDescription(os);\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    GetCastTypeDescription(os);\n    matcher_.DescribeNegationTo(os);\n  }\n\n protected:\n  const Matcher<To> matcher_;\n\n  static std::string GetToName() {\n    return GetTypeName<To>();\n  }\n\n private:\n  static void GetCastTypeDescription(::std::ostream* os) {\n    *os << \"when dynamic_cast to \" << GetToName() << \", \";\n  }\n};\n\n// Primary template.\n// To is a pointer. Cast and forward the result.\ntemplate <typename To>\nclass WhenDynamicCastToMatcher : public WhenDynamicCastToMatcherBase<To> {\n public:\n  explicit WhenDynamicCastToMatcher(const Matcher<To>& matcher)\n      : WhenDynamicCastToMatcherBase<To>(matcher) {}\n\n  template <typename From>\n  bool MatchAndExplain(From from, MatchResultListener* listener) const {\n    To to = dynamic_cast<To>(from);\n    return MatchPrintAndExplain(to, this->matcher_, listener);\n  }\n};\n\n// Specialize for references.\n// In this case we return false if the dynamic_cast fails.\ntemplate <typename To>\nclass WhenDynamicCastToMatcher<To&> : public WhenDynamicCastToMatcherBase<To&> {\n public:\n  explicit WhenDynamicCastToMatcher(const Matcher<To&>& matcher)\n      : WhenDynamicCastToMatcherBase<To&>(matcher) {}\n\n  template <typename From>\n  bool MatchAndExplain(From& from, MatchResultListener* listener) const {\n    // We don't want an std::bad_cast here, so do the cast with pointers.\n    To* to = dynamic_cast<To*>(&from);\n    if (to == nullptr) {\n      *listener << \"which cannot be dynamic_cast to \" << this->GetToName();\n      return false;\n    }\n    return MatchPrintAndExplain(*to, this->matcher_, listener);\n  }\n};\n#endif  // GTEST_HAS_RTTI\n\n// Implements the Field() matcher for matching a field (i.e. member\n// variable) of an object.\ntemplate <typename Class, typename FieldType>\nclass FieldMatcher {\n public:\n  FieldMatcher(FieldType Class::*field,\n               const Matcher<const FieldType&>& matcher)\n      : field_(field), matcher_(matcher), whose_field_(\"whose given field \") {}\n\n  FieldMatcher(const std::string& field_name, FieldType Class::*field,\n               const Matcher<const FieldType&>& matcher)\n      : field_(field),\n        matcher_(matcher),\n        whose_field_(\"whose field `\" + field_name + \"` \") {}\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"is an object \" << whose_field_;\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"is an object \" << whose_field_;\n    matcher_.DescribeNegationTo(os);\n  }\n\n  template <typename T>\n  bool MatchAndExplain(const T& value, MatchResultListener* listener) const {\n    // FIXME: The dispatch on std::is_pointer was introduced as a workaround for\n    // a compiler bug, and can now be removed.\n    return MatchAndExplainImpl(\n        typename std::is_pointer<typename std::remove_const<T>::type>::type(),\n        value, listener);\n  }\n\n private:\n  bool MatchAndExplainImpl(std::false_type /* is_not_pointer */,\n                           const Class& obj,\n                           MatchResultListener* listener) const {\n    *listener << whose_field_ << \"is \";\n    return MatchPrintAndExplain(obj.*field_, matcher_, listener);\n  }\n\n  bool MatchAndExplainImpl(std::true_type /* is_pointer */, const Class* p,\n                           MatchResultListener* listener) const {\n    if (p == nullptr) return false;\n\n    *listener << \"which points to an object \";\n    // Since *p has a field, it must be a class/struct/union type and\n    // thus cannot be a pointer.  Therefore we pass false_type() as\n    // the first argument.\n    return MatchAndExplainImpl(std::false_type(), *p, listener);\n  }\n\n  const FieldType Class::*field_;\n  const Matcher<const FieldType&> matcher_;\n\n  // Contains either \"whose given field \" if the name of the field is unknown\n  // or \"whose field `name_of_field` \" if the name is known.\n  const std::string whose_field_;\n};\n\n// Implements the Property() matcher for matching a property\n// (i.e. return value of a getter method) of an object.\n//\n// Property is a const-qualified member function of Class returning\n// PropertyType.\ntemplate <typename Class, typename PropertyType, typename Property>\nclass PropertyMatcher {\n public:\n  typedef const PropertyType& RefToConstProperty;\n\n  PropertyMatcher(Property property, const Matcher<RefToConstProperty>& matcher)\n      : property_(property),\n        matcher_(matcher),\n        whose_property_(\"whose given property \") {}\n\n  PropertyMatcher(const std::string& property_name, Property property,\n                  const Matcher<RefToConstProperty>& matcher)\n      : property_(property),\n        matcher_(matcher),\n        whose_property_(\"whose property `\" + property_name + \"` \") {}\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"is an object \" << whose_property_;\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"is an object \" << whose_property_;\n    matcher_.DescribeNegationTo(os);\n  }\n\n  template <typename T>\n  bool MatchAndExplain(const T&value, MatchResultListener* listener) const {\n    return MatchAndExplainImpl(\n        typename std::is_pointer<typename std::remove_const<T>::type>::type(),\n        value, listener);\n  }\n\n private:\n  bool MatchAndExplainImpl(std::false_type /* is_not_pointer */,\n                           const Class& obj,\n                           MatchResultListener* listener) const {\n    *listener << whose_property_ << \"is \";\n    // Cannot pass the return value (for example, int) to MatchPrintAndExplain,\n    // which takes a non-const reference as argument.\n    RefToConstProperty result = (obj.*property_)();\n    return MatchPrintAndExplain(result, matcher_, listener);\n  }\n\n  bool MatchAndExplainImpl(std::true_type /* is_pointer */, const Class* p,\n                           MatchResultListener* listener) const {\n    if (p == nullptr) return false;\n\n    *listener << \"which points to an object \";\n    // Since *p has a property method, it must be a class/struct/union\n    // type and thus cannot be a pointer.  Therefore we pass\n    // false_type() as the first argument.\n    return MatchAndExplainImpl(std::false_type(), *p, listener);\n  }\n\n  Property property_;\n  const Matcher<RefToConstProperty> matcher_;\n\n  // Contains either \"whose given property \" if the name of the property is\n  // unknown or \"whose property `name_of_property` \" if the name is known.\n  const std::string whose_property_;\n};\n\n// Type traits specifying various features of different functors for ResultOf.\n// The default template specifies features for functor objects.\ntemplate <typename Functor>\nstruct CallableTraits {\n  typedef Functor StorageType;\n\n  static void CheckIsValid(Functor /* functor */) {}\n\n  template <typename T>\n  static auto Invoke(Functor f, const T& arg) -> decltype(f(arg)) {\n    return f(arg);\n  }\n};\n\n// Specialization for function pointers.\ntemplate <typename ArgType, typename ResType>\nstruct CallableTraits<ResType(*)(ArgType)> {\n  typedef ResType ResultType;\n  typedef ResType(*StorageType)(ArgType);\n\n  static void CheckIsValid(ResType(*f)(ArgType)) {\n    GTEST_CHECK_(f != nullptr)\n        << \"NULL function pointer is passed into ResultOf().\";\n  }\n  template <typename T>\n  static ResType Invoke(ResType(*f)(ArgType), T arg) {\n    return (*f)(arg);\n  }\n};\n\n// Implements the ResultOf() matcher for matching a return value of a\n// unary function of an object.\ntemplate <typename Callable, typename InnerMatcher>\nclass ResultOfMatcher {\n public:\n  ResultOfMatcher(Callable callable, InnerMatcher matcher)\n      : callable_(std::move(callable)), matcher_(std::move(matcher)) {\n    CallableTraits<Callable>::CheckIsValid(callable_);\n  }\n\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new Impl<const T&>(callable_, matcher_));\n  }\n\n private:\n  typedef typename CallableTraits<Callable>::StorageType CallableStorageType;\n\n  template <typename T>\n  class Impl : public MatcherInterface<T> {\n    using ResultType = decltype(CallableTraits<Callable>::template Invoke<T>(\n        std::declval<CallableStorageType>(), std::declval<T>()));\n\n   public:\n    template <typename M>\n    Impl(const CallableStorageType& callable, const M& matcher)\n        : callable_(callable), matcher_(MatcherCast<ResultType>(matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"is mapped by the given callable to a value that \";\n      matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"is mapped by the given callable to a value that \";\n      matcher_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(T obj, MatchResultListener* listener) const override {\n      *listener << \"which is mapped by the given callable to \";\n      // Cannot pass the return value directly to MatchPrintAndExplain, which\n      // takes a non-const reference as argument.\n      // Also, specifying template argument explicitly is needed because T could\n      // be a non-const reference (e.g. Matcher<Uncopyable&>).\n      ResultType result =\n          CallableTraits<Callable>::template Invoke<T>(callable_, obj);\n      return MatchPrintAndExplain(result, matcher_, listener);\n    }\n\n   private:\n    // Functors often define operator() as non-const method even though\n    // they are actually stateless. But we need to use them even when\n    // 'this' is a const pointer. It's the user's responsibility not to\n    // use stateful callables with ResultOf(), which doesn't guarantee\n    // how many times the callable will be invoked.\n    mutable CallableStorageType callable_;\n    const Matcher<ResultType> matcher_;\n  };  // class Impl\n\n  const CallableStorageType callable_;\n  const InnerMatcher matcher_;\n};\n\n// Implements a matcher that checks the size of an STL-style container.\ntemplate <typename SizeMatcher>\nclass SizeIsMatcher {\n public:\n  explicit SizeIsMatcher(const SizeMatcher& size_matcher)\n       : size_matcher_(size_matcher) {\n  }\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return Matcher<Container>(new Impl<const Container&>(size_matcher_));\n  }\n\n  template <typename Container>\n  class Impl : public MatcherInterface<Container> {\n   public:\n    using SizeType = decltype(std::declval<Container>().size());\n    explicit Impl(const SizeMatcher& size_matcher)\n        : size_matcher_(MatcherCast<SizeType>(size_matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"size \";\n      size_matcher_.DescribeTo(os);\n    }\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"size \";\n      size_matcher_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(Container container,\n                         MatchResultListener* listener) const override {\n      SizeType size = container.size();\n      StringMatchResultListener size_listener;\n      const bool result = size_matcher_.MatchAndExplain(size, &size_listener);\n      *listener\n          << \"whose size \" << size << (result ? \" matches\" : \" doesn't match\");\n      PrintIfNotEmpty(size_listener.str(), listener->stream());\n      return result;\n    }\n\n   private:\n    const Matcher<SizeType> size_matcher_;\n  };\n\n private:\n  const SizeMatcher size_matcher_;\n};\n\n// Implements a matcher that checks the begin()..end() distance of an STL-style\n// container.\ntemplate <typename DistanceMatcher>\nclass BeginEndDistanceIsMatcher {\n public:\n  explicit BeginEndDistanceIsMatcher(const DistanceMatcher& distance_matcher)\n      : distance_matcher_(distance_matcher) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return Matcher<Container>(new Impl<const Container&>(distance_matcher_));\n  }\n\n  template <typename Container>\n  class Impl : public MatcherInterface<Container> {\n   public:\n    typedef internal::StlContainerView<\n        GTEST_REMOVE_REFERENCE_AND_CONST_(Container)> ContainerView;\n    typedef typename std::iterator_traits<\n        typename ContainerView::type::const_iterator>::difference_type\n        DistanceType;\n    explicit Impl(const DistanceMatcher& distance_matcher)\n        : distance_matcher_(MatcherCast<DistanceType>(distance_matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"distance between begin() and end() \";\n      distance_matcher_.DescribeTo(os);\n    }\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"distance between begin() and end() \";\n      distance_matcher_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(Container container,\n                         MatchResultListener* listener) const override {\n      using std::begin;\n      using std::end;\n      DistanceType distance = std::distance(begin(container), end(container));\n      StringMatchResultListener distance_listener;\n      const bool result =\n          distance_matcher_.MatchAndExplain(distance, &distance_listener);\n      *listener << \"whose distance between begin() and end() \" << distance\n                << (result ? \" matches\" : \" doesn't match\");\n      PrintIfNotEmpty(distance_listener.str(), listener->stream());\n      return result;\n    }\n\n   private:\n    const Matcher<DistanceType> distance_matcher_;\n  };\n\n private:\n  const DistanceMatcher distance_matcher_;\n};\n\n// Implements an equality matcher for any STL-style container whose elements\n// support ==. This matcher is like Eq(), but its failure explanations provide\n// more detailed information that is useful when the container is used as a set.\n// The failure message reports elements that are in one of the operands but not\n// the other. The failure messages do not report duplicate or out-of-order\n// elements in the containers (which don't properly matter to sets, but can\n// occur if the containers are vectors or lists, for example).\n//\n// Uses the container's const_iterator, value_type, operator ==,\n// begin(), and end().\ntemplate <typename Container>\nclass ContainerEqMatcher {\n public:\n  typedef internal::StlContainerView<Container> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n\n  static_assert(!std::is_const<Container>::value,\n                \"Container type must not be const\");\n  static_assert(!std::is_reference<Container>::value,\n                \"Container type must not be a reference\");\n\n  // We make a copy of expected in case the elements in it are modified\n  // after this matcher is created.\n  explicit ContainerEqMatcher(const Container& expected)\n      : expected_(View::Copy(expected)) {}\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"equals \";\n    UniversalPrint(expected_, os);\n  }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"does not equal \";\n    UniversalPrint(expected_, os);\n  }\n\n  template <typename LhsContainer>\n  bool MatchAndExplain(const LhsContainer& lhs,\n                       MatchResultListener* listener) const {\n    typedef internal::StlContainerView<\n        typename std::remove_const<LhsContainer>::type>\n        LhsView;\n    typedef typename LhsView::type LhsStlContainer;\n    StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);\n    if (lhs_stl_container == expected_)\n      return true;\n\n    ::std::ostream* const os = listener->stream();\n    if (os != nullptr) {\n      // Something is different. Check for extra values first.\n      bool printed_header = false;\n      for (typename LhsStlContainer::const_iterator it =\n               lhs_stl_container.begin();\n           it != lhs_stl_container.end(); ++it) {\n        if (internal::ArrayAwareFind(expected_.begin(), expected_.end(), *it) ==\n            expected_.end()) {\n          if (printed_header) {\n            *os << \", \";\n          } else {\n            *os << \"which has these unexpected elements: \";\n            printed_header = true;\n          }\n          UniversalPrint(*it, os);\n        }\n      }\n\n      // Now check for missing values.\n      bool printed_header2 = false;\n      for (typename StlContainer::const_iterator it = expected_.begin();\n           it != expected_.end(); ++it) {\n        if (internal::ArrayAwareFind(\n                lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==\n            lhs_stl_container.end()) {\n          if (printed_header2) {\n            *os << \", \";\n          } else {\n            *os << (printed_header ? \",\\nand\" : \"which\")\n                << \" doesn't have these expected elements: \";\n            printed_header2 = true;\n          }\n          UniversalPrint(*it, os);\n        }\n      }\n    }\n\n    return false;\n  }\n\n private:\n  const StlContainer expected_;\n};\n\n// A comparator functor that uses the < operator to compare two values.\nstruct LessComparator {\n  template <typename T, typename U>\n  bool operator()(const T& lhs, const U& rhs) const { return lhs < rhs; }\n};\n\n// Implements WhenSortedBy(comparator, container_matcher).\ntemplate <typename Comparator, typename ContainerMatcher>\nclass WhenSortedByMatcher {\n public:\n  WhenSortedByMatcher(const Comparator& comparator,\n                      const ContainerMatcher& matcher)\n      : comparator_(comparator), matcher_(matcher) {}\n\n  template <typename LhsContainer>\n  operator Matcher<LhsContainer>() const {\n    return MakeMatcher(new Impl<LhsContainer>(comparator_, matcher_));\n  }\n\n  template <typename LhsContainer>\n  class Impl : public MatcherInterface<LhsContainer> {\n   public:\n    typedef internal::StlContainerView<\n         GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;\n    typedef typename LhsView::type LhsStlContainer;\n    typedef typename LhsView::const_reference LhsStlContainerReference;\n    // Transforms std::pair<const Key, Value> into std::pair<Key, Value>\n    // so that we can match associative containers.\n    typedef typename RemoveConstFromKey<\n        typename LhsStlContainer::value_type>::type LhsValue;\n\n    Impl(const Comparator& comparator, const ContainerMatcher& matcher)\n        : comparator_(comparator), matcher_(matcher) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"(when sorted) \";\n      matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"(when sorted) \";\n      matcher_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(LhsContainer lhs,\n                         MatchResultListener* listener) const override {\n      LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);\n      ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),\n                                               lhs_stl_container.end());\n      ::std::sort(\n           sorted_container.begin(), sorted_container.end(), comparator_);\n\n      if (!listener->IsInterested()) {\n        // If the listener is not interested, we do not need to\n        // construct the inner explanation.\n        return matcher_.Matches(sorted_container);\n      }\n\n      *listener << \"which is \";\n      UniversalPrint(sorted_container, listener->stream());\n      *listener << \" when sorted\";\n\n      StringMatchResultListener inner_listener;\n      const bool match = matcher_.MatchAndExplain(sorted_container,\n                                                  &inner_listener);\n      PrintIfNotEmpty(inner_listener.str(), listener->stream());\n      return match;\n    }\n\n   private:\n    const Comparator comparator_;\n    const Matcher<const ::std::vector<LhsValue>&> matcher_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);\n  };\n\n private:\n  const Comparator comparator_;\n  const ContainerMatcher matcher_;\n};\n\n// Implements Pointwise(tuple_matcher, rhs_container).  tuple_matcher\n// must be able to be safely cast to Matcher<std::tuple<const T1&, const\n// T2&> >, where T1 and T2 are the types of elements in the LHS\n// container and the RHS container respectively.\ntemplate <typename TupleMatcher, typename RhsContainer>\nclass PointwiseMatcher {\n  GTEST_COMPILE_ASSERT_(\n      !IsHashTable<GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)>::value,\n      use_UnorderedPointwise_with_hash_tables);\n\n public:\n  typedef internal::StlContainerView<RhsContainer> RhsView;\n  typedef typename RhsView::type RhsStlContainer;\n  typedef typename RhsStlContainer::value_type RhsValue;\n\n  static_assert(!std::is_const<RhsContainer>::value,\n                \"RhsContainer type must not be const\");\n  static_assert(!std::is_reference<RhsContainer>::value,\n                \"RhsContainer type must not be a reference\");\n\n  // Like ContainerEq, we make a copy of rhs in case the elements in\n  // it are modified after this matcher is created.\n  PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)\n      : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs)) {}\n\n  template <typename LhsContainer>\n  operator Matcher<LhsContainer>() const {\n    GTEST_COMPILE_ASSERT_(\n        !IsHashTable<GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)>::value,\n        use_UnorderedPointwise_with_hash_tables);\n\n    return Matcher<LhsContainer>(\n        new Impl<const LhsContainer&>(tuple_matcher_, rhs_));\n  }\n\n  template <typename LhsContainer>\n  class Impl : public MatcherInterface<LhsContainer> {\n   public:\n    typedef internal::StlContainerView<\n         GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;\n    typedef typename LhsView::type LhsStlContainer;\n    typedef typename LhsView::const_reference LhsStlContainerReference;\n    typedef typename LhsStlContainer::value_type LhsValue;\n    // We pass the LHS value and the RHS value to the inner matcher by\n    // reference, as they may be expensive to copy.  We must use tuple\n    // instead of pair here, as a pair cannot hold references (C++ 98,\n    // 20.2.2 [lib.pairs]).\n    typedef ::std::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;\n\n    Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)\n        // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.\n        : mono_tuple_matcher_(SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),\n          rhs_(rhs) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"contains \" << rhs_.size()\n          << \" values, where each value and its corresponding value in \";\n      UniversalPrinter<RhsStlContainer>::Print(rhs_, os);\n      *os << \" \";\n      mono_tuple_matcher_.DescribeTo(os);\n    }\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"doesn't contain exactly \" << rhs_.size()\n          << \" values, or contains a value x at some index i\"\n          << \" where x and the i-th value of \";\n      UniversalPrint(rhs_, os);\n      *os << \" \";\n      mono_tuple_matcher_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(LhsContainer lhs,\n                         MatchResultListener* listener) const override {\n      LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);\n      const size_t actual_size = lhs_stl_container.size();\n      if (actual_size != rhs_.size()) {\n        *listener << \"which contains \" << actual_size << \" values\";\n        return false;\n      }\n\n      typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();\n      typename RhsStlContainer::const_iterator right = rhs_.begin();\n      for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {\n        if (listener->IsInterested()) {\n          StringMatchResultListener inner_listener;\n          // Create InnerMatcherArg as a temporarily object to avoid it outlives\n          // *left and *right. Dereference or the conversion to `const T&` may\n          // return temp objects, e.g for vector<bool>.\n          if (!mono_tuple_matcher_.MatchAndExplain(\n                  InnerMatcherArg(ImplicitCast_<const LhsValue&>(*left),\n                                  ImplicitCast_<const RhsValue&>(*right)),\n                  &inner_listener)) {\n            *listener << \"where the value pair (\";\n            UniversalPrint(*left, listener->stream());\n            *listener << \", \";\n            UniversalPrint(*right, listener->stream());\n            *listener << \") at index #\" << i << \" don't match\";\n            PrintIfNotEmpty(inner_listener.str(), listener->stream());\n            return false;\n          }\n        } else {\n          if (!mono_tuple_matcher_.Matches(\n                  InnerMatcherArg(ImplicitCast_<const LhsValue&>(*left),\n                                  ImplicitCast_<const RhsValue&>(*right))))\n            return false;\n        }\n      }\n\n      return true;\n    }\n\n   private:\n    const Matcher<InnerMatcherArg> mono_tuple_matcher_;\n    const RhsStlContainer rhs_;\n  };\n\n private:\n  const TupleMatcher tuple_matcher_;\n  const RhsStlContainer rhs_;\n};\n\n// Holds the logic common to ContainsMatcherImpl and EachMatcherImpl.\ntemplate <typename Container>\nclass QuantifierMatcherImpl : public MatcherInterface<Container> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n  typedef StlContainerView<RawContainer> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n  typedef typename StlContainer::value_type Element;\n\n  template <typename InnerMatcher>\n  explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)\n      : inner_matcher_(\n           testing::SafeMatcherCast<const Element&>(inner_matcher)) {}\n\n  // Checks whether:\n  // * All elements in the container match, if all_elements_should_match.\n  // * Any element in the container matches, if !all_elements_should_match.\n  bool MatchAndExplainImpl(bool all_elements_should_match,\n                           Container container,\n                           MatchResultListener* listener) const {\n    StlContainerReference stl_container = View::ConstReference(container);\n    size_t i = 0;\n    for (typename StlContainer::const_iterator it = stl_container.begin();\n         it != stl_container.end(); ++it, ++i) {\n      StringMatchResultListener inner_listener;\n      const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);\n\n      if (matches != all_elements_should_match) {\n        *listener << \"whose element #\" << i\n                  << (matches ? \" matches\" : \" doesn't match\");\n        PrintIfNotEmpty(inner_listener.str(), listener->stream());\n        return !all_elements_should_match;\n      }\n    }\n    return all_elements_should_match;\n  }\n\n protected:\n  const Matcher<const Element&> inner_matcher_;\n};\n\n// Implements Contains(element_matcher) for the given argument type Container.\n// Symmetric to EachMatcherImpl.\ntemplate <typename Container>\nclass ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {\n public:\n  template <typename InnerMatcher>\n  explicit ContainsMatcherImpl(InnerMatcher inner_matcher)\n      : QuantifierMatcherImpl<Container>(inner_matcher) {}\n\n  // Describes what this matcher does.\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"contains at least one element that \";\n    this->inner_matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"doesn't contain any element that \";\n    this->inner_matcher_.DescribeTo(os);\n  }\n\n  bool MatchAndExplain(Container container,\n                       MatchResultListener* listener) const override {\n    return this->MatchAndExplainImpl(false, container, listener);\n  }\n};\n\n// Implements Each(element_matcher) for the given argument type Container.\n// Symmetric to ContainsMatcherImpl.\ntemplate <typename Container>\nclass EachMatcherImpl : public QuantifierMatcherImpl<Container> {\n public:\n  template <typename InnerMatcher>\n  explicit EachMatcherImpl(InnerMatcher inner_matcher)\n      : QuantifierMatcherImpl<Container>(inner_matcher) {}\n\n  // Describes what this matcher does.\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"only contains elements that \";\n    this->inner_matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"contains some element that \";\n    this->inner_matcher_.DescribeNegationTo(os);\n  }\n\n  bool MatchAndExplain(Container container,\n                       MatchResultListener* listener) const override {\n    return this->MatchAndExplainImpl(true, container, listener);\n  }\n};\n\n// Implements polymorphic Contains(element_matcher).\ntemplate <typename M>\nclass ContainsMatcher {\n public:\n  explicit ContainsMatcher(M m) : inner_matcher_(m) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return Matcher<Container>(\n        new ContainsMatcherImpl<const Container&>(inner_matcher_));\n  }\n\n private:\n  const M inner_matcher_;\n};\n\n// Implements polymorphic Each(element_matcher).\ntemplate <typename M>\nclass EachMatcher {\n public:\n  explicit EachMatcher(M m) : inner_matcher_(m) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return Matcher<Container>(\n        new EachMatcherImpl<const Container&>(inner_matcher_));\n  }\n\n private:\n  const M inner_matcher_;\n};\n\nstruct Rank1 {};\nstruct Rank0 : Rank1 {};\n\nnamespace pair_getters {\nusing std::get;\ntemplate <typename T>\nauto First(T& x, Rank1) -> decltype(get<0>(x)) {  // NOLINT\n  return get<0>(x);\n}\ntemplate <typename T>\nauto First(T& x, Rank0) -> decltype((x.first)) {  // NOLINT\n  return x.first;\n}\n\ntemplate <typename T>\nauto Second(T& x, Rank1) -> decltype(get<1>(x)) {  // NOLINT\n  return get<1>(x);\n}\ntemplate <typename T>\nauto Second(T& x, Rank0) -> decltype((x.second)) {  // NOLINT\n  return x.second;\n}\n}  // namespace pair_getters\n\n// Implements Key(inner_matcher) for the given argument pair type.\n// Key(inner_matcher) matches an std::pair whose 'first' field matches\n// inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an\n// std::map that contains at least one element whose key is >= 5.\ntemplate <typename PairType>\nclass KeyMatcherImpl : public MatcherInterface<PairType> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;\n  typedef typename RawPairType::first_type KeyType;\n\n  template <typename InnerMatcher>\n  explicit KeyMatcherImpl(InnerMatcher inner_matcher)\n      : inner_matcher_(\n          testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {\n  }\n\n  // Returns true if and only if 'key_value.first' (the key) matches the inner\n  // matcher.\n  bool MatchAndExplain(PairType key_value,\n                       MatchResultListener* listener) const override {\n    StringMatchResultListener inner_listener;\n    const bool match = inner_matcher_.MatchAndExplain(\n        pair_getters::First(key_value, Rank0()), &inner_listener);\n    const std::string explanation = inner_listener.str();\n    if (explanation != \"\") {\n      *listener << \"whose first field is a value \" << explanation;\n    }\n    return match;\n  }\n\n  // Describes what this matcher does.\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"has a key that \";\n    inner_matcher_.DescribeTo(os);\n  }\n\n  // Describes what the negation of this matcher does.\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"doesn't have a key that \";\n    inner_matcher_.DescribeTo(os);\n  }\n\n private:\n  const Matcher<const KeyType&> inner_matcher_;\n};\n\n// Implements polymorphic Key(matcher_for_key).\ntemplate <typename M>\nclass KeyMatcher {\n public:\n  explicit KeyMatcher(M m) : matcher_for_key_(m) {}\n\n  template <typename PairType>\n  operator Matcher<PairType>() const {\n    return Matcher<PairType>(\n        new KeyMatcherImpl<const PairType&>(matcher_for_key_));\n  }\n\n private:\n  const M matcher_for_key_;\n};\n\n// Implements polymorphic Address(matcher_for_address).\ntemplate <typename InnerMatcher>\nclass AddressMatcher {\n public:\n  explicit AddressMatcher(InnerMatcher m) : matcher_(m) {}\n\n  template <typename Type>\n  operator Matcher<Type>() const {  // NOLINT\n    return Matcher<Type>(new Impl<const Type&>(matcher_));\n  }\n\n private:\n  // The monomorphic implementation that works for a particular object type.\n  template <typename Type>\n  class Impl : public MatcherInterface<Type> {\n   public:\n    using Address = const GTEST_REMOVE_REFERENCE_AND_CONST_(Type) *;\n    explicit Impl(const InnerMatcher& matcher)\n        : matcher_(MatcherCast<Address>(matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"has address that \";\n      matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"does not have address that \";\n      matcher_.DescribeTo(os);\n    }\n\n    bool MatchAndExplain(Type object,\n                         MatchResultListener* listener) const override {\n      *listener << \"which has address \";\n      Address address = std::addressof(object);\n      return MatchPrintAndExplain(address, matcher_, listener);\n    }\n\n   private:\n    const Matcher<Address> matcher_;\n  };\n  const InnerMatcher matcher_;\n};\n\n// Implements Pair(first_matcher, second_matcher) for the given argument pair\n// type with its two matchers. See Pair() function below.\ntemplate <typename PairType>\nclass PairMatcherImpl : public MatcherInterface<PairType> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;\n  typedef typename RawPairType::first_type FirstType;\n  typedef typename RawPairType::second_type SecondType;\n\n  template <typename FirstMatcher, typename SecondMatcher>\n  PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)\n      : first_matcher_(\n            testing::SafeMatcherCast<const FirstType&>(first_matcher)),\n        second_matcher_(\n            testing::SafeMatcherCast<const SecondType&>(second_matcher)) {\n  }\n\n  // Describes what this matcher does.\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"has a first field that \";\n    first_matcher_.DescribeTo(os);\n    *os << \", and has a second field that \";\n    second_matcher_.DescribeTo(os);\n  }\n\n  // Describes what the negation of this matcher does.\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"has a first field that \";\n    first_matcher_.DescribeNegationTo(os);\n    *os << \", or has a second field that \";\n    second_matcher_.DescribeNegationTo(os);\n  }\n\n  // Returns true if and only if 'a_pair.first' matches first_matcher and\n  // 'a_pair.second' matches second_matcher.\n  bool MatchAndExplain(PairType a_pair,\n                       MatchResultListener* listener) const override {\n    if (!listener->IsInterested()) {\n      // If the listener is not interested, we don't need to construct the\n      // explanation.\n      return first_matcher_.Matches(pair_getters::First(a_pair, Rank0())) &&\n             second_matcher_.Matches(pair_getters::Second(a_pair, Rank0()));\n    }\n    StringMatchResultListener first_inner_listener;\n    if (!first_matcher_.MatchAndExplain(pair_getters::First(a_pair, Rank0()),\n                                        &first_inner_listener)) {\n      *listener << \"whose first field does not match\";\n      PrintIfNotEmpty(first_inner_listener.str(), listener->stream());\n      return false;\n    }\n    StringMatchResultListener second_inner_listener;\n    if (!second_matcher_.MatchAndExplain(pair_getters::Second(a_pair, Rank0()),\n                                         &second_inner_listener)) {\n      *listener << \"whose second field does not match\";\n      PrintIfNotEmpty(second_inner_listener.str(), listener->stream());\n      return false;\n    }\n    ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),\n                   listener);\n    return true;\n  }\n\n private:\n  void ExplainSuccess(const std::string& first_explanation,\n                      const std::string& second_explanation,\n                      MatchResultListener* listener) const {\n    *listener << \"whose both fields match\";\n    if (first_explanation != \"\") {\n      *listener << \", where the first field is a value \" << first_explanation;\n    }\n    if (second_explanation != \"\") {\n      *listener << \", \";\n      if (first_explanation != \"\") {\n        *listener << \"and \";\n      } else {\n        *listener << \"where \";\n      }\n      *listener << \"the second field is a value \" << second_explanation;\n    }\n  }\n\n  const Matcher<const FirstType&> first_matcher_;\n  const Matcher<const SecondType&> second_matcher_;\n};\n\n// Implements polymorphic Pair(first_matcher, second_matcher).\ntemplate <typename FirstMatcher, typename SecondMatcher>\nclass PairMatcher {\n public:\n  PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)\n      : first_matcher_(first_matcher), second_matcher_(second_matcher) {}\n\n  template <typename PairType>\n  operator Matcher<PairType> () const {\n    return Matcher<PairType>(\n        new PairMatcherImpl<const PairType&>(first_matcher_, second_matcher_));\n  }\n\n private:\n  const FirstMatcher first_matcher_;\n  const SecondMatcher second_matcher_;\n};\n\ntemplate <typename T, size_t... I>\nauto UnpackStructImpl(const T& t, IndexSequence<I...>, int)\n    -> decltype(std::tie(get<I>(t)...)) {\n  static_assert(std::tuple_size<T>::value == sizeof...(I),\n                \"Number of arguments doesn't match the number of fields.\");\n  return std::tie(get<I>(t)...);\n}\n\n#if defined(__cpp_structured_bindings) && __cpp_structured_bindings >= 201606\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<1>, char) {\n  const auto& [a] = t;\n  return std::tie(a);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<2>, char) {\n  const auto& [a, b] = t;\n  return std::tie(a, b);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<3>, char) {\n  const auto& [a, b, c] = t;\n  return std::tie(a, b, c);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<4>, char) {\n  const auto& [a, b, c, d] = t;\n  return std::tie(a, b, c, d);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<5>, char) {\n  const auto& [a, b, c, d, e] = t;\n  return std::tie(a, b, c, d, e);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<6>, char) {\n  const auto& [a, b, c, d, e, f] = t;\n  return std::tie(a, b, c, d, e, f);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<7>, char) {\n  const auto& [a, b, c, d, e, f, g] = t;\n  return std::tie(a, b, c, d, e, f, g);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<8>, char) {\n  const auto& [a, b, c, d, e, f, g, h] = t;\n  return std::tie(a, b, c, d, e, f, g, h);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<9>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<10>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<11>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j, k] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j, k);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<12>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j, k, l] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j, k, l);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<13>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<14>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<15>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);\n}\ntemplate <typename T>\nauto UnpackStructImpl(const T& t, MakeIndexSequence<16>, char) {\n  const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = t;\n  return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);\n}\n#endif  // defined(__cpp_structured_bindings)\n\ntemplate <size_t I, typename T>\nauto UnpackStruct(const T& t)\n    -> decltype((UnpackStructImpl)(t, MakeIndexSequence<I>{}, 0)) {\n  return (UnpackStructImpl)(t, MakeIndexSequence<I>{}, 0);\n}\n\n// Helper function to do comma folding in C++11.\n// The array ensures left-to-right order of evaluation.\n// Usage: VariadicExpand({expr...});\ntemplate <typename T, size_t N>\nvoid VariadicExpand(const T (&)[N]) {}\n\ntemplate <typename Struct, typename StructSize>\nclass FieldsAreMatcherImpl;\n\ntemplate <typename Struct, size_t... I>\nclass FieldsAreMatcherImpl<Struct, IndexSequence<I...>>\n    : public MatcherInterface<Struct> {\n  using UnpackedType =\n      decltype(UnpackStruct<sizeof...(I)>(std::declval<const Struct&>()));\n  using MatchersType = std::tuple<\n      Matcher<const typename std::tuple_element<I, UnpackedType>::type&>...>;\n\n public:\n  template <typename Inner>\n  explicit FieldsAreMatcherImpl(const Inner& matchers)\n      : matchers_(testing::SafeMatcherCast<\n                  const typename std::tuple_element<I, UnpackedType>::type&>(\n            std::get<I>(matchers))...) {}\n\n  void DescribeTo(::std::ostream* os) const override {\n    const char* separator = \"\";\n    VariadicExpand(\n        {(*os << separator << \"has field #\" << I << \" that \",\n          std::get<I>(matchers_).DescribeTo(os), separator = \", and \")...});\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    const char* separator = \"\";\n    VariadicExpand({(*os << separator << \"has field #\" << I << \" that \",\n                     std::get<I>(matchers_).DescribeNegationTo(os),\n                     separator = \", or \")...});\n  }\n\n  bool MatchAndExplain(Struct t, MatchResultListener* listener) const override {\n    return MatchInternal((UnpackStruct<sizeof...(I)>)(t), listener);\n  }\n\n private:\n  bool MatchInternal(UnpackedType tuple, MatchResultListener* listener) const {\n    if (!listener->IsInterested()) {\n      // If the listener is not interested, we don't need to construct the\n      // explanation.\n      bool good = true;\n      VariadicExpand({good = good && std::get<I>(matchers_).Matches(\n                                         std::get<I>(tuple))...});\n      return good;\n    }\n\n    size_t failed_pos = ~size_t{};\n\n    std::vector<StringMatchResultListener> inner_listener(sizeof...(I));\n\n    VariadicExpand(\n        {failed_pos == ~size_t{} && !std::get<I>(matchers_).MatchAndExplain(\n                                        std::get<I>(tuple), &inner_listener[I])\n             ? failed_pos = I\n             : 0 ...});\n    if (failed_pos != ~size_t{}) {\n      *listener << \"whose field #\" << failed_pos << \" does not match\";\n      PrintIfNotEmpty(inner_listener[failed_pos].str(), listener->stream());\n      return false;\n    }\n\n    *listener << \"whose all elements match\";\n    const char* separator = \", where\";\n    for (size_t index = 0; index < sizeof...(I); ++index) {\n      const std::string str = inner_listener[index].str();\n      if (!str.empty()) {\n        *listener << separator << \" field #\" << index << \" is a value \" << str;\n        separator = \", and\";\n      }\n    }\n\n    return true;\n  }\n\n  MatchersType matchers_;\n};\n\ntemplate <typename... Inner>\nclass FieldsAreMatcher {\n public:\n  explicit FieldsAreMatcher(Inner... inner) : matchers_(std::move(inner)...) {}\n\n  template <typename Struct>\n  operator Matcher<Struct>() const {  // NOLINT\n    return Matcher<Struct>(\n        new FieldsAreMatcherImpl<const Struct&, IndexSequenceFor<Inner...>>(\n            matchers_));\n  }\n\n private:\n  std::tuple<Inner...> matchers_;\n};\n\n// Implements ElementsAre() and ElementsAreArray().\ntemplate <typename Container>\nclass ElementsAreMatcherImpl : public MatcherInterface<Container> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n  typedef internal::StlContainerView<RawContainer> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n  typedef typename StlContainer::value_type Element;\n\n  // Constructs the matcher from a sequence of element values or\n  // element matchers.\n  template <typename InputIter>\n  ElementsAreMatcherImpl(InputIter first, InputIter last) {\n    while (first != last) {\n      matchers_.push_back(MatcherCast<const Element&>(*first++));\n    }\n  }\n\n  // Describes what this matcher does.\n  void DescribeTo(::std::ostream* os) const override {\n    if (count() == 0) {\n      *os << \"is empty\";\n    } else if (count() == 1) {\n      *os << \"has 1 element that \";\n      matchers_[0].DescribeTo(os);\n    } else {\n      *os << \"has \" << Elements(count()) << \" where\\n\";\n      for (size_t i = 0; i != count(); ++i) {\n        *os << \"element #\" << i << \" \";\n        matchers_[i].DescribeTo(os);\n        if (i + 1 < count()) {\n          *os << \",\\n\";\n        }\n      }\n    }\n  }\n\n  // Describes what the negation of this matcher does.\n  void DescribeNegationTo(::std::ostream* os) const override {\n    if (count() == 0) {\n      *os << \"isn't empty\";\n      return;\n    }\n\n    *os << \"doesn't have \" << Elements(count()) << \", or\\n\";\n    for (size_t i = 0; i != count(); ++i) {\n      *os << \"element #\" << i << \" \";\n      matchers_[i].DescribeNegationTo(os);\n      if (i + 1 < count()) {\n        *os << \", or\\n\";\n      }\n    }\n  }\n\n  bool MatchAndExplain(Container container,\n                       MatchResultListener* listener) const override {\n    // To work with stream-like \"containers\", we must only walk\n    // through the elements in one pass.\n\n    const bool listener_interested = listener->IsInterested();\n\n    // explanations[i] is the explanation of the element at index i.\n    ::std::vector<std::string> explanations(count());\n    StlContainerReference stl_container = View::ConstReference(container);\n    typename StlContainer::const_iterator it = stl_container.begin();\n    size_t exam_pos = 0;\n    bool mismatch_found = false;  // Have we found a mismatched element yet?\n\n    // Go through the elements and matchers in pairs, until we reach\n    // the end of either the elements or the matchers, or until we find a\n    // mismatch.\n    for (; it != stl_container.end() && exam_pos != count(); ++it, ++exam_pos) {\n      bool match;  // Does the current element match the current matcher?\n      if (listener_interested) {\n        StringMatchResultListener s;\n        match = matchers_[exam_pos].MatchAndExplain(*it, &s);\n        explanations[exam_pos] = s.str();\n      } else {\n        match = matchers_[exam_pos].Matches(*it);\n      }\n\n      if (!match) {\n        mismatch_found = true;\n        break;\n      }\n    }\n    // If mismatch_found is true, 'exam_pos' is the index of the mismatch.\n\n    // Find how many elements the actual container has.  We avoid\n    // calling size() s.t. this code works for stream-like \"containers\"\n    // that don't define size().\n    size_t actual_count = exam_pos;\n    for (; it != stl_container.end(); ++it) {\n      ++actual_count;\n    }\n\n    if (actual_count != count()) {\n      // The element count doesn't match.  If the container is empty,\n      // there's no need to explain anything as Google Mock already\n      // prints the empty container.  Otherwise we just need to show\n      // how many elements there actually are.\n      if (listener_interested && (actual_count != 0)) {\n        *listener << \"which has \" << Elements(actual_count);\n      }\n      return false;\n    }\n\n    if (mismatch_found) {\n      // The element count matches, but the exam_pos-th element doesn't match.\n      if (listener_interested) {\n        *listener << \"whose element #\" << exam_pos << \" doesn't match\";\n        PrintIfNotEmpty(explanations[exam_pos], listener->stream());\n      }\n      return false;\n    }\n\n    // Every element matches its expectation.  We need to explain why\n    // (the obvious ones can be skipped).\n    if (listener_interested) {\n      bool reason_printed = false;\n      for (size_t i = 0; i != count(); ++i) {\n        const std::string& s = explanations[i];\n        if (!s.empty()) {\n          if (reason_printed) {\n            *listener << \",\\nand \";\n          }\n          *listener << \"whose element #\" << i << \" matches, \" << s;\n          reason_printed = true;\n        }\n      }\n    }\n    return true;\n  }\n\n private:\n  static Message Elements(size_t count) {\n    return Message() << count << (count == 1 ? \" element\" : \" elements\");\n  }\n\n  size_t count() const { return matchers_.size(); }\n\n  ::std::vector<Matcher<const Element&> > matchers_;\n};\n\n// Connectivity matrix of (elements X matchers), in element-major order.\n// Initially, there are no edges.\n// Use NextGraph() to iterate over all possible edge configurations.\n// Use Randomize() to generate a random edge configuration.\nclass GTEST_API_ MatchMatrix {\n public:\n  MatchMatrix(size_t num_elements, size_t num_matchers)\n      : num_elements_(num_elements),\n        num_matchers_(num_matchers),\n        matched_(num_elements_* num_matchers_, 0) {\n  }\n\n  size_t LhsSize() const { return num_elements_; }\n  size_t RhsSize() const { return num_matchers_; }\n  bool HasEdge(size_t ilhs, size_t irhs) const {\n    return matched_[SpaceIndex(ilhs, irhs)] == 1;\n  }\n  void SetEdge(size_t ilhs, size_t irhs, bool b) {\n    matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;\n  }\n\n  // Treating the connectivity matrix as a (LhsSize()*RhsSize())-bit number,\n  // adds 1 to that number; returns false if incrementing the graph left it\n  // empty.\n  bool NextGraph();\n\n  void Randomize();\n\n  std::string DebugString() const;\n\n private:\n  size_t SpaceIndex(size_t ilhs, size_t irhs) const {\n    return ilhs * num_matchers_ + irhs;\n  }\n\n  size_t num_elements_;\n  size_t num_matchers_;\n\n  // Each element is a char interpreted as bool. They are stored as a\n  // flattened array in lhs-major order, use 'SpaceIndex()' to translate\n  // a (ilhs, irhs) matrix coordinate into an offset.\n  ::std::vector<char> matched_;\n};\n\ntypedef ::std::pair<size_t, size_t> ElementMatcherPair;\ntypedef ::std::vector<ElementMatcherPair> ElementMatcherPairs;\n\n// Returns a maximum bipartite matching for the specified graph 'g'.\n// The matching is represented as a vector of {element, matcher} pairs.\nGTEST_API_ ElementMatcherPairs\nFindMaxBipartiteMatching(const MatchMatrix& g);\n\nstruct UnorderedMatcherRequire {\n  enum Flags {\n    Superset = 1 << 0,\n    Subset = 1 << 1,\n    ExactMatch = Superset | Subset,\n  };\n};\n\n// Untyped base class for implementing UnorderedElementsAre.  By\n// putting logic that's not specific to the element type here, we\n// reduce binary bloat and increase compilation speed.\nclass GTEST_API_ UnorderedElementsAreMatcherImplBase {\n protected:\n  explicit UnorderedElementsAreMatcherImplBase(\n      UnorderedMatcherRequire::Flags matcher_flags)\n      : match_flags_(matcher_flags) {}\n\n  // A vector of matcher describers, one for each element matcher.\n  // Does not own the describers (and thus can be used only when the\n  // element matchers are alive).\n  typedef ::std::vector<const MatcherDescriberInterface*> MatcherDescriberVec;\n\n  // Describes this UnorderedElementsAre matcher.\n  void DescribeToImpl(::std::ostream* os) const;\n\n  // Describes the negation of this UnorderedElementsAre matcher.\n  void DescribeNegationToImpl(::std::ostream* os) const;\n\n  bool VerifyMatchMatrix(const ::std::vector<std::string>& element_printouts,\n                         const MatchMatrix& matrix,\n                         MatchResultListener* listener) const;\n\n  bool FindPairing(const MatchMatrix& matrix,\n                   MatchResultListener* listener) const;\n\n  MatcherDescriberVec& matcher_describers() {\n    return matcher_describers_;\n  }\n\n  static Message Elements(size_t n) {\n    return Message() << n << \" element\" << (n == 1 ? \"\" : \"s\");\n  }\n\n  UnorderedMatcherRequire::Flags match_flags() const { return match_flags_; }\n\n private:\n  UnorderedMatcherRequire::Flags match_flags_;\n  MatcherDescriberVec matcher_describers_;\n};\n\n// Implements UnorderedElementsAre, UnorderedElementsAreArray, IsSubsetOf, and\n// IsSupersetOf.\ntemplate <typename Container>\nclass UnorderedElementsAreMatcherImpl\n    : public MatcherInterface<Container>,\n      public UnorderedElementsAreMatcherImplBase {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n  typedef internal::StlContainerView<RawContainer> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n  typedef typename StlContainer::const_iterator StlContainerConstIterator;\n  typedef typename StlContainer::value_type Element;\n\n  template <typename InputIter>\n  UnorderedElementsAreMatcherImpl(UnorderedMatcherRequire::Flags matcher_flags,\n                                  InputIter first, InputIter last)\n      : UnorderedElementsAreMatcherImplBase(matcher_flags) {\n    for (; first != last; ++first) {\n      matchers_.push_back(MatcherCast<const Element&>(*first));\n    }\n    for (const auto& m : matchers_) {\n      matcher_describers().push_back(m.GetDescriber());\n    }\n  }\n\n  // Describes what this matcher does.\n  void DescribeTo(::std::ostream* os) const override {\n    return UnorderedElementsAreMatcherImplBase::DescribeToImpl(os);\n  }\n\n  // Describes what the negation of this matcher does.\n  void DescribeNegationTo(::std::ostream* os) const override {\n    return UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(os);\n  }\n\n  bool MatchAndExplain(Container container,\n                       MatchResultListener* listener) const override {\n    StlContainerReference stl_container = View::ConstReference(container);\n    ::std::vector<std::string> element_printouts;\n    MatchMatrix matrix =\n        AnalyzeElements(stl_container.begin(), stl_container.end(),\n                        &element_printouts, listener);\n\n    if (matrix.LhsSize() == 0 && matrix.RhsSize() == 0) {\n      return true;\n    }\n\n    if (match_flags() == UnorderedMatcherRequire::ExactMatch) {\n      if (matrix.LhsSize() != matrix.RhsSize()) {\n        // The element count doesn't match.  If the container is empty,\n        // there's no need to explain anything as Google Mock already\n        // prints the empty container. Otherwise we just need to show\n        // how many elements there actually are.\n        if (matrix.LhsSize() != 0 && listener->IsInterested()) {\n          *listener << \"which has \" << Elements(matrix.LhsSize());\n        }\n        return false;\n      }\n    }\n\n    return VerifyMatchMatrix(element_printouts, matrix, listener) &&\n           FindPairing(matrix, listener);\n  }\n\n private:\n  template <typename ElementIter>\n  MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,\n                              ::std::vector<std::string>* element_printouts,\n                              MatchResultListener* listener) const {\n    element_printouts->clear();\n    ::std::vector<char> did_match;\n    size_t num_elements = 0;\n    DummyMatchResultListener dummy;\n    for (; elem_first != elem_last; ++num_elements, ++elem_first) {\n      if (listener->IsInterested()) {\n        element_printouts->push_back(PrintToString(*elem_first));\n      }\n      for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {\n        did_match.push_back(\n            matchers_[irhs].MatchAndExplain(*elem_first, &dummy));\n      }\n    }\n\n    MatchMatrix matrix(num_elements, matchers_.size());\n    ::std::vector<char>::const_iterator did_match_iter = did_match.begin();\n    for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {\n      for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {\n        matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);\n      }\n    }\n    return matrix;\n  }\n\n  ::std::vector<Matcher<const Element&> > matchers_;\n};\n\n// Functor for use in TransformTuple.\n// Performs MatcherCast<Target> on an input argument of any type.\ntemplate <typename Target>\nstruct CastAndAppendTransform {\n  template <typename Arg>\n  Matcher<Target> operator()(const Arg& a) const {\n    return MatcherCast<Target>(a);\n  }\n};\n\n// Implements UnorderedElementsAre.\ntemplate <typename MatcherTuple>\nclass UnorderedElementsAreMatcher {\n public:\n  explicit UnorderedElementsAreMatcher(const MatcherTuple& args)\n      : matchers_(args) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n    typedef typename internal::StlContainerView<RawContainer>::type View;\n    typedef typename View::value_type Element;\n    typedef ::std::vector<Matcher<const Element&> > MatcherVec;\n    MatcherVec matchers;\n    matchers.reserve(::std::tuple_size<MatcherTuple>::value);\n    TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,\n                         ::std::back_inserter(matchers));\n    return Matcher<Container>(\n        new UnorderedElementsAreMatcherImpl<const Container&>(\n            UnorderedMatcherRequire::ExactMatch, matchers.begin(),\n            matchers.end()));\n  }\n\n private:\n  const MatcherTuple matchers_;\n};\n\n// Implements ElementsAre.\ntemplate <typename MatcherTuple>\nclass ElementsAreMatcher {\n public:\n  explicit ElementsAreMatcher(const MatcherTuple& args) : matchers_(args) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    GTEST_COMPILE_ASSERT_(\n        !IsHashTable<GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>::value ||\n            ::std::tuple_size<MatcherTuple>::value < 2,\n        use_UnorderedElementsAre_with_hash_tables);\n\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n    typedef typename internal::StlContainerView<RawContainer>::type View;\n    typedef typename View::value_type Element;\n    typedef ::std::vector<Matcher<const Element&> > MatcherVec;\n    MatcherVec matchers;\n    matchers.reserve(::std::tuple_size<MatcherTuple>::value);\n    TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,\n                         ::std::back_inserter(matchers));\n    return Matcher<Container>(new ElementsAreMatcherImpl<const Container&>(\n        matchers.begin(), matchers.end()));\n  }\n\n private:\n  const MatcherTuple matchers_;\n};\n\n// Implements UnorderedElementsAreArray(), IsSubsetOf(), and IsSupersetOf().\ntemplate <typename T>\nclass UnorderedElementsAreArrayMatcher {\n public:\n  template <typename Iter>\n  UnorderedElementsAreArrayMatcher(UnorderedMatcherRequire::Flags match_flags,\n                                   Iter first, Iter last)\n      : match_flags_(match_flags), matchers_(first, last) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return Matcher<Container>(\n        new UnorderedElementsAreMatcherImpl<const Container&>(\n            match_flags_, matchers_.begin(), matchers_.end()));\n  }\n\n private:\n  UnorderedMatcherRequire::Flags match_flags_;\n  ::std::vector<T> matchers_;\n};\n\n// Implements ElementsAreArray().\ntemplate <typename T>\nclass ElementsAreArrayMatcher {\n public:\n  template <typename Iter>\n  ElementsAreArrayMatcher(Iter first, Iter last) : matchers_(first, last) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    GTEST_COMPILE_ASSERT_(\n        !IsHashTable<GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>::value,\n        use_UnorderedElementsAreArray_with_hash_tables);\n\n    return Matcher<Container>(new ElementsAreMatcherImpl<const Container&>(\n        matchers_.begin(), matchers_.end()));\n  }\n\n private:\n  const ::std::vector<T> matchers_;\n};\n\n// Given a 2-tuple matcher tm of type Tuple2Matcher and a value second\n// of type Second, BoundSecondMatcher<Tuple2Matcher, Second>(tm,\n// second) is a polymorphic matcher that matches a value x if and only if\n// tm matches tuple (x, second).  Useful for implementing\n// UnorderedPointwise() in terms of UnorderedElementsAreArray().\n//\n// BoundSecondMatcher is copyable and assignable, as we need to put\n// instances of this class in a vector when implementing\n// UnorderedPointwise().\ntemplate <typename Tuple2Matcher, typename Second>\nclass BoundSecondMatcher {\n public:\n  BoundSecondMatcher(const Tuple2Matcher& tm, const Second& second)\n      : tuple2_matcher_(tm), second_value_(second) {}\n\n  BoundSecondMatcher(const BoundSecondMatcher& other) = default;\n\n  template <typename T>\n  operator Matcher<T>() const {\n    return MakeMatcher(new Impl<T>(tuple2_matcher_, second_value_));\n  }\n\n  // We have to define this for UnorderedPointwise() to compile in\n  // C++98 mode, as it puts BoundSecondMatcher instances in a vector,\n  // which requires the elements to be assignable in C++98.  The\n  // compiler cannot generate the operator= for us, as Tuple2Matcher\n  // and Second may not be assignable.\n  //\n  // However, this should never be called, so the implementation just\n  // need to assert.\n  void operator=(const BoundSecondMatcher& /*rhs*/) {\n    GTEST_LOG_(FATAL) << \"BoundSecondMatcher should never be assigned.\";\n  }\n\n private:\n  template <typename T>\n  class Impl : public MatcherInterface<T> {\n   public:\n    typedef ::std::tuple<T, Second> ArgTuple;\n\n    Impl(const Tuple2Matcher& tm, const Second& second)\n        : mono_tuple2_matcher_(SafeMatcherCast<const ArgTuple&>(tm)),\n          second_value_(second) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"and \";\n      UniversalPrint(second_value_, os);\n      *os << \" \";\n      mono_tuple2_matcher_.DescribeTo(os);\n    }\n\n    bool MatchAndExplain(T x, MatchResultListener* listener) const override {\n      return mono_tuple2_matcher_.MatchAndExplain(ArgTuple(x, second_value_),\n                                                  listener);\n    }\n\n   private:\n    const Matcher<const ArgTuple&> mono_tuple2_matcher_;\n    const Second second_value_;\n  };\n\n  const Tuple2Matcher tuple2_matcher_;\n  const Second second_value_;\n};\n\n// Given a 2-tuple matcher tm and a value second,\n// MatcherBindSecond(tm, second) returns a matcher that matches a\n// value x if and only if tm matches tuple (x, second).  Useful for\n// implementing UnorderedPointwise() in terms of UnorderedElementsAreArray().\ntemplate <typename Tuple2Matcher, typename Second>\nBoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond(\n    const Tuple2Matcher& tm, const Second& second) {\n  return BoundSecondMatcher<Tuple2Matcher, Second>(tm, second);\n}\n\n// Returns the description for a matcher defined using the MATCHER*()\n// macro where the user-supplied description string is \"\", if\n// 'negation' is false; otherwise returns the description of the\n// negation of the matcher.  'param_values' contains a list of strings\n// that are the print-out of the matcher's parameters.\nGTEST_API_ std::string FormatMatcherDescription(bool negation,\n                                                const char* matcher_name,\n                                                const Strings& param_values);\n\n// Implements a matcher that checks the value of a optional<> type variable.\ntemplate <typename ValueMatcher>\nclass OptionalMatcher {\n public:\n  explicit OptionalMatcher(const ValueMatcher& value_matcher)\n      : value_matcher_(value_matcher) {}\n\n  template <typename Optional>\n  operator Matcher<Optional>() const {\n    return Matcher<Optional>(new Impl<const Optional&>(value_matcher_));\n  }\n\n  template <typename Optional>\n  class Impl : public MatcherInterface<Optional> {\n   public:\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Optional) OptionalView;\n    typedef typename OptionalView::value_type ValueType;\n    explicit Impl(const ValueMatcher& value_matcher)\n        : value_matcher_(MatcherCast<ValueType>(value_matcher)) {}\n\n    void DescribeTo(::std::ostream* os) const override {\n      *os << \"value \";\n      value_matcher_.DescribeTo(os);\n    }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      *os << \"value \";\n      value_matcher_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(Optional optional,\n                         MatchResultListener* listener) const override {\n      if (!optional) {\n        *listener << \"which is not engaged\";\n        return false;\n      }\n      const ValueType& value = *optional;\n      StringMatchResultListener value_listener;\n      const bool match = value_matcher_.MatchAndExplain(value, &value_listener);\n      *listener << \"whose value \" << PrintToString(value)\n                << (match ? \" matches\" : \" doesn't match\");\n      PrintIfNotEmpty(value_listener.str(), listener->stream());\n      return match;\n    }\n\n   private:\n    const Matcher<ValueType> value_matcher_;\n  };\n\n private:\n  const ValueMatcher value_matcher_;\n};\n\nnamespace variant_matcher {\n// Overloads to allow VariantMatcher to do proper ADL lookup.\ntemplate <typename T>\nvoid holds_alternative() {}\ntemplate <typename T>\nvoid get() {}\n\n// Implements a matcher that checks the value of a variant<> type variable.\ntemplate <typename T>\nclass VariantMatcher {\n public:\n  explicit VariantMatcher(::testing::Matcher<const T&> matcher)\n      : matcher_(std::move(matcher)) {}\n\n  template <typename Variant>\n  bool MatchAndExplain(const Variant& value,\n                       ::testing::MatchResultListener* listener) const {\n    using std::get;\n    if (!listener->IsInterested()) {\n      return holds_alternative<T>(value) && matcher_.Matches(get<T>(value));\n    }\n\n    if (!holds_alternative<T>(value)) {\n      *listener << \"whose value is not of type '\" << GetTypeName() << \"'\";\n      return false;\n    }\n\n    const T& elem = get<T>(value);\n    StringMatchResultListener elem_listener;\n    const bool match = matcher_.MatchAndExplain(elem, &elem_listener);\n    *listener << \"whose value \" << PrintToString(elem)\n              << (match ? \" matches\" : \" doesn't match\");\n    PrintIfNotEmpty(elem_listener.str(), listener->stream());\n    return match;\n  }\n\n  void DescribeTo(std::ostream* os) const {\n    *os << \"is a variant<> with value of type '\" << GetTypeName()\n        << \"' and the value \";\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(std::ostream* os) const {\n    *os << \"is a variant<> with value of type other than '\" << GetTypeName()\n        << \"' or the value \";\n    matcher_.DescribeNegationTo(os);\n  }\n\n private:\n  static std::string GetTypeName() {\n#if GTEST_HAS_RTTI\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(\n        return internal::GetTypeName<T>());\n#endif\n    return \"the element type\";\n  }\n\n  const ::testing::Matcher<const T&> matcher_;\n};\n\n}  // namespace variant_matcher\n\nnamespace any_cast_matcher {\n\n// Overloads to allow AnyCastMatcher to do proper ADL lookup.\ntemplate <typename T>\nvoid any_cast() {}\n\n// Implements a matcher that any_casts the value.\ntemplate <typename T>\nclass AnyCastMatcher {\n public:\n  explicit AnyCastMatcher(const ::testing::Matcher<const T&>& matcher)\n      : matcher_(matcher) {}\n\n  template <typename AnyType>\n  bool MatchAndExplain(const AnyType& value,\n                       ::testing::MatchResultListener* listener) const {\n    if (!listener->IsInterested()) {\n      const T* ptr = any_cast<T>(&value);\n      return ptr != nullptr && matcher_.Matches(*ptr);\n    }\n\n    const T* elem = any_cast<T>(&value);\n    if (elem == nullptr) {\n      *listener << \"whose value is not of type '\" << GetTypeName() << \"'\";\n      return false;\n    }\n\n    StringMatchResultListener elem_listener;\n    const bool match = matcher_.MatchAndExplain(*elem, &elem_listener);\n    *listener << \"whose value \" << PrintToString(*elem)\n              << (match ? \" matches\" : \" doesn't match\");\n    PrintIfNotEmpty(elem_listener.str(), listener->stream());\n    return match;\n  }\n\n  void DescribeTo(std::ostream* os) const {\n    *os << \"is an 'any' type with value of type '\" << GetTypeName()\n        << \"' and the value \";\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(std::ostream* os) const {\n    *os << \"is an 'any' type with value of type other than '\" << GetTypeName()\n        << \"' or the value \";\n    matcher_.DescribeNegationTo(os);\n  }\n\n private:\n  static std::string GetTypeName() {\n#if GTEST_HAS_RTTI\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(\n        return internal::GetTypeName<T>());\n#endif\n    return \"the element type\";\n  }\n\n  const ::testing::Matcher<const T&> matcher_;\n};\n\n}  // namespace any_cast_matcher\n\n// Implements the Args() matcher.\ntemplate <class ArgsTuple, size_t... k>\nclass ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {\n public:\n  using RawArgsTuple = typename std::decay<ArgsTuple>::type;\n  using SelectedArgs =\n      std::tuple<typename std::tuple_element<k, RawArgsTuple>::type...>;\n  using MonomorphicInnerMatcher = Matcher<const SelectedArgs&>;\n\n  template <typename InnerMatcher>\n  explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)\n      : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}\n\n  bool MatchAndExplain(ArgsTuple args,\n                       MatchResultListener* listener) const override {\n    // Workaround spurious C4100 on MSVC<=15.7 when k is empty.\n    (void)args;\n    const SelectedArgs& selected_args =\n        std::forward_as_tuple(std::get<k>(args)...);\n    if (!listener->IsInterested()) return inner_matcher_.Matches(selected_args);\n\n    PrintIndices(listener->stream());\n    *listener << \"are \" << PrintToString(selected_args);\n\n    StringMatchResultListener inner_listener;\n    const bool match =\n        inner_matcher_.MatchAndExplain(selected_args, &inner_listener);\n    PrintIfNotEmpty(inner_listener.str(), listener->stream());\n    return match;\n  }\n\n  void DescribeTo(::std::ostream* os) const override {\n    *os << \"are a tuple \";\n    PrintIndices(os);\n    inner_matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const override {\n    *os << \"are a tuple \";\n    PrintIndices(os);\n    inner_matcher_.DescribeNegationTo(os);\n  }\n\n private:\n  // Prints the indices of the selected fields.\n  static void PrintIndices(::std::ostream* os) {\n    *os << \"whose fields (\";\n    const char* sep = \"\";\n    // Workaround spurious C4189 on MSVC<=15.7 when k is empty.\n    (void)sep;\n    const char* dummy[] = {\"\", (*os << sep << \"#\" << k, sep = \", \")...};\n    (void)dummy;\n    *os << \") \";\n  }\n\n  MonomorphicInnerMatcher inner_matcher_;\n};\n\ntemplate <class InnerMatcher, size_t... k>\nclass ArgsMatcher {\n public:\n  explicit ArgsMatcher(InnerMatcher inner_matcher)\n      : inner_matcher_(std::move(inner_matcher)) {}\n\n  template <typename ArgsTuple>\n  operator Matcher<ArgsTuple>() const {  // NOLINT\n    return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k...>(inner_matcher_));\n  }\n\n private:\n  InnerMatcher inner_matcher_;\n};\n\n}  // namespace internal\n\n// ElementsAreArray(iterator_first, iterator_last)\n// ElementsAreArray(pointer, count)\n// ElementsAreArray(array)\n// ElementsAreArray(container)\n// ElementsAreArray({ e1, e2, ..., en })\n//\n// The ElementsAreArray() functions are like ElementsAre(...), except\n// that they are given a homogeneous sequence rather than taking each\n// element as a function argument. The sequence can be specified as an\n// array, a pointer and count, a vector, an initializer list, or an\n// STL iterator range. In each of these cases, the underlying sequence\n// can be either a sequence of values or a sequence of matchers.\n//\n// All forms of ElementsAreArray() make a copy of the input matcher sequence.\n\ntemplate <typename Iter>\ninline internal::ElementsAreArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nElementsAreArray(Iter first, Iter last) {\n  typedef typename ::std::iterator_traits<Iter>::value_type T;\n  return internal::ElementsAreArrayMatcher<T>(first, last);\n}\n\ntemplate <typename T>\ninline internal::ElementsAreArrayMatcher<T> ElementsAreArray(\n    const T* pointer, size_t count) {\n  return ElementsAreArray(pointer, pointer + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::ElementsAreArrayMatcher<T> ElementsAreArray(\n    const T (&array)[N]) {\n  return ElementsAreArray(array, N);\n}\n\ntemplate <typename Container>\ninline internal::ElementsAreArrayMatcher<typename Container::value_type>\nElementsAreArray(const Container& container) {\n  return ElementsAreArray(container.begin(), container.end());\n}\n\ntemplate <typename T>\ninline internal::ElementsAreArrayMatcher<T>\nElementsAreArray(::std::initializer_list<T> xs) {\n  return ElementsAreArray(xs.begin(), xs.end());\n}\n\n// UnorderedElementsAreArray(iterator_first, iterator_last)\n// UnorderedElementsAreArray(pointer, count)\n// UnorderedElementsAreArray(array)\n// UnorderedElementsAreArray(container)\n// UnorderedElementsAreArray({ e1, e2, ..., en })\n//\n// UnorderedElementsAreArray() verifies that a bijective mapping onto a\n// collection of matchers exists.\n//\n// The matchers can be specified as an array, a pointer and count, a container,\n// an initializer list, or an STL iterator range. In each of these cases, the\n// underlying matchers can be either values or matchers.\n\ntemplate <typename Iter>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nUnorderedElementsAreArray(Iter first, Iter last) {\n  typedef typename ::std::iterator_traits<Iter>::value_type T;\n  return internal::UnorderedElementsAreArrayMatcher<T>(\n      internal::UnorderedMatcherRequire::ExactMatch, first, last);\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(const T* pointer, size_t count) {\n  return UnorderedElementsAreArray(pointer, pointer + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(const T (&array)[N]) {\n  return UnorderedElementsAreArray(array, N);\n}\n\ntemplate <typename Container>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename Container::value_type>\nUnorderedElementsAreArray(const Container& container) {\n  return UnorderedElementsAreArray(container.begin(), container.end());\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(::std::initializer_list<T> xs) {\n  return UnorderedElementsAreArray(xs.begin(), xs.end());\n}\n\n// _ is a matcher that matches anything of any type.\n//\n// This definition is fine as:\n//\n//   1. The C++ standard permits using the name _ in a namespace that\n//      is not the global namespace or ::std.\n//   2. The AnythingMatcher class has no data member or constructor,\n//      so it's OK to create global variables of this type.\n//   3. c-style has approved of using _ in this case.\nconst internal::AnythingMatcher _ = {};\n// Creates a matcher that matches any value of the given type T.\ntemplate <typename T>\ninline Matcher<T> A() {\n  return _;\n}\n\n// Creates a matcher that matches any value of the given type T.\ntemplate <typename T>\ninline Matcher<T> An() {\n  return _;\n}\n\ntemplate <typename T, typename M>\nMatcher<T> internal::MatcherCastImpl<T, M>::CastImpl(\n    const M& value, std::false_type /* convertible_to_matcher */,\n    std::false_type /* convertible_to_T */) {\n  return Eq(value);\n}\n\n// Creates a polymorphic matcher that matches any NULL pointer.\ninline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {\n  return MakePolymorphicMatcher(internal::IsNullMatcher());\n}\n\n// Creates a polymorphic matcher that matches any non-NULL pointer.\n// This is convenient as Not(NULL) doesn't compile (the compiler\n// thinks that that expression is comparing a pointer with an integer).\ninline PolymorphicMatcher<internal::NotNullMatcher > NotNull() {\n  return MakePolymorphicMatcher(internal::NotNullMatcher());\n}\n\n// Creates a polymorphic matcher that matches any argument that\n// references variable x.\ntemplate <typename T>\ninline internal::RefMatcher<T&> Ref(T& x) {  // NOLINT\n  return internal::RefMatcher<T&>(x);\n}\n\n// Creates a polymorphic matcher that matches any NaN floating point.\ninline PolymorphicMatcher<internal::IsNanMatcher> IsNan() {\n  return MakePolymorphicMatcher(internal::IsNanMatcher());\n}\n\n// Creates a matcher that matches any double argument approximately\n// equal to rhs, where two NANs are considered unequal.\ninline internal::FloatingEqMatcher<double> DoubleEq(double rhs) {\n  return internal::FloatingEqMatcher<double>(rhs, false);\n}\n\n// Creates a matcher that matches any double argument approximately\n// equal to rhs, including NaN values when rhs is NaN.\ninline internal::FloatingEqMatcher<double> NanSensitiveDoubleEq(double rhs) {\n  return internal::FloatingEqMatcher<double>(rhs, true);\n}\n\n// Creates a matcher that matches any double argument approximately equal to\n// rhs, up to the specified max absolute error bound, where two NANs are\n// considered unequal.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<double> DoubleNear(\n    double rhs, double max_abs_error) {\n  return internal::FloatingEqMatcher<double>(rhs, false, max_abs_error);\n}\n\n// Creates a matcher that matches any double argument approximately equal to\n// rhs, up to the specified max absolute error bound, including NaN values when\n// rhs is NaN.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<double> NanSensitiveDoubleNear(\n    double rhs, double max_abs_error) {\n  return internal::FloatingEqMatcher<double>(rhs, true, max_abs_error);\n}\n\n// Creates a matcher that matches any float argument approximately\n// equal to rhs, where two NANs are considered unequal.\ninline internal::FloatingEqMatcher<float> FloatEq(float rhs) {\n  return internal::FloatingEqMatcher<float>(rhs, false);\n}\n\n// Creates a matcher that matches any float argument approximately\n// equal to rhs, including NaN values when rhs is NaN.\ninline internal::FloatingEqMatcher<float> NanSensitiveFloatEq(float rhs) {\n  return internal::FloatingEqMatcher<float>(rhs, true);\n}\n\n// Creates a matcher that matches any float argument approximately equal to\n// rhs, up to the specified max absolute error bound, where two NANs are\n// considered unequal.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<float> FloatNear(\n    float rhs, float max_abs_error) {\n  return internal::FloatingEqMatcher<float>(rhs, false, max_abs_error);\n}\n\n// Creates a matcher that matches any float argument approximately equal to\n// rhs, up to the specified max absolute error bound, including NaN values when\n// rhs is NaN.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<float> NanSensitiveFloatNear(\n    float rhs, float max_abs_error) {\n  return internal::FloatingEqMatcher<float>(rhs, true, max_abs_error);\n}\n\n// Creates a matcher that matches a pointer (raw or smart) that points\n// to a value that matches inner_matcher.\ntemplate <typename InnerMatcher>\ninline internal::PointeeMatcher<InnerMatcher> Pointee(\n    const InnerMatcher& inner_matcher) {\n  return internal::PointeeMatcher<InnerMatcher>(inner_matcher);\n}\n\n#if GTEST_HAS_RTTI\n// Creates a matcher that matches a pointer or reference that matches\n// inner_matcher when dynamic_cast<To> is applied.\n// The result of dynamic_cast<To> is forwarded to the inner matcher.\n// If To is a pointer and the cast fails, the inner matcher will receive NULL.\n// If To is a reference and the cast fails, this matcher returns false\n// immediately.\ntemplate <typename To>\ninline PolymorphicMatcher<internal::WhenDynamicCastToMatcher<To> >\nWhenDynamicCastTo(const Matcher<To>& inner_matcher) {\n  return MakePolymorphicMatcher(\n      internal::WhenDynamicCastToMatcher<To>(inner_matcher));\n}\n#endif  // GTEST_HAS_RTTI\n\n// Creates a matcher that matches an object whose given field matches\n// 'matcher'.  For example,\n//   Field(&Foo::number, Ge(5))\n// matches a Foo object x if and only if x.number >= 5.\ntemplate <typename Class, typename FieldType, typename FieldMatcher>\ninline PolymorphicMatcher<\n  internal::FieldMatcher<Class, FieldType> > Field(\n    FieldType Class::*field, const FieldMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::FieldMatcher<Class, FieldType>(\n          field, MatcherCast<const FieldType&>(matcher)));\n  // The call to MatcherCast() is required for supporting inner\n  // matchers of compatible types.  For example, it allows\n  //   Field(&Foo::bar, m)\n  // to compile where bar is an int32 and m is a matcher for int64.\n}\n\n// Same as Field() but also takes the name of the field to provide better error\n// messages.\ntemplate <typename Class, typename FieldType, typename FieldMatcher>\ninline PolymorphicMatcher<internal::FieldMatcher<Class, FieldType> > Field(\n    const std::string& field_name, FieldType Class::*field,\n    const FieldMatcher& matcher) {\n  return MakePolymorphicMatcher(internal::FieldMatcher<Class, FieldType>(\n      field_name, field, MatcherCast<const FieldType&>(matcher)));\n}\n\n// Creates a matcher that matches an object whose given property\n// matches 'matcher'.  For example,\n//   Property(&Foo::str, StartsWith(\"hi\"))\n// matches a Foo object x if and only if x.str() starts with \"hi\".\ntemplate <typename Class, typename PropertyType, typename PropertyMatcher>\ninline PolymorphicMatcher<internal::PropertyMatcher<\n    Class, PropertyType, PropertyType (Class::*)() const> >\nProperty(PropertyType (Class::*property)() const,\n         const PropertyMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::PropertyMatcher<Class, PropertyType,\n                                PropertyType (Class::*)() const>(\n          property, MatcherCast<const PropertyType&>(matcher)));\n  // The call to MatcherCast() is required for supporting inner\n  // matchers of compatible types.  For example, it allows\n  //   Property(&Foo::bar, m)\n  // to compile where bar() returns an int32 and m is a matcher for int64.\n}\n\n// Same as Property() above, but also takes the name of the property to provide\n// better error messages.\ntemplate <typename Class, typename PropertyType, typename PropertyMatcher>\ninline PolymorphicMatcher<internal::PropertyMatcher<\n    Class, PropertyType, PropertyType (Class::*)() const> >\nProperty(const std::string& property_name,\n         PropertyType (Class::*property)() const,\n         const PropertyMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::PropertyMatcher<Class, PropertyType,\n                                PropertyType (Class::*)() const>(\n          property_name, property, MatcherCast<const PropertyType&>(matcher)));\n}\n\n// The same as above but for reference-qualified member functions.\ntemplate <typename Class, typename PropertyType, typename PropertyMatcher>\ninline PolymorphicMatcher<internal::PropertyMatcher<\n    Class, PropertyType, PropertyType (Class::*)() const &> >\nProperty(PropertyType (Class::*property)() const &,\n         const PropertyMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::PropertyMatcher<Class, PropertyType,\n                                PropertyType (Class::*)() const&>(\n          property, MatcherCast<const PropertyType&>(matcher)));\n}\n\n// Three-argument form for reference-qualified member functions.\ntemplate <typename Class, typename PropertyType, typename PropertyMatcher>\ninline PolymorphicMatcher<internal::PropertyMatcher<\n    Class, PropertyType, PropertyType (Class::*)() const &> >\nProperty(const std::string& property_name,\n         PropertyType (Class::*property)() const &,\n         const PropertyMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::PropertyMatcher<Class, PropertyType,\n                                PropertyType (Class::*)() const&>(\n          property_name, property, MatcherCast<const PropertyType&>(matcher)));\n}\n\n// Creates a matcher that matches an object if and only if the result of\n// applying a callable to x matches 'matcher'. For example,\n//   ResultOf(f, StartsWith(\"hi\"))\n// matches a Foo object x if and only if f(x) starts with \"hi\".\n// `callable` parameter can be a function, function pointer, or a functor. It is\n// required to keep no state affecting the results of the calls on it and make\n// no assumptions about how many calls will be made. Any state it keeps must be\n// protected from the concurrent access.\ntemplate <typename Callable, typename InnerMatcher>\ninternal::ResultOfMatcher<Callable, InnerMatcher> ResultOf(\n    Callable callable, InnerMatcher matcher) {\n  return internal::ResultOfMatcher<Callable, InnerMatcher>(\n      std::move(callable), std::move(matcher));\n}\n\n// String matchers.\n\n// Matches a string equal to str.\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::StrEqualityMatcher<std::string> > StrEq(\n    const internal::StringLike<T>& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::string>(std::string(str), true, true));\n}\n\n// Matches a string not equal to str.\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::StrEqualityMatcher<std::string> > StrNe(\n    const internal::StringLike<T>& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::string>(std::string(str), false, true));\n}\n\n// Matches a string equal to str, ignoring case.\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::StrEqualityMatcher<std::string> > StrCaseEq(\n    const internal::StringLike<T>& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::string>(std::string(str), true, false));\n}\n\n// Matches a string not equal to str, ignoring case.\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::StrEqualityMatcher<std::string> > StrCaseNe(\n    const internal::StringLike<T>& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<std::string>(\n      std::string(str), false, false));\n}\n\n// Creates a matcher that matches any string, std::string, or C string\n// that contains the given substring.\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::HasSubstrMatcher<std::string> > HasSubstr(\n    const internal::StringLike<T>& substring) {\n  return MakePolymorphicMatcher(\n      internal::HasSubstrMatcher<std::string>(std::string(substring)));\n}\n\n// Matches a string that starts with 'prefix' (case-sensitive).\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::StartsWithMatcher<std::string> > StartsWith(\n    const internal::StringLike<T>& prefix) {\n  return MakePolymorphicMatcher(\n      internal::StartsWithMatcher<std::string>(std::string(prefix)));\n}\n\n// Matches a string that ends with 'suffix' (case-sensitive).\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::EndsWithMatcher<std::string> > EndsWith(\n    const internal::StringLike<T>& suffix) {\n  return MakePolymorphicMatcher(\n      internal::EndsWithMatcher<std::string>(std::string(suffix)));\n}\n\n#if GTEST_HAS_STD_WSTRING\n// Wide string matchers.\n\n// Matches a string equal to str.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> > StrEq(\n    const std::wstring& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::wstring>(str, true, true));\n}\n\n// Matches a string not equal to str.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> > StrNe(\n    const std::wstring& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::wstring>(str, false, true));\n}\n\n// Matches a string equal to str, ignoring case.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> >\nStrCaseEq(const std::wstring& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::wstring>(str, true, false));\n}\n\n// Matches a string not equal to str, ignoring case.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<std::wstring> >\nStrCaseNe(const std::wstring& str) {\n  return MakePolymorphicMatcher(\n      internal::StrEqualityMatcher<std::wstring>(str, false, false));\n}\n\n// Creates a matcher that matches any ::wstring, std::wstring, or C wide string\n// that contains the given substring.\ninline PolymorphicMatcher<internal::HasSubstrMatcher<std::wstring> > HasSubstr(\n    const std::wstring& substring) {\n  return MakePolymorphicMatcher(\n      internal::HasSubstrMatcher<std::wstring>(substring));\n}\n\n// Matches a string that starts with 'prefix' (case-sensitive).\ninline PolymorphicMatcher<internal::StartsWithMatcher<std::wstring> >\nStartsWith(const std::wstring& prefix) {\n  return MakePolymorphicMatcher(\n      internal::StartsWithMatcher<std::wstring>(prefix));\n}\n\n// Matches a string that ends with 'suffix' (case-sensitive).\ninline PolymorphicMatcher<internal::EndsWithMatcher<std::wstring> > EndsWith(\n    const std::wstring& suffix) {\n  return MakePolymorphicMatcher(\n      internal::EndsWithMatcher<std::wstring>(suffix));\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field == the second field.\ninline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field >= the second field.\ninline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field > the second field.\ninline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field <= the second field.\ninline internal::Le2Matcher Le() { return internal::Le2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field < the second field.\ninline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field != the second field.\ninline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// FloatEq(first field) matches the second field.\ninline internal::FloatingEq2Matcher<float> FloatEq() {\n  return internal::FloatingEq2Matcher<float>();\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// DoubleEq(first field) matches the second field.\ninline internal::FloatingEq2Matcher<double> DoubleEq() {\n  return internal::FloatingEq2Matcher<double>();\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// FloatEq(first field) matches the second field with NaN equality.\ninline internal::FloatingEq2Matcher<float> NanSensitiveFloatEq() {\n  return internal::FloatingEq2Matcher<float>(true);\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// DoubleEq(first field) matches the second field with NaN equality.\ninline internal::FloatingEq2Matcher<double> NanSensitiveDoubleEq() {\n  return internal::FloatingEq2Matcher<double>(true);\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// FloatNear(first field, max_abs_error) matches the second field.\ninline internal::FloatingEq2Matcher<float> FloatNear(float max_abs_error) {\n  return internal::FloatingEq2Matcher<float>(max_abs_error);\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// DoubleNear(first field, max_abs_error) matches the second field.\ninline internal::FloatingEq2Matcher<double> DoubleNear(double max_abs_error) {\n  return internal::FloatingEq2Matcher<double>(max_abs_error);\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// FloatNear(first field, max_abs_error) matches the second field with NaN\n// equality.\ninline internal::FloatingEq2Matcher<float> NanSensitiveFloatNear(\n    float max_abs_error) {\n  return internal::FloatingEq2Matcher<float>(max_abs_error, true);\n}\n\n// Creates a polymorphic matcher that matches a 2-tuple where\n// DoubleNear(first field, max_abs_error) matches the second field with NaN\n// equality.\ninline internal::FloatingEq2Matcher<double> NanSensitiveDoubleNear(\n    double max_abs_error) {\n  return internal::FloatingEq2Matcher<double>(max_abs_error, true);\n}\n\n// Creates a matcher that matches any value of type T that m doesn't\n// match.\ntemplate <typename InnerMatcher>\ninline internal::NotMatcher<InnerMatcher> Not(InnerMatcher m) {\n  return internal::NotMatcher<InnerMatcher>(m);\n}\n\n// Returns a matcher that matches anything that satisfies the given\n// predicate.  The predicate can be any unary function or functor\n// whose return type can be implicitly converted to bool.\ntemplate <typename Predicate>\ninline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >\nTruly(Predicate pred) {\n  return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred));\n}\n\n// Returns a matcher that matches the container size. The container must\n// support both size() and size_type which all STL-like containers provide.\n// Note that the parameter 'size' can be a value of type size_type as well as\n// matcher. For instance:\n//   EXPECT_THAT(container, SizeIs(2));     // Checks container has 2 elements.\n//   EXPECT_THAT(container, SizeIs(Le(2));  // Checks container has at most 2.\ntemplate <typename SizeMatcher>\ninline internal::SizeIsMatcher<SizeMatcher>\nSizeIs(const SizeMatcher& size_matcher) {\n  return internal::SizeIsMatcher<SizeMatcher>(size_matcher);\n}\n\n// Returns a matcher that matches the distance between the container's begin()\n// iterator and its end() iterator, i.e. the size of the container. This matcher\n// can be used instead of SizeIs with containers such as std::forward_list which\n// do not implement size(). The container must provide const_iterator (with\n// valid iterator_traits), begin() and end().\ntemplate <typename DistanceMatcher>\ninline internal::BeginEndDistanceIsMatcher<DistanceMatcher>\nBeginEndDistanceIs(const DistanceMatcher& distance_matcher) {\n  return internal::BeginEndDistanceIsMatcher<DistanceMatcher>(distance_matcher);\n}\n\n// Returns a matcher that matches an equal container.\n// This matcher behaves like Eq(), but in the event of mismatch lists the\n// values that are included in one container but not the other. (Duplicate\n// values and order differences are not explained.)\ntemplate <typename Container>\ninline PolymorphicMatcher<internal::ContainerEqMatcher<\n    typename std::remove_const<Container>::type>>\nContainerEq(const Container& rhs) {\n  return MakePolymorphicMatcher(internal::ContainerEqMatcher<Container>(rhs));\n}\n\n// Returns a matcher that matches a container that, when sorted using\n// the given comparator, matches container_matcher.\ntemplate <typename Comparator, typename ContainerMatcher>\ninline internal::WhenSortedByMatcher<Comparator, ContainerMatcher>\nWhenSortedBy(const Comparator& comparator,\n             const ContainerMatcher& container_matcher) {\n  return internal::WhenSortedByMatcher<Comparator, ContainerMatcher>(\n      comparator, container_matcher);\n}\n\n// Returns a matcher that matches a container that, when sorted using\n// the < operator, matches container_matcher.\ntemplate <typename ContainerMatcher>\ninline internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>\nWhenSorted(const ContainerMatcher& container_matcher) {\n  return\n      internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>(\n          internal::LessComparator(), container_matcher);\n}\n\n// Matches an STL-style container or a native array that contains the\n// same number of elements as in rhs, where its i-th element and rhs's\n// i-th element (as a pair) satisfy the given pair matcher, for all i.\n// TupleMatcher must be able to be safely cast to Matcher<std::tuple<const\n// T1&, const T2&> >, where T1 and T2 are the types of elements in the\n// LHS container and the RHS container respectively.\ntemplate <typename TupleMatcher, typename Container>\ninline internal::PointwiseMatcher<TupleMatcher,\n                                  typename std::remove_const<Container>::type>\nPointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {\n  return internal::PointwiseMatcher<TupleMatcher, Container>(tuple_matcher,\n                                                             rhs);\n}\n\n\n// Supports the Pointwise(m, {a, b, c}) syntax.\ntemplate <typename TupleMatcher, typename T>\ninline internal::PointwiseMatcher<TupleMatcher, std::vector<T> > Pointwise(\n    const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {\n  return Pointwise(tuple_matcher, std::vector<T>(rhs));\n}\n\n\n// UnorderedPointwise(pair_matcher, rhs) matches an STL-style\n// container or a native array that contains the same number of\n// elements as in rhs, where in some permutation of the container, its\n// i-th element and rhs's i-th element (as a pair) satisfy the given\n// pair matcher, for all i.  Tuple2Matcher must be able to be safely\n// cast to Matcher<std::tuple<const T1&, const T2&> >, where T1 and T2 are\n// the types of elements in the LHS container and the RHS container\n// respectively.\n//\n// This is like Pointwise(pair_matcher, rhs), except that the element\n// order doesn't matter.\ntemplate <typename Tuple2Matcher, typename RhsContainer>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename internal::BoundSecondMatcher<\n        Tuple2Matcher,\n        typename internal::StlContainerView<\n            typename std::remove_const<RhsContainer>::type>::type::value_type>>\nUnorderedPointwise(const Tuple2Matcher& tuple2_matcher,\n                   const RhsContainer& rhs_container) {\n  // RhsView allows the same code to handle RhsContainer being a\n  // STL-style container and it being a native C-style array.\n  typedef typename internal::StlContainerView<RhsContainer> RhsView;\n  typedef typename RhsView::type RhsStlContainer;\n  typedef typename RhsStlContainer::value_type Second;\n  const RhsStlContainer& rhs_stl_container =\n      RhsView::ConstReference(rhs_container);\n\n  // Create a matcher for each element in rhs_container.\n  ::std::vector<internal::BoundSecondMatcher<Tuple2Matcher, Second> > matchers;\n  for (typename RhsStlContainer::const_iterator it = rhs_stl_container.begin();\n       it != rhs_stl_container.end(); ++it) {\n    matchers.push_back(\n        internal::MatcherBindSecond(tuple2_matcher, *it));\n  }\n\n  // Delegate the work to UnorderedElementsAreArray().\n  return UnorderedElementsAreArray(matchers);\n}\n\n\n// Supports the UnorderedPointwise(m, {a, b, c}) syntax.\ntemplate <typename Tuple2Matcher, typename T>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename internal::BoundSecondMatcher<Tuple2Matcher, T> >\nUnorderedPointwise(const Tuple2Matcher& tuple2_matcher,\n                   std::initializer_list<T> rhs) {\n  return UnorderedPointwise(tuple2_matcher, std::vector<T>(rhs));\n}\n\n\n// Matches an STL-style container or a native array that contains at\n// least one element matching the given value or matcher.\n//\n// Examples:\n//   ::std::set<int> page_ids;\n//   page_ids.insert(3);\n//   page_ids.insert(1);\n//   EXPECT_THAT(page_ids, Contains(1));\n//   EXPECT_THAT(page_ids, Contains(Gt(2)));\n//   EXPECT_THAT(page_ids, Not(Contains(4)));\n//\n//   ::std::map<int, size_t> page_lengths;\n//   page_lengths[1] = 100;\n//   EXPECT_THAT(page_lengths,\n//               Contains(::std::pair<const int, size_t>(1, 100)));\n//\n//   const char* user_ids[] = { \"joe\", \"mike\", \"tom\" };\n//   EXPECT_THAT(user_ids, Contains(Eq(::std::string(\"tom\"))));\ntemplate <typename M>\ninline internal::ContainsMatcher<M> Contains(M matcher) {\n  return internal::ContainsMatcher<M>(matcher);\n}\n\n// IsSupersetOf(iterator_first, iterator_last)\n// IsSupersetOf(pointer, count)\n// IsSupersetOf(array)\n// IsSupersetOf(container)\n// IsSupersetOf({e1, e2, ..., en})\n//\n// IsSupersetOf() verifies that a surjective partial mapping onto a collection\n// of matchers exists. In other words, a container matches\n// IsSupersetOf({e1, ..., en}) if and only if there is a permutation\n// {y1, ..., yn} of some of the container's elements where y1 matches e1,\n// ..., and yn matches en. Obviously, the size of the container must be >= n\n// in order to have a match. Examples:\n//\n// - {1, 2, 3} matches IsSupersetOf({Ge(3), Ne(0)}), as 3 matches Ge(3) and\n//   1 matches Ne(0).\n// - {1, 2} doesn't match IsSupersetOf({Eq(1), Lt(2)}), even though 1 matches\n//   both Eq(1) and Lt(2). The reason is that different matchers must be used\n//   for elements in different slots of the container.\n// - {1, 1, 2} matches IsSupersetOf({Eq(1), Lt(2)}), as (the first) 1 matches\n//   Eq(1) and (the second) 1 matches Lt(2).\n// - {1, 2, 3} matches IsSupersetOf(Gt(1), Gt(1)), as 2 matches (the first)\n//   Gt(1) and 3 matches (the second) Gt(1).\n//\n// The matchers can be specified as an array, a pointer and count, a container,\n// an initializer list, or an STL iterator range. In each of these cases, the\n// underlying matchers can be either values or matchers.\n\ntemplate <typename Iter>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nIsSupersetOf(Iter first, Iter last) {\n  typedef typename ::std::iterator_traits<Iter>::value_type T;\n  return internal::UnorderedElementsAreArrayMatcher<T>(\n      internal::UnorderedMatcherRequire::Superset, first, last);\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf(\n    const T* pointer, size_t count) {\n  return IsSupersetOf(pointer, pointer + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf(\n    const T (&array)[N]) {\n  return IsSupersetOf(array, N);\n}\n\ntemplate <typename Container>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename Container::value_type>\nIsSupersetOf(const Container& container) {\n  return IsSupersetOf(container.begin(), container.end());\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf(\n    ::std::initializer_list<T> xs) {\n  return IsSupersetOf(xs.begin(), xs.end());\n}\n\n// IsSubsetOf(iterator_first, iterator_last)\n// IsSubsetOf(pointer, count)\n// IsSubsetOf(array)\n// IsSubsetOf(container)\n// IsSubsetOf({e1, e2, ..., en})\n//\n// IsSubsetOf() verifies that an injective mapping onto a collection of matchers\n// exists.  In other words, a container matches IsSubsetOf({e1, ..., en}) if and\n// only if there is a subset of matchers {m1, ..., mk} which would match the\n// container using UnorderedElementsAre.  Obviously, the size of the container\n// must be <= n in order to have a match. Examples:\n//\n// - {1} matches IsSubsetOf({Gt(0), Lt(0)}), as 1 matches Gt(0).\n// - {1, -1} matches IsSubsetOf({Lt(0), Gt(0)}), as 1 matches Gt(0) and -1\n//   matches Lt(0).\n// - {1, 2} doesn't matches IsSubsetOf({Gt(0), Lt(0)}), even though 1 and 2 both\n//   match Gt(0). The reason is that different matchers must be used for\n//   elements in different slots of the container.\n//\n// The matchers can be specified as an array, a pointer and count, a container,\n// an initializer list, or an STL iterator range. In each of these cases, the\n// underlying matchers can be either values or matchers.\n\ntemplate <typename Iter>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nIsSubsetOf(Iter first, Iter last) {\n  typedef typename ::std::iterator_traits<Iter>::value_type T;\n  return internal::UnorderedElementsAreArrayMatcher<T>(\n      internal::UnorderedMatcherRequire::Subset, first, last);\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf(\n    const T* pointer, size_t count) {\n  return IsSubsetOf(pointer, pointer + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf(\n    const T (&array)[N]) {\n  return IsSubsetOf(array, N);\n}\n\ntemplate <typename Container>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename Container::value_type>\nIsSubsetOf(const Container& container) {\n  return IsSubsetOf(container.begin(), container.end());\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf(\n    ::std::initializer_list<T> xs) {\n  return IsSubsetOf(xs.begin(), xs.end());\n}\n\n// Matches an STL-style container or a native array that contains only\n// elements matching the given value or matcher.\n//\n// Each(m) is semantically equivalent to Not(Contains(Not(m))). Only\n// the messages are different.\n//\n// Examples:\n//   ::std::set<int> page_ids;\n//   // Each(m) matches an empty container, regardless of what m is.\n//   EXPECT_THAT(page_ids, Each(Eq(1)));\n//   EXPECT_THAT(page_ids, Each(Eq(77)));\n//\n//   page_ids.insert(3);\n//   EXPECT_THAT(page_ids, Each(Gt(0)));\n//   EXPECT_THAT(page_ids, Not(Each(Gt(4))));\n//   page_ids.insert(1);\n//   EXPECT_THAT(page_ids, Not(Each(Lt(2))));\n//\n//   ::std::map<int, size_t> page_lengths;\n//   page_lengths[1] = 100;\n//   page_lengths[2] = 200;\n//   page_lengths[3] = 300;\n//   EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));\n//   EXPECT_THAT(page_lengths, Each(Key(Le(3))));\n//\n//   const char* user_ids[] = { \"joe\", \"mike\", \"tom\" };\n//   EXPECT_THAT(user_ids, Not(Each(Eq(::std::string(\"tom\")))));\ntemplate <typename M>\ninline internal::EachMatcher<M> Each(M matcher) {\n  return internal::EachMatcher<M>(matcher);\n}\n\n// Key(inner_matcher) matches an std::pair whose 'first' field matches\n// inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an\n// std::map that contains at least one element whose key is >= 5.\ntemplate <typename M>\ninline internal::KeyMatcher<M> Key(M inner_matcher) {\n  return internal::KeyMatcher<M>(inner_matcher);\n}\n\n// Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field\n// matches first_matcher and whose 'second' field matches second_matcher.  For\n// example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), \"foo\"))) can be used\n// to match a std::map<int, string> that contains exactly one element whose key\n// is >= 5 and whose value equals \"foo\".\ntemplate <typename FirstMatcher, typename SecondMatcher>\ninline internal::PairMatcher<FirstMatcher, SecondMatcher>\nPair(FirstMatcher first_matcher, SecondMatcher second_matcher) {\n  return internal::PairMatcher<FirstMatcher, SecondMatcher>(\n      first_matcher, second_matcher);\n}\n\nnamespace no_adl {\n// FieldsAre(matchers...) matches piecewise the fields of compatible structs.\n// These include those that support `get<I>(obj)`, and when structured bindings\n// are enabled any class that supports them.\n// In particular, `std::tuple`, `std::pair`, `std::array` and aggregate types.\ntemplate <typename... M>\ninternal::FieldsAreMatcher<typename std::decay<M>::type...> FieldsAre(\n    M&&... matchers) {\n  return internal::FieldsAreMatcher<typename std::decay<M>::type...>(\n      std::forward<M>(matchers)...);\n}\n\n// Creates a matcher that matches a pointer (raw or smart) that matches\n// inner_matcher.\ntemplate <typename InnerMatcher>\ninline internal::PointerMatcher<InnerMatcher> Pointer(\n    const InnerMatcher& inner_matcher) {\n  return internal::PointerMatcher<InnerMatcher>(inner_matcher);\n}\n\n// Creates a matcher that matches an object that has an address that matches\n// inner_matcher.\ntemplate <typename InnerMatcher>\ninline internal::AddressMatcher<InnerMatcher> Address(\n    const InnerMatcher& inner_matcher) {\n  return internal::AddressMatcher<InnerMatcher>(inner_matcher);\n}\n}  // namespace no_adl\n\n// Returns a predicate that is satisfied by anything that matches the\n// given matcher.\ntemplate <typename M>\ninline internal::MatcherAsPredicate<M> Matches(M matcher) {\n  return internal::MatcherAsPredicate<M>(matcher);\n}\n\n// Returns true if and only if the value matches the matcher.\ntemplate <typename T, typename M>\ninline bool Value(const T& value, M matcher) {\n  return testing::Matches(matcher)(value);\n}\n\n// Matches the value against the given matcher and explains the match\n// result to listener.\ntemplate <typename T, typename M>\ninline bool ExplainMatchResult(\n    M matcher, const T& value, MatchResultListener* listener) {\n  return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);\n}\n\n// Returns a string representation of the given matcher.  Useful for description\n// strings of matchers defined using MATCHER_P* macros that accept matchers as\n// their arguments.  For example:\n//\n// MATCHER_P(XAndYThat, matcher,\n//           \"X that \" + DescribeMatcher<int>(matcher, negation) +\n//               \" and Y that \" + DescribeMatcher<double>(matcher, negation)) {\n//   return ExplainMatchResult(matcher, arg.x(), result_listener) &&\n//          ExplainMatchResult(matcher, arg.y(), result_listener);\n// }\ntemplate <typename T, typename M>\nstd::string DescribeMatcher(const M& matcher, bool negation = false) {\n  ::std::stringstream ss;\n  Matcher<T> monomorphic_matcher = SafeMatcherCast<T>(matcher);\n  if (negation) {\n    monomorphic_matcher.DescribeNegationTo(&ss);\n  } else {\n    monomorphic_matcher.DescribeTo(&ss);\n  }\n  return ss.str();\n}\n\ntemplate <typename... Args>\ninternal::ElementsAreMatcher<\n    std::tuple<typename std::decay<const Args&>::type...>>\nElementsAre(const Args&... matchers) {\n  return internal::ElementsAreMatcher<\n      std::tuple<typename std::decay<const Args&>::type...>>(\n      std::make_tuple(matchers...));\n}\n\ntemplate <typename... Args>\ninternal::UnorderedElementsAreMatcher<\n    std::tuple<typename std::decay<const Args&>::type...>>\nUnorderedElementsAre(const Args&... matchers) {\n  return internal::UnorderedElementsAreMatcher<\n      std::tuple<typename std::decay<const Args&>::type...>>(\n      std::make_tuple(matchers...));\n}\n\n// Define variadic matcher versions.\ntemplate <typename... Args>\ninternal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(\n    const Args&... matchers) {\n  return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(\n      matchers...);\n}\n\ntemplate <typename... Args>\ninternal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(\n    const Args&... matchers) {\n  return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(\n      matchers...);\n}\n\n// AnyOfArray(array)\n// AnyOfArray(pointer, count)\n// AnyOfArray(container)\n// AnyOfArray({ e1, e2, ..., en })\n// AnyOfArray(iterator_first, iterator_last)\n//\n// AnyOfArray() verifies whether a given value matches any member of a\n// collection of matchers.\n//\n// AllOfArray(array)\n// AllOfArray(pointer, count)\n// AllOfArray(container)\n// AllOfArray({ e1, e2, ..., en })\n// AllOfArray(iterator_first, iterator_last)\n//\n// AllOfArray() verifies whether a given value matches all members of a\n// collection of matchers.\n//\n// The matchers can be specified as an array, a pointer and count, a container,\n// an initializer list, or an STL iterator range. In each of these cases, the\n// underlying matchers can be either values or matchers.\n\ntemplate <typename Iter>\ninline internal::AnyOfArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nAnyOfArray(Iter first, Iter last) {\n  return internal::AnyOfArrayMatcher<\n      typename ::std::iterator_traits<Iter>::value_type>(first, last);\n}\n\ntemplate <typename Iter>\ninline internal::AllOfArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nAllOfArray(Iter first, Iter last) {\n  return internal::AllOfArrayMatcher<\n      typename ::std::iterator_traits<Iter>::value_type>(first, last);\n}\n\ntemplate <typename T>\ninline internal::AnyOfArrayMatcher<T> AnyOfArray(const T* ptr, size_t count) {\n  return AnyOfArray(ptr, ptr + count);\n}\n\ntemplate <typename T>\ninline internal::AllOfArrayMatcher<T> AllOfArray(const T* ptr, size_t count) {\n  return AllOfArray(ptr, ptr + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::AnyOfArrayMatcher<T> AnyOfArray(const T (&array)[N]) {\n  return AnyOfArray(array, N);\n}\n\ntemplate <typename T, size_t N>\ninline internal::AllOfArrayMatcher<T> AllOfArray(const T (&array)[N]) {\n  return AllOfArray(array, N);\n}\n\ntemplate <typename Container>\ninline internal::AnyOfArrayMatcher<typename Container::value_type> AnyOfArray(\n    const Container& container) {\n  return AnyOfArray(container.begin(), container.end());\n}\n\ntemplate <typename Container>\ninline internal::AllOfArrayMatcher<typename Container::value_type> AllOfArray(\n    const Container& container) {\n  return AllOfArray(container.begin(), container.end());\n}\n\ntemplate <typename T>\ninline internal::AnyOfArrayMatcher<T> AnyOfArray(\n    ::std::initializer_list<T> xs) {\n  return AnyOfArray(xs.begin(), xs.end());\n}\n\ntemplate <typename T>\ninline internal::AllOfArrayMatcher<T> AllOfArray(\n    ::std::initializer_list<T> xs) {\n  return AllOfArray(xs.begin(), xs.end());\n}\n\n// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected\n// fields of it matches a_matcher.  C++ doesn't support default\n// arguments for function templates, so we have to overload it.\ntemplate <size_t... k, typename InnerMatcher>\ninternal::ArgsMatcher<typename std::decay<InnerMatcher>::type, k...> Args(\n    InnerMatcher&& matcher) {\n  return internal::ArgsMatcher<typename std::decay<InnerMatcher>::type, k...>(\n      std::forward<InnerMatcher>(matcher));\n}\n\n// AllArgs(m) is a synonym of m.  This is useful in\n//\n//   EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));\n//\n// which is easier to read than\n//\n//   EXPECT_CALL(foo, Bar(_, _)).With(Eq());\ntemplate <typename InnerMatcher>\ninline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }\n\n// Returns a matcher that matches the value of an optional<> type variable.\n// The matcher implementation only uses '!arg' and requires that the optional<>\n// type has a 'value_type' member type and that '*arg' is of type 'value_type'\n// and is printable using 'PrintToString'. It is compatible with\n// std::optional/std::experimental::optional.\n// Note that to compare an optional type variable against nullopt you should\n// use Eq(nullopt) and not Eq(Optional(nullopt)). The latter implies that the\n// optional value contains an optional itself.\ntemplate <typename ValueMatcher>\ninline internal::OptionalMatcher<ValueMatcher> Optional(\n    const ValueMatcher& value_matcher) {\n  return internal::OptionalMatcher<ValueMatcher>(value_matcher);\n}\n\n// Returns a matcher that matches the value of a absl::any type variable.\ntemplate <typename T>\nPolymorphicMatcher<internal::any_cast_matcher::AnyCastMatcher<T> > AnyWith(\n    const Matcher<const T&>& matcher) {\n  return MakePolymorphicMatcher(\n      internal::any_cast_matcher::AnyCastMatcher<T>(matcher));\n}\n\n// Returns a matcher that matches the value of a variant<> type variable.\n// The matcher implementation uses ADL to find the holds_alternative and get\n// functions.\n// It is compatible with std::variant.\ntemplate <typename T>\nPolymorphicMatcher<internal::variant_matcher::VariantMatcher<T> > VariantWith(\n    const Matcher<const T&>& matcher) {\n  return MakePolymorphicMatcher(\n      internal::variant_matcher::VariantMatcher<T>(matcher));\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Anything inside the `internal` namespace is internal to the implementation\n// and must not be used in user code!\nnamespace internal {\n\nclass WithWhatMatcherImpl {\n public:\n  WithWhatMatcherImpl(Matcher<std::string> matcher)\n      : matcher_(std::move(matcher)) {}\n\n  void DescribeTo(std::ostream* os) const {\n    *os << \"contains .what() that \";\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(std::ostream* os) const {\n    *os << \"contains .what() that does not \";\n    matcher_.DescribeTo(os);\n  }\n\n  template <typename Err>\n  bool MatchAndExplain(const Err& err, MatchResultListener* listener) const {\n    *listener << \"which contains .what() that \";\n    return matcher_.MatchAndExplain(err.what(), listener);\n  }\n\n private:\n  const Matcher<std::string> matcher_;\n};\n\ninline PolymorphicMatcher<WithWhatMatcherImpl> WithWhat(\n    Matcher<std::string> m) {\n  return MakePolymorphicMatcher(WithWhatMatcherImpl(std::move(m)));\n}\n\ntemplate <typename Err>\nclass ExceptionMatcherImpl {\n  class NeverThrown {\n   public:\n    const char* what() const noexcept {\n      return \"this exception should never be thrown\";\n    }\n  };\n\n  // If the matchee raises an exception of a wrong type, we'd like to\n  // catch it and print its message and type. To do that, we add an additional\n  // catch clause:\n  //\n  //     try { ... }\n  //     catch (const Err&) { /* an expected exception */ }\n  //     catch (const std::exception&) { /* exception of a wrong type */ }\n  //\n  // However, if the `Err` itself is `std::exception`, we'd end up with two\n  // identical `catch` clauses:\n  //\n  //     try { ... }\n  //     catch (const std::exception&) { /* an expected exception */ }\n  //     catch (const std::exception&) { /* exception of a wrong type */ }\n  //\n  // This can cause a warning or an error in some compilers. To resolve\n  // the issue, we use a fake error type whenever `Err` is `std::exception`:\n  //\n  //     try { ... }\n  //     catch (const std::exception&) { /* an expected exception */ }\n  //     catch (const NeverThrown&) { /* exception of a wrong type */ }\n  using DefaultExceptionType = typename std::conditional<\n      std::is_same<typename std::remove_cv<\n                       typename std::remove_reference<Err>::type>::type,\n                   std::exception>::value,\n      const NeverThrown&, const std::exception&>::type;\n\n public:\n  ExceptionMatcherImpl(Matcher<const Err&> matcher)\n      : matcher_(std::move(matcher)) {}\n\n  void DescribeTo(std::ostream* os) const {\n    *os << \"throws an exception which is a \" << GetTypeName<Err>();\n    *os << \" which \";\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(std::ostream* os) const {\n    *os << \"throws an exception which is not a \" << GetTypeName<Err>();\n    *os << \" which \";\n    matcher_.DescribeNegationTo(os);\n  }\n\n  template <typename T>\n  bool MatchAndExplain(T&& x, MatchResultListener* listener) const {\n    try {\n      (void)(std::forward<T>(x)());\n    } catch (const Err& err) {\n      *listener << \"throws an exception which is a \" << GetTypeName<Err>();\n      *listener << \" \";\n      return matcher_.MatchAndExplain(err, listener);\n    } catch (DefaultExceptionType err) {\n#if GTEST_HAS_RTTI\n      *listener << \"throws an exception of type \" << GetTypeName(typeid(err));\n      *listener << \" \";\n#else\n      *listener << \"throws an std::exception-derived type \";\n#endif\n      *listener << \"with description \\\"\" << err.what() << \"\\\"\";\n      return false;\n    } catch (...) {\n      *listener << \"throws an exception of an unknown type\";\n      return false;\n    }\n\n    *listener << \"does not throw any exception\";\n    return false;\n  }\n\n private:\n  const Matcher<const Err&> matcher_;\n};\n\n}  // namespace internal\n\n// Throws()\n// Throws(exceptionMatcher)\n// ThrowsMessage(messageMatcher)\n//\n// This matcher accepts a callable and verifies that when invoked, it throws\n// an exception with the given type and properties.\n//\n// Examples:\n//\n//   EXPECT_THAT(\n//       []() { throw std::runtime_error(\"message\"); },\n//       Throws<std::runtime_error>());\n//\n//   EXPECT_THAT(\n//       []() { throw std::runtime_error(\"message\"); },\n//       ThrowsMessage<std::runtime_error>(HasSubstr(\"message\")));\n//\n//   EXPECT_THAT(\n//       []() { throw std::runtime_error(\"message\"); },\n//       Throws<std::runtime_error>(\n//           Property(&std::runtime_error::what, HasSubstr(\"message\"))));\n\ntemplate <typename Err>\nPolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> Throws() {\n  return MakePolymorphicMatcher(\n      internal::ExceptionMatcherImpl<Err>(A<const Err&>()));\n}\n\ntemplate <typename Err, typename ExceptionMatcher>\nPolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> Throws(\n    const ExceptionMatcher& exception_matcher) {\n  // Using matcher cast allows users to pass a matcher of a more broad type.\n  // For example user may want to pass Matcher<std::exception>\n  // to Throws<std::runtime_error>, or Matcher<int64> to Throws<int32>.\n  return MakePolymorphicMatcher(internal::ExceptionMatcherImpl<Err>(\n      SafeMatcherCast<const Err&>(exception_matcher)));\n}\n\ntemplate <typename Err, typename MessageMatcher>\nPolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(\n    MessageMatcher&& message_matcher) {\n  static_assert(std::is_base_of<std::exception, Err>::value,\n                \"expected an std::exception-derived type\");\n  return Throws<Err>(internal::WithWhat(\n      MatcherCast<std::string>(std::forward<MessageMatcher>(message_matcher))));\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// These macros allow using matchers to check values in Google Test\n// tests.  ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)\n// succeed if and only if the value matches the matcher.  If the assertion\n// fails, the value and the description of the matcher will be printed.\n#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\\\n    ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)\n#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\\\n    ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)\n\n// MATCHER* macroses itself are listed below.\n#define MATCHER(name, description)                                             \\\n  class name##Matcher                                                          \\\n      : public ::testing::internal::MatcherBaseImpl<name##Matcher> {           \\\n   public:                                                                     \\\n    template <typename arg_type>                                               \\\n    class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> {   \\\n     public:                                                                   \\\n      gmock_Impl() {}                                                          \\\n      bool MatchAndExplain(                                                    \\\n          const arg_type& arg,                                                 \\\n          ::testing::MatchResultListener* result_listener) const override;     \\\n      void DescribeTo(::std::ostream* gmock_os) const override {               \\\n        *gmock_os << FormatDescription(false);                                 \\\n      }                                                                        \\\n      void DescribeNegationTo(::std::ostream* gmock_os) const override {       \\\n        *gmock_os << FormatDescription(true);                                  \\\n      }                                                                        \\\n                                                                               \\\n     private:                                                                  \\\n      ::std::string FormatDescription(bool negation) const {                   \\\n        ::std::string gmock_description = (description);                       \\\n        if (!gmock_description.empty()) {                                      \\\n          return gmock_description;                                            \\\n        }                                                                      \\\n        return ::testing::internal::FormatMatcherDescription(negation, #name,  \\\n                                                             {});              \\\n      }                                                                        \\\n    };                                                                         \\\n  };                                                                           \\\n  GTEST_ATTRIBUTE_UNUSED_ inline name##Matcher name() { return {}; }           \\\n  template <typename arg_type>                                                 \\\n  bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(                   \\\n      const arg_type& arg,                                                     \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) \\\n      const\n\n#define MATCHER_P(name, p0, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP, description, (p0))\n#define MATCHER_P2(name, p0, p1, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP2, description, (p0, p1))\n#define MATCHER_P3(name, p0, p1, p2, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP3, description, (p0, p1, p2))\n#define MATCHER_P4(name, p0, p1, p2, p3, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP4, description, (p0, p1, p2, p3))\n#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)    \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP5, description, \\\n                         (p0, p1, p2, p3, p4))\n#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP6, description,  \\\n                         (p0, p1, p2, p3, p4, p5))\n#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP7, description,      \\\n                         (p0, p1, p2, p3, p4, p5, p6))\n#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP8, description,          \\\n                         (p0, p1, p2, p3, p4, p5, p6, p7))\n#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP9, description,              \\\n                         (p0, p1, p2, p3, p4, p5, p6, p7, p8))\n#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description) \\\n  GMOCK_INTERNAL_MATCHER(name, name##MatcherP10, description,                  \\\n                         (p0, p1, p2, p3, p4, p5, p6, p7, p8, p9))\n\n#define GMOCK_INTERNAL_MATCHER(name, full_name, description, args)             \\\n  template <GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args)>                      \\\n  class full_name : public ::testing::internal::MatcherBaseImpl<               \\\n                        full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>> { \\\n   public:                                                                     \\\n    using full_name::MatcherBaseImpl::MatcherBaseImpl;                         \\\n    template <typename arg_type>                                               \\\n    class gmock_Impl : public ::testing::MatcherInterface<const arg_type&> {   \\\n     public:                                                                   \\\n      explicit gmock_Impl(GMOCK_INTERNAL_MATCHER_FUNCTION_ARGS(args))          \\\n          : GMOCK_INTERNAL_MATCHER_FORWARD_ARGS(args) {}                       \\\n      bool MatchAndExplain(                                                    \\\n          const arg_type& arg,                                                 \\\n          ::testing::MatchResultListener* result_listener) const override;     \\\n      void DescribeTo(::std::ostream* gmock_os) const override {               \\\n        *gmock_os << FormatDescription(false);                                 \\\n      }                                                                        \\\n      void DescribeNegationTo(::std::ostream* gmock_os) const override {       \\\n        *gmock_os << FormatDescription(true);                                  \\\n      }                                                                        \\\n      GMOCK_INTERNAL_MATCHER_MEMBERS(args)                                     \\\n                                                                               \\\n     private:                                                                  \\\n      ::std::string FormatDescription(bool negation) const {                   \\\n        ::std::string gmock_description = (description);                       \\\n        if (!gmock_description.empty()) {                                      \\\n          return gmock_description;                                            \\\n        }                                                                      \\\n        return ::testing::internal::FormatMatcherDescription(                  \\\n            negation, #name,                                                   \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(      \\\n                ::std::tuple<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>(        \\\n                    GMOCK_INTERNAL_MATCHER_MEMBERS_USAGE(args))));             \\\n      }                                                                        \\\n    };                                                                         \\\n  };                                                                           \\\n  template <GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args)>                      \\\n  inline full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)> name(             \\\n      GMOCK_INTERNAL_MATCHER_FUNCTION_ARGS(args)) {                            \\\n    return full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>(                \\\n        GMOCK_INTERNAL_MATCHER_ARGS_USAGE(args));                              \\\n  }                                                                            \\\n  template <GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args)>                      \\\n  template <typename arg_type>                                                 \\\n  bool full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>::gmock_Impl<        \\\n      arg_type>::MatchAndExplain(const arg_type& arg,                          \\\n                                 ::testing::MatchResultListener*               \\\n                                     result_listener GTEST_ATTRIBUTE_UNUSED_)  \\\n      const\n\n#define GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args) \\\n  GMOCK_PP_TAIL(                                     \\\n      GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAM, , args))\n#define GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAM(i_unused, data_unused, arg) \\\n  , typename arg##_type\n\n#define GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_TYPE_PARAM, , args))\n#define GMOCK_INTERNAL_MATCHER_TYPE_PARAM(i_unused, data_unused, arg) \\\n  , arg##_type\n\n#define GMOCK_INTERNAL_MATCHER_FUNCTION_ARGS(args) \\\n  GMOCK_PP_TAIL(dummy_first GMOCK_PP_FOR_EACH(     \\\n      GMOCK_INTERNAL_MATCHER_FUNCTION_ARG, , args))\n#define GMOCK_INTERNAL_MATCHER_FUNCTION_ARG(i, data_unused, arg) \\\n  , arg##_type gmock_p##i\n\n#define GMOCK_INTERNAL_MATCHER_FORWARD_ARGS(args) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_FORWARD_ARG, , args))\n#define GMOCK_INTERNAL_MATCHER_FORWARD_ARG(i, data_unused, arg) \\\n  , arg(::std::forward<arg##_type>(gmock_p##i))\n\n#define GMOCK_INTERNAL_MATCHER_MEMBERS(args) \\\n  GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_MEMBER, , args)\n#define GMOCK_INTERNAL_MATCHER_MEMBER(i_unused, data_unused, arg) \\\n  const arg##_type arg;\n\n#define GMOCK_INTERNAL_MATCHER_MEMBERS_USAGE(args) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_MEMBER_USAGE, , args))\n#define GMOCK_INTERNAL_MATCHER_MEMBER_USAGE(i_unused, data_unused, arg) , arg\n\n#define GMOCK_INTERNAL_MATCHER_ARGS_USAGE(args) \\\n  GMOCK_PP_TAIL(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_MATCHER_ARG_USAGE, , args))\n#define GMOCK_INTERNAL_MATCHER_ARG_USAGE(i, data_unused, arg_unused) \\\n  , gmock_p##i\n\n// To prevent ADL on certain functions we put them on a separate namespace.\nusing namespace no_adl;  // NOLINT\n\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251 5046\n\n// Include any custom callback matchers added by the local installation.\n// We must include this header at the end to make sure it can use the\n// declarations from this file.\n// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Injection point for custom user configurations. See README for details\n//\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>  // NOLINT\n#endif\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// An abstract handle of an expectation.\nclass Expectation;\n\n// A set of expectation handles.\nclass ExpectationSet;\n\n// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION\n// and MUST NOT BE USED IN USER CODE!!!\nnamespace internal {\n\n// Implements a mock function.\ntemplate <typename F> class FunctionMocker;\n\n// Base class for expectations.\nclass ExpectationBase;\n\n// Implements an expectation.\ntemplate <typename F> class TypedExpectation;\n\n// Helper class for testing the Expectation class template.\nclass ExpectationTester;\n\n// Helper classes for implementing NiceMock, StrictMock, and NaggyMock.\ntemplate <typename MockClass>\nclass NiceMockImpl;\ntemplate <typename MockClass>\nclass StrictMockImpl;\ntemplate <typename MockClass>\nclass NaggyMockImpl;\n\n// Protects the mock object registry (in class Mock), all function\n// mockers, and all expectations.\n//\n// The reason we don't use more fine-grained protection is: when a\n// mock function Foo() is called, it needs to consult its expectations\n// to see which one should be picked.  If another thread is allowed to\n// call a mock function (either Foo() or a different one) at the same\n// time, it could affect the \"retired\" attributes of Foo()'s\n// expectations when InSequence() is used, and thus affect which\n// expectation gets picked.  Therefore, we sequence all mock function\n// calls to ensure the integrity of the mock objects' states.\nGTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);\n\n// Untyped base class for ActionResultHolder<R>.\nclass UntypedActionResultHolderBase;\n\n// Abstract base class of FunctionMocker.  This is the\n// type-agnostic part of the function mocker interface.  Its pure\n// virtual methods are implemented by FunctionMocker.\nclass GTEST_API_ UntypedFunctionMockerBase {\n public:\n  UntypedFunctionMockerBase();\n  virtual ~UntypedFunctionMockerBase();\n\n  // Verifies that all expectations on this mock function have been\n  // satisfied.  Reports one or more Google Test non-fatal failures\n  // and returns false if not.\n  bool VerifyAndClearExpectationsLocked()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Clears the ON_CALL()s set on this mock function.\n  virtual void ClearDefaultActionsLocked()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) = 0;\n\n  // In all of the following Untyped* functions, it's the caller's\n  // responsibility to guarantee the correctness of the arguments'\n  // types.\n\n  // Performs the default action with the given arguments and returns\n  // the action's result.  The call description string will be used in\n  // the error message to describe the call in the case the default\n  // action fails.\n  // L = *\n  virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(\n      void* untyped_args, const std::string& call_description) const = 0;\n\n  // Performs the given action with the given arguments and returns\n  // the action's result.\n  // L = *\n  virtual UntypedActionResultHolderBase* UntypedPerformAction(\n      const void* untyped_action, void* untyped_args) const = 0;\n\n  // Writes a message that the call is uninteresting (i.e. neither\n  // explicitly expected nor explicitly unexpected) to the given\n  // ostream.\n  virtual void UntypedDescribeUninterestingCall(\n      const void* untyped_args,\n      ::std::ostream* os) const\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;\n\n  // Returns the expectation that matches the given function arguments\n  // (or NULL is there's no match); when a match is found,\n  // untyped_action is set to point to the action that should be\n  // performed (or NULL if the action is \"do default\"), and\n  // is_excessive is modified to indicate whether the call exceeds the\n  // expected number.\n  virtual const ExpectationBase* UntypedFindMatchingExpectation(\n      const void* untyped_args,\n      const void** untyped_action, bool* is_excessive,\n      ::std::ostream* what, ::std::ostream* why)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;\n\n  // Prints the given function arguments to the ostream.\n  virtual void UntypedPrintArgs(const void* untyped_args,\n                                ::std::ostream* os) const = 0;\n\n  // Sets the mock object this mock method belongs to, and registers\n  // this information in the global mock registry.  Will be called\n  // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock\n  // method.\n  void RegisterOwner(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Sets the mock object this mock method belongs to, and sets the\n  // name of the mock function.  Will be called upon each invocation\n  // of this mock function.\n  void SetOwnerAndName(const void* mock_obj, const char* name)\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Returns the mock object this mock method belongs to.  Must be\n  // called after RegisterOwner() or SetOwnerAndName() has been\n  // called.\n  const void* MockObject() const\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Returns the name of this mock method.  Must be called after\n  // SetOwnerAndName() has been called.\n  const char* Name() const\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Returns the result of invoking this mock function with the given\n  // arguments.  This function can be safely called from multiple\n  // threads concurrently.  The caller is responsible for deleting the\n  // result.\n  UntypedActionResultHolderBase* UntypedInvokeWith(void* untyped_args)\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n protected:\n  typedef std::vector<const void*> UntypedOnCallSpecs;\n\n  using UntypedExpectations = std::vector<std::shared_ptr<ExpectationBase>>;\n\n  // Returns an Expectation object that references and co-owns exp,\n  // which must be an expectation on this mock function.\n  Expectation GetHandleOf(ExpectationBase* exp);\n\n  // Address of the mock object this mock method belongs to.  Only\n  // valid after this mock method has been called or\n  // ON_CALL/EXPECT_CALL has been invoked on it.\n  const void* mock_obj_;  // Protected by g_gmock_mutex.\n\n  // Name of the function being mocked.  Only valid after this mock\n  // method has been called.\n  const char* name_;  // Protected by g_gmock_mutex.\n\n  // All default action specs for this function mocker.\n  UntypedOnCallSpecs untyped_on_call_specs_;\n\n  // All expectations for this function mocker.\n  //\n  // It's undefined behavior to interleave expectations (EXPECT_CALLs\n  // or ON_CALLs) and mock function calls.  Also, the order of\n  // expectations is important.  Therefore it's a logic race condition\n  // to read/write untyped_expectations_ concurrently.  In order for\n  // tools like tsan to catch concurrent read/write accesses to\n  // untyped_expectations, we deliberately leave accesses to it\n  // unprotected.\n  UntypedExpectations untyped_expectations_;\n};  // class UntypedFunctionMockerBase\n\n// Untyped base class for OnCallSpec<F>.\nclass UntypedOnCallSpecBase {\n public:\n  // The arguments are the location of the ON_CALL() statement.\n  UntypedOnCallSpecBase(const char* a_file, int a_line)\n      : file_(a_file), line_(a_line), last_clause_(kNone) {}\n\n  // Where in the source file was the default action spec defined?\n  const char* file() const { return file_; }\n  int line() const { return line_; }\n\n protected:\n  // Gives each clause in the ON_CALL() statement a name.\n  enum Clause {\n    // Do not change the order of the enum members!  The run-time\n    // syntax checking relies on it.\n    kNone,\n    kWith,\n    kWillByDefault\n  };\n\n  // Asserts that the ON_CALL() statement has a certain property.\n  void AssertSpecProperty(bool property,\n                          const std::string& failure_message) const {\n    Assert(property, file_, line_, failure_message);\n  }\n\n  // Expects that the ON_CALL() statement has a certain property.\n  void ExpectSpecProperty(bool property,\n                          const std::string& failure_message) const {\n    Expect(property, file_, line_, failure_message);\n  }\n\n  const char* file_;\n  int line_;\n\n  // The last clause in the ON_CALL() statement as seen so far.\n  // Initially kNone and changes as the statement is parsed.\n  Clause last_clause_;\n};  // class UntypedOnCallSpecBase\n\n// This template class implements an ON_CALL spec.\ntemplate <typename F>\nclass OnCallSpec : public UntypedOnCallSpecBase {\n public:\n  typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;\n\n  // Constructs an OnCallSpec object from the information inside\n  // the parenthesis of an ON_CALL() statement.\n  OnCallSpec(const char* a_file, int a_line,\n             const ArgumentMatcherTuple& matchers)\n      : UntypedOnCallSpecBase(a_file, a_line),\n        matchers_(matchers),\n        // By default, extra_matcher_ should match anything.  However,\n        // we cannot initialize it with _ as that causes ambiguity between\n        // Matcher's copy and move constructor for some argument types.\n        extra_matcher_(A<const ArgumentTuple&>()) {}\n\n  // Implements the .With() clause.\n  OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {\n    // Makes sure this is called at most once.\n    ExpectSpecProperty(last_clause_ < kWith,\n                       \".With() cannot appear \"\n                       \"more than once in an ON_CALL().\");\n    last_clause_ = kWith;\n\n    extra_matcher_ = m;\n    return *this;\n  }\n\n  // Implements the .WillByDefault() clause.\n  OnCallSpec& WillByDefault(const Action<F>& action) {\n    ExpectSpecProperty(last_clause_ < kWillByDefault,\n                       \".WillByDefault() must appear \"\n                       \"exactly once in an ON_CALL().\");\n    last_clause_ = kWillByDefault;\n\n    ExpectSpecProperty(!action.IsDoDefault(),\n                       \"DoDefault() cannot be used in ON_CALL().\");\n    action_ = action;\n    return *this;\n  }\n\n  // Returns true if and only if the given arguments match the matchers.\n  bool Matches(const ArgumentTuple& args) const {\n    return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);\n  }\n\n  // Returns the action specified by the user.\n  const Action<F>& GetAction() const {\n    AssertSpecProperty(last_clause_ == kWillByDefault,\n                       \".WillByDefault() must appear exactly \"\n                       \"once in an ON_CALL().\");\n    return action_;\n  }\n\n private:\n  // The information in statement\n  //\n  //   ON_CALL(mock_object, Method(matchers))\n  //       .With(multi-argument-matcher)\n  //       .WillByDefault(action);\n  //\n  // is recorded in the data members like this:\n  //\n  //   source file that contains the statement => file_\n  //   line number of the statement            => line_\n  //   matchers                                => matchers_\n  //   multi-argument-matcher                  => extra_matcher_\n  //   action                                  => action_\n  ArgumentMatcherTuple matchers_;\n  Matcher<const ArgumentTuple&> extra_matcher_;\n  Action<F> action_;\n};  // class OnCallSpec\n\n// Possible reactions on uninteresting calls.\nenum CallReaction {\n  kAllow,\n  kWarn,\n  kFail,\n};\n\n}  // namespace internal\n\n// Utilities for manipulating mock objects.\nclass GTEST_API_ Mock {\n public:\n  // The following public methods can be called concurrently.\n\n  // Tells Google Mock to ignore mock_obj when checking for leaked\n  // mock objects.\n  static void AllowLeak(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Verifies and clears all expectations on the given mock object.\n  // If the expectations aren't satisfied, generates one or more\n  // Google Test non-fatal failures and returns false.\n  static bool VerifyAndClearExpectations(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Verifies all expectations on the given mock object and clears its\n  // default actions and expectations.  Returns true if and only if the\n  // verification was successful.\n  static bool VerifyAndClear(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Returns whether the mock was created as a naggy mock (default)\n  static bool IsNaggy(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n  // Returns whether the mock was created as a nice mock\n  static bool IsNice(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n  // Returns whether the mock was created as a strict mock\n  static bool IsStrict(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n private:\n  friend class internal::UntypedFunctionMockerBase;\n\n  // Needed for a function mocker to register itself (so that we know\n  // how to clear a mock object).\n  template <typename F>\n  friend class internal::FunctionMocker;\n\n  template <typename MockClass>\n  friend class internal::NiceMockImpl;\n  template <typename MockClass>\n  friend class internal::NaggyMockImpl;\n  template <typename MockClass>\n  friend class internal::StrictMockImpl;\n\n  // Tells Google Mock to allow uninteresting calls on the given mock\n  // object.\n  static void AllowUninterestingCalls(uintptr_t mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock to warn the user about uninteresting calls on\n  // the given mock object.\n  static void WarnUninterestingCalls(uintptr_t mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock to fail uninteresting calls on the given mock\n  // object.\n  static void FailUninterestingCalls(uintptr_t mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock the given mock object is being destroyed and\n  // its entry in the call-reaction table should be removed.\n  static void UnregisterCallReaction(uintptr_t mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Returns the reaction Google Mock will have on uninteresting calls\n  // made on the given mock object.\n  static internal::CallReaction GetReactionOnUninterestingCalls(\n      const void* mock_obj)\n          GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Verifies that all expectations on the given mock object have been\n  // satisfied.  Reports one or more Google Test non-fatal failures\n  // and returns false if not.\n  static bool VerifyAndClearExpectationsLocked(void* mock_obj)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);\n\n  // Clears all ON_CALL()s set on the given mock object.\n  static void ClearDefaultActionsLocked(void* mock_obj)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);\n\n  // Registers a mock object and a mock method it owns.\n  static void Register(\n      const void* mock_obj,\n      internal::UntypedFunctionMockerBase* mocker)\n          GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock where in the source code mock_obj is used in an\n  // ON_CALL or EXPECT_CALL.  In case mock_obj is leaked, this\n  // information helps the user identify which object it is.\n  static void RegisterUseByOnCallOrExpectCall(\n      const void* mock_obj, const char* file, int line)\n          GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Unregisters a mock method; removes the owning mock object from\n  // the registry when the last mock method associated with it has\n  // been unregistered.  This is called only in the destructor of\n  // FunctionMocker.\n  static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);\n};  // class Mock\n\n// An abstract handle of an expectation.  Useful in the .After()\n// clause of EXPECT_CALL() for setting the (partial) order of\n// expectations.  The syntax:\n//\n//   Expectation e1 = EXPECT_CALL(...)...;\n//   EXPECT_CALL(...).After(e1)...;\n//\n// sets two expectations where the latter can only be matched after\n// the former has been satisfied.\n//\n// Notes:\n//   - This class is copyable and has value semantics.\n//   - Constness is shallow: a const Expectation object itself cannot\n//     be modified, but the mutable methods of the ExpectationBase\n//     object it references can be called via expectation_base().\n\nclass GTEST_API_ Expectation {\n public:\n  // Constructs a null object that doesn't reference any expectation.\n  Expectation();\n  Expectation(Expectation&&) = default;\n  Expectation(const Expectation&) = default;\n  Expectation& operator=(Expectation&&) = default;\n  Expectation& operator=(const Expectation&) = default;\n  ~Expectation();\n\n  // This single-argument ctor must not be explicit, in order to support the\n  //   Expectation e = EXPECT_CALL(...);\n  // syntax.\n  //\n  // A TypedExpectation object stores its pre-requisites as\n  // Expectation objects, and needs to call the non-const Retire()\n  // method on the ExpectationBase objects they reference.  Therefore\n  // Expectation must receive a *non-const* reference to the\n  // ExpectationBase object.\n  Expectation(internal::ExpectationBase& exp);  // NOLINT\n\n  // The compiler-generated copy ctor and operator= work exactly as\n  // intended, so we don't need to define our own.\n\n  // Returns true if and only if rhs references the same expectation as this\n  // object does.\n  bool operator==(const Expectation& rhs) const {\n    return expectation_base_ == rhs.expectation_base_;\n  }\n\n  bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }\n\n private:\n  friend class ExpectationSet;\n  friend class Sequence;\n  friend class ::testing::internal::ExpectationBase;\n  friend class ::testing::internal::UntypedFunctionMockerBase;\n\n  template <typename F>\n  friend class ::testing::internal::FunctionMocker;\n\n  template <typename F>\n  friend class ::testing::internal::TypedExpectation;\n\n  // This comparator is needed for putting Expectation objects into a set.\n  class Less {\n   public:\n    bool operator()(const Expectation& lhs, const Expectation& rhs) const {\n      return lhs.expectation_base_.get() < rhs.expectation_base_.get();\n    }\n  };\n\n  typedef ::std::set<Expectation, Less> Set;\n\n  Expectation(\n      const std::shared_ptr<internal::ExpectationBase>& expectation_base);\n\n  // Returns the expectation this object references.\n  const std::shared_ptr<internal::ExpectationBase>& expectation_base() const {\n    return expectation_base_;\n  }\n\n  // A shared_ptr that co-owns the expectation this handle references.\n  std::shared_ptr<internal::ExpectationBase> expectation_base_;\n};\n\n// A set of expectation handles.  Useful in the .After() clause of\n// EXPECT_CALL() for setting the (partial) order of expectations.  The\n// syntax:\n//\n//   ExpectationSet es;\n//   es += EXPECT_CALL(...)...;\n//   es += EXPECT_CALL(...)...;\n//   EXPECT_CALL(...).After(es)...;\n//\n// sets three expectations where the last one can only be matched\n// after the first two have both been satisfied.\n//\n// This class is copyable and has value semantics.\nclass ExpectationSet {\n public:\n  // A bidirectional iterator that can read a const element in the set.\n  typedef Expectation::Set::const_iterator const_iterator;\n\n  // An object stored in the set.  This is an alias of Expectation.\n  typedef Expectation::Set::value_type value_type;\n\n  // Constructs an empty set.\n  ExpectationSet() {}\n\n  // This single-argument ctor must not be explicit, in order to support the\n  //   ExpectationSet es = EXPECT_CALL(...);\n  // syntax.\n  ExpectationSet(internal::ExpectationBase& exp) {  // NOLINT\n    *this += Expectation(exp);\n  }\n\n  // This single-argument ctor implements implicit conversion from\n  // Expectation and thus must not be explicit.  This allows either an\n  // Expectation or an ExpectationSet to be used in .After().\n  ExpectationSet(const Expectation& e) {  // NOLINT\n    *this += e;\n  }\n\n  // The compiler-generator ctor and operator= works exactly as\n  // intended, so we don't need to define our own.\n\n  // Returns true if and only if rhs contains the same set of Expectation\n  // objects as this does.\n  bool operator==(const ExpectationSet& rhs) const {\n    return expectations_ == rhs.expectations_;\n  }\n\n  bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }\n\n  // Implements the syntax\n  //   expectation_set += EXPECT_CALL(...);\n  ExpectationSet& operator+=(const Expectation& e) {\n    expectations_.insert(e);\n    return *this;\n  }\n\n  int size() const { return static_cast<int>(expectations_.size()); }\n\n  const_iterator begin() const { return expectations_.begin(); }\n  const_iterator end() const { return expectations_.end(); }\n\n private:\n  Expectation::Set expectations_;\n};\n\n\n// Sequence objects are used by a user to specify the relative order\n// in which the expectations should match.  They are copyable (we rely\n// on the compiler-defined copy constructor and assignment operator).\nclass GTEST_API_ Sequence {\n public:\n  // Constructs an empty sequence.\n  Sequence() : last_expectation_(new Expectation) {}\n\n  // Adds an expectation to this sequence.  The caller must ensure\n  // that no other thread is accessing this Sequence object.\n  void AddExpectation(const Expectation& expectation) const;\n\n private:\n  // The last expectation in this sequence.\n  std::shared_ptr<Expectation> last_expectation_;\n};  // class Sequence\n\n// An object of this type causes all EXPECT_CALL() statements\n// encountered in its scope to be put in an anonymous sequence.  The\n// work is done in the constructor and destructor.  You should only\n// create an InSequence object on the stack.\n//\n// The sole purpose for this class is to support easy definition of\n// sequential expectations, e.g.\n//\n//   {\n//     InSequence dummy;  // The name of the object doesn't matter.\n//\n//     // The following expectations must match in the order they appear.\n//     EXPECT_CALL(a, Bar())...;\n//     EXPECT_CALL(a, Baz())...;\n//     ...\n//     EXPECT_CALL(b, Xyz())...;\n//   }\n//\n// You can create InSequence objects in multiple threads, as long as\n// they are used to affect different mock objects.  The idea is that\n// each thread can create and set up its own mocks as if it's the only\n// thread.  However, for clarity of your tests we recommend you to set\n// up mocks in the main thread unless you have a good reason not to do\n// so.\nclass GTEST_API_ InSequence {\n public:\n  InSequence();\n  ~InSequence();\n private:\n  bool sequence_created_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence);  // NOLINT\n} GTEST_ATTRIBUTE_UNUSED_;\n\nnamespace internal {\n\n// Points to the implicit sequence introduced by a living InSequence\n// object (if any) in the current thread or NULL.\nGTEST_API_ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;\n\n// Base class for implementing expectations.\n//\n// There are two reasons for having a type-agnostic base class for\n// Expectation:\n//\n//   1. We need to store collections of expectations of different\n//   types (e.g. all pre-requisites of a particular expectation, all\n//   expectations in a sequence).  Therefore these expectation objects\n//   must share a common base class.\n//\n//   2. We can avoid binary code bloat by moving methods not depending\n//   on the template argument of Expectation to the base class.\n//\n// This class is internal and mustn't be used by user code directly.\nclass GTEST_API_ ExpectationBase {\n public:\n  // source_text is the EXPECT_CALL(...) source that created this Expectation.\n  ExpectationBase(const char* file, int line, const std::string& source_text);\n\n  virtual ~ExpectationBase();\n\n  // Where in the source file was the expectation spec defined?\n  const char* file() const { return file_; }\n  int line() const { return line_; }\n  const char* source_text() const { return source_text_.c_str(); }\n  // Returns the cardinality specified in the expectation spec.\n  const Cardinality& cardinality() const { return cardinality_; }\n\n  // Describes the source file location of this expectation.\n  void DescribeLocationTo(::std::ostream* os) const {\n    *os << FormatFileLocation(file(), line()) << \" \";\n  }\n\n  // Describes how many times a function call matching this\n  // expectation has occurred.\n  void DescribeCallCountTo(::std::ostream* os) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // If this mock method has an extra matcher (i.e. .With(matcher)),\n  // describes it to the ostream.\n  virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;\n\n protected:\n  friend class ::testing::Expectation;\n  friend class UntypedFunctionMockerBase;\n\n  enum Clause {\n    // Don't change the order of the enum members!\n    kNone,\n    kWith,\n    kTimes,\n    kInSequence,\n    kAfter,\n    kWillOnce,\n    kWillRepeatedly,\n    kRetiresOnSaturation\n  };\n\n  typedef std::vector<const void*> UntypedActions;\n\n  // Returns an Expectation object that references and co-owns this\n  // expectation.\n  virtual Expectation GetHandle() = 0;\n\n  // Asserts that the EXPECT_CALL() statement has the given property.\n  void AssertSpecProperty(bool property,\n                          const std::string& failure_message) const {\n    Assert(property, file_, line_, failure_message);\n  }\n\n  // Expects that the EXPECT_CALL() statement has the given property.\n  void ExpectSpecProperty(bool property,\n                          const std::string& failure_message) const {\n    Expect(property, file_, line_, failure_message);\n  }\n\n  // Explicitly specifies the cardinality of this expectation.  Used\n  // by the subclasses to implement the .Times() clause.\n  void SpecifyCardinality(const Cardinality& cardinality);\n\n  // Returns true if and only if the user specified the cardinality\n  // explicitly using a .Times().\n  bool cardinality_specified() const { return cardinality_specified_; }\n\n  // Sets the cardinality of this expectation spec.\n  void set_cardinality(const Cardinality& a_cardinality) {\n    cardinality_ = a_cardinality;\n  }\n\n  // The following group of methods should only be called after the\n  // EXPECT_CALL() statement, and only when g_gmock_mutex is held by\n  // the current thread.\n\n  // Retires all pre-requisites of this expectation.\n  void RetireAllPreRequisites()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Returns true if and only if this expectation is retired.\n  bool is_retired() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return retired_;\n  }\n\n  // Retires this expectation.\n  void Retire()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    retired_ = true;\n  }\n\n  // Returns true if and only if this expectation is satisfied.\n  bool IsSatisfied() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return cardinality().IsSatisfiedByCallCount(call_count_);\n  }\n\n  // Returns true if and only if this expectation is saturated.\n  bool IsSaturated() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return cardinality().IsSaturatedByCallCount(call_count_);\n  }\n\n  // Returns true if and only if this expectation is over-saturated.\n  bool IsOverSaturated() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return cardinality().IsOverSaturatedByCallCount(call_count_);\n  }\n\n  // Returns true if and only if all pre-requisites of this expectation are\n  // satisfied.\n  bool AllPrerequisitesAreSatisfied() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Adds unsatisfied pre-requisites of this expectation to 'result'.\n  void FindUnsatisfiedPrerequisites(ExpectationSet* result) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Returns the number this expectation has been invoked.\n  int call_count() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return call_count_;\n  }\n\n  // Increments the number this expectation has been invoked.\n  void IncrementCallCount()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    call_count_++;\n  }\n\n  // Checks the action count (i.e. the number of WillOnce() and\n  // WillRepeatedly() clauses) against the cardinality if this hasn't\n  // been done before.  Prints a warning if there are too many or too\n  // few actions.\n  void CheckActionCountIfNotDone() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  friend class ::testing::Sequence;\n  friend class ::testing::internal::ExpectationTester;\n\n  template <typename Function>\n  friend class TypedExpectation;\n\n  // Implements the .Times() clause.\n  void UntypedTimes(const Cardinality& a_cardinality);\n\n  // This group of fields are part of the spec and won't change after\n  // an EXPECT_CALL() statement finishes.\n  const char* file_;          // The file that contains the expectation.\n  int line_;                  // The line number of the expectation.\n  const std::string source_text_;  // The EXPECT_CALL(...) source text.\n  // True if and only if the cardinality is specified explicitly.\n  bool cardinality_specified_;\n  Cardinality cardinality_;            // The cardinality of the expectation.\n  // The immediate pre-requisites (i.e. expectations that must be\n  // satisfied before this expectation can be matched) of this\n  // expectation.  We use std::shared_ptr in the set because we want an\n  // Expectation object to be co-owned by its FunctionMocker and its\n  // successors.  This allows multiple mock objects to be deleted at\n  // different times.\n  ExpectationSet immediate_prerequisites_;\n\n  // This group of fields are the current state of the expectation,\n  // and can change as the mock function is called.\n  int call_count_;  // How many times this expectation has been invoked.\n  bool retired_;    // True if and only if this expectation has retired.\n  UntypedActions untyped_actions_;\n  bool extra_matcher_specified_;\n  bool repeated_action_specified_;  // True if a WillRepeatedly() was specified.\n  bool retires_on_saturation_;\n  Clause last_clause_;\n  mutable bool action_count_checked_;  // Under mutex_.\n  mutable Mutex mutex_;  // Protects action_count_checked_.\n};  // class ExpectationBase\n\n// Impements an expectation for the given function type.\ntemplate <typename F>\nclass TypedExpectation : public ExpectationBase {\n public:\n  typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;\n  typedef typename Function<F>::Result Result;\n\n  TypedExpectation(FunctionMocker<F>* owner, const char* a_file, int a_line,\n                   const std::string& a_source_text,\n                   const ArgumentMatcherTuple& m)\n      : ExpectationBase(a_file, a_line, a_source_text),\n        owner_(owner),\n        matchers_(m),\n        // By default, extra_matcher_ should match anything.  However,\n        // we cannot initialize it with _ as that causes ambiguity between\n        // Matcher's copy and move constructor for some argument types.\n        extra_matcher_(A<const ArgumentTuple&>()),\n        repeated_action_(DoDefault()) {}\n\n  ~TypedExpectation() override {\n    // Check the validity of the action count if it hasn't been done\n    // yet (for example, if the expectation was never used).\n    CheckActionCountIfNotDone();\n    for (UntypedActions::const_iterator it = untyped_actions_.begin();\n         it != untyped_actions_.end(); ++it) {\n      delete static_cast<const Action<F>*>(*it);\n    }\n  }\n\n  // Implements the .With() clause.\n  TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {\n    if (last_clause_ == kWith) {\n      ExpectSpecProperty(false,\n                         \".With() cannot appear \"\n                         \"more than once in an EXPECT_CALL().\");\n    } else {\n      ExpectSpecProperty(last_clause_ < kWith,\n                         \".With() must be the first \"\n                         \"clause in an EXPECT_CALL().\");\n    }\n    last_clause_ = kWith;\n\n    extra_matcher_ = m;\n    extra_matcher_specified_ = true;\n    return *this;\n  }\n\n  // Implements the .Times() clause.\n  TypedExpectation& Times(const Cardinality& a_cardinality) {\n    ExpectationBase::UntypedTimes(a_cardinality);\n    return *this;\n  }\n\n  // Implements the .Times() clause.\n  TypedExpectation& Times(int n) {\n    return Times(Exactly(n));\n  }\n\n  // Implements the .InSequence() clause.\n  TypedExpectation& InSequence(const Sequence& s) {\n    ExpectSpecProperty(last_clause_ <= kInSequence,\n                       \".InSequence() cannot appear after .After(),\"\n                       \" .WillOnce(), .WillRepeatedly(), or \"\n                       \".RetiresOnSaturation().\");\n    last_clause_ = kInSequence;\n\n    s.AddExpectation(GetHandle());\n    return *this;\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {\n    return InSequence(s1).InSequence(s2);\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,\n                               const Sequence& s3) {\n    return InSequence(s1, s2).InSequence(s3);\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,\n                               const Sequence& s3, const Sequence& s4) {\n    return InSequence(s1, s2, s3).InSequence(s4);\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,\n                               const Sequence& s3, const Sequence& s4,\n                               const Sequence& s5) {\n    return InSequence(s1, s2, s3, s4).InSequence(s5);\n  }\n\n  // Implements that .After() clause.\n  TypedExpectation& After(const ExpectationSet& s) {\n    ExpectSpecProperty(last_clause_ <= kAfter,\n                       \".After() cannot appear after .WillOnce(),\"\n                       \" .WillRepeatedly(), or \"\n                       \".RetiresOnSaturation().\");\n    last_clause_ = kAfter;\n\n    for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {\n      immediate_prerequisites_ += *it;\n    }\n    return *this;\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {\n    return After(s1).After(s2);\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,\n                          const ExpectationSet& s3) {\n    return After(s1, s2).After(s3);\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,\n                          const ExpectationSet& s3, const ExpectationSet& s4) {\n    return After(s1, s2, s3).After(s4);\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,\n                          const ExpectationSet& s3, const ExpectationSet& s4,\n                          const ExpectationSet& s5) {\n    return After(s1, s2, s3, s4).After(s5);\n  }\n\n  // Implements the .WillOnce() clause.\n  TypedExpectation& WillOnce(const Action<F>& action) {\n    ExpectSpecProperty(last_clause_ <= kWillOnce,\n                       \".WillOnce() cannot appear after \"\n                       \".WillRepeatedly() or .RetiresOnSaturation().\");\n    last_clause_ = kWillOnce;\n\n    untyped_actions_.push_back(new Action<F>(action));\n    if (!cardinality_specified()) {\n      set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));\n    }\n    return *this;\n  }\n\n  // Implements the .WillRepeatedly() clause.\n  TypedExpectation& WillRepeatedly(const Action<F>& action) {\n    if (last_clause_ == kWillRepeatedly) {\n      ExpectSpecProperty(false,\n                         \".WillRepeatedly() cannot appear \"\n                         \"more than once in an EXPECT_CALL().\");\n    } else {\n      ExpectSpecProperty(last_clause_ < kWillRepeatedly,\n                         \".WillRepeatedly() cannot appear \"\n                         \"after .RetiresOnSaturation().\");\n    }\n    last_clause_ = kWillRepeatedly;\n    repeated_action_specified_ = true;\n\n    repeated_action_ = action;\n    if (!cardinality_specified()) {\n      set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));\n    }\n\n    // Now that no more action clauses can be specified, we check\n    // whether their count makes sense.\n    CheckActionCountIfNotDone();\n    return *this;\n  }\n\n  // Implements the .RetiresOnSaturation() clause.\n  TypedExpectation& RetiresOnSaturation() {\n    ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,\n                       \".RetiresOnSaturation() cannot appear \"\n                       \"more than once.\");\n    last_clause_ = kRetiresOnSaturation;\n    retires_on_saturation_ = true;\n\n    // Now that no more action clauses can be specified, we check\n    // whether their count makes sense.\n    CheckActionCountIfNotDone();\n    return *this;\n  }\n\n  // Returns the matchers for the arguments as specified inside the\n  // EXPECT_CALL() macro.\n  const ArgumentMatcherTuple& matchers() const {\n    return matchers_;\n  }\n\n  // Returns the matcher specified by the .With() clause.\n  const Matcher<const ArgumentTuple&>& extra_matcher() const {\n    return extra_matcher_;\n  }\n\n  // Returns the action specified by the .WillRepeatedly() clause.\n  const Action<F>& repeated_action() const { return repeated_action_; }\n\n  // If this mock method has an extra matcher (i.e. .With(matcher)),\n  // describes it to the ostream.\n  void MaybeDescribeExtraMatcherTo(::std::ostream* os) override {\n    if (extra_matcher_specified_) {\n      *os << \"    Expected args: \";\n      extra_matcher_.DescribeTo(os);\n      *os << \"\\n\";\n    }\n  }\n\n private:\n  template <typename Function>\n  friend class FunctionMocker;\n\n  // Returns an Expectation object that references and co-owns this\n  // expectation.\n  Expectation GetHandle() override { return owner_->GetHandleOf(this); }\n\n  // The following methods will be called only after the EXPECT_CALL()\n  // statement finishes and when the current thread holds\n  // g_gmock_mutex.\n\n  // Returns true if and only if this expectation matches the given arguments.\n  bool Matches(const ArgumentTuple& args) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);\n  }\n\n  // Returns true if and only if this expectation should handle the given\n  // arguments.\n  bool ShouldHandleArguments(const ArgumentTuple& args) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n\n    // In case the action count wasn't checked when the expectation\n    // was defined (e.g. if this expectation has no WillRepeatedly()\n    // or RetiresOnSaturation() clause), we check it when the\n    // expectation is used for the first time.\n    CheckActionCountIfNotDone();\n    return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);\n  }\n\n  // Describes the result of matching the arguments against this\n  // expectation to the given ostream.\n  void ExplainMatchResultTo(\n      const ArgumentTuple& args,\n      ::std::ostream* os) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n\n    if (is_retired()) {\n      *os << \"         Expected: the expectation is active\\n\"\n          << \"           Actual: it is retired\\n\";\n    } else if (!Matches(args)) {\n      if (!TupleMatches(matchers_, args)) {\n        ExplainMatchFailureTupleTo(matchers_, args, os);\n      }\n      StringMatchResultListener listener;\n      if (!extra_matcher_.MatchAndExplain(args, &listener)) {\n        *os << \"    Expected args: \";\n        extra_matcher_.DescribeTo(os);\n        *os << \"\\n           Actual: don't match\";\n\n        internal::PrintIfNotEmpty(listener.str(), os);\n        *os << \"\\n\";\n      }\n    } else if (!AllPrerequisitesAreSatisfied()) {\n      *os << \"         Expected: all pre-requisites are satisfied\\n\"\n          << \"           Actual: the following immediate pre-requisites \"\n          << \"are not satisfied:\\n\";\n      ExpectationSet unsatisfied_prereqs;\n      FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);\n      int i = 0;\n      for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();\n           it != unsatisfied_prereqs.end(); ++it) {\n        it->expectation_base()->DescribeLocationTo(os);\n        *os << \"pre-requisite #\" << i++ << \"\\n\";\n      }\n      *os << \"                   (end of pre-requisites)\\n\";\n    } else {\n      // This line is here just for completeness' sake.  It will never\n      // be executed as currently the ExplainMatchResultTo() function\n      // is called only when the mock function call does NOT match the\n      // expectation.\n      *os << \"The call matches the expectation.\\n\";\n    }\n  }\n\n  // Returns the action that should be taken for the current invocation.\n  const Action<F>& GetCurrentAction(const FunctionMocker<F>* mocker,\n                                    const ArgumentTuple& args) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    const int count = call_count();\n    Assert(count >= 1, __FILE__, __LINE__,\n           \"call_count() is <= 0 when GetCurrentAction() is \"\n           \"called - this should never happen.\");\n\n    const int action_count = static_cast<int>(untyped_actions_.size());\n    if (action_count > 0 && !repeated_action_specified_ &&\n        count > action_count) {\n      // If there is at least one WillOnce() and no WillRepeatedly(),\n      // we warn the user when the WillOnce() clauses ran out.\n      ::std::stringstream ss;\n      DescribeLocationTo(&ss);\n      ss << \"Actions ran out in \" << source_text() << \"...\\n\"\n         << \"Called \" << count << \" times, but only \"\n         << action_count << \" WillOnce()\"\n         << (action_count == 1 ? \" is\" : \"s are\") << \" specified - \";\n      mocker->DescribeDefaultActionTo(args, &ss);\n      Log(kWarning, ss.str(), 1);\n    }\n\n    return count <= action_count\n               ? *static_cast<const Action<F>*>(\n                     untyped_actions_[static_cast<size_t>(count - 1)])\n               : repeated_action();\n  }\n\n  // Given the arguments of a mock function call, if the call will\n  // over-saturate this expectation, returns the default action;\n  // otherwise, returns the next action in this expectation.  Also\n  // describes *what* happened to 'what', and explains *why* Google\n  // Mock does it to 'why'.  This method is not const as it calls\n  // IncrementCallCount().  A return value of NULL means the default\n  // action.\n  const Action<F>* GetActionForArguments(const FunctionMocker<F>* mocker,\n                                         const ArgumentTuple& args,\n                                         ::std::ostream* what,\n                                         ::std::ostream* why)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    if (IsSaturated()) {\n      // We have an excessive call.\n      IncrementCallCount();\n      *what << \"Mock function called more times than expected - \";\n      mocker->DescribeDefaultActionTo(args, what);\n      DescribeCallCountTo(why);\n\n      return nullptr;\n    }\n\n    IncrementCallCount();\n    RetireAllPreRequisites();\n\n    if (retires_on_saturation_ && IsSaturated()) {\n      Retire();\n    }\n\n    // Must be done after IncrementCount()!\n    *what << \"Mock function call matches \" << source_text() <<\"...\\n\";\n    return &(GetCurrentAction(mocker, args));\n  }\n\n  // All the fields below won't change once the EXPECT_CALL()\n  // statement finishes.\n  FunctionMocker<F>* const owner_;\n  ArgumentMatcherTuple matchers_;\n  Matcher<const ArgumentTuple&> extra_matcher_;\n  Action<F> repeated_action_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);\n};  // class TypedExpectation\n\n// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for\n// specifying the default behavior of, or expectation on, a mock\n// function.\n\n// Note: class MockSpec really belongs to the ::testing namespace.\n// However if we define it in ::testing, MSVC will complain when\n// classes in ::testing::internal declare it as a friend class\n// template.  To workaround this compiler bug, we define MockSpec in\n// ::testing::internal and import it into ::testing.\n\n// Logs a message including file and line number information.\nGTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,\n                                const char* file, int line,\n                                const std::string& message);\n\ntemplate <typename F>\nclass MockSpec {\n public:\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename internal::Function<F>::ArgumentMatcherTuple\n      ArgumentMatcherTuple;\n\n  // Constructs a MockSpec object, given the function mocker object\n  // that the spec is associated with.\n  MockSpec(internal::FunctionMocker<F>* function_mocker,\n           const ArgumentMatcherTuple& matchers)\n      : function_mocker_(function_mocker), matchers_(matchers) {}\n\n  // Adds a new default action spec to the function mocker and returns\n  // the newly created spec.\n  internal::OnCallSpec<F>& InternalDefaultActionSetAt(\n      const char* file, int line, const char* obj, const char* call) {\n    LogWithLocation(internal::kInfo, file, line,\n                    std::string(\"ON_CALL(\") + obj + \", \" + call + \") invoked\");\n    return function_mocker_->AddNewOnCallSpec(file, line, matchers_);\n  }\n\n  // Adds a new expectation spec to the function mocker and returns\n  // the newly created spec.\n  internal::TypedExpectation<F>& InternalExpectedAt(\n      const char* file, int line, const char* obj, const char* call) {\n    const std::string source_text(std::string(\"EXPECT_CALL(\") + obj + \", \" +\n                                  call + \")\");\n    LogWithLocation(internal::kInfo, file, line, source_text + \" invoked\");\n    return function_mocker_->AddNewExpectation(\n        file, line, source_text, matchers_);\n  }\n\n  // This operator overload is used to swallow the superfluous parameter list\n  // introduced by the ON/EXPECT_CALL macros. See the macro comments for more\n  // explanation.\n  MockSpec<F>& operator()(const internal::WithoutMatchers&, void* const) {\n    return *this;\n  }\n\n private:\n  template <typename Function>\n  friend class internal::FunctionMocker;\n\n  // The function mocker that owns this spec.\n  internal::FunctionMocker<F>* const function_mocker_;\n  // The argument matchers specified in the spec.\n  ArgumentMatcherTuple matchers_;\n};  // class MockSpec\n\n// Wrapper type for generically holding an ordinary value or lvalue reference.\n// If T is not a reference type, it must be copyable or movable.\n// ReferenceOrValueWrapper<T> is movable, and will also be copyable unless\n// T is a move-only value type (which means that it will always be copyable\n// if the current platform does not support move semantics).\n//\n// The primary template defines handling for values, but function header\n// comments describe the contract for the whole template (including\n// specializations).\ntemplate <typename T>\nclass ReferenceOrValueWrapper {\n public:\n  // Constructs a wrapper from the given value/reference.\n  explicit ReferenceOrValueWrapper(T value)\n      : value_(std::move(value)) {\n  }\n\n  // Unwraps and returns the underlying value/reference, exactly as\n  // originally passed. The behavior of calling this more than once on\n  // the same object is unspecified.\n  T Unwrap() { return std::move(value_); }\n\n  // Provides nondestructive access to the underlying value/reference.\n  // Always returns a const reference (more precisely,\n  // const std::add_lvalue_reference<T>::type). The behavior of calling this\n  // after calling Unwrap on the same object is unspecified.\n  const T& Peek() const {\n    return value_;\n  }\n\n private:\n  T value_;\n};\n\n// Specialization for lvalue reference types. See primary template\n// for documentation.\ntemplate <typename T>\nclass ReferenceOrValueWrapper<T&> {\n public:\n  // Workaround for debatable pass-by-reference lint warning (c-library-team\n  // policy precludes NOLINT in this context)\n  typedef T& reference;\n  explicit ReferenceOrValueWrapper(reference ref)\n      : value_ptr_(&ref) {}\n  T& Unwrap() { return *value_ptr_; }\n  const T& Peek() const { return *value_ptr_; }\n\n private:\n  T* value_ptr_;\n};\n\n// C++ treats the void type specially.  For example, you cannot define\n// a void-typed variable or pass a void value to a function.\n// ActionResultHolder<T> holds a value of type T, where T must be a\n// copyable type or void (T doesn't need to be default-constructable).\n// It hides the syntactic difference between void and other types, and\n// is used to unify the code for invoking both void-returning and\n// non-void-returning mock functions.\n\n// Untyped base class for ActionResultHolder<T>.\nclass UntypedActionResultHolderBase {\n public:\n  virtual ~UntypedActionResultHolderBase() {}\n\n  // Prints the held value as an action's result to os.\n  virtual void PrintAsActionResult(::std::ostream* os) const = 0;\n};\n\n// This generic definition is used when T is not void.\ntemplate <typename T>\nclass ActionResultHolder : public UntypedActionResultHolderBase {\n public:\n  // Returns the held value. Must not be called more than once.\n  T Unwrap() {\n    return result_.Unwrap();\n  }\n\n  // Prints the held value as an action's result to os.\n  void PrintAsActionResult(::std::ostream* os) const override {\n    *os << \"\\n          Returns: \";\n    // T may be a reference type, so we don't use UniversalPrint().\n    UniversalPrinter<T>::Print(result_.Peek(), os);\n  }\n\n  // Performs the given mock function's default action and returns the\n  // result in a new-ed ActionResultHolder.\n  template <typename F>\n  static ActionResultHolder* PerformDefaultAction(\n      const FunctionMocker<F>* func_mocker,\n      typename Function<F>::ArgumentTuple&& args,\n      const std::string& call_description) {\n    return new ActionResultHolder(Wrapper(func_mocker->PerformDefaultAction(\n        std::move(args), call_description)));\n  }\n\n  // Performs the given action and returns the result in a new-ed\n  // ActionResultHolder.\n  template <typename F>\n  static ActionResultHolder* PerformAction(\n      const Action<F>& action, typename Function<F>::ArgumentTuple&& args) {\n    return new ActionResultHolder(\n        Wrapper(action.Perform(std::move(args))));\n  }\n\n private:\n  typedef ReferenceOrValueWrapper<T> Wrapper;\n\n  explicit ActionResultHolder(Wrapper result)\n      : result_(std::move(result)) {\n  }\n\n  Wrapper result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);\n};\n\n// Specialization for T = void.\ntemplate <>\nclass ActionResultHolder<void> : public UntypedActionResultHolderBase {\n public:\n  void Unwrap() { }\n\n  void PrintAsActionResult(::std::ostream* /* os */) const override {}\n\n  // Performs the given mock function's default action and returns ownership\n  // of an empty ActionResultHolder*.\n  template <typename F>\n  static ActionResultHolder* PerformDefaultAction(\n      const FunctionMocker<F>* func_mocker,\n      typename Function<F>::ArgumentTuple&& args,\n      const std::string& call_description) {\n    func_mocker->PerformDefaultAction(std::move(args), call_description);\n    return new ActionResultHolder;\n  }\n\n  // Performs the given action and returns ownership of an empty\n  // ActionResultHolder*.\n  template <typename F>\n  static ActionResultHolder* PerformAction(\n      const Action<F>& action, typename Function<F>::ArgumentTuple&& args) {\n    action.Perform(std::move(args));\n    return new ActionResultHolder;\n  }\n\n private:\n  ActionResultHolder() {}\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);\n};\n\ntemplate <typename F>\nclass FunctionMocker;\n\ntemplate <typename R, typename... Args>\nclass FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {\n  using F = R(Args...);\n\n public:\n  using Result = R;\n  using ArgumentTuple = std::tuple<Args...>;\n  using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;\n\n  FunctionMocker() {}\n\n  // There is no generally useful and implementable semantics of\n  // copying a mock object, so copying a mock is usually a user error.\n  // Thus we disallow copying function mockers.  If the user really\n  // wants to copy a mock object, they should implement their own copy\n  // operation, for example:\n  //\n  //   class MockFoo : public Foo {\n  //    public:\n  //     // Defines a copy constructor explicitly.\n  //     MockFoo(const MockFoo& src) {}\n  //     ...\n  //   };\n  FunctionMocker(const FunctionMocker&) = delete;\n  FunctionMocker& operator=(const FunctionMocker&) = delete;\n\n  // The destructor verifies that all expectations on this mock\n  // function have been satisfied.  If not, it will report Google Test\n  // non-fatal failures for the violations.\n  ~FunctionMocker() override GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    MutexLock l(&g_gmock_mutex);\n    VerifyAndClearExpectationsLocked();\n    Mock::UnregisterLocked(this);\n    ClearDefaultActionsLocked();\n  }\n\n  // Returns the ON_CALL spec that matches this mock function with the\n  // given arguments; returns NULL if no matching ON_CALL is found.\n  // L = *\n  const OnCallSpec<F>* FindOnCallSpec(\n      const ArgumentTuple& args) const {\n    for (UntypedOnCallSpecs::const_reverse_iterator it\n             = untyped_on_call_specs_.rbegin();\n         it != untyped_on_call_specs_.rend(); ++it) {\n      const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);\n      if (spec->Matches(args))\n        return spec;\n    }\n\n    return nullptr;\n  }\n\n  // Performs the default action of this mock function on the given\n  // arguments and returns the result. Asserts (or throws if\n  // exceptions are enabled) with a helpful call descrption if there\n  // is no valid return value. This method doesn't depend on the\n  // mutable state of this object, and thus can be called concurrently\n  // without locking.\n  // L = *\n  Result PerformDefaultAction(ArgumentTuple&& args,\n                              const std::string& call_description) const {\n    const OnCallSpec<F>* const spec =\n        this->FindOnCallSpec(args);\n    if (spec != nullptr) {\n      return spec->GetAction().Perform(std::move(args));\n    }\n    const std::string message =\n        call_description +\n        \"\\n    The mock function has no default action \"\n        \"set, and its return type has no default value set.\";\n#if GTEST_HAS_EXCEPTIONS\n    if (!DefaultValue<Result>::Exists()) {\n      throw std::runtime_error(message);\n    }\n#else\n    Assert(DefaultValue<Result>::Exists(), \"\", -1, message);\n#endif\n    return DefaultValue<Result>::Get();\n  }\n\n  // Performs the default action with the given arguments and returns\n  // the action's result.  The call description string will be used in\n  // the error message to describe the call in the case the default\n  // action fails.  The caller is responsible for deleting the result.\n  // L = *\n  UntypedActionResultHolderBase* UntypedPerformDefaultAction(\n      void* untyped_args,  // must point to an ArgumentTuple\n      const std::string& call_description) const override {\n    ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args);\n    return ResultHolder::PerformDefaultAction(this, std::move(*args),\n                                              call_description);\n  }\n\n  // Performs the given action with the given arguments and returns\n  // the action's result.  The caller is responsible for deleting the\n  // result.\n  // L = *\n  UntypedActionResultHolderBase* UntypedPerformAction(\n      const void* untyped_action, void* untyped_args) const override {\n    // Make a copy of the action before performing it, in case the\n    // action deletes the mock object (and thus deletes itself).\n    const Action<F> action = *static_cast<const Action<F>*>(untyped_action);\n    ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args);\n    return ResultHolder::PerformAction(action, std::move(*args));\n  }\n\n  // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():\n  // clears the ON_CALL()s set on this mock function.\n  void ClearDefaultActionsLocked() override\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n\n    // Deleting our default actions may trigger other mock objects to be\n    // deleted, for example if an action contains a reference counted smart\n    // pointer to that mock object, and that is the last reference. So if we\n    // delete our actions within the context of the global mutex we may deadlock\n    // when this method is called again. Instead, make a copy of the set of\n    // actions to delete, clear our set within the mutex, and then delete the\n    // actions outside of the mutex.\n    UntypedOnCallSpecs specs_to_delete;\n    untyped_on_call_specs_.swap(specs_to_delete);\n\n    g_gmock_mutex.Unlock();\n    for (UntypedOnCallSpecs::const_iterator it =\n             specs_to_delete.begin();\n         it != specs_to_delete.end(); ++it) {\n      delete static_cast<const OnCallSpec<F>*>(*it);\n    }\n\n    // Lock the mutex again, since the caller expects it to be locked when we\n    // return.\n    g_gmock_mutex.Lock();\n  }\n\n  // Returns the result of invoking this mock function with the given\n  // arguments.  This function can be safely called from multiple\n  // threads concurrently.\n  Result Invoke(Args... args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    ArgumentTuple tuple(std::forward<Args>(args)...);\n    std::unique_ptr<ResultHolder> holder(DownCast_<ResultHolder*>(\n        this->UntypedInvokeWith(static_cast<void*>(&tuple))));\n    return holder->Unwrap();\n  }\n\n  MockSpec<F> With(Matcher<Args>... m) {\n    return MockSpec<F>(this, ::std::make_tuple(std::move(m)...));\n  }\n\n protected:\n  template <typename Function>\n  friend class MockSpec;\n\n  typedef ActionResultHolder<Result> ResultHolder;\n\n  // Adds and returns a default action spec for this mock function.\n  OnCallSpec<F>& AddNewOnCallSpec(\n      const char* file, int line,\n      const ArgumentMatcherTuple& m)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);\n    OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);\n    untyped_on_call_specs_.push_back(on_call_spec);\n    return *on_call_spec;\n  }\n\n  // Adds and returns an expectation spec for this mock function.\n  TypedExpectation<F>& AddNewExpectation(const char* file, int line,\n                                         const std::string& source_text,\n                                         const ArgumentMatcherTuple& m)\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);\n    TypedExpectation<F>* const expectation =\n        new TypedExpectation<F>(this, file, line, source_text, m);\n    const std::shared_ptr<ExpectationBase> untyped_expectation(expectation);\n    // See the definition of untyped_expectations_ for why access to\n    // it is unprotected here.\n    untyped_expectations_.push_back(untyped_expectation);\n\n    // Adds this expectation into the implicit sequence if there is one.\n    Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();\n    if (implicit_sequence != nullptr) {\n      implicit_sequence->AddExpectation(Expectation(untyped_expectation));\n    }\n\n    return *expectation;\n  }\n\n private:\n  template <typename Func> friend class TypedExpectation;\n\n  // Some utilities needed for implementing UntypedInvokeWith().\n\n  // Describes what default action will be performed for the given\n  // arguments.\n  // L = *\n  void DescribeDefaultActionTo(const ArgumentTuple& args,\n                               ::std::ostream* os) const {\n    const OnCallSpec<F>* const spec = FindOnCallSpec(args);\n\n    if (spec == nullptr) {\n      *os << (std::is_void<Result>::value ? \"returning directly.\\n\"\n                                          : \"returning default value.\\n\");\n    } else {\n      *os << \"taking default action specified at:\\n\"\n          << FormatFileLocation(spec->file(), spec->line()) << \"\\n\";\n    }\n  }\n\n  // Writes a message that the call is uninteresting (i.e. neither\n  // explicitly expected nor explicitly unexpected) to the given\n  // ostream.\n  void UntypedDescribeUninterestingCall(const void* untyped_args,\n                                        ::std::ostream* os) const override\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    *os << \"Uninteresting mock function call - \";\n    DescribeDefaultActionTo(args, os);\n    *os << \"    Function call: \" << Name();\n    UniversalPrint(args, os);\n  }\n\n  // Returns the expectation that matches the given function arguments\n  // (or NULL is there's no match); when a match is found,\n  // untyped_action is set to point to the action that should be\n  // performed (or NULL if the action is \"do default\"), and\n  // is_excessive is modified to indicate whether the call exceeds the\n  // expected number.\n  //\n  // Critical section: We must find the matching expectation and the\n  // corresponding action that needs to be taken in an ATOMIC\n  // transaction.  Otherwise another thread may call this mock\n  // method in the middle and mess up the state.\n  //\n  // However, performing the action has to be left out of the critical\n  // section.  The reason is that we have no control on what the\n  // action does (it can invoke an arbitrary user function or even a\n  // mock function) and excessive locking could cause a dead lock.\n  const ExpectationBase* UntypedFindMatchingExpectation(\n      const void* untyped_args, const void** untyped_action, bool* is_excessive,\n      ::std::ostream* what, ::std::ostream* why) override\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    MutexLock l(&g_gmock_mutex);\n    TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);\n    if (exp == nullptr) {  // A match wasn't found.\n      this->FormatUnexpectedCallMessageLocked(args, what, why);\n      return nullptr;\n    }\n\n    // This line must be done before calling GetActionForArguments(),\n    // which will increment the call count for *exp and thus affect\n    // its saturation status.\n    *is_excessive = exp->IsSaturated();\n    const Action<F>* action = exp->GetActionForArguments(this, args, what, why);\n    if (action != nullptr && action->IsDoDefault())\n      action = nullptr;  // Normalize \"do default\" to NULL.\n    *untyped_action = action;\n    return exp;\n  }\n\n  // Prints the given function arguments to the ostream.\n  void UntypedPrintArgs(const void* untyped_args,\n                        ::std::ostream* os) const override {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    UniversalPrint(args, os);\n  }\n\n  // Returns the expectation that matches the arguments, or NULL if no\n  // expectation matches them.\n  TypedExpectation<F>* FindMatchingExpectationLocked(\n      const ArgumentTuple& args) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    // See the definition of untyped_expectations_ for why access to\n    // it is unprotected here.\n    for (typename UntypedExpectations::const_reverse_iterator it =\n             untyped_expectations_.rbegin();\n         it != untyped_expectations_.rend(); ++it) {\n      TypedExpectation<F>* const exp =\n          static_cast<TypedExpectation<F>*>(it->get());\n      if (exp->ShouldHandleArguments(args)) {\n        return exp;\n      }\n    }\n    return nullptr;\n  }\n\n  // Returns a message that the arguments don't match any expectation.\n  void FormatUnexpectedCallMessageLocked(\n      const ArgumentTuple& args,\n      ::std::ostream* os,\n      ::std::ostream* why) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    *os << \"\\nUnexpected mock function call - \";\n    DescribeDefaultActionTo(args, os);\n    PrintTriedExpectationsLocked(args, why);\n  }\n\n  // Prints a list of expectations that have been tried against the\n  // current mock function call.\n  void PrintTriedExpectationsLocked(\n      const ArgumentTuple& args,\n      ::std::ostream* why) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    const size_t count = untyped_expectations_.size();\n    *why << \"Google Mock tried the following \" << count << \" \"\n         << (count == 1 ? \"expectation, but it didn't match\" :\n             \"expectations, but none matched\")\n         << \":\\n\";\n    for (size_t i = 0; i < count; i++) {\n      TypedExpectation<F>* const expectation =\n          static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());\n      *why << \"\\n\";\n      expectation->DescribeLocationTo(why);\n      if (count > 1) {\n        *why << \"tried expectation #\" << i << \": \";\n      }\n      *why << expectation->source_text() << \"...\\n\";\n      expectation->ExplainMatchResultTo(args, why);\n      expectation->DescribeCallCountTo(why);\n    }\n  }\n};  // class FunctionMocker\n\n// Reports an uninteresting call (whose description is in msg) in the\n// manner specified by 'reaction'.\nvoid ReportUninterestingCall(CallReaction reaction, const std::string& msg);\n\n}  // namespace internal\n\nnamespace internal {\n\ntemplate <typename F>\nclass MockFunction;\n\ntemplate <typename R, typename... Args>\nclass MockFunction<R(Args...)> {\n public:\n  MockFunction(const MockFunction&) = delete;\n  MockFunction& operator=(const MockFunction&) = delete;\n\n  std::function<R(Args...)> AsStdFunction() {\n    return [this](Args... args) -> R {\n      return this->Call(std::forward<Args>(args)...);\n    };\n  }\n\n  // Implementation detail: the expansion of the MOCK_METHOD macro.\n  R Call(Args... args) {\n    mock_.SetOwnerAndName(this, \"Call\");\n    return mock_.Invoke(std::forward<Args>(args)...);\n  }\n\n  MockSpec<R(Args...)> gmock_Call(Matcher<Args>... m) {\n    mock_.RegisterOwner(this);\n    return mock_.With(std::move(m)...);\n  }\n\n  MockSpec<R(Args...)> gmock_Call(const WithoutMatchers&, R (*)(Args...)) {\n    return this->gmock_Call(::testing::A<Args>()...);\n  }\n\n protected:\n  MockFunction() = default;\n  ~MockFunction() = default;\n\n private:\n  FunctionMocker<R(Args...)> mock_;\n};\n\n/*\nThe SignatureOf<F> struct is a meta-function returning function signature\ncorresponding to the provided F argument.\n\nIt makes use of MockFunction easier by allowing it to accept more F arguments\nthan just function signatures.\n\nSpecializations provided here cover only a signature type itself and\nstd::function. However, if need be it can be easily extended to cover also other\ntypes (like for example boost::function).\n*/\n\ntemplate <typename F>\nstruct SignatureOf;\n\ntemplate <typename R, typename... Args>\nstruct SignatureOf<R(Args...)> {\n  using type = R(Args...);\n};\n\ntemplate <typename F>\nstruct SignatureOf<std::function<F>> : SignatureOf<F> {};\n\ntemplate <typename F>\nusing SignatureOfT = typename SignatureOf<F>::type;\n\n}  // namespace internal\n\n// A MockFunction<F> type has one mock method whose type is\n// internal::SignatureOfT<F>.  It is useful when you just want your\n// test code to emit some messages and have Google Mock verify the\n// right messages are sent (and perhaps at the right times).  For\n// example, if you are exercising code:\n//\n//   Foo(1);\n//   Foo(2);\n//   Foo(3);\n//\n// and want to verify that Foo(1) and Foo(3) both invoke\n// mock.Bar(\"a\"), but Foo(2) doesn't invoke anything, you can write:\n//\n// TEST(FooTest, InvokesBarCorrectly) {\n//   MyMock mock;\n//   MockFunction<void(string check_point_name)> check;\n//   {\n//     InSequence s;\n//\n//     EXPECT_CALL(mock, Bar(\"a\"));\n//     EXPECT_CALL(check, Call(\"1\"));\n//     EXPECT_CALL(check, Call(\"2\"));\n//     EXPECT_CALL(mock, Bar(\"a\"));\n//   }\n//   Foo(1);\n//   check.Call(\"1\");\n//   Foo(2);\n//   check.Call(\"2\");\n//   Foo(3);\n// }\n//\n// The expectation spec says that the first Bar(\"a\") must happen\n// before check point \"1\", the second Bar(\"a\") must happen after check\n// point \"2\", and nothing should happen between the two check\n// points. The explicit check points make it easy to tell which\n// Bar(\"a\") is called by which call to Foo().\n//\n// MockFunction<F> can also be used to exercise code that accepts\n// std::function<internal::SignatureOfT<F>> callbacks. To do so, use\n// AsStdFunction() method to create std::function proxy forwarding to\n// original object's Call. Example:\n//\n// TEST(FooTest, RunsCallbackWithBarArgument) {\n//   MockFunction<int(string)> callback;\n//   EXPECT_CALL(callback, Call(\"bar\")).WillOnce(Return(1));\n//   Foo(callback.AsStdFunction());\n// }\n//\n// The internal::SignatureOfT<F> indirection allows to use other types\n// than just function signature type. This is typically useful when\n// providing a mock for a predefined std::function type. Example:\n//\n// using FilterPredicate = std::function<bool(string)>;\n// void MyFilterAlgorithm(FilterPredicate predicate);\n//\n// TEST(FooTest, FilterPredicateAlwaysAccepts) {\n//   MockFunction<FilterPredicate> predicateMock;\n//   EXPECT_CALL(predicateMock, Call(_)).WillRepeatedly(Return(true));\n//   MyFilterAlgorithm(predicateMock.AsStdFunction());\n// }\ntemplate <typename F>\nclass MockFunction : public internal::MockFunction<internal::SignatureOfT<F>> {\n  using Base = internal::MockFunction<internal::SignatureOfT<F>>;\n\n public:\n  using Base::Base;\n};\n\n// The style guide prohibits \"using\" statements in a namespace scope\n// inside a header file.  However, the MockSpec class template is\n// meant to be defined in the ::testing namespace.  The following line\n// is just a trick for working around a bug in MSVC 8.0, which cannot\n// handle it if we define MockSpec in ::testing.\nusing internal::MockSpec;\n\n// Const(x) is a convenient function for obtaining a const reference\n// to x.  This is useful for setting expectations on an overloaded\n// const mock method, e.g.\n//\n//   class MockFoo : public FooInterface {\n//    public:\n//     MOCK_METHOD0(Bar, int());\n//     MOCK_CONST_METHOD0(Bar, int&());\n//   };\n//\n//   MockFoo foo;\n//   // Expects a call to non-const MockFoo::Bar().\n//   EXPECT_CALL(foo, Bar());\n//   // Expects a call to const MockFoo::Bar().\n//   EXPECT_CALL(Const(foo), Bar());\ntemplate <typename T>\ninline const T& Const(const T& x) { return x; }\n\n// Constructs an Expectation object that references and co-owns exp.\ninline Expectation::Expectation(internal::ExpectationBase& exp)  // NOLINT\n    : expectation_base_(exp.GetHandle().expectation_base()) {}\n\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n// Implementation for ON_CALL and EXPECT_CALL macros. A separate macro is\n// required to avoid compile errors when the name of the method used in call is\n// a result of macro expansion. See CompilesWithMethodNameExpandedFromMacro\n// tests in internal/gmock-spec-builders_test.cc for more details.\n//\n// This macro supports statements both with and without parameter matchers. If\n// the parameter list is omitted, gMock will accept any parameters, which allows\n// tests to be written that don't need to encode the number of method\n// parameter. This technique may only be used for non-overloaded methods.\n//\n//   // These are the same:\n//   ON_CALL(mock, NoArgsMethod()).WillByDefault(...);\n//   ON_CALL(mock, NoArgsMethod).WillByDefault(...);\n//\n//   // As are these:\n//   ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(...);\n//   ON_CALL(mock, TwoArgsMethod).WillByDefault(...);\n//\n//   // Can also specify args if you want, of course:\n//   ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(...);\n//\n//   // Overloads work as long as you specify parameters:\n//   ON_CALL(mock, OverloadedMethod(_)).WillByDefault(...);\n//   ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(...);\n//\n//   // Oops! Which overload did you want?\n//   ON_CALL(mock, OverloadedMethod).WillByDefault(...);\n//     => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous\n//\n// How this works: The mock class uses two overloads of the gmock_Method\n// expectation setter method plus an operator() overload on the MockSpec object.\n// In the matcher list form, the macro expands to:\n//\n//   // This statement:\n//   ON_CALL(mock, TwoArgsMethod(_, 45))...\n//\n//   // ...expands to:\n//   mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)...\n//   |-------------v---------------||------------v-------------|\n//       invokes first overload        swallowed by operator()\n//\n//   // ...which is essentially:\n//   mock.gmock_TwoArgsMethod(_, 45)...\n//\n// Whereas the form without a matcher list:\n//\n//   // This statement:\n//   ON_CALL(mock, TwoArgsMethod)...\n//\n//   // ...expands to:\n//   mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)...\n//   |-----------------------v--------------------------|\n//                 invokes second overload\n//\n//   // ...which is essentially:\n//   mock.gmock_TwoArgsMethod(_, _)...\n//\n// The WithoutMatchers() argument is used to disambiguate overloads and to\n// block the caller from accidentally invoking the second overload directly. The\n// second argument is an internal type derived from the method signature. The\n// failure to disambiguate two overloads of this method in the ON_CALL statement\n// is how we block callers from setting expectations on overloaded methods.\n#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call)                    \\\n  ((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), \\\n                             nullptr)                                   \\\n      .Setter(__FILE__, __LINE__, #mock_expr, #call)\n\n#define ON_CALL(obj, call) \\\n  GMOCK_ON_CALL_IMPL_(obj, InternalDefaultActionSetAt, call)\n\n#define EXPECT_CALL(obj, call) \\\n  GMOCK_ON_CALL_IMPL_(obj, InternalExpectedAt, call)\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_\n\nnamespace testing {\nnamespace internal {\ntemplate <typename T>\nusing identity_t = T;\n\ntemplate <typename Pattern>\nstruct ThisRefAdjuster {\n  template <typename T>\n  using AdjustT = typename std::conditional<\n      std::is_const<typename std::remove_reference<Pattern>::type>::value,\n      typename std::conditional<std::is_lvalue_reference<Pattern>::value,\n                                const T&, const T&&>::type,\n      typename std::conditional<std::is_lvalue_reference<Pattern>::value, T&,\n                                T&&>::type>::type;\n\n  template <typename MockType>\n  static AdjustT<MockType> Adjust(const MockType& mock) {\n    return static_cast<AdjustT<MockType>>(const_cast<MockType&>(mock));\n  }\n};\n\n}  // namespace internal\n\n// The style guide prohibits \"using\" statements in a namespace scope\n// inside a header file.  However, the FunctionMocker class template\n// is meant to be defined in the ::testing namespace.  The following\n// line is just a trick for working around a bug in MSVC 8.0, which\n// cannot handle it if we define FunctionMocker in ::testing.\nusing internal::FunctionMocker;\n}  // namespace testing\n\n#define MOCK_METHOD(...) \\\n  GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__)\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_1(...) \\\n  GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_2(...) \\\n  GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_3(_Ret, _MethodName, _Args) \\\n  GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, ())\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec)     \\\n  GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args);                                   \\\n  GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec);                                   \\\n  GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(                                      \\\n      GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args));           \\\n  GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec)                                     \\\n  GMOCK_INTERNAL_MOCK_METHOD_IMPL(                                            \\\n      GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec),     \\\n      GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec),    \\\n      GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Spec),                                \\\n      GMOCK_INTERNAL_GET_CALLTYPE(_Spec), GMOCK_INTERNAL_GET_REF_SPEC(_Spec), \\\n      (GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)))\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_5(...) \\\n  GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_6(...) \\\n  GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)\n\n#define GMOCK_INTERNAL_MOCK_METHOD_ARG_7(...) \\\n  GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__)\n\n#define GMOCK_INTERNAL_WRONG_ARITY(...)                                      \\\n  static_assert(                                                             \\\n      false,                                                                 \\\n      \"MOCK_METHOD must be called with 3 or 4 arguments. _Ret, \"             \\\n      \"_MethodName, _Args and optionally _Spec. _Args and _Spec must be \"    \\\n      \"enclosed in parentheses. If _Ret is a type with unprotected commas, \" \\\n      \"it must also be enclosed in parentheses.\")\n\n#define GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Tuple) \\\n  static_assert(                                  \\\n      GMOCK_PP_IS_ENCLOSED_PARENS(_Tuple),        \\\n      GMOCK_PP_STRINGIZE(_Tuple) \" should be enclosed in parentheses.\")\n\n#define GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(_N, ...)                 \\\n  static_assert(                                                       \\\n      std::is_function<__VA_ARGS__>::value,                            \\\n      \"Signature must be a function type, maybe return type contains \" \\\n      \"unprotected comma.\");                                           \\\n  static_assert(                                                       \\\n      ::testing::tuple_size<typename ::testing::internal::Function<    \\\n              __VA_ARGS__>::ArgumentTuple>::value == _N,               \\\n      \"This method does not take \" GMOCK_PP_STRINGIZE(                 \\\n          _N) \" arguments. Parenthesize all types with unprotected commas.\")\n\n#define GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \\\n  GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT, ~, _Spec)\n\n#define GMOCK_INTERNAL_MOCK_METHOD_IMPL(_N, _MethodName, _Constness,           \\\n                                        _Override, _Final, _NoexceptSpec,      \\\n                                        _CallType, _RefSpec, _Signature)       \\\n  typename ::testing::internal::Function<GMOCK_PP_REMOVE_PARENS(               \\\n      _Signature)>::Result                                                     \\\n  GMOCK_INTERNAL_EXPAND(_CallType)                                             \\\n      _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N))   \\\n          GMOCK_PP_IF(_Constness, const, ) _RefSpec _NoexceptSpec              \\\n          GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) {    \\\n    GMOCK_MOCKER_(_N, _Constness, _MethodName)                                 \\\n        .SetOwnerAndName(this, #_MethodName);                                  \\\n    return GMOCK_MOCKER_(_N, _Constness, _MethodName)                          \\\n        .Invoke(GMOCK_PP_REPEAT(GMOCK_INTERNAL_FORWARD_ARG, _Signature, _N));  \\\n  }                                                                            \\\n  ::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \\\n      GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_PARAMETER, _Signature, _N))       \\\n      GMOCK_PP_IF(_Constness, const, ) _RefSpec {                              \\\n    GMOCK_MOCKER_(_N, _Constness, _MethodName).RegisterOwner(this);            \\\n    return GMOCK_MOCKER_(_N, _Constness, _MethodName)                          \\\n        .With(GMOCK_PP_REPEAT(GMOCK_INTERNAL_MATCHER_ARGUMENT, , _N));         \\\n  }                                                                            \\\n  ::testing::MockSpec<GMOCK_PP_REMOVE_PARENS(_Signature)> gmock_##_MethodName( \\\n      const ::testing::internal::WithoutMatchers&,                             \\\n      GMOCK_PP_IF(_Constness, const, )::testing::internal::Function<           \\\n          GMOCK_PP_REMOVE_PARENS(_Signature)>*) const _RefSpec _NoexceptSpec { \\\n    return ::testing::internal::ThisRefAdjuster<GMOCK_PP_IF(                   \\\n        _Constness, const, ) int _RefSpec>::Adjust(*this)                      \\\n        .gmock_##_MethodName(GMOCK_PP_REPEAT(                                  \\\n            GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N));               \\\n  }                                                                            \\\n  mutable ::testing::FunctionMocker<GMOCK_PP_REMOVE_PARENS(_Signature)>        \\\n      GMOCK_MOCKER_(_N, _Constness, _MethodName)\n\n#define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__\n\n// Five Valid modifiers.\n#define GMOCK_INTERNAL_HAS_CONST(_Tuple) \\\n  GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_CONST, ~, _Tuple))\n\n#define GMOCK_INTERNAL_HAS_OVERRIDE(_Tuple) \\\n  GMOCK_PP_HAS_COMMA(                       \\\n      GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_OVERRIDE, ~, _Tuple))\n\n#define GMOCK_INTERNAL_HAS_FINAL(_Tuple) \\\n  GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_FINAL, ~, _Tuple))\n\n#define GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Tuple) \\\n  GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT, ~, _Tuple)\n\n#define GMOCK_INTERNAL_NOEXCEPT_SPEC_IF_NOEXCEPT(_i, _, _elem)          \\\n  GMOCK_PP_IF(                                                          \\\n      GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)), \\\n      _elem, )\n\n#define GMOCK_INTERNAL_GET_REF_SPEC(_Tuple) \\\n  GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_REF_SPEC_IF_REF, ~, _Tuple)\n\n#define GMOCK_INTERNAL_REF_SPEC_IF_REF(_i, _, _elem)                       \\\n  GMOCK_PP_IF(GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)), \\\n              GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), )\n\n#define GMOCK_INTERNAL_GET_CALLTYPE(_Tuple) \\\n  GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_CALLTYPE_IMPL, ~, _Tuple)\n\n#define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem)            \\\n  static_assert(                                                          \\\n      (GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem)) +    \\\n       GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem)) + \\\n       GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem)) +    \\\n       GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)) + \\\n       GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)) +      \\\n       GMOCK_INTERNAL_IS_CALLTYPE(_elem)) == 1,                           \\\n      GMOCK_PP_STRINGIZE(                                                 \\\n          _elem) \" cannot be recognized as a valid specification modifier.\");\n\n// Modifiers implementation.\n#define GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem) \\\n  GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CONST_I_, _elem)\n\n#define GMOCK_INTERNAL_DETECT_CONST_I_const ,\n\n#define GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem) \\\n  GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_OVERRIDE_I_, _elem)\n\n#define GMOCK_INTERNAL_DETECT_OVERRIDE_I_override ,\n\n#define GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem) \\\n  GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_FINAL_I_, _elem)\n\n#define GMOCK_INTERNAL_DETECT_FINAL_I_final ,\n\n#define GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem) \\\n  GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_NOEXCEPT_I_, _elem)\n\n#define GMOCK_INTERNAL_DETECT_NOEXCEPT_I_noexcept ,\n\n#define GMOCK_INTERNAL_DETECT_REF(_i, _, _elem) \\\n  GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_REF_I_, _elem)\n\n#define GMOCK_INTERNAL_DETECT_REF_I_ref ,\n\n#define GMOCK_INTERNAL_UNPACK_ref(x) x\n\n#define GMOCK_INTERNAL_GET_CALLTYPE_IMPL(_i, _, _elem)           \\\n  GMOCK_PP_IF(GMOCK_INTERNAL_IS_CALLTYPE(_elem),                 \\\n              GMOCK_INTERNAL_GET_VALUE_CALLTYPE, GMOCK_PP_EMPTY) \\\n  (_elem)\n\n// TODO(iserna): GMOCK_INTERNAL_IS_CALLTYPE and\n// GMOCK_INTERNAL_GET_VALUE_CALLTYPE needed more expansions to work on windows\n// maybe they can be simplified somehow.\n#define GMOCK_INTERNAL_IS_CALLTYPE(_arg) \\\n  GMOCK_INTERNAL_IS_CALLTYPE_I(          \\\n      GMOCK_PP_CAT(GMOCK_INTERNAL_IS_CALLTYPE_HELPER_, _arg))\n#define GMOCK_INTERNAL_IS_CALLTYPE_I(_arg) GMOCK_PP_IS_ENCLOSED_PARENS(_arg)\n\n#define GMOCK_INTERNAL_GET_VALUE_CALLTYPE(_arg) \\\n  GMOCK_INTERNAL_GET_VALUE_CALLTYPE_I(          \\\n      GMOCK_PP_CAT(GMOCK_INTERNAL_IS_CALLTYPE_HELPER_, _arg))\n#define GMOCK_INTERNAL_GET_VALUE_CALLTYPE_I(_arg) \\\n  GMOCK_PP_IDENTITY _arg\n\n#define GMOCK_INTERNAL_IS_CALLTYPE_HELPER_Calltype\n\n// Note: The use of `identity_t` here allows _Ret to represent return types that\n// would normally need to be specified in a different way. For example, a method\n// returning a function pointer must be written as\n//\n// fn_ptr_return_t (*method(method_args_t...))(fn_ptr_args_t...)\n//\n// But we only support placing the return type at the beginning. To handle this,\n// we wrap all calls in identity_t, so that a declaration will be expanded to\n//\n// identity_t<fn_ptr_return_t (*)(fn_ptr_args_t...)> method(method_args_t...)\n//\n// This allows us to work around the syntactic oddities of function/method\n// types.\n#define GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)                                 \\\n  ::testing::internal::identity_t<GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_Ret), \\\n                                              GMOCK_PP_REMOVE_PARENS,         \\\n                                              GMOCK_PP_IDENTITY)(_Ret)>(      \\\n      GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_TYPE, _, _Args))\n\n#define GMOCK_INTERNAL_GET_TYPE(_i, _, _elem)                          \\\n  GMOCK_PP_COMMA_IF(_i)                                                \\\n  GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(_elem), GMOCK_PP_REMOVE_PARENS, \\\n              GMOCK_PP_IDENTITY)                                       \\\n  (_elem)\n\n#define GMOCK_INTERNAL_PARAMETER(_i, _Signature, _)            \\\n  GMOCK_PP_COMMA_IF(_i)                                        \\\n  GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \\\n  gmock_a##_i\n\n#define GMOCK_INTERNAL_FORWARD_ARG(_i, _Signature, _) \\\n  GMOCK_PP_COMMA_IF(_i)                               \\\n  ::std::forward<GMOCK_INTERNAL_ARG_O(                \\\n      _i, GMOCK_PP_REMOVE_PARENS(_Signature))>(gmock_a##_i)\n\n#define GMOCK_INTERNAL_MATCHER_PARAMETER(_i, _Signature, _)        \\\n  GMOCK_PP_COMMA_IF(_i)                                            \\\n  GMOCK_INTERNAL_MATCHER_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature)) \\\n  gmock_a##_i\n\n#define GMOCK_INTERNAL_MATCHER_ARGUMENT(_i, _1, _2) \\\n  GMOCK_PP_COMMA_IF(_i)                             \\\n  gmock_a##_i\n\n#define GMOCK_INTERNAL_A_MATCHER_ARGUMENT(_i, _Signature, _) \\\n  GMOCK_PP_COMMA_IF(_i)                                      \\\n  ::testing::A<GMOCK_INTERNAL_ARG_O(_i, GMOCK_PP_REMOVE_PARENS(_Signature))>()\n\n#define GMOCK_INTERNAL_ARG_O(_i, ...) \\\n  typename ::testing::internal::Function<__VA_ARGS__>::template Arg<_i>::type\n\n#define GMOCK_INTERNAL_MATCHER_O(_i, ...)                          \\\n  const ::testing::Matcher<typename ::testing::internal::Function< \\\n      __VA_ARGS__>::template Arg<_i>::type>&\n\n#define MOCK_METHOD0(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 0, __VA_ARGS__)\n#define MOCK_METHOD1(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 1, __VA_ARGS__)\n#define MOCK_METHOD2(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 2, __VA_ARGS__)\n#define MOCK_METHOD3(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 3, __VA_ARGS__)\n#define MOCK_METHOD4(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 4, __VA_ARGS__)\n#define MOCK_METHOD5(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 5, __VA_ARGS__)\n#define MOCK_METHOD6(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 6, __VA_ARGS__)\n#define MOCK_METHOD7(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 7, __VA_ARGS__)\n#define MOCK_METHOD8(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 8, __VA_ARGS__)\n#define MOCK_METHOD9(m, ...) GMOCK_INTERNAL_MOCK_METHODN(, , m, 9, __VA_ARGS__)\n#define MOCK_METHOD10(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, , m, 10, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 0, __VA_ARGS__)\n#define MOCK_CONST_METHOD1(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 1, __VA_ARGS__)\n#define MOCK_CONST_METHOD2(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 2, __VA_ARGS__)\n#define MOCK_CONST_METHOD3(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 3, __VA_ARGS__)\n#define MOCK_CONST_METHOD4(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 4, __VA_ARGS__)\n#define MOCK_CONST_METHOD5(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 5, __VA_ARGS__)\n#define MOCK_CONST_METHOD6(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 6, __VA_ARGS__)\n#define MOCK_CONST_METHOD7(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 7, __VA_ARGS__)\n#define MOCK_CONST_METHOD8(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 8, __VA_ARGS__)\n#define MOCK_CONST_METHOD9(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 9, __VA_ARGS__)\n#define MOCK_CONST_METHOD10(m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, , m, 10, __VA_ARGS__)\n\n#define MOCK_METHOD0_T(m, ...) MOCK_METHOD0(m, __VA_ARGS__)\n#define MOCK_METHOD1_T(m, ...) MOCK_METHOD1(m, __VA_ARGS__)\n#define MOCK_METHOD2_T(m, ...) MOCK_METHOD2(m, __VA_ARGS__)\n#define MOCK_METHOD3_T(m, ...) MOCK_METHOD3(m, __VA_ARGS__)\n#define MOCK_METHOD4_T(m, ...) MOCK_METHOD4(m, __VA_ARGS__)\n#define MOCK_METHOD5_T(m, ...) MOCK_METHOD5(m, __VA_ARGS__)\n#define MOCK_METHOD6_T(m, ...) MOCK_METHOD6(m, __VA_ARGS__)\n#define MOCK_METHOD7_T(m, ...) MOCK_METHOD7(m, __VA_ARGS__)\n#define MOCK_METHOD8_T(m, ...) MOCK_METHOD8(m, __VA_ARGS__)\n#define MOCK_METHOD9_T(m, ...) MOCK_METHOD9(m, __VA_ARGS__)\n#define MOCK_METHOD10_T(m, ...) MOCK_METHOD10(m, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0_T(m, ...) MOCK_CONST_METHOD0(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD1_T(m, ...) MOCK_CONST_METHOD1(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD2_T(m, ...) MOCK_CONST_METHOD2(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD3_T(m, ...) MOCK_CONST_METHOD3(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD4_T(m, ...) MOCK_CONST_METHOD4(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD5_T(m, ...) MOCK_CONST_METHOD5(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD6_T(m, ...) MOCK_CONST_METHOD6(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD7_T(m, ...) MOCK_CONST_METHOD7(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD8_T(m, ...) MOCK_CONST_METHOD8(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD9_T(m, ...) MOCK_CONST_METHOD9(m, __VA_ARGS__)\n#define MOCK_CONST_METHOD10_T(m, ...) MOCK_CONST_METHOD10(m, __VA_ARGS__)\n\n#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 0, __VA_ARGS__)\n#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 1, __VA_ARGS__)\n#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 2, __VA_ARGS__)\n#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 3, __VA_ARGS__)\n#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 4, __VA_ARGS__)\n#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 5, __VA_ARGS__)\n#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 6, __VA_ARGS__)\n#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 7, __VA_ARGS__)\n#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 8, __VA_ARGS__)\n#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 9, __VA_ARGS__)\n#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(, ct, m, 10, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 0, __VA_ARGS__)\n#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 1, __VA_ARGS__)\n#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 2, __VA_ARGS__)\n#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 3, __VA_ARGS__)\n#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 4, __VA_ARGS__)\n#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 5, __VA_ARGS__)\n#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 6, __VA_ARGS__)\n#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 7, __VA_ARGS__)\n#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 8, __VA_ARGS__)\n#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 9, __VA_ARGS__)\n#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \\\n  GMOCK_INTERNAL_MOCK_METHODN(const, ct, m, 10, __VA_ARGS__)\n\n#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD0_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD1_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD2_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD3_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD4_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD5_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD6_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD7_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD8_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD9_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \\\n  MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, __VA_ARGS__)\n\n#define GMOCK_INTERNAL_MOCK_METHODN(constness, ct, Method, args_num, ...) \\\n  GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE(                                  \\\n      args_num, ::testing::internal::identity_t<__VA_ARGS__>);            \\\n  GMOCK_INTERNAL_MOCK_METHOD_IMPL(                                        \\\n      args_num, Method, GMOCK_PP_NARG0(constness), 0, 0, , ct, ,          \\\n      (::testing::internal::identity_t<__VA_ARGS__>))\n\n#define GMOCK_MOCKER_(arity, constness, Method) \\\n  GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used variadic actions.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_\n\n#include <memory>\n#include <utility>\n\n\n// Include any custom callback actions added by the local installation.\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_\n\n// Sometimes you want to give an action explicit template parameters\n// that cannot be inferred from its value parameters.  ACTION() and\n// ACTION_P*() don't support that.  ACTION_TEMPLATE() remedies that\n// and can be viewed as an extension to ACTION() and ACTION_P*().\n//\n// The syntax:\n//\n//   ACTION_TEMPLATE(ActionName,\n//                   HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),\n//                   AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }\n//\n// defines an action template that takes m explicit template\n// parameters and n value parameters.  name_i is the name of the i-th\n// template parameter, and kind_i specifies whether it's a typename,\n// an integral constant, or a template.  p_i is the name of the i-th\n// value parameter.\n//\n// Example:\n//\n//   // DuplicateArg<k, T>(output) converts the k-th argument of the mock\n//   // function to type T and copies it to *output.\n//   ACTION_TEMPLATE(DuplicateArg,\n//                   HAS_2_TEMPLATE_PARAMS(int, k, typename, T),\n//                   AND_1_VALUE_PARAMS(output)) {\n//     *output = T(::std::get<k>(args));\n//   }\n//   ...\n//     int n;\n//     EXPECT_CALL(mock, Foo(_, _))\n//         .WillOnce(DuplicateArg<1, unsigned char>(&n));\n//\n// To create an instance of an action template, write:\n//\n//   ActionName<t1, ..., t_m>(v1, ..., v_n)\n//\n// where the ts are the template arguments and the vs are the value\n// arguments.  The value argument types are inferred by the compiler.\n// If you want to explicitly specify the value argument types, you can\n// provide additional template arguments:\n//\n//   ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)\n//\n// where u_i is the desired type of v_i.\n//\n// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the\n// number of value parameters, but not on the number of template\n// parameters.  Without the restriction, the meaning of the following\n// is unclear:\n//\n//   OverloadedAction<int, bool>(x);\n//\n// Are we using a single-template-parameter action where 'bool' refers\n// to the type of x, or are we using a two-template-parameter action\n// where the compiler is asked to infer the type of x?\n//\n// Implementation notes:\n//\n// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and\n// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for\n// implementing ACTION_TEMPLATE.  The main trick we use is to create\n// new macro invocations when expanding a macro.  For example, we have\n//\n//   #define ACTION_TEMPLATE(name, template_params, value_params)\n//       ... GMOCK_INTERNAL_DECL_##template_params ...\n//\n// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)\n// to expand to\n//\n//       ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...\n//\n// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the\n// preprocessor will continue to expand it to\n//\n//       ... typename T ...\n//\n// This technique conforms to the C++ standard and is portable.  It\n// allows us to implement action templates using O(N) code, where N is\n// the maximum number of template/value parameters supported.  Without\n// using it, we'd have to devote O(N^2) amount of code to implement all\n// combinations of m and n.\n\n// Declares the template parameters.\n#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0\n#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1) kind0 name0, kind1 name1\n#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2) kind0 name0, kind1 name1, kind2 name2\n#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \\\n    kind3 name3\n#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \\\n    kind2 name2, kind3 name3, kind4 name4\n#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \\\n    kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5\n#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \\\n    kind5 name5, kind6 name6\n#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \\\n    kind4 name4, kind5 name5, kind6 name6, kind7 name7\n#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \\\n    kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \\\n    kind8 name8\n#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \\\n    kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \\\n    kind6 name6, kind7 name7, kind8 name8, kind9 name9\n\n// Lists the template parameters.\n#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0\n#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1) name0, name1\n#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2) name0, name1, name2\n#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3) name0, name1, name2, name3\n#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \\\n    name4\n#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \\\n    name2, name3, name4, name5\n#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6) name0, name1, name2, name3, name4, name5, name6\n#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7\n#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \\\n    name6, name7, name8\n#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \\\n    name3, name4, name5, name6, name7, name8, name9\n\n// Declares the types of value parameters.\n#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \\\n    typename p0##_type, typename p1##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) , typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type, \\\n    typename p6##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type, \\\n    typename p6##_type, typename p7##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type, \\\n    typename p6##_type, typename p7##_type, typename p8##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \\\n    typename p2##_type, typename p3##_type, typename p4##_type, \\\n    typename p5##_type, typename p6##_type, typename p7##_type, \\\n    typename p8##_type, typename p9##_type\n\n// Initializes the value parameters.\n#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\\\n    ()\n#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\\\n    (p0##_type gmock_p0) : p0(::std::move(gmock_p0))\n#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1))\n#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2))\n#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3))\n#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4))\n#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \\\n        p5(::std::move(gmock_p5))\n#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \\\n        p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6))\n#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \\\n        p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \\\n        p7(::std::move(gmock_p7))\n#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6, p7##_type gmock_p7, \\\n        p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \\\n        p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \\\n        p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8))\n#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \\\n        p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \\\n        p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \\\n        p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \\\n        p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \\\n        p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \\\n        p9(::std::move(gmock_p9))\n\n// Defines the copy constructor\n#define GMOCK_INTERNAL_DEFN_COPY_AND_0_VALUE_PARAMS() \\\n    {}  // Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82134\n#define GMOCK_INTERNAL_DEFN_COPY_AND_1_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_2_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_3_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_4_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_5_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_6_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_7_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_8_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_9_VALUE_PARAMS(...) = default;\n#define GMOCK_INTERNAL_DEFN_COPY_AND_10_VALUE_PARAMS(...) = default;\n\n// Declares the fields for storing the value parameters.\n#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;\n#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \\\n    p1##_type p1;\n#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \\\n    p1##_type p1; p2##_type p2;\n#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \\\n    p1##_type p1; p2##_type p2; p3##_type p3;\n#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \\\n    p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;\n#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \\\n    p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \\\n    p5##_type p5;\n#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \\\n    p5##_type p5; p6##_type p6;\n#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \\\n    p5##_type p5; p6##_type p6; p7##_type p7;\n#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \\\n    p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;\n#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \\\n    p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \\\n    p9##_type p9;\n\n// Lists the value parameters.\n#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0\n#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1\n#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2\n#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3\n#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \\\n    p2, p3, p4\n#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \\\n    p1, p2, p3, p4, p5\n#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) p0, p1, p2, p3, p4, p5, p6\n#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) p0, p1, p2, p3, p4, p5, p6, p7\n#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8\n#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9\n\n// Lists the value parameter types.\n#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \\\n    p1##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \\\n    p1##_type, p2##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \\\n    p0##_type, p1##_type, p2##_type, p3##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \\\n    p0##_type, p1##_type, p2##_type, p3##_type, p4##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \\\n    p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \\\n    p6##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n    p5##_type, p6##_type, p7##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n    p5##_type, p6##_type, p7##_type, p8##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n    p5##_type, p6##_type, p7##_type, p8##_type, p9##_type\n\n// Declares the value parameters.\n#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0\n#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \\\n    p1##_type p1\n#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \\\n    p1##_type p1, p2##_type p2\n#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \\\n    p1##_type p1, p2##_type p2, p3##_type p3\n#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \\\n    p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4\n#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \\\n    p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \\\n    p5##_type p5\n#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \\\n    p5##_type p5, p6##_type p6\n#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \\\n    p5##_type p5, p6##_type p6, p7##_type p7\n#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n    p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8\n#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n    p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \\\n    p9##_type p9\n\n// The suffix of the class template implementing the action template.\n#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P\n#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2\n#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3\n#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4\n#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5\n#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6\n#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7\n#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) P8\n#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) P9\n#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) P10\n\n// The name of the class template implementing the action template.\n#define GMOCK_ACTION_CLASS_(name, value_params)\\\n    GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)\n\n#define ACTION_TEMPLATE(name, template_params, value_params)                   \\\n  template <GMOCK_INTERNAL_DECL_##template_params                              \\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>                           \\\n  class GMOCK_ACTION_CLASS_(name, value_params) {                              \\\n   public:                                                                     \\\n    explicit GMOCK_ACTION_CLASS_(name, value_params)(                          \\\n        GMOCK_INTERNAL_DECL_##value_params)                                    \\\n        GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params),    \\\n                    = default; ,                                               \\\n                    : impl_(std::make_shared<gmock_Impl>(                      \\\n                                GMOCK_INTERNAL_LIST_##value_params)) { })      \\\n    GMOCK_ACTION_CLASS_(name, value_params)(                                   \\\n        const GMOCK_ACTION_CLASS_(name, value_params)&) noexcept               \\\n        GMOCK_INTERNAL_DEFN_COPY_##value_params                                \\\n    GMOCK_ACTION_CLASS_(name, value_params)(                                   \\\n        GMOCK_ACTION_CLASS_(name, value_params)&&) noexcept                    \\\n        GMOCK_INTERNAL_DEFN_COPY_##value_params                                \\\n    template <typename F>                                                      \\\n    operator ::testing::Action<F>() const {                                    \\\n      return GMOCK_PP_IF(                                                      \\\n          GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params),              \\\n                      (::testing::internal::MakeAction<F, gmock_Impl>()),      \\\n                      (::testing::internal::MakeAction<F>(impl_)));            \\\n    }                                                                          \\\n   private:                                                                    \\\n    class gmock_Impl {                                                         \\\n     public:                                                                   \\\n      explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}                \\\n      template <typename function_type, typename return_type,                  \\\n                typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>         \\\n      return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;  \\\n      GMOCK_INTERNAL_DEFN_##value_params                                       \\\n    };                                                                         \\\n    GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params),        \\\n                , std::shared_ptr<const gmock_Impl> impl_;)                    \\\n  };                                                                           \\\n  template <GMOCK_INTERNAL_DECL_##template_params                              \\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>                           \\\n  GMOCK_ACTION_CLASS_(name, value_params)<                                     \\\n      GMOCK_INTERNAL_LIST_##template_params                                    \\\n      GMOCK_INTERNAL_LIST_TYPE_##value_params> name(                           \\\n          GMOCK_INTERNAL_DECL_##value_params) GTEST_MUST_USE_RESULT_;          \\\n  template <GMOCK_INTERNAL_DECL_##template_params                              \\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>                           \\\n  inline GMOCK_ACTION_CLASS_(name, value_params)<                              \\\n      GMOCK_INTERNAL_LIST_##template_params                                    \\\n      GMOCK_INTERNAL_LIST_TYPE_##value_params> name(                           \\\n          GMOCK_INTERNAL_DECL_##value_params) {                                \\\n    return GMOCK_ACTION_CLASS_(name, value_params)<                            \\\n        GMOCK_INTERNAL_LIST_##template_params                                  \\\n        GMOCK_INTERNAL_LIST_TYPE_##value_params>(                              \\\n            GMOCK_INTERNAL_LIST_##value_params);                               \\\n  }                                                                            \\\n  template <GMOCK_INTERNAL_DECL_##template_params                              \\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>                           \\\n  template <typename function_type, typename return_type, typename args_type,  \\\n            GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>                                 \\\n  return_type GMOCK_ACTION_CLASS_(name, value_params)<                         \\\n      GMOCK_INTERNAL_LIST_##template_params                                    \\\n      GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::gmock_PerformImpl( \\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\nnamespace testing {\n\n// The ACTION*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\nnamespace internal {\n\n// internal::InvokeArgument - a helper for InvokeArgument action.\n// The basic overloads are provided here for generic functors.\n// Overloads for other custom-callables are provided in the\n// internal/custom/gmock-generated-actions.h header.\ntemplate <typename F, typename... Args>\nauto InvokeArgument(F f, Args... args) -> decltype(f(args...)) {\n  return f(args...);\n}\n\ntemplate <std::size_t index, typename... Params>\nstruct InvokeArgumentAction {\n  template <typename... Args>\n  auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument(\n      std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)),\n      std::declval<const Params&>()...)) {\n    internal::FlatTuple<Args&&...> args_tuple(FlatTupleConstructTag{},\n                                              std::forward<Args>(args)...);\n    return params.Apply([&](const Params&... unpacked_params) {\n      auto&& callable = args_tuple.template Get<index>();\n      return internal::InvokeArgument(\n          std::forward<decltype(callable)>(callable), unpacked_params...);\n    });\n  }\n\n  internal::FlatTuple<Params...> params;\n};\n\n}  // namespace internal\n\n// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th\n// (0-based) argument, which must be a k-ary callable, of the mock\n// function, with arguments a1, a2, ..., a_k.\n//\n// Notes:\n//\n//   1. The arguments are passed by value by default.  If you need to\n//   pass an argument by reference, wrap it inside std::ref().  For\n//   example,\n//\n//     InvokeArgument<1>(5, string(\"Hello\"), std::ref(foo))\n//\n//   passes 5 and string(\"Hello\") by value, and passes foo by\n//   reference.\n//\n//   2. If the callable takes an argument by reference but std::ref() is\n//   not used, it will receive the reference to a copy of the value,\n//   instead of the original value.  For example, when the 0-th\n//   argument of the mock function takes a const string&, the action\n//\n//     InvokeArgument<0>(string(\"Hello\"))\n//\n//   makes a copy of the temporary string(\"Hello\") object and passes a\n//   reference of the copy, instead of the original temporary object,\n//   to the callable.  This makes it easy for a user to define an\n//   InvokeArgument action from temporary values and have it performed\n//   later.\ntemplate <std::size_t index, typename... Params>\ninternal::InvokeArgumentAction<index, typename std::decay<Params>::type...>\nInvokeArgument(Params&&... params) {\n  return {internal::FlatTuple<typename std::decay<Params>::type...>(\n      internal::FlatTupleConstructTag{}, std::forward<Params>(params)...)};\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace testing\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_\n// Copyright 2013, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some matchers that depend on gmock-matchers.h.\n//\n// Note that tests are implemented in gmock-matchers_test.cc rather than\n// gmock-more-matchers-test.cc.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_\n\n\nnamespace testing {\n\n// Silence C4100 (unreferenced formal\n// parameter) for MSVC\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#if (_MSC_VER == 1900)\n// and silence C4800 (C4800: 'int *const ': forcing value\n// to bool 'true' or 'false') for MSVC 14\n# pragma warning(disable:4800)\n  #endif\n#endif\n\n// Defines a matcher that matches an empty container. The container must\n// support both size() and empty(), which all STL-like containers provide.\nMATCHER(IsEmpty, negation ? \"isn't empty\" : \"is empty\") {\n  if (arg.empty()) {\n    return true;\n  }\n  *result_listener << \"whose size is \" << arg.size();\n  return false;\n}\n\n// Define a matcher that matches a value that evaluates in boolean\n// context to true.  Useful for types that define \"explicit operator\n// bool\" operators and so can't be compared for equality with true\n// and false.\nMATCHER(IsTrue, negation ? \"is false\" : \"is true\") {\n  return static_cast<bool>(arg);\n}\n\n// Define a matcher that matches a value that evaluates in boolean\n// context to false.  Useful for types that define \"explicit operator\n// bool\" operators and so can't be compared for equality with true\n// and false.\nMATCHER(IsFalse, negation ? \"is true\" : \"is false\") {\n  return !static_cast<bool>(arg);\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n\n}  // namespace testing\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Implements class templates NiceMock, NaggyMock, and StrictMock.\n//\n// Given a mock class MockFoo that is created using Google Mock,\n// NiceMock<MockFoo> is a subclass of MockFoo that allows\n// uninteresting calls (i.e. calls to mock methods that have no\n// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo\n// that prints a warning when an uninteresting call occurs, and\n// StrictMock<MockFoo> is a subclass of MockFoo that treats all\n// uninteresting calls as errors.\n//\n// Currently a mock is naggy by default, so MockFoo and\n// NaggyMock<MockFoo> behave like the same.  However, we will soon\n// switch the default behavior of mocks to be nice, as that in general\n// leads to more maintainable tests.  When that happens, MockFoo will\n// stop behaving like NaggyMock<MockFoo> and start behaving like\n// NiceMock<MockFoo>.\n//\n// NiceMock, NaggyMock, and StrictMock \"inherit\" the constructors of\n// their respective base class.  Therefore you can write\n// NiceMock<MockFoo>(5, \"a\") to construct a nice mock where MockFoo\n// has a constructor that accepts (int, const char*), for example.\n//\n// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,\n// and StrictMock<MockFoo> only works for mock methods defined using\n// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.\n// If a mock method is defined in a base class of MockFoo, the \"nice\"\n// or \"strict\" modifier may not affect it, depending on the compiler.\n// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT\n// supported.\n\n// GOOGLETEST_CM0002 DO NOT DELETE\n\n#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_\n#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_\n\n#include <cstdint>\n#include <type_traits>\n\n\nnamespace testing {\ntemplate <class MockClass>\nclass NiceMock;\ntemplate <class MockClass>\nclass NaggyMock;\ntemplate <class MockClass>\nclass StrictMock;\n\nnamespace internal {\ntemplate <typename T>\nstd::true_type StrictnessModifierProbe(const NiceMock<T>&);\ntemplate <typename T>\nstd::true_type StrictnessModifierProbe(const NaggyMock<T>&);\ntemplate <typename T>\nstd::true_type StrictnessModifierProbe(const StrictMock<T>&);\nstd::false_type StrictnessModifierProbe(...);\n\ntemplate <typename T>\nconstexpr bool HasStrictnessModifier() {\n  return decltype(StrictnessModifierProbe(std::declval<const T&>()))::value;\n}\n\n// Base classes that register and deregister with testing::Mock to alter the\n// default behavior around uninteresting calls. Inheriting from one of these\n// classes first and then MockClass ensures the MockClass constructor is run\n// after registration, and that the MockClass destructor runs before\n// deregistration. This guarantees that MockClass's constructor and destructor\n// run with the same level of strictness as its instance methods.\n\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW && \\\n    (defined(_MSC_VER) || defined(__clang__))\n// We need to mark these classes with this declspec to ensure that\n// the empty base class optimization is performed.\n#define GTEST_INTERNAL_EMPTY_BASE_CLASS __declspec(empty_bases)\n#else\n#define GTEST_INTERNAL_EMPTY_BASE_CLASS\n#endif\n\ntemplate <typename Base>\nclass NiceMockImpl {\n public:\n  NiceMockImpl() {\n    ::testing::Mock::AllowUninterestingCalls(reinterpret_cast<uintptr_t>(this));\n  }\n\n  ~NiceMockImpl() {\n    ::testing::Mock::UnregisterCallReaction(reinterpret_cast<uintptr_t>(this));\n  }\n};\n\ntemplate <typename Base>\nclass NaggyMockImpl {\n public:\n  NaggyMockImpl() {\n    ::testing::Mock::WarnUninterestingCalls(reinterpret_cast<uintptr_t>(this));\n  }\n\n  ~NaggyMockImpl() {\n    ::testing::Mock::UnregisterCallReaction(reinterpret_cast<uintptr_t>(this));\n  }\n};\n\ntemplate <typename Base>\nclass StrictMockImpl {\n public:\n  StrictMockImpl() {\n    ::testing::Mock::FailUninterestingCalls(reinterpret_cast<uintptr_t>(this));\n  }\n\n  ~StrictMockImpl() {\n    ::testing::Mock::UnregisterCallReaction(reinterpret_cast<uintptr_t>(this));\n  }\n};\n\n}  // namespace internal\n\ntemplate <class MockClass>\nclass GTEST_INTERNAL_EMPTY_BASE_CLASS NiceMock\n    : private internal::NiceMockImpl<MockClass>,\n      public MockClass {\n public:\n  static_assert(!internal::HasStrictnessModifier<MockClass>(),\n                \"Can't apply NiceMock to a class hierarchy that already has a \"\n                \"strictness modifier. See \"\n                \"https://google.github.io/googletest/\"\n                \"gmock_cook_book.html#NiceStrictNaggy\");\n  NiceMock() : MockClass() {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n  // Ideally, we would inherit base class's constructors through a using\n  // declaration, which would preserve their visibility. However, many existing\n  // tests rely on the fact that current implementation reexports protected\n  // constructors as public. These tests would need to be cleaned up first.\n\n  // Single argument constructor is special-cased so that it can be\n  // made explicit.\n  template <typename A>\n  explicit NiceMock(A&& arg) : MockClass(std::forward<A>(arg)) {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n  template <typename TArg1, typename TArg2, typename... An>\n  NiceMock(TArg1&& arg1, TArg2&& arg2, An&&... args)\n      : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),\n                  std::forward<An>(args)...) {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);\n};\n\ntemplate <class MockClass>\nclass GTEST_INTERNAL_EMPTY_BASE_CLASS NaggyMock\n    : private internal::NaggyMockImpl<MockClass>,\n      public MockClass {\n  static_assert(!internal::HasStrictnessModifier<MockClass>(),\n                \"Can't apply NaggyMock to a class hierarchy that already has a \"\n                \"strictness modifier. See \"\n                \"https://google.github.io/googletest/\"\n                \"gmock_cook_book.html#NiceStrictNaggy\");\n\n public:\n  NaggyMock() : MockClass() {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n  // Ideally, we would inherit base class's constructors through a using\n  // declaration, which would preserve their visibility. However, many existing\n  // tests rely on the fact that current implementation reexports protected\n  // constructors as public. These tests would need to be cleaned up first.\n\n  // Single argument constructor is special-cased so that it can be\n  // made explicit.\n  template <typename A>\n  explicit NaggyMock(A&& arg) : MockClass(std::forward<A>(arg)) {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n  template <typename TArg1, typename TArg2, typename... An>\n  NaggyMock(TArg1&& arg1, TArg2&& arg2, An&&... args)\n      : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),\n                  std::forward<An>(args)...) {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock);\n};\n\ntemplate <class MockClass>\nclass GTEST_INTERNAL_EMPTY_BASE_CLASS StrictMock\n    : private internal::StrictMockImpl<MockClass>,\n      public MockClass {\n public:\n  static_assert(\n      !internal::HasStrictnessModifier<MockClass>(),\n      \"Can't apply StrictMock to a class hierarchy that already has a \"\n      \"strictness modifier. See \"\n      \"https://google.github.io/googletest/\"\n      \"gmock_cook_book.html#NiceStrictNaggy\");\n  StrictMock() : MockClass() {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n  // Ideally, we would inherit base class's constructors through a using\n  // declaration, which would preserve their visibility. However, many existing\n  // tests rely on the fact that current implementation reexports protected\n  // constructors as public. These tests would need to be cleaned up first.\n\n  // Single argument constructor is special-cased so that it can be\n  // made explicit.\n  template <typename A>\n  explicit StrictMock(A&& arg) : MockClass(std::forward<A>(arg)) {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n  template <typename TArg1, typename TArg2, typename... An>\n  StrictMock(TArg1&& arg1, TArg2&& arg2, An&&... args)\n      : MockClass(std::forward<TArg1>(arg1), std::forward<TArg2>(arg2),\n                  std::forward<An>(args)...) {\n    static_assert(sizeof(*this) == sizeof(MockClass),\n                  \"The impl subclass shouldn't introduce any padding\");\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);\n};\n\n#undef GTEST_INTERNAL_EMPTY_BASE_CLASS\n\n}  // namespace testing\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_\n\nnamespace testing {\n\n// Declares Google Mock flags that we want a user to use programmatically.\nGMOCK_DECLARE_bool_(catch_leaked_mocks);\nGMOCK_DECLARE_string_(verbose);\nGMOCK_DECLARE_int32_(default_mock_behavior);\n\n// Initializes Google Mock.  This must be called before running the\n// tests.  In particular, it parses the command line for the flags\n// that Google Mock recognizes.  Whenever a Google Mock flag is seen,\n// it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Mock flag variables are\n// updated.\n//\n// Since Google Test is needed for Google Mock to work, this function\n// also initializes Google Test and parses its flags, if that hasn't\n// been done.\nGTEST_API_ void InitGoogleMock(int* argc, char** argv);\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv);\n\n// This overloaded version can be used on Arduino/embedded platforms where\n// there is no argc/argv.\nGTEST_API_ void InitGoogleMock();\n\n}  // namespace testing\n\n#endif  // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_H_\n"
  },
  {
    "path": "test/gtest/gmock-gtest-all.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// Google C++ Testing and Mocking Framework (Google Test)\n//\n// Sometimes it's desirable to build Google Test by compiling a single file.\n// This file serves this purpose.\n\n// This line ensures that gtest.h can be compiled on its own, even\n// when it's fused.\n#include \"gtest/gtest.h\"\n\n// The following lines pull in the real gtest *.cc files.\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// Utilities for testing Google Test itself and code that uses Google Test\n// (e.g. frameworks built on top of Google Test).\n\n// GOOGLETEST_CM0004 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_\n\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// This helper class can be used to mock out Google Test failure reporting\n// so that we can test Google Test or code that builds on Google Test.\n//\n// An object of this class appends a TestPartResult object to the\n// TestPartResultArray object given in the constructor whenever a Google Test\n// failure is reported. It can either intercept only failures that are\n// generated in the same thread that created this object or it can intercept\n// all generated failures. The scope of this mock object can be controlled with\n// the second argument to the two arguments constructor.\nclass GTEST_API_ ScopedFakeTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  // The two possible mocking modes of this object.\n  enum InterceptMode {\n    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.\n    INTERCEPT_ALL_THREADS           // Intercepts all failures.\n  };\n\n  // The c'tor sets this object as the test part result reporter used\n  // by Google Test.  The 'result' parameter specifies where to report the\n  // results. This reporter will only catch failures generated in the current\n  // thread. DEPRECATED\n  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);\n\n  // Same as above, but you can choose the interception scope of this object.\n  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,\n                                   TestPartResultArray* result);\n\n  // The d'tor restores the previous test part result reporter.\n  ~ScopedFakeTestPartResultReporter() override;\n\n  // Appends the TestPartResult object to the TestPartResultArray\n  // received in the constructor.\n  //\n  // This method is from the TestPartResultReporterInterface\n  // interface.\n  void ReportTestPartResult(const TestPartResult& result) override;\n\n private:\n  void Init();\n\n  const InterceptMode intercept_mode_;\n  TestPartResultReporterInterface* old_reporter_;\n  TestPartResultArray* const result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);\n};\n\nnamespace internal {\n\n// A helper class for implementing EXPECT_FATAL_FAILURE() and\n// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nclass GTEST_API_ SingleFailureChecker {\n public:\n  // The constructor remembers the arguments.\n  SingleFailureChecker(const TestPartResultArray* results,\n                       TestPartResult::Type type, const std::string& substr);\n  ~SingleFailureChecker();\n private:\n  const TestPartResultArray* const results_;\n  const TestPartResult::Type type_;\n  const std::string substr_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n// A set of macros for testing Google Test assertions or code that's expected\n// to generate Google Test fatal failures.  It verifies that the given\n// statement will cause exactly one fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_FATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - 'statement' cannot reference local non-static variables or\n//     non-static members of the current object.\n//   - 'statement' cannot return a value.\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in\n// gtest_unittest.cc will fail to compile if we do that.\n#define EXPECT_FATAL_FAILURE(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ALL_THREADS, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n// A macro for testing Google Test assertions or code that's expected to\n// generate Google Test non-fatal failures.  It asserts that the given\n// statement will cause exactly one non-fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// 'statement' is allowed to reference local variables and members of\n// the current object.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  If we do that, the code won't compile when the user gives\n// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that\n// expands to code containing an unprotected comma.  The\n// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc\n// catches that.\n//\n// For the same reason, we have to write\n//   if (::testing::internal::AlwaysTrue()) { statement; }\n// instead of\n//   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n// to avoid an MSVC warning on unreachable code.\n#define EXPECT_NONFATAL_FAILURE(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \\\n          &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_\n\n#include <ctype.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n#include <wchar.h>\n#include <wctype.h>\n\n#include <algorithm>\n#include <chrono>  // NOLINT\n#include <cmath>\n#include <cstdint>\n#include <iomanip>\n#include <limits>\n#include <list>\n#include <map>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <vector>\n\n#if GTEST_OS_LINUX\n\n# include <fcntl.h>  // NOLINT\n# include <limits.h>  // NOLINT\n# include <sched.h>  // NOLINT\n// Declares vsnprintf().  This header is not available on Windows.\n# include <strings.h>  // NOLINT\n# include <sys/mman.h>  // NOLINT\n# include <sys/time.h>  // NOLINT\n# include <unistd.h>  // NOLINT\n# include <string>\n\n#elif GTEST_OS_ZOS\n# include <sys/time.h>  // NOLINT\n\n// On z/OS we additionally need strings.h for strcasecmp.\n# include <strings.h>  // NOLINT\n\n#elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.\n\n# include <windows.h>  // NOLINT\n# undef min\n\n#elif GTEST_OS_WINDOWS  // We are on Windows proper.\n\n# include <windows.h>  // NOLINT\n# undef min\n\n#ifdef _MSC_VER\n# include <crtdbg.h>  // NOLINT\n#endif\n\n# include <io.h>  // NOLINT\n# include <sys/timeb.h>  // NOLINT\n# include <sys/types.h>  // NOLINT\n# include <sys/stat.h>  // NOLINT\n\n# if GTEST_OS_WINDOWS_MINGW\n#  include <sys/time.h>  // NOLINT\n# endif  // GTEST_OS_WINDOWS_MINGW\n\n#else\n\n// cpplint thinks that the header is already included, so we want to\n// silence it.\n# include <sys/time.h>  // NOLINT\n# include <unistd.h>  // NOLINT\n\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n#if GTEST_CAN_STREAM_RESULTS_\n# include <arpa/inet.h>  // NOLINT\n# include <netdb.h>  // NOLINT\n# include <sys/socket.h>  // NOLINT\n# include <sys/types.h>  // NOLINT\n#endif\n\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Utility functions and classes used by the Google C++ testing framework.//\n// This file contains purely Google Test's internal implementation.  Please\n// DO NOT #INCLUDE IT IN A USER PROGRAM.\n\n#ifndef GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_\n#define GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_\n\n#ifndef _WIN32_WCE\n# include <errno.h>\n#endif  // !_WIN32_WCE\n#include <stddef.h>\n#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.\n#include <string.h>  // For memmove.\n\n#include <algorithm>\n#include <cstdint>\n#include <memory>\n#include <string>\n#include <vector>\n\n\n#if GTEST_CAN_STREAM_RESULTS_\n# include <arpa/inet.h>  // NOLINT\n# include <netdb.h>  // NOLINT\n#endif\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// Declares the flags.\n//\n// We don't want the users to modify this flag in the code, but want\n// Google Test's own unit tests to be able to access it. Therefore we\n// declare it here as opposed to in gtest.h.\nGTEST_DECLARE_bool_(death_test_use_fork);\n\nnamespace internal {\n\n// The value of GetTestTypeId() as seen from within the Google Test\n// library.  This is solely for testing GetTestTypeId().\nGTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;\n\n// Names of the flags (needed for parsing Google Test flags).\nconst char kAlsoRunDisabledTestsFlag[] = \"also_run_disabled_tests\";\nconst char kBreakOnFailureFlag[] = \"break_on_failure\";\nconst char kCatchExceptionsFlag[] = \"catch_exceptions\";\nconst char kColorFlag[] = \"color\";\nconst char kFailFast[] = \"fail_fast\";\nconst char kFilterFlag[] = \"filter\";\nconst char kListTestsFlag[] = \"list_tests\";\nconst char kOutputFlag[] = \"output\";\nconst char kBriefFlag[] = \"brief\";\nconst char kPrintTimeFlag[] = \"print_time\";\nconst char kPrintUTF8Flag[] = \"print_utf8\";\nconst char kRandomSeedFlag[] = \"random_seed\";\nconst char kRepeatFlag[] = \"repeat\";\nconst char kShuffleFlag[] = \"shuffle\";\nconst char kStackTraceDepthFlag[] = \"stack_trace_depth\";\nconst char kStreamResultToFlag[] = \"stream_result_to\";\nconst char kThrowOnFailureFlag[] = \"throw_on_failure\";\nconst char kFlagfileFlag[] = \"flagfile\";\n\n// A valid random seed must be in [1, kMaxRandomSeed].\nconst int kMaxRandomSeed = 99999;\n\n// g_help_flag is true if and only if the --help flag or an equivalent form\n// is specified on the command line.\nGTEST_API_ extern bool g_help_flag;\n\n// Returns the current time in milliseconds.\nGTEST_API_ TimeInMillis GetTimeInMillis();\n\n// Returns true if and only if Google Test should use colors in the output.\nGTEST_API_ bool ShouldUseColor(bool stdout_is_tty);\n\n// Formats the given time in milliseconds as seconds.\nGTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);\n\n// Converts the given time in milliseconds to a date string in the ISO 8601\n// format, without the timezone information.  N.B.: due to the use the\n// non-reentrant localtime() function, this function is not thread safe.  Do\n// not use it in any code that can be called from multiple threads.\nGTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms);\n\n// Parses a string for an Int32 flag, in the form of \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nGTEST_API_ bool ParseInt32Flag(\n    const char* str, const char* flag, int32_t* value);\n\n// Returns a random seed in range [1, kMaxRandomSeed] based on the\n// given --gtest_random_seed flag value.\ninline int GetRandomSeedFromFlag(int32_t random_seed_flag) {\n  const unsigned int raw_seed = (random_seed_flag == 0) ?\n      static_cast<unsigned int>(GetTimeInMillis()) :\n      static_cast<unsigned int>(random_seed_flag);\n\n  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that\n  // it's easy to type.\n  const int normalized_seed =\n      static_cast<int>((raw_seed - 1U) %\n                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;\n  return normalized_seed;\n}\n\n// Returns the first valid random seed after 'seed'.  The behavior is\n// undefined if 'seed' is invalid.  The seed after kMaxRandomSeed is\n// considered to be 1.\ninline int GetNextRandomSeed(int seed) {\n  GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed)\n      << \"Invalid random seed \" << seed << \" - must be in [1, \"\n      << kMaxRandomSeed << \"].\";\n  const int next_seed = seed + 1;\n  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;\n}\n\n// This class saves the values of all Google Test flags in its c'tor, and\n// restores them in its d'tor.\nclass GTestFlagSaver {\n public:\n  // The c'tor.\n  GTestFlagSaver() {\n    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);\n    break_on_failure_ = GTEST_FLAG(break_on_failure);\n    catch_exceptions_ = GTEST_FLAG(catch_exceptions);\n    color_ = GTEST_FLAG(color);\n    death_test_style_ = GTEST_FLAG(death_test_style);\n    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);\n    fail_fast_ = GTEST_FLAG(fail_fast);\n    filter_ = GTEST_FLAG(filter);\n    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);\n    list_tests_ = GTEST_FLAG(list_tests);\n    output_ = GTEST_FLAG(output);\n    brief_ = GTEST_FLAG(brief);\n    print_time_ = GTEST_FLAG(print_time);\n    print_utf8_ = GTEST_FLAG(print_utf8);\n    random_seed_ = GTEST_FLAG(random_seed);\n    repeat_ = GTEST_FLAG(repeat);\n    shuffle_ = GTEST_FLAG(shuffle);\n    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);\n    stream_result_to_ = GTEST_FLAG(stream_result_to);\n    throw_on_failure_ = GTEST_FLAG(throw_on_failure);\n  }\n\n  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.\n  ~GTestFlagSaver() {\n    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;\n    GTEST_FLAG(break_on_failure) = break_on_failure_;\n    GTEST_FLAG(catch_exceptions) = catch_exceptions_;\n    GTEST_FLAG(color) = color_;\n    GTEST_FLAG(death_test_style) = death_test_style_;\n    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;\n    GTEST_FLAG(filter) = filter_;\n    GTEST_FLAG(fail_fast) = fail_fast_;\n    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;\n    GTEST_FLAG(list_tests) = list_tests_;\n    GTEST_FLAG(output) = output_;\n    GTEST_FLAG(brief) = brief_;\n    GTEST_FLAG(print_time) = print_time_;\n    GTEST_FLAG(print_utf8) = print_utf8_;\n    GTEST_FLAG(random_seed) = random_seed_;\n    GTEST_FLAG(repeat) = repeat_;\n    GTEST_FLAG(shuffle) = shuffle_;\n    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;\n    GTEST_FLAG(stream_result_to) = stream_result_to_;\n    GTEST_FLAG(throw_on_failure) = throw_on_failure_;\n  }\n\n private:\n  // Fields for saving the original values of flags.\n  bool also_run_disabled_tests_;\n  bool break_on_failure_;\n  bool catch_exceptions_;\n  std::string color_;\n  std::string death_test_style_;\n  bool death_test_use_fork_;\n  bool fail_fast_;\n  std::string filter_;\n  std::string internal_run_death_test_;\n  bool list_tests_;\n  std::string output_;\n  bool brief_;\n  bool print_time_;\n  bool print_utf8_;\n  int32_t random_seed_;\n  int32_t repeat_;\n  bool shuffle_;\n  int32_t stack_trace_depth_;\n  std::string stream_result_to_;\n  bool throw_on_failure_;\n} GTEST_ATTRIBUTE_UNUSED_;\n\n// Converts a Unicode code point to a narrow string in UTF-8 encoding.\n// code_point parameter is of type UInt32 because wchar_t may not be\n// wide enough to contain a code point.\n// If the code_point is not a valid Unicode code point\n// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted\n// to \"(Invalid Unicode 0xXXXXXXXX)\".\nGTEST_API_ std::string CodePointToUtf8(uint32_t code_point);\n\n// Converts a wide string to a narrow string in UTF-8 encoding.\n// The wide string is assumed to have the following encoding:\n//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin)\n//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)\n// Parameter str points to a null-terminated wide string.\n// Parameter num_chars may additionally limit the number\n// of wchar_t characters processed. -1 is used when the entire string\n// should be processed.\n// If the string contains code points that are not valid Unicode code points\n// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output\n// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding\n// and contains invalid UTF-16 surrogate pairs, values in those pairs\n// will be encoded as individual Unicode characters from Basic Normal Plane.\nGTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars);\n\n// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file\n// if the variable is present. If a file already exists at this location, this\n// function will write over it. If the variable is present, but the file cannot\n// be created, prints an error and exits.\nvoid WriteToShardStatusFileIfNeeded();\n\n// Checks whether sharding is enabled by examining the relevant\n// environment variable values. If the variables are present,\n// but inconsistent (e.g., shard_index >= total_shards), prints\n// an error and exits. If in_subprocess_for_death_test, sharding is\n// disabled because it must only be applied to the original test\n// process. Otherwise, we could filter out death tests we intended to execute.\nGTEST_API_ bool ShouldShard(const char* total_shards_str,\n                            const char* shard_index_str,\n                            bool in_subprocess_for_death_test);\n\n// Parses the environment variable var as a 32-bit integer. If it is unset,\n// returns default_val. If it is not a 32-bit integer, prints an error and\n// and aborts.\nGTEST_API_ int32_t Int32FromEnvOrDie(const char* env_var, int32_t default_val);\n\n// Given the total number of shards, the shard index, and the test id,\n// returns true if and only if the test should be run on this shard. The test id\n// is some arbitrary but unique non-negative integer assigned to each test\n// method. Assumes that 0 <= shard_index < total_shards.\nGTEST_API_ bool ShouldRunTestOnShard(\n    int total_shards, int shard_index, int test_id);\n\n// STL container utilities.\n\n// Returns the number of elements in the given container that satisfy\n// the given predicate.\ntemplate <class Container, typename Predicate>\ninline int CountIf(const Container& c, Predicate predicate) {\n  // Implemented as an explicit loop since std::count_if() in libCstd on\n  // Solaris has a non-standard signature.\n  int count = 0;\n  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {\n    if (predicate(*it))\n      ++count;\n  }\n  return count;\n}\n\n// Applies a function/functor to each element in the container.\ntemplate <class Container, typename Functor>\nvoid ForEach(const Container& c, Functor functor) {\n  std::for_each(c.begin(), c.end(), functor);\n}\n\n// Returns the i-th element of the vector, or default_value if i is not\n// in range [0, v.size()).\ntemplate <typename E>\ninline E GetElementOr(const std::vector<E>& v, int i, E default_value) {\n  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value\n                                                    : v[static_cast<size_t>(i)];\n}\n\n// Performs an in-place shuffle of a range of the vector's elements.\n// 'begin' and 'end' are element indices as an STL-style range;\n// i.e. [begin, end) are shuffled, where 'end' == size() means to\n// shuffle to the end of the vector.\ntemplate <typename E>\nvoid ShuffleRange(internal::Random* random, int begin, int end,\n                  std::vector<E>* v) {\n  const int size = static_cast<int>(v->size());\n  GTEST_CHECK_(0 <= begin && begin <= size)\n      << \"Invalid shuffle range start \" << begin << \": must be in range [0, \"\n      << size << \"].\";\n  GTEST_CHECK_(begin <= end && end <= size)\n      << \"Invalid shuffle range finish \" << end << \": must be in range [\"\n      << begin << \", \" << size << \"].\";\n\n  // Fisher-Yates shuffle, from\n  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle\n  for (int range_width = end - begin; range_width >= 2; range_width--) {\n    const int last_in_range = begin + range_width - 1;\n    const int selected =\n        begin +\n        static_cast<int>(random->Generate(static_cast<uint32_t>(range_width)));\n    std::swap((*v)[static_cast<size_t>(selected)],\n              (*v)[static_cast<size_t>(last_in_range)]);\n  }\n}\n\n// Performs an in-place shuffle of the vector's elements.\ntemplate <typename E>\ninline void Shuffle(internal::Random* random, std::vector<E>* v) {\n  ShuffleRange(random, 0, static_cast<int>(v->size()), v);\n}\n\n// A function for deleting an object.  Handy for being used as a\n// functor.\ntemplate <typename T>\nstatic void Delete(T* x) {\n  delete x;\n}\n\n// A predicate that checks the key of a TestProperty against a known key.\n//\n// TestPropertyKeyIs is copyable.\nclass TestPropertyKeyIs {\n public:\n  // Constructor.\n  //\n  // TestPropertyKeyIs has NO default constructor.\n  explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}\n\n  // Returns true if and only if the test name of test property matches on key_.\n  bool operator()(const TestProperty& test_property) const {\n    return test_property.key() == key_;\n  }\n\n private:\n  std::string key_;\n};\n\n// Class UnitTestOptions.\n//\n// This class contains functions for processing options the user\n// specifies when running the tests.  It has only static members.\n//\n// In most cases, the user can specify an option using either an\n// environment variable or a command line flag.  E.g. you can set the\n// test filter using either GTEST_FILTER or --gtest_filter.  If both\n// the variable and the flag are present, the latter overrides the\n// former.\nclass GTEST_API_ UnitTestOptions {\n public:\n  // Functions for processing the gtest_output flag.\n\n  // Returns the output format, or \"\" for normal printed output.\n  static std::string GetOutputFormat();\n\n  // Returns the absolute path of the requested output file, or the\n  // default (test_detail.xml in the original working directory) if\n  // none was explicitly specified.\n  static std::string GetAbsolutePathToOutputFile();\n\n  // Functions for processing the gtest_filter flag.\n\n  // Returns true if and only if the user-specified filter matches the test\n  // suite name and the test name.\n  static bool FilterMatchesTest(const std::string& test_suite_name,\n                                const std::string& test_name);\n\n#if GTEST_OS_WINDOWS\n  // Function for supporting the gtest_catch_exception flag.\n\n  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the\n  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.\n  // This function is useful as an __except condition.\n  static int GTestShouldProcessSEH(DWORD exception_code);\n#endif  // GTEST_OS_WINDOWS\n\n  // Returns true if \"name\" matches the ':' separated list of glob-style\n  // filters in \"filter\".\n  static bool MatchesFilter(const std::string& name, const char* filter);\n};\n\n// Returns the current application's name, removing directory path if that\n// is present.  Used by UnitTestOptions::GetOutputFile.\nGTEST_API_ FilePath GetCurrentExecutableName();\n\n// The role interface for getting the OS stack trace as a string.\nclass OsStackTraceGetterInterface {\n public:\n  OsStackTraceGetterInterface() {}\n  virtual ~OsStackTraceGetterInterface() {}\n\n  // Returns the current OS stack trace as an std::string.  Parameters:\n  //\n  //   max_depth  - the maximum number of stack frames to be included\n  //                in the trace.\n  //   skip_count - the number of top frames to be skipped; doesn't count\n  //                against max_depth.\n  virtual std::string CurrentStackTrace(int max_depth, int skip_count) = 0;\n\n  // UponLeavingGTest() should be called immediately before Google Test calls\n  // user code. It saves some information about the current stack that\n  // CurrentStackTrace() will use to find and hide Google Test stack frames.\n  virtual void UponLeavingGTest() = 0;\n\n  // This string is inserted in place of stack frames that are part of\n  // Google Test's implementation.\n  static const char* const kElidedFramesMarker;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);\n};\n\n// A working implementation of the OsStackTraceGetterInterface interface.\nclass OsStackTraceGetter : public OsStackTraceGetterInterface {\n public:\n  OsStackTraceGetter() {}\n\n  std::string CurrentStackTrace(int max_depth, int skip_count) override;\n  void UponLeavingGTest() override;\n\n private:\n#if GTEST_HAS_ABSL\n  Mutex mutex_;  // Protects all internal state.\n\n  // We save the stack frame below the frame that calls user code.\n  // We do this because the address of the frame immediately below\n  // the user code changes between the call to UponLeavingGTest()\n  // and any calls to the stack trace code from within the user code.\n  void* caller_frame_ = nullptr;\n#endif  // GTEST_HAS_ABSL\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);\n};\n\n// Information about a Google Test trace point.\nstruct TraceInfo {\n  const char* file;\n  int line;\n  std::string message;\n};\n\n// This is the default global test part result reporter used in UnitTestImpl.\n// This class should only be used by UnitTestImpl.\nclass DefaultGlobalTestPartResultReporter\n  : public TestPartResultReporterInterface {\n public:\n  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);\n  // Implements the TestPartResultReporterInterface. Reports the test part\n  // result in the current test.\n  void ReportTestPartResult(const TestPartResult& result) override;\n\n private:\n  UnitTestImpl* const unit_test_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);\n};\n\n// This is the default per thread test part result reporter used in\n// UnitTestImpl. This class should only be used by UnitTestImpl.\nclass DefaultPerThreadTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);\n  // Implements the TestPartResultReporterInterface. The implementation just\n  // delegates to the current global test part result reporter of *unit_test_.\n  void ReportTestPartResult(const TestPartResult& result) override;\n\n private:\n  UnitTestImpl* const unit_test_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);\n};\n\n// The private implementation of the UnitTest class.  We don't protect\n// the methods under a mutex, as this class is not accessible by a\n// user and the UnitTest class that delegates work to this class does\n// proper locking.\nclass GTEST_API_ UnitTestImpl {\n public:\n  explicit UnitTestImpl(UnitTest* parent);\n  virtual ~UnitTestImpl();\n\n  // There are two different ways to register your own TestPartResultReporter.\n  // You can register your own repoter to listen either only for test results\n  // from the current thread or for results from all threads.\n  // By default, each per-thread test result repoter just passes a new\n  // TestPartResult to the global test result reporter, which registers the\n  // test part result for the currently running test.\n\n  // Returns the global test part result reporter.\n  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();\n\n  // Sets the global test part result reporter.\n  void SetGlobalTestPartResultReporter(\n      TestPartResultReporterInterface* reporter);\n\n  // Returns the test part result reporter for the current thread.\n  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();\n\n  // Sets the test part result reporter for the current thread.\n  void SetTestPartResultReporterForCurrentThread(\n      TestPartResultReporterInterface* reporter);\n\n  // Gets the number of successful test suites.\n  int successful_test_suite_count() const;\n\n  // Gets the number of failed test suites.\n  int failed_test_suite_count() const;\n\n  // Gets the number of all test suites.\n  int total_test_suite_count() const;\n\n  // Gets the number of all test suites that contain at least one test\n  // that should run.\n  int test_suite_to_run_count() const;\n\n  // Gets the number of successful tests.\n  int successful_test_count() const;\n\n  // Gets the number of skipped tests.\n  int skipped_test_count() const;\n\n  // Gets the number of failed tests.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Gets the number of all tests.\n  int total_test_count() const;\n\n  // Gets the number of tests that should run.\n  int test_to_run_count() const;\n\n  // Gets the time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const { return start_timestamp_; }\n\n  // Gets the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns true if and only if the unit test passed (i.e. all test suites\n  // passed).\n  bool Passed() const { return !Failed(); }\n\n  // Returns true if and only if the unit test failed (i.e. some test suite\n  // failed or something outside of all tests failed).\n  bool Failed() const {\n    return failed_test_suite_count() > 0 || ad_hoc_test_result()->Failed();\n  }\n\n  // Gets the i-th test suite among all the test suites. i can range from 0 to\n  // total_test_suite_count() - 1. If i is not in that range, returns NULL.\n  const TestSuite* GetTestSuite(int i) const {\n    const int index = GetElementOr(test_suite_indices_, i, -1);\n    return index < 0 ? nullptr : test_suites_[static_cast<size_t>(i)];\n  }\n\n  //  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  const TestCase* GetTestCase(int i) const { return GetTestSuite(i); }\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Gets the i-th test suite among all the test suites. i can range from 0 to\n  // total_test_suite_count() - 1. If i is not in that range, returns NULL.\n  TestSuite* GetMutableSuiteCase(int i) {\n    const int index = GetElementOr(test_suite_indices_, i, -1);\n    return index < 0 ? nullptr : test_suites_[static_cast<size_t>(index)];\n  }\n\n  // Provides access to the event listener list.\n  TestEventListeners* listeners() { return &listeners_; }\n\n  // Returns the TestResult for the test that's currently running, or\n  // the TestResult for the ad hoc test if no test is running.\n  TestResult* current_test_result();\n\n  // Returns the TestResult for the ad hoc test.\n  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }\n\n  // Sets the OS stack trace getter.\n  //\n  // Does nothing if the input and the current OS stack trace getter\n  // are the same; otherwise, deletes the old getter and makes the\n  // input the current getter.\n  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);\n\n  // Returns the current OS stack trace getter if it is not NULL;\n  // otherwise, creates an OsStackTraceGetter, makes it the current\n  // getter, and returns it.\n  OsStackTraceGetterInterface* os_stack_trace_getter();\n\n  // Returns the current OS stack trace as an std::string.\n  //\n  // The maximum number of stack frames to be included is specified by\n  // the gtest_stack_trace_depth flag.  The skip_count parameter\n  // specifies the number of top frames to be skipped, which doesn't\n  // count against the number of frames to be included.\n  //\n  // For example, if Foo() calls Bar(), which in turn calls\n  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the\n  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.\n  std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_;\n\n  // Finds and returns a TestSuite with the given name.  If one doesn't\n  // exist, creates one and returns it.\n  //\n  // Arguments:\n  //\n  //   test_suite_name: name of the test suite\n  //   type_param:      the name of the test's type parameter, or NULL if\n  //                    this is not a typed or a type-parameterized test.\n  //   set_up_tc:       pointer to the function that sets up the test suite\n  //   tear_down_tc:    pointer to the function that tears down the test suite\n  TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,\n                          internal::SetUpTestSuiteFunc set_up_tc,\n                          internal::TearDownTestSuiteFunc tear_down_tc);\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  TestCase* GetTestCase(const char* test_case_name, const char* type_param,\n                        internal::SetUpTestSuiteFunc set_up_tc,\n                        internal::TearDownTestSuiteFunc tear_down_tc) {\n    return GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);\n  }\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Adds a TestInfo to the unit test.\n  //\n  // Arguments:\n  //\n  //   set_up_tc:    pointer to the function that sets up the test suite\n  //   tear_down_tc: pointer to the function that tears down the test suite\n  //   test_info:    the TestInfo object\n  void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,\n                   internal::TearDownTestSuiteFunc tear_down_tc,\n                   TestInfo* test_info) {\n#if GTEST_HAS_DEATH_TEST\n    // In order to support thread-safe death tests, we need to\n    // remember the original working directory when the test program\n    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as\n    // the user may have changed the current directory before calling\n    // RUN_ALL_TESTS().  Therefore we capture the current directory in\n    // AddTestInfo(), which is called to register a TEST or TEST_F\n    // before main() is reached.\n    if (original_working_dir_.IsEmpty()) {\n      original_working_dir_.Set(FilePath::GetCurrentDir());\n      GTEST_CHECK_(!original_working_dir_.IsEmpty())\n          << \"Failed to get the current working directory.\";\n    }\n#endif  // GTEST_HAS_DEATH_TEST\n\n    GetTestSuite(test_info->test_suite_name(), test_info->type_param(),\n                 set_up_tc, tear_down_tc)\n        ->AddTestInfo(test_info);\n  }\n\n  // Returns ParameterizedTestSuiteRegistry object used to keep track of\n  // value-parameterized tests and instantiate and register them.\n  internal::ParameterizedTestSuiteRegistry& parameterized_test_registry() {\n    return parameterized_test_registry_;\n  }\n\n  std::set<std::string>* ignored_parameterized_test_suites() {\n    return &ignored_parameterized_test_suites_;\n  }\n\n  // Returns TypeParameterizedTestSuiteRegistry object used to keep track of\n  // type-parameterized tests and instantiations of them.\n  internal::TypeParameterizedTestSuiteRegistry&\n  type_parameterized_test_registry() {\n    return type_parameterized_test_registry_;\n  }\n\n  // Sets the TestSuite object for the test that's currently running.\n  void set_current_test_suite(TestSuite* a_current_test_suite) {\n    current_test_suite_ = a_current_test_suite;\n  }\n\n  // Sets the TestInfo object for the test that's currently running.  If\n  // current_test_info is NULL, the assertion results will be stored in\n  // ad_hoc_test_result_.\n  void set_current_test_info(TestInfo* a_current_test_info) {\n    current_test_info_ = a_current_test_info;\n  }\n\n  // Registers all parameterized tests defined using TEST_P and\n  // INSTANTIATE_TEST_SUITE_P, creating regular tests for each test/parameter\n  // combination. This method can be called more then once; it has guards\n  // protecting from registering the tests more then once.  If\n  // value-parameterized tests are disabled, RegisterParameterizedTests is\n  // present but does nothing.\n  void RegisterParameterizedTests();\n\n  // Runs all tests in this UnitTest object, prints the result, and\n  // returns true if all tests are successful.  If any exception is\n  // thrown during a test, this test is considered to be failed, but\n  // the rest of the tests will still be run.\n  bool RunAllTests();\n\n  // Clears the results of all tests, except the ad hoc tests.\n  void ClearNonAdHocTestResult() {\n    ForEach(test_suites_, TestSuite::ClearTestSuiteResult);\n  }\n\n  // Clears the results of ad-hoc test assertions.\n  void ClearAdHocTestResult() {\n    ad_hoc_test_result_.Clear();\n  }\n\n  // Adds a TestProperty to the current TestResult object when invoked in a\n  // context of a test or a test suite, or to the global property set. If the\n  // result already contains a property with the same key, the value will be\n  // updated.\n  void RecordProperty(const TestProperty& test_property);\n\n  enum ReactionToSharding {\n    HONOR_SHARDING_PROTOCOL,\n    IGNORE_SHARDING_PROTOCOL\n  };\n\n  // Matches the full name of each test against the user-specified\n  // filter to decide whether the test should run, then records the\n  // result in each TestSuite and TestInfo object.\n  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests\n  // based on sharding variables in the environment.\n  // Returns the number of tests that should run.\n  int FilterTests(ReactionToSharding shard_tests);\n\n  // Prints the names of the tests matching the user-specified filter flag.\n  void ListTestsMatchingFilter();\n\n  const TestSuite* current_test_suite() const { return current_test_suite_; }\n  TestInfo* current_test_info() { return current_test_info_; }\n  const TestInfo* current_test_info() const { return current_test_info_; }\n\n  // Returns the vector of environments that need to be set-up/torn-down\n  // before/after the tests are run.\n  std::vector<Environment*>& environments() { return environments_; }\n\n  // Getters for the per-thread Google Test trace stack.\n  std::vector<TraceInfo>& gtest_trace_stack() {\n    return *(gtest_trace_stack_.pointer());\n  }\n  const std::vector<TraceInfo>& gtest_trace_stack() const {\n    return gtest_trace_stack_.get();\n  }\n\n#if GTEST_HAS_DEATH_TEST\n  void InitDeathTestSubprocessControlInfo() {\n    internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());\n  }\n  // Returns a pointer to the parsed --gtest_internal_run_death_test\n  // flag, or NULL if that flag was not specified.\n  // This information is useful only in a death test child process.\n  // Must not be called before a call to InitGoogleTest.\n  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {\n    return internal_run_death_test_flag_.get();\n  }\n\n  // Returns a pointer to the current death test factory.\n  internal::DeathTestFactory* death_test_factory() {\n    return death_test_factory_.get();\n  }\n\n  void SuppressTestEventsIfInSubprocess();\n\n  friend class ReplaceDeathTestFactory;\n#endif  // GTEST_HAS_DEATH_TEST\n\n  // Initializes the event listener performing XML output as specified by\n  // UnitTestOptions. Must not be called before InitGoogleTest.\n  void ConfigureXmlOutput();\n\n#if GTEST_CAN_STREAM_RESULTS_\n  // Initializes the event listener for streaming test results to a socket.\n  // Must not be called before InitGoogleTest.\n  void ConfigureStreamingOutput();\n#endif\n\n  // Performs initialization dependent upon flag values obtained in\n  // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to\n  // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest\n  // this function is also called from RunAllTests.  Since this function can be\n  // called more than once, it has to be idempotent.\n  void PostFlagParsingInit();\n\n  // Gets the random seed used at the start of the current test iteration.\n  int random_seed() const { return random_seed_; }\n\n  // Gets the random number generator.\n  internal::Random* random() { return &random_; }\n\n  // Shuffles all test suites, and the tests within each test suite,\n  // making sure that death tests are still run first.\n  void ShuffleTests();\n\n  // Restores the test suites and tests to their order before the first shuffle.\n  void UnshuffleTests();\n\n  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment\n  // UnitTest::Run() starts.\n  bool catch_exceptions() const { return catch_exceptions_; }\n\n private:\n  friend class ::testing::UnitTest;\n\n  // Used by UnitTest::Run() to capture the state of\n  // GTEST_FLAG(catch_exceptions) at the moment it starts.\n  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }\n\n  // The UnitTest object that owns this implementation object.\n  UnitTest* const parent_;\n\n  // The working directory when the first TEST() or TEST_F() was\n  // executed.\n  internal::FilePath original_working_dir_;\n\n  // The default test part result reporters.\n  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;\n  DefaultPerThreadTestPartResultReporter\n      default_per_thread_test_part_result_reporter_;\n\n  // Points to (but doesn't own) the global test part result reporter.\n  TestPartResultReporterInterface* global_test_part_result_repoter_;\n\n  // Protects read and write access to global_test_part_result_reporter_.\n  internal::Mutex global_test_part_result_reporter_mutex_;\n\n  // Points to (but doesn't own) the per-thread test part result reporter.\n  internal::ThreadLocal<TestPartResultReporterInterface*>\n      per_thread_test_part_result_reporter_;\n\n  // The vector of environments that need to be set-up/torn-down\n  // before/after the tests are run.\n  std::vector<Environment*> environments_;\n\n  // The vector of TestSuites in their original order.  It owns the\n  // elements in the vector.\n  std::vector<TestSuite*> test_suites_;\n\n  // Provides a level of indirection for the test suite list to allow\n  // easy shuffling and restoring the test suite order.  The i-th\n  // element of this vector is the index of the i-th test suite in the\n  // shuffled order.\n  std::vector<int> test_suite_indices_;\n\n  // ParameterizedTestRegistry object used to register value-parameterized\n  // tests.\n  internal::ParameterizedTestSuiteRegistry parameterized_test_registry_;\n  internal::TypeParameterizedTestSuiteRegistry\n      type_parameterized_test_registry_;\n\n  // The set holding the name of parameterized\n  // test suites that may go uninstantiated.\n  std::set<std::string> ignored_parameterized_test_suites_;\n\n  // Indicates whether RegisterParameterizedTests() has been called already.\n  bool parameterized_tests_registered_;\n\n  // Index of the last death test suite registered.  Initially -1.\n  int last_death_test_suite_;\n\n  // This points to the TestSuite for the currently running test.  It\n  // changes as Google Test goes through one test suite after another.\n  // When no test is running, this is set to NULL and Google Test\n  // stores assertion results in ad_hoc_test_result_.  Initially NULL.\n  TestSuite* current_test_suite_;\n\n  // This points to the TestInfo for the currently running test.  It\n  // changes as Google Test goes through one test after another.  When\n  // no test is running, this is set to NULL and Google Test stores\n  // assertion results in ad_hoc_test_result_.  Initially NULL.\n  TestInfo* current_test_info_;\n\n  // Normally, a user only writes assertions inside a TEST or TEST_F,\n  // or inside a function called by a TEST or TEST_F.  Since Google\n  // Test keeps track of which test is current running, it can\n  // associate such an assertion with the test it belongs to.\n  //\n  // If an assertion is encountered when no TEST or TEST_F is running,\n  // Google Test attributes the assertion result to an imaginary \"ad hoc\"\n  // test, and records the result in ad_hoc_test_result_.\n  TestResult ad_hoc_test_result_;\n\n  // The list of event listeners that can be used to track events inside\n  // Google Test.\n  TestEventListeners listeners_;\n\n  // The OS stack trace getter.  Will be deleted when the UnitTest\n  // object is destructed.  By default, an OsStackTraceGetter is used,\n  // but the user can set this field to use a custom getter if that is\n  // desired.\n  OsStackTraceGetterInterface* os_stack_trace_getter_;\n\n  // True if and only if PostFlagParsingInit() has been called.\n  bool post_flag_parse_init_performed_;\n\n  // The random number seed used at the beginning of the test run.\n  int random_seed_;\n\n  // Our random number generator.\n  internal::Random random_;\n\n  // The time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp_;\n\n  // How long the test took to run, in milliseconds.\n  TimeInMillis elapsed_time_;\n\n#if GTEST_HAS_DEATH_TEST\n  // The decomposed components of the gtest_internal_run_death_test flag,\n  // parsed when RUN_ALL_TESTS is called.\n  std::unique_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;\n  std::unique_ptr<internal::DeathTestFactory> death_test_factory_;\n#endif  // GTEST_HAS_DEATH_TEST\n\n  // A per-thread stack of traces created by the SCOPED_TRACE() macro.\n  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;\n\n  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()\n  // starts.\n  bool catch_exceptions_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);\n};  // class UnitTestImpl\n\n// Convenience function for accessing the global UnitTest\n// implementation object.\ninline UnitTestImpl* GetUnitTestImpl() {\n  return UnitTest::GetInstance()->impl();\n}\n\n#if GTEST_USES_SIMPLE_RE\n\n// Internal helper functions for implementing the simple regular\n// expression matcher.\nGTEST_API_ bool IsInSet(char ch, const char* str);\nGTEST_API_ bool IsAsciiDigit(char ch);\nGTEST_API_ bool IsAsciiPunct(char ch);\nGTEST_API_ bool IsRepeat(char ch);\nGTEST_API_ bool IsAsciiWhiteSpace(char ch);\nGTEST_API_ bool IsAsciiWordChar(char ch);\nGTEST_API_ bool IsValidEscape(char ch);\nGTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);\nGTEST_API_ bool ValidateRegex(const char* regex);\nGTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);\nGTEST_API_ bool MatchRepetitionAndRegexAtHead(\n    bool escaped, char ch, char repeat, const char* regex, const char* str);\nGTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);\n\n#endif  // GTEST_USES_SIMPLE_RE\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.\nGTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);\nGTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);\n\n#if GTEST_HAS_DEATH_TEST\n\n// Returns the message describing the last system error, regardless of the\n// platform.\nGTEST_API_ std::string GetLastErrnoDescription();\n\n// Attempts to parse a string into a positive integer pointed to by the\n// number parameter.  Returns true if that is possible.\n// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use\n// it here.\ntemplate <typename Integer>\nbool ParseNaturalNumber(const ::std::string& str, Integer* number) {\n  // Fail fast if the given string does not begin with a digit;\n  // this bypasses strtoXXX's \"optional leading whitespace and plus\n  // or minus sign\" semantics, which are undesirable here.\n  if (str.empty() || !IsDigit(str[0])) {\n    return false;\n  }\n  errno = 0;\n\n  char* end;\n  // BiggestConvertible is the largest integer type that system-provided\n  // string-to-number conversion routines can return.\n  using BiggestConvertible = unsigned long long;  // NOLINT\n\n  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);  // NOLINT\n  const bool parse_success = *end == '\\0' && errno == 0;\n\n  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));\n\n  const Integer result = static_cast<Integer>(parsed);\n  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {\n    *number = result;\n    return true;\n  }\n  return false;\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n// TestResult contains some private methods that should be hidden from\n// Google Test user but are required for testing. This class allow our tests\n// to access them.\n//\n// This class is supplied only for the purpose of testing Google Test's own\n// constructs. Do not use it in user tests, either directly or indirectly.\nclass TestResultAccessor {\n public:\n  static void RecordProperty(TestResult* test_result,\n                             const std::string& xml_element,\n                             const TestProperty& property) {\n    test_result->RecordProperty(xml_element, property);\n  }\n\n  static void ClearTestPartResults(TestResult* test_result) {\n    test_result->ClearTestPartResults();\n  }\n\n  static const std::vector<testing::TestPartResult>& test_part_results(\n      const TestResult& test_result) {\n    return test_result.test_part_results();\n  }\n};\n\n#if GTEST_CAN_STREAM_RESULTS_\n\n// Streams test results to the given port on the given host machine.\nclass StreamingListener : public EmptyTestEventListener {\n public:\n  // Abstract base class for writing strings to a socket.\n  class AbstractSocketWriter {\n   public:\n    virtual ~AbstractSocketWriter() {}\n\n    // Sends a string to the socket.\n    virtual void Send(const std::string& message) = 0;\n\n    // Closes the socket.\n    virtual void CloseConnection() {}\n\n    // Sends a string and a newline to the socket.\n    void SendLn(const std::string& message) { Send(message + \"\\n\"); }\n  };\n\n  // Concrete class for actually writing strings to a socket.\n  class SocketWriter : public AbstractSocketWriter {\n   public:\n    SocketWriter(const std::string& host, const std::string& port)\n        : sockfd_(-1), host_name_(host), port_num_(port) {\n      MakeConnection();\n    }\n\n    ~SocketWriter() override {\n      if (sockfd_ != -1)\n        CloseConnection();\n    }\n\n    // Sends a string to the socket.\n    void Send(const std::string& message) override {\n      GTEST_CHECK_(sockfd_ != -1)\n          << \"Send() can be called only when there is a connection.\";\n\n      const auto len = static_cast<size_t>(message.length());\n      if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) {\n        GTEST_LOG_(WARNING)\n            << \"stream_result_to: failed to stream to \"\n            << host_name_ << \":\" << port_num_;\n      }\n    }\n\n   private:\n    // Creates a client socket and connects to the server.\n    void MakeConnection();\n\n    // Closes the socket.\n    void CloseConnection() override {\n      GTEST_CHECK_(sockfd_ != -1)\n          << \"CloseConnection() can be called only when there is a connection.\";\n\n      close(sockfd_);\n      sockfd_ = -1;\n    }\n\n    int sockfd_;  // socket file descriptor\n    const std::string host_name_;\n    const std::string port_num_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);\n  };  // class SocketWriter\n\n  // Escapes '=', '&', '%', and '\\n' characters in str as \"%xx\".\n  static std::string UrlEncode(const char* str);\n\n  StreamingListener(const std::string& host, const std::string& port)\n      : socket_writer_(new SocketWriter(host, port)) {\n    Start();\n  }\n\n  explicit StreamingListener(AbstractSocketWriter* socket_writer)\n      : socket_writer_(socket_writer) { Start(); }\n\n  void OnTestProgramStart(const UnitTest& /* unit_test */) override {\n    SendLn(\"event=TestProgramStart\");\n  }\n\n  void OnTestProgramEnd(const UnitTest& unit_test) override {\n    // Note that Google Test current only report elapsed time for each\n    // test iteration, not for the entire test program.\n    SendLn(\"event=TestProgramEnd&passed=\" + FormatBool(unit_test.Passed()));\n\n    // Notify the streaming server to stop.\n    socket_writer_->CloseConnection();\n  }\n\n  void OnTestIterationStart(const UnitTest& /* unit_test */,\n                            int iteration) override {\n    SendLn(\"event=TestIterationStart&iteration=\" +\n           StreamableToString(iteration));\n  }\n\n  void OnTestIterationEnd(const UnitTest& unit_test,\n                          int /* iteration */) override {\n    SendLn(\"event=TestIterationEnd&passed=\" +\n           FormatBool(unit_test.Passed()) + \"&elapsed_time=\" +\n           StreamableToString(unit_test.elapsed_time()) + \"ms\");\n  }\n\n  // Note that \"event=TestCaseStart\" is a wire format and has to remain\n  // \"case\" for compatibility\n  void OnTestCaseStart(const TestCase& test_case) override {\n    SendLn(std::string(\"event=TestCaseStart&name=\") + test_case.name());\n  }\n\n  // Note that \"event=TestCaseEnd\" is a wire format and has to remain\n  // \"case\" for compatibility\n  void OnTestCaseEnd(const TestCase& test_case) override {\n    SendLn(\"event=TestCaseEnd&passed=\" + FormatBool(test_case.Passed()) +\n           \"&elapsed_time=\" + StreamableToString(test_case.elapsed_time()) +\n           \"ms\");\n  }\n\n  void OnTestStart(const TestInfo& test_info) override {\n    SendLn(std::string(\"event=TestStart&name=\") + test_info.name());\n  }\n\n  void OnTestEnd(const TestInfo& test_info) override {\n    SendLn(\"event=TestEnd&passed=\" +\n           FormatBool((test_info.result())->Passed()) +\n           \"&elapsed_time=\" +\n           StreamableToString((test_info.result())->elapsed_time()) + \"ms\");\n  }\n\n  void OnTestPartResult(const TestPartResult& test_part_result) override {\n    const char* file_name = test_part_result.file_name();\n    if (file_name == nullptr) file_name = \"\";\n    SendLn(\"event=TestPartResult&file=\" + UrlEncode(file_name) +\n           \"&line=\" + StreamableToString(test_part_result.line_number()) +\n           \"&message=\" + UrlEncode(test_part_result.message()));\n  }\n\n private:\n  // Sends the given message and a newline to the socket.\n  void SendLn(const std::string& message) { socket_writer_->SendLn(message); }\n\n  // Called at the start of streaming to notify the receiver what\n  // protocol we are using.\n  void Start() { SendLn(\"gtest_streaming_protocol_version=1.0\"); }\n\n  std::string FormatBool(bool value) { return value ? \"1\" : \"0\"; }\n\n  const std::unique_ptr<AbstractSocketWriter> socket_writer_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);\n};  // class StreamingListener\n\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n}  // namespace internal\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n#endif  // GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_\n\n#if GTEST_OS_WINDOWS\n# define vsnprintf _vsnprintf\n#endif  // GTEST_OS_WINDOWS\n\n#if GTEST_OS_MAC\n#ifndef GTEST_OS_IOS\n#include <crt_externs.h>\n#endif\n#endif\n\n#if GTEST_HAS_ABSL\n#include \"absl/debugging/failure_signal_handler.h\"\n#include \"absl/debugging/stacktrace.h\"\n#include \"absl/debugging/symbolize.h\"\n#include \"absl/strings/str_cat.h\"\n#endif  // GTEST_HAS_ABSL\n\nnamespace testing {\n\nusing internal::CountIf;\nusing internal::ForEach;\nusing internal::GetElementOr;\nusing internal::Shuffle;\n\n// Constants.\n\n// A test whose test suite name or test name matches this filter is\n// disabled and not run.\nstatic const char kDisableTestFilter[] = \"DISABLED_*:*/DISABLED_*\";\n\n// A test suite whose name matches this filter is considered a death\n// test suite and will be run before test suites whose name doesn't\n// match this filter.\nstatic const char kDeathTestSuiteFilter[] = \"*DeathTest:*DeathTest/*\";\n\n// A test filter that matches everything.\nstatic const char kUniversalFilter[] = \"*\";\n\n// The default output format.\nstatic const char kDefaultOutputFormat[] = \"xml\";\n// The default output file.\nstatic const char kDefaultOutputFile[] = \"test_detail\";\n\n// The environment variable name for the test shard index.\nstatic const char kTestShardIndex[] = \"GTEST_SHARD_INDEX\";\n// The environment variable name for the total number of test shards.\nstatic const char kTestTotalShards[] = \"GTEST_TOTAL_SHARDS\";\n// The environment variable name for the test shard status file.\nstatic const char kTestShardStatusFile[] = \"GTEST_SHARD_STATUS_FILE\";\n\nnamespace internal {\n\n// The text used in failure messages to indicate the start of the\n// stack trace.\nconst char kStackTraceMarker[] = \"\\nStack trace:\\n\";\n\n// g_help_flag is true if and only if the --help flag or an equivalent form\n// is specified on the command line.\nbool g_help_flag = false;\n\n// Utilty function to Open File for Writing\nstatic FILE* OpenFileForWriting(const std::string& output_file) {\n  FILE* fileout = nullptr;\n  FilePath output_file_path(output_file);\n  FilePath output_dir(output_file_path.RemoveFileName());\n\n  if (output_dir.CreateDirectoriesRecursively()) {\n    fileout = posix::FOpen(output_file.c_str(), \"w\");\n  }\n  if (fileout == nullptr) {\n    GTEST_LOG_(FATAL) << \"Unable to open file \\\"\" << output_file << \"\\\"\";\n  }\n  return fileout;\n}\n\n}  // namespace internal\n\n// Bazel passes in the argument to '--test_filter' via the TESTBRIDGE_TEST_ONLY\n// environment variable.\nstatic const char* GetDefaultFilter() {\n  const char* const testbridge_test_only =\n      internal::posix::GetEnv(\"TESTBRIDGE_TEST_ONLY\");\n  if (testbridge_test_only != nullptr) {\n    return testbridge_test_only;\n  }\n  return kUniversalFilter;\n}\n\n// Bazel passes in the argument to '--test_runner_fail_fast' via the\n// TESTBRIDGE_TEST_RUNNER_FAIL_FAST environment variable.\nstatic bool GetDefaultFailFast() {\n  const char* const testbridge_test_runner_fail_fast =\n      internal::posix::GetEnv(\"TESTBRIDGE_TEST_RUNNER_FAIL_FAST\");\n  if (testbridge_test_runner_fail_fast != nullptr) {\n    return strcmp(testbridge_test_runner_fail_fast, \"1\") == 0;\n  }\n  return false;\n}\n\nGTEST_DEFINE_bool_(\n    fail_fast, internal::BoolFromGTestEnv(\"fail_fast\", GetDefaultFailFast()),\n    \"True if and only if a test failure should stop further test execution.\");\n\nGTEST_DEFINE_bool_(\n    also_run_disabled_tests,\n    internal::BoolFromGTestEnv(\"also_run_disabled_tests\", false),\n    \"Run disabled tests too, in addition to the tests normally being run.\");\n\nGTEST_DEFINE_bool_(\n    break_on_failure, internal::BoolFromGTestEnv(\"break_on_failure\", false),\n    \"True if and only if a failed assertion should be a debugger \"\n    \"break-point.\");\n\nGTEST_DEFINE_bool_(catch_exceptions,\n                   internal::BoolFromGTestEnv(\"catch_exceptions\", true),\n                   \"True if and only if \" GTEST_NAME_\n                   \" should catch exceptions and treat them as test failures.\");\n\nGTEST_DEFINE_string_(\n    color,\n    internal::StringFromGTestEnv(\"color\", \"auto\"),\n    \"Whether to use colors in the output.  Valid values: yes, no, \"\n    \"and auto.  'auto' means to use colors if the output is \"\n    \"being sent to a terminal and the TERM environment variable \"\n    \"is set to a terminal type that supports colors.\");\n\nGTEST_DEFINE_string_(\n    filter,\n    internal::StringFromGTestEnv(\"filter\", GetDefaultFilter()),\n    \"A colon-separated list of glob (not regex) patterns \"\n    \"for filtering the tests to run, optionally followed by a \"\n    \"'-' and a : separated list of negative patterns (tests to \"\n    \"exclude).  A test is run if it matches one of the positive \"\n    \"patterns and does not match any of the negative patterns.\");\n\nGTEST_DEFINE_bool_(\n    install_failure_signal_handler,\n    internal::BoolFromGTestEnv(\"install_failure_signal_handler\", false),\n    \"If true and supported on the current platform, \" GTEST_NAME_ \" should \"\n    \"install a signal handler that dumps debugging information when fatal \"\n    \"signals are raised.\");\n\nGTEST_DEFINE_bool_(list_tests, false,\n                   \"List all tests without running them.\");\n\n// The net priority order after flag processing is thus:\n//   --gtest_output command line flag\n//   GTEST_OUTPUT environment variable\n//   XML_OUTPUT_FILE environment variable\n//   ''\nGTEST_DEFINE_string_(\n    output,\n    internal::StringFromGTestEnv(\"output\",\n      internal::OutputFlagAlsoCheckEnvVar().c_str()),\n    \"A format (defaults to \\\"xml\\\" but can be specified to be \\\"json\\\"), \"\n    \"optionally followed by a colon and an output file name or directory. \"\n    \"A directory is indicated by a trailing pathname separator. \"\n    \"Examples: \\\"xml:filename.xml\\\", \\\"xml::directoryname/\\\". \"\n    \"If a directory is specified, output files will be created \"\n    \"within that directory, with file-names based on the test \"\n    \"executable's name and, if necessary, made unique by adding \"\n    \"digits.\");\n\nGTEST_DEFINE_bool_(\n    brief, internal::BoolFromGTestEnv(\"brief\", false),\n    \"True if only test failures should be displayed in text output.\");\n\nGTEST_DEFINE_bool_(print_time, internal::BoolFromGTestEnv(\"print_time\", true),\n                   \"True if and only if \" GTEST_NAME_\n                   \" should display elapsed time in text output.\");\n\nGTEST_DEFINE_bool_(print_utf8, internal::BoolFromGTestEnv(\"print_utf8\", true),\n                   \"True if and only if \" GTEST_NAME_\n                   \" prints UTF8 characters as text.\");\n\nGTEST_DEFINE_int32_(\n    random_seed,\n    internal::Int32FromGTestEnv(\"random_seed\", 0),\n    \"Random number seed to use when shuffling test orders.  Must be in range \"\n    \"[1, 99999], or 0 to use a seed based on the current time.\");\n\nGTEST_DEFINE_int32_(\n    repeat,\n    internal::Int32FromGTestEnv(\"repeat\", 1),\n    \"How many times to repeat each test.  Specify a negative number \"\n    \"for repeating forever.  Useful for shaking out flaky tests.\");\n\nGTEST_DEFINE_bool_(show_internal_stack_frames, false,\n                   \"True if and only if \" GTEST_NAME_\n                   \" should include internal stack frames when \"\n                   \"printing test failure stack traces.\");\n\nGTEST_DEFINE_bool_(shuffle, internal::BoolFromGTestEnv(\"shuffle\", false),\n                   \"True if and only if \" GTEST_NAME_\n                   \" should randomize tests' order on every run.\");\n\nGTEST_DEFINE_int32_(\n    stack_trace_depth,\n    internal::Int32FromGTestEnv(\"stack_trace_depth\", kMaxStackTraceDepth),\n    \"The maximum number of stack frames to print when an \"\n    \"assertion fails.  The valid range is 0 through 100, inclusive.\");\n\nGTEST_DEFINE_string_(\n    stream_result_to,\n    internal::StringFromGTestEnv(\"stream_result_to\", \"\"),\n    \"This flag specifies the host name and the port number on which to stream \"\n    \"test results. Example: \\\"localhost:555\\\". The flag is effective only on \"\n    \"Linux.\");\n\nGTEST_DEFINE_bool_(\n    throw_on_failure,\n    internal::BoolFromGTestEnv(\"throw_on_failure\", false),\n    \"When this flag is specified, a failed assertion will throw an exception \"\n    \"if exceptions are enabled or exit the program with a non-zero code \"\n    \"otherwise. For use with an external test framework.\");\n\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\nGTEST_DEFINE_string_(\n    flagfile,\n    internal::StringFromGTestEnv(\"flagfile\", \"\"),\n    \"This flag specifies the flagfile to read command-line flags from.\");\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n\nnamespace internal {\n\n// Generates a random number from [0, range), using a Linear\n// Congruential Generator (LCG).  Crashes if 'range' is 0 or greater\n// than kMaxRange.\nuint32_t Random::Generate(uint32_t range) {\n  // These constants are the same as are used in glibc's rand(3).\n  // Use wider types than necessary to prevent unsigned overflow diagnostics.\n  state_ = static_cast<uint32_t>(1103515245ULL*state_ + 12345U) % kMaxRange;\n\n  GTEST_CHECK_(range > 0)\n      << \"Cannot generate a number in the range [0, 0).\";\n  GTEST_CHECK_(range <= kMaxRange)\n      << \"Generation of a number in [0, \" << range << \") was requested, \"\n      << \"but this can only generate numbers in [0, \" << kMaxRange << \").\";\n\n  // Converting via modulus introduces a bit of downward bias, but\n  // it's simple, and a linear congruential generator isn't too good\n  // to begin with.\n  return state_ % range;\n}\n\n// GTestIsInitialized() returns true if and only if the user has initialized\n// Google Test.  Useful for catching the user mistake of not initializing\n// Google Test before calling RUN_ALL_TESTS().\nstatic bool GTestIsInitialized() { return GetArgvs().size() > 0; }\n\n// Iterates over a vector of TestSuites, keeping a running sum of the\n// results of calling a given int-returning method on each.\n// Returns the sum.\nstatic int SumOverTestSuiteList(const std::vector<TestSuite*>& case_list,\n                                int (TestSuite::*method)() const) {\n  int sum = 0;\n  for (size_t i = 0; i < case_list.size(); i++) {\n    sum += (case_list[i]->*method)();\n  }\n  return sum;\n}\n\n// Returns true if and only if the test suite passed.\nstatic bool TestSuitePassed(const TestSuite* test_suite) {\n  return test_suite->should_run() && test_suite->Passed();\n}\n\n// Returns true if and only if the test suite failed.\nstatic bool TestSuiteFailed(const TestSuite* test_suite) {\n  return test_suite->should_run() && test_suite->Failed();\n}\n\n// Returns true if and only if test_suite contains at least one test that\n// should run.\nstatic bool ShouldRunTestSuite(const TestSuite* test_suite) {\n  return test_suite->should_run();\n}\n\n// AssertHelper constructor.\nAssertHelper::AssertHelper(TestPartResult::Type type,\n                           const char* file,\n                           int line,\n                           const char* message)\n    : data_(new AssertHelperData(type, file, line, message)) {\n}\n\nAssertHelper::~AssertHelper() {\n  delete data_;\n}\n\n// Message assignment, for assertion streaming support.\nvoid AssertHelper::operator=(const Message& message) const {\n  UnitTest::GetInstance()->\n    AddTestPartResult(data_->type, data_->file, data_->line,\n                      AppendUserMessage(data_->message, message),\n                      UnitTest::GetInstance()->impl()\n                      ->CurrentOsStackTraceExceptTop(1)\n                      // Skips the stack frame for this function itself.\n                      );  // NOLINT\n}\n\nnamespace {\n\n// When TEST_P is found without a matching INSTANTIATE_TEST_SUITE_P\n// to creates test cases for it, a synthetic test case is\n// inserted to report ether an error or a log message.\n//\n// This configuration bit will likely be removed at some point.\nconstexpr bool kErrorOnUninstantiatedParameterizedTest = true;\nconstexpr bool kErrorOnUninstantiatedTypeParameterizedTest = true;\n\n// A test that fails at a given file/line location with a given message.\nclass FailureTest : public Test {\n public:\n  explicit FailureTest(const CodeLocation& loc, std::string error_message,\n                       bool as_error)\n      : loc_(loc),\n        error_message_(std::move(error_message)),\n        as_error_(as_error) {}\n\n  void TestBody() override {\n    if (as_error_) {\n      AssertHelper(TestPartResult::kNonFatalFailure, loc_.file.c_str(),\n                   loc_.line, \"\") = Message() << error_message_;\n    } else {\n      std::cout << error_message_ << std::endl;\n    }\n  }\n\n private:\n  const CodeLocation loc_;\n  const std::string error_message_;\n  const bool as_error_;\n};\n\n\n}  // namespace\n\nstd::set<std::string>* GetIgnoredParameterizedTestSuites() {\n  return UnitTest::GetInstance()->impl()->ignored_parameterized_test_suites();\n}\n\n// Add a given test_suit to the list of them allow to go un-instantiated.\nMarkAsIgnored::MarkAsIgnored(const char* test_suite) {\n  GetIgnoredParameterizedTestSuites()->insert(test_suite);\n}\n\n// If this parameterized test suite has no instantiations (and that\n// has not been marked as okay), emit a test case reporting that.\nvoid InsertSyntheticTestCase(const std::string& name, CodeLocation location,\n                             bool has_test_p) {\n  const auto& ignored = *GetIgnoredParameterizedTestSuites();\n  if (ignored.find(name) != ignored.end()) return;\n\n  const char kMissingInstantiation[] =  //\n      \" is defined via TEST_P, but never instantiated. None of the test cases \"\n      \"will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only \"\n      \"ones provided expand to nothing.\"\n      \"\\n\\n\"\n      \"Ideally, TEST_P definitions should only ever be included as part of \"\n      \"binaries that intend to use them. (As opposed to, for example, being \"\n      \"placed in a library that may be linked in to get other utilities.)\";\n\n  const char kMissingTestCase[] =  //\n      \" is instantiated via INSTANTIATE_TEST_SUITE_P, but no tests are \"\n      \"defined via TEST_P . No test cases will run.\"\n      \"\\n\\n\"\n      \"Ideally, INSTANTIATE_TEST_SUITE_P should only ever be invoked from \"\n      \"code that always depend on code that provides TEST_P. Failing to do \"\n      \"so is often an indication of dead code, e.g. the last TEST_P was \"\n      \"removed but the rest got left behind.\";\n\n  std::string message =\n      \"Parameterized test suite \" + name +\n      (has_test_p ? kMissingInstantiation : kMissingTestCase) +\n      \"\\n\\n\"\n      \"To suppress this error for this test suite, insert the following line \"\n      \"(in a non-header) in the namespace it is defined in:\"\n      \"\\n\\n\"\n      \"GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(\" + name + \");\";\n\n  std::string full_name = \"UninstantiatedParameterizedTestSuite<\" + name + \">\";\n  RegisterTest(  //\n      \"GoogleTestVerification\", full_name.c_str(),\n      nullptr,  // No type parameter.\n      nullptr,  // No value parameter.\n      location.file.c_str(), location.line, [message, location] {\n        return new FailureTest(location, message,\n                               kErrorOnUninstantiatedParameterizedTest);\n      });\n}\n\nvoid RegisterTypeParameterizedTestSuite(const char* test_suite_name,\n                                        CodeLocation code_location) {\n  GetUnitTestImpl()->type_parameterized_test_registry().RegisterTestSuite(\n      test_suite_name, code_location);\n}\n\nvoid RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {\n  GetUnitTestImpl()\n      ->type_parameterized_test_registry()\n      .RegisterInstantiation(case_name);\n}\n\nvoid TypeParameterizedTestSuiteRegistry::RegisterTestSuite(\n    const char* test_suite_name, CodeLocation code_location) {\n  suites_.emplace(std::string(test_suite_name),\n                 TypeParameterizedTestSuiteInfo(code_location));\n}\n\nvoid TypeParameterizedTestSuiteRegistry::RegisterInstantiation(\n        const char* test_suite_name) {\n  auto it = suites_.find(std::string(test_suite_name));\n  if (it != suites_.end()) {\n    it->second.instantiated = true;\n  } else {\n    GTEST_LOG_(ERROR) << \"Unknown type parameterized test suit '\"\n                      << test_suite_name << \"'\";\n  }\n}\n\nvoid TypeParameterizedTestSuiteRegistry::CheckForInstantiations() {\n  const auto& ignored = *GetIgnoredParameterizedTestSuites();\n  for (const auto& testcase : suites_) {\n    if (testcase.second.instantiated) continue;\n    if (ignored.find(testcase.first) != ignored.end()) continue;\n\n    std::string message =\n        \"Type parameterized test suite \" + testcase.first +\n        \" is defined via REGISTER_TYPED_TEST_SUITE_P, but never instantiated \"\n        \"via INSTANTIATE_TYPED_TEST_SUITE_P. None of the test cases will run.\"\n        \"\\n\\n\"\n        \"Ideally, TYPED_TEST_P definitions should only ever be included as \"\n        \"part of binaries that intend to use them. (As opposed to, for \"\n        \"example, being placed in a library that may be linked in to get other \"\n        \"utilities.)\"\n        \"\\n\\n\"\n        \"To suppress this error for this test suite, insert the following line \"\n        \"(in a non-header) in the namespace it is defined in:\"\n        \"\\n\\n\"\n        \"GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(\" +\n        testcase.first + \");\";\n\n    std::string full_name =\n        \"UninstantiatedTypeParameterizedTestSuite<\" + testcase.first + \">\";\n    RegisterTest(  //\n        \"GoogleTestVerification\", full_name.c_str(),\n        nullptr,  // No type parameter.\n        nullptr,  // No value parameter.\n        testcase.second.code_location.file.c_str(),\n        testcase.second.code_location.line, [message, testcase] {\n          return new FailureTest(testcase.second.code_location, message,\n                                 kErrorOnUninstantiatedTypeParameterizedTest);\n        });\n  }\n}\n\n// A copy of all command line arguments.  Set by InitGoogleTest().\nstatic ::std::vector<std::string> g_argvs;\n\n::std::vector<std::string> GetArgvs() {\n#if defined(GTEST_CUSTOM_GET_ARGVS_)\n  // GTEST_CUSTOM_GET_ARGVS_() may return a container of std::string or\n  // ::string. This code converts it to the appropriate type.\n  const auto& custom = GTEST_CUSTOM_GET_ARGVS_();\n  return ::std::vector<std::string>(custom.begin(), custom.end());\n#else   // defined(GTEST_CUSTOM_GET_ARGVS_)\n  return g_argvs;\n#endif  // defined(GTEST_CUSTOM_GET_ARGVS_)\n}\n\n// Returns the current application's name, removing directory path if that\n// is present.\nFilePath GetCurrentExecutableName() {\n  FilePath result;\n\n#if GTEST_OS_WINDOWS || GTEST_OS_OS2\n  result.Set(FilePath(GetArgvs()[0]).RemoveExtension(\"exe\"));\n#else\n  result.Set(FilePath(GetArgvs()[0]));\n#endif  // GTEST_OS_WINDOWS\n\n  return result.RemoveDirectoryName();\n}\n\n// Functions for processing the gtest_output flag.\n\n// Returns the output format, or \"\" for normal printed output.\nstd::string UnitTestOptions::GetOutputFormat() {\n  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();\n  const char* const colon = strchr(gtest_output_flag, ':');\n  return (colon == nullptr)\n             ? std::string(gtest_output_flag)\n             : std::string(gtest_output_flag,\n                           static_cast<size_t>(colon - gtest_output_flag));\n}\n\n// Returns the name of the requested output file, or the default if none\n// was explicitly specified.\nstd::string UnitTestOptions::GetAbsolutePathToOutputFile() {\n  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();\n\n  std::string format = GetOutputFormat();\n  if (format.empty())\n    format = std::string(kDefaultOutputFormat);\n\n  const char* const colon = strchr(gtest_output_flag, ':');\n  if (colon == nullptr)\n    return internal::FilePath::MakeFileName(\n        internal::FilePath(\n            UnitTest::GetInstance()->original_working_dir()),\n        internal::FilePath(kDefaultOutputFile), 0,\n        format.c_str()).string();\n\n  internal::FilePath output_name(colon + 1);\n  if (!output_name.IsAbsolutePath())\n    output_name = internal::FilePath::ConcatPaths(\n        internal::FilePath(UnitTest::GetInstance()->original_working_dir()),\n        internal::FilePath(colon + 1));\n\n  if (!output_name.IsDirectory())\n    return output_name.string();\n\n  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(\n      output_name, internal::GetCurrentExecutableName(),\n      GetOutputFormat().c_str()));\n  return result.string();\n}\n\n// Returns true if and only if the wildcard pattern matches the string. Each\n// pattern consists of regular characters, single-character wildcards (?), and\n// multi-character wildcards (*).\n//\n// This function implements a linear-time string globbing algorithm based on\n// https://research.swtch.com/glob.\nstatic bool PatternMatchesString(const std::string& name_str,\n                                 const char* pattern, const char* pattern_end) {\n  const char* name = name_str.c_str();\n  const char* const name_begin = name;\n  const char* const name_end = name + name_str.size();\n\n  const char* pattern_next = pattern;\n  const char* name_next = name;\n\n  while (pattern < pattern_end || name < name_end) {\n    if (pattern < pattern_end) {\n      switch (*pattern) {\n        default:  // Match an ordinary character.\n          if (name < name_end && *name == *pattern) {\n            ++pattern;\n            ++name;\n            continue;\n          }\n          break;\n        case '?':  // Match any single character.\n          if (name < name_end) {\n            ++pattern;\n            ++name;\n            continue;\n          }\n          break;\n        case '*':\n          // Match zero or more characters. Start by skipping over the wildcard\n          // and matching zero characters from name. If that fails, restart and\n          // match one more character than the last attempt.\n          pattern_next = pattern;\n          name_next = name + 1;\n          ++pattern;\n          continue;\n      }\n    }\n    // Failed to match a character. Restart if possible.\n    if (name_begin < name_next && name_next <= name_end) {\n      pattern = pattern_next;\n      name = name_next;\n      continue;\n    }\n    return false;\n  }\n  return true;\n}\n\nbool UnitTestOptions::MatchesFilter(const std::string& name_str,\n                                    const char* filter) {\n  // The filter is a list of patterns separated by colons (:).\n  const char* pattern = filter;\n  while (true) {\n    // Find the bounds of this pattern.\n    const char* const next_sep = strchr(pattern, ':');\n    const char* const pattern_end =\n        next_sep != nullptr ? next_sep : pattern + strlen(pattern);\n\n    // Check if this pattern matches name_str.\n    if (PatternMatchesString(name_str, pattern, pattern_end)) {\n      break;\n    }\n\n    // Give up on this pattern. However, if we found a pattern separator (:),\n    // advance to the next pattern (skipping over the separator) and restart.\n    if (next_sep == nullptr) {\n      return false;\n    }\n    pattern = next_sep + 1;\n  }\n  return true;\n}\n\n// Returns true if and only if the user-specified filter matches the test\n// suite name and the test name.\nbool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,\n                                        const std::string& test_name) {\n  const std::string& full_name = test_suite_name + \".\" + test_name.c_str();\n\n  // Split --gtest_filter at '-', if there is one, to separate into\n  // positive filter and negative filter portions\n  const char* const p = GTEST_FLAG(filter).c_str();\n  const char* const dash = strchr(p, '-');\n  std::string positive;\n  std::string negative;\n  if (dash == nullptr) {\n    positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter\n    negative = \"\";\n  } else {\n    positive = std::string(p, dash);   // Everything up to the dash\n    negative = std::string(dash + 1);  // Everything after the dash\n    if (positive.empty()) {\n      // Treat '-test1' as the same as '*-test1'\n      positive = kUniversalFilter;\n    }\n  }\n\n  // A filter is a colon-separated list of patterns.  It matches a\n  // test if any pattern in it matches the test.\n  return (MatchesFilter(full_name, positive.c_str()) &&\n          !MatchesFilter(full_name, negative.c_str()));\n}\n\n#if GTEST_HAS_SEH\n// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the\n// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.\n// This function is useful as an __except condition.\nint UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {\n  // Google Test should handle a SEH exception if:\n  //   1. the user wants it to, AND\n  //   2. this is not a breakpoint exception, AND\n  //   3. this is not a C++ exception (VC++ implements them via SEH,\n  //      apparently).\n  //\n  // SEH exception code for C++ exceptions.\n  // (see http://support.microsoft.com/kb/185294 for more information).\n  const DWORD kCxxExceptionCode = 0xe06d7363;\n\n  bool should_handle = true;\n\n  if (!GTEST_FLAG(catch_exceptions))\n    should_handle = false;\n  else if (exception_code == EXCEPTION_BREAKPOINT)\n    should_handle = false;\n  else if (exception_code == kCxxExceptionCode)\n    should_handle = false;\n\n  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;\n}\n#endif  // GTEST_HAS_SEH\n\n}  // namespace internal\n\n// The c'tor sets this object as the test part result reporter used by\n// Google Test.  The 'result' parameter specifies where to report the\n// results. Intercepts only failures from the current thread.\nScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(\n    TestPartResultArray* result)\n    : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),\n      result_(result) {\n  Init();\n}\n\n// The c'tor sets this object as the test part result reporter used by\n// Google Test.  The 'result' parameter specifies where to report the\n// results.\nScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(\n    InterceptMode intercept_mode, TestPartResultArray* result)\n    : intercept_mode_(intercept_mode),\n      result_(result) {\n  Init();\n}\n\nvoid ScopedFakeTestPartResultReporter::Init() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {\n    old_reporter_ = impl->GetGlobalTestPartResultReporter();\n    impl->SetGlobalTestPartResultReporter(this);\n  } else {\n    old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();\n    impl->SetTestPartResultReporterForCurrentThread(this);\n  }\n}\n\n// The d'tor restores the test part result reporter used by Google Test\n// before.\nScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {\n    impl->SetGlobalTestPartResultReporter(old_reporter_);\n  } else {\n    impl->SetTestPartResultReporterForCurrentThread(old_reporter_);\n  }\n}\n\n// Increments the test part result count and remembers the result.\n// This method is from the TestPartResultReporterInterface interface.\nvoid ScopedFakeTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  result_->Append(result);\n}\n\nnamespace internal {\n\n// Returns the type ID of ::testing::Test.  We should always call this\n// instead of GetTypeId< ::testing::Test>() to get the type ID of\n// testing::Test.  This is to work around a suspected linker bug when\n// using Google Test as a framework on Mac OS X.  The bug causes\n// GetTypeId< ::testing::Test>() to return different values depending\n// on whether the call is from the Google Test framework itself or\n// from user test code.  GetTestTypeId() is guaranteed to always\n// return the same value, as it always calls GetTypeId<>() from the\n// gtest.cc, which is within the Google Test framework.\nTypeId GetTestTypeId() {\n  return GetTypeId<Test>();\n}\n\n// The value of GetTestTypeId() as seen from within the Google Test\n// library.  This is solely for testing GetTestTypeId().\nextern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();\n\n// This predicate-formatter checks that 'results' contains a test part\n// failure of the given type and that the failure message contains the\n// given substring.\nstatic AssertionResult HasOneFailure(const char* /* results_expr */,\n                                     const char* /* type_expr */,\n                                     const char* /* substr_expr */,\n                                     const TestPartResultArray& results,\n                                     TestPartResult::Type type,\n                                     const std::string& substr) {\n  const std::string expected(type == TestPartResult::kFatalFailure ?\n                        \"1 fatal failure\" :\n                        \"1 non-fatal failure\");\n  Message msg;\n  if (results.size() != 1) {\n    msg << \"Expected: \" << expected << \"\\n\"\n        << \"  Actual: \" << results.size() << \" failures\";\n    for (int i = 0; i < results.size(); i++) {\n      msg << \"\\n\" << results.GetTestPartResult(i);\n    }\n    return AssertionFailure() << msg;\n  }\n\n  const TestPartResult& r = results.GetTestPartResult(0);\n  if (r.type() != type) {\n    return AssertionFailure() << \"Expected: \" << expected << \"\\n\"\n                              << \"  Actual:\\n\"\n                              << r;\n  }\n\n  if (strstr(r.message(), substr.c_str()) == nullptr) {\n    return AssertionFailure() << \"Expected: \" << expected << \" containing \\\"\"\n                              << substr << \"\\\"\\n\"\n                              << \"  Actual:\\n\"\n                              << r;\n  }\n\n  return AssertionSuccess();\n}\n\n// The constructor of SingleFailureChecker remembers where to look up\n// test part results, what type of failure we expect, and what\n// substring the failure message should contain.\nSingleFailureChecker::SingleFailureChecker(const TestPartResultArray* results,\n                                           TestPartResult::Type type,\n                                           const std::string& substr)\n    : results_(results), type_(type), substr_(substr) {}\n\n// The destructor of SingleFailureChecker verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nSingleFailureChecker::~SingleFailureChecker() {\n  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);\n}\n\nDefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(\n    UnitTestImpl* unit_test) : unit_test_(unit_test) {}\n\nvoid DefaultGlobalTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  unit_test_->current_test_result()->AddTestPartResult(result);\n  unit_test_->listeners()->repeater()->OnTestPartResult(result);\n}\n\nDefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(\n    UnitTestImpl* unit_test) : unit_test_(unit_test) {}\n\nvoid DefaultPerThreadTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);\n}\n\n// Returns the global test part result reporter.\nTestPartResultReporterInterface*\nUnitTestImpl::GetGlobalTestPartResultReporter() {\n  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);\n  return global_test_part_result_repoter_;\n}\n\n// Sets the global test part result reporter.\nvoid UnitTestImpl::SetGlobalTestPartResultReporter(\n    TestPartResultReporterInterface* reporter) {\n  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);\n  global_test_part_result_repoter_ = reporter;\n}\n\n// Returns the test part result reporter for the current thread.\nTestPartResultReporterInterface*\nUnitTestImpl::GetTestPartResultReporterForCurrentThread() {\n  return per_thread_test_part_result_reporter_.get();\n}\n\n// Sets the test part result reporter for the current thread.\nvoid UnitTestImpl::SetTestPartResultReporterForCurrentThread(\n    TestPartResultReporterInterface* reporter) {\n  per_thread_test_part_result_reporter_.set(reporter);\n}\n\n// Gets the number of successful test suites.\nint UnitTestImpl::successful_test_suite_count() const {\n  return CountIf(test_suites_, TestSuitePassed);\n}\n\n// Gets the number of failed test suites.\nint UnitTestImpl::failed_test_suite_count() const {\n  return CountIf(test_suites_, TestSuiteFailed);\n}\n\n// Gets the number of all test suites.\nint UnitTestImpl::total_test_suite_count() const {\n  return static_cast<int>(test_suites_.size());\n}\n\n// Gets the number of all test suites that contain at least one test\n// that should run.\nint UnitTestImpl::test_suite_to_run_count() const {\n  return CountIf(test_suites_, ShouldRunTestSuite);\n}\n\n// Gets the number of successful tests.\nint UnitTestImpl::successful_test_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::successful_test_count);\n}\n\n// Gets the number of skipped tests.\nint UnitTestImpl::skipped_test_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::skipped_test_count);\n}\n\n// Gets the number of failed tests.\nint UnitTestImpl::failed_test_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::failed_test_count);\n}\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint UnitTestImpl::reportable_disabled_test_count() const {\n  return SumOverTestSuiteList(test_suites_,\n                              &TestSuite::reportable_disabled_test_count);\n}\n\n// Gets the number of disabled tests.\nint UnitTestImpl::disabled_test_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::disabled_test_count);\n}\n\n// Gets the number of tests to be printed in the XML report.\nint UnitTestImpl::reportable_test_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::reportable_test_count);\n}\n\n// Gets the number of all tests.\nint UnitTestImpl::total_test_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::total_test_count);\n}\n\n// Gets the number of tests that should run.\nint UnitTestImpl::test_to_run_count() const {\n  return SumOverTestSuiteList(test_suites_, &TestSuite::test_to_run_count);\n}\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// CurrentOsStackTraceExceptTop(1), Foo() will be included in the\n// trace but Bar() and CurrentOsStackTraceExceptTop() won't.\nstd::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {\n  return os_stack_trace_getter()->CurrentStackTrace(\n      static_cast<int>(GTEST_FLAG(stack_trace_depth)),\n      skip_count + 1\n      // Skips the user-specified number of frames plus this function\n      // itself.\n      );  // NOLINT\n}\n\n// A helper class for measuring elapsed times.\nclass Timer {\n public:\n  Timer() : start_(std::chrono::steady_clock::now()) {}\n\n  // Return time elapsed in milliseconds since the timer was created.\n  TimeInMillis Elapsed() {\n    return std::chrono::duration_cast<std::chrono::milliseconds>(\n               std::chrono::steady_clock::now() - start_)\n        .count();\n  }\n\n private:\n  std::chrono::steady_clock::time_point start_;\n};\n\n// Returns a timestamp as milliseconds since the epoch. Note this time may jump\n// around subject to adjustments by the system, to measure elapsed time use\n// Timer instead.\nTimeInMillis GetTimeInMillis() {\n  return std::chrono::duration_cast<std::chrono::milliseconds>(\n             std::chrono::system_clock::now() -\n             std::chrono::system_clock::from_time_t(0))\n      .count();\n}\n\n// Utilities\n\n// class String.\n\n#if GTEST_OS_WINDOWS_MOBILE\n// Creates a UTF-16 wide string from the given ANSI string, allocating\n// memory using new. The caller is responsible for deleting the return\n// value using delete[]. Returns the wide string, or NULL if the\n// input is NULL.\nLPCWSTR String::AnsiToUtf16(const char* ansi) {\n  if (!ansi) return nullptr;\n  const int length = strlen(ansi);\n  const int unicode_length =\n      MultiByteToWideChar(CP_ACP, 0, ansi, length, nullptr, 0);\n  WCHAR* unicode = new WCHAR[unicode_length + 1];\n  MultiByteToWideChar(CP_ACP, 0, ansi, length,\n                      unicode, unicode_length);\n  unicode[unicode_length] = 0;\n  return unicode;\n}\n\n// Creates an ANSI string from the given wide string, allocating\n// memory using new. The caller is responsible for deleting the return\n// value using delete[]. Returns the ANSI string, or NULL if the\n// input is NULL.\nconst char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {\n  if (!utf16_str) return nullptr;\n  const int ansi_length = WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, nullptr,\n                                              0, nullptr, nullptr);\n  char* ansi = new char[ansi_length + 1];\n  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, ansi, ansi_length, nullptr,\n                      nullptr);\n  ansi[ansi_length] = 0;\n  return ansi;\n}\n\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Compares two C strings.  Returns true if and only if they have the same\n// content.\n//\n// Unlike strcmp(), this function can handle NULL argument(s).  A NULL\n// C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::CStringEquals(const char * lhs, const char * rhs) {\n  if (lhs == nullptr) return rhs == nullptr;\n\n  if (rhs == nullptr) return false;\n\n  return strcmp(lhs, rhs) == 0;\n}\n\n#if GTEST_HAS_STD_WSTRING\n\n// Converts an array of wide chars to a narrow string using the UTF-8\n// encoding, and streams the result to the given Message object.\nstatic void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,\n                                     Message* msg) {\n  for (size_t i = 0; i != length; ) {  // NOLINT\n    if (wstr[i] != L'\\0') {\n      *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));\n      while (i != length && wstr[i] != L'\\0')\n        i++;\n    } else {\n      *msg << '\\0';\n      i++;\n    }\n  }\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\nvoid SplitString(const ::std::string& str, char delimiter,\n                 ::std::vector< ::std::string>* dest) {\n  ::std::vector< ::std::string> parsed;\n  ::std::string::size_type pos = 0;\n  while (::testing::internal::AlwaysTrue()) {\n    const ::std::string::size_type colon = str.find(delimiter, pos);\n    if (colon == ::std::string::npos) {\n      parsed.push_back(str.substr(pos));\n      break;\n    } else {\n      parsed.push_back(str.substr(pos, colon - pos));\n      pos = colon + 1;\n    }\n  }\n  dest->swap(parsed);\n}\n\n}  // namespace internal\n\n// Constructs an empty Message.\n// We allocate the stringstream separately because otherwise each use of\n// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's\n// stack frame leading to huge stack frames in some cases; gcc does not reuse\n// the stack space.\nMessage::Message() : ss_(new ::std::stringstream) {\n  // By default, we want there to be enough precision when printing\n  // a double to a Message.\n  *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);\n}\n\n// These two overloads allow streaming a wide C string to a Message\n// using the UTF-8 encoding.\nMessage& Message::operator <<(const wchar_t* wide_c_str) {\n  return *this << internal::String::ShowWideCString(wide_c_str);\n}\nMessage& Message::operator <<(wchar_t* wide_c_str) {\n  return *this << internal::String::ShowWideCString(wide_c_str);\n}\n\n#if GTEST_HAS_STD_WSTRING\n// Converts the given wide string to a narrow string using the UTF-8\n// encoding, and streams the result to this Message object.\nMessage& Message::operator <<(const ::std::wstring& wstr) {\n  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);\n  return *this;\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Gets the text streamed to this object so far as an std::string.\n// Each '\\0' character in the buffer is replaced with \"\\\\0\".\nstd::string Message::GetString() const {\n  return internal::StringStreamToString(ss_.get());\n}\n\n// AssertionResult constructors.\n// Used in EXPECT_TRUE/FALSE(assertion_result).\nAssertionResult::AssertionResult(const AssertionResult& other)\n    : success_(other.success_),\n      message_(other.message_.get() != nullptr\n                   ? new ::std::string(*other.message_)\n                   : static_cast< ::std::string*>(nullptr)) {}\n\n// Swaps two AssertionResults.\nvoid AssertionResult::swap(AssertionResult& other) {\n  using std::swap;\n  swap(success_, other.success_);\n  swap(message_, other.message_);\n}\n\n// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.\nAssertionResult AssertionResult::operator!() const {\n  AssertionResult negation(!success_);\n  if (message_.get() != nullptr) negation << *message_;\n  return negation;\n}\n\n// Makes a successful assertion result.\nAssertionResult AssertionSuccess() {\n  return AssertionResult(true);\n}\n\n// Makes a failed assertion result.\nAssertionResult AssertionFailure() {\n  return AssertionResult(false);\n}\n\n// Makes a failed assertion result with the given failure message.\n// Deprecated; use AssertionFailure() << message.\nAssertionResult AssertionFailure(const Message& message) {\n  return AssertionFailure() << message;\n}\n\nnamespace internal {\n\nnamespace edit_distance {\nstd::vector<EditType> CalculateOptimalEdits(const std::vector<size_t>& left,\n                                            const std::vector<size_t>& right) {\n  std::vector<std::vector<double> > costs(\n      left.size() + 1, std::vector<double>(right.size() + 1));\n  std::vector<std::vector<EditType> > best_move(\n      left.size() + 1, std::vector<EditType>(right.size() + 1));\n\n  // Populate for empty right.\n  for (size_t l_i = 0; l_i < costs.size(); ++l_i) {\n    costs[l_i][0] = static_cast<double>(l_i);\n    best_move[l_i][0] = kRemove;\n  }\n  // Populate for empty left.\n  for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) {\n    costs[0][r_i] = static_cast<double>(r_i);\n    best_move[0][r_i] = kAdd;\n  }\n\n  for (size_t l_i = 0; l_i < left.size(); ++l_i) {\n    for (size_t r_i = 0; r_i < right.size(); ++r_i) {\n      if (left[l_i] == right[r_i]) {\n        // Found a match. Consume it.\n        costs[l_i + 1][r_i + 1] = costs[l_i][r_i];\n        best_move[l_i + 1][r_i + 1] = kMatch;\n        continue;\n      }\n\n      const double add = costs[l_i + 1][r_i];\n      const double remove = costs[l_i][r_i + 1];\n      const double replace = costs[l_i][r_i];\n      if (add < remove && add < replace) {\n        costs[l_i + 1][r_i + 1] = add + 1;\n        best_move[l_i + 1][r_i + 1] = kAdd;\n      } else if (remove < add && remove < replace) {\n        costs[l_i + 1][r_i + 1] = remove + 1;\n        best_move[l_i + 1][r_i + 1] = kRemove;\n      } else {\n        // We make replace a little more expensive than add/remove to lower\n        // their priority.\n        costs[l_i + 1][r_i + 1] = replace + 1.00001;\n        best_move[l_i + 1][r_i + 1] = kReplace;\n      }\n    }\n  }\n\n  // Reconstruct the best path. We do it in reverse order.\n  std::vector<EditType> best_path;\n  for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {\n    EditType move = best_move[l_i][r_i];\n    best_path.push_back(move);\n    l_i -= move != kAdd;\n    r_i -= move != kRemove;\n  }\n  std::reverse(best_path.begin(), best_path.end());\n  return best_path;\n}\n\nnamespace {\n\n// Helper class to convert string into ids with deduplication.\nclass InternalStrings {\n public:\n  size_t GetId(const std::string& str) {\n    IdMap::iterator it = ids_.find(str);\n    if (it != ids_.end()) return it->second;\n    size_t id = ids_.size();\n    return ids_[str] = id;\n  }\n\n private:\n  typedef std::map<std::string, size_t> IdMap;\n  IdMap ids_;\n};\n\n}  // namespace\n\nstd::vector<EditType> CalculateOptimalEdits(\n    const std::vector<std::string>& left,\n    const std::vector<std::string>& right) {\n  std::vector<size_t> left_ids, right_ids;\n  {\n    InternalStrings intern_table;\n    for (size_t i = 0; i < left.size(); ++i) {\n      left_ids.push_back(intern_table.GetId(left[i]));\n    }\n    for (size_t i = 0; i < right.size(); ++i) {\n      right_ids.push_back(intern_table.GetId(right[i]));\n    }\n  }\n  return CalculateOptimalEdits(left_ids, right_ids);\n}\n\nnamespace {\n\n// Helper class that holds the state for one hunk and prints it out to the\n// stream.\n// It reorders adds/removes when possible to group all removes before all\n// adds. It also adds the hunk header before printint into the stream.\nclass Hunk {\n public:\n  Hunk(size_t left_start, size_t right_start)\n      : left_start_(left_start),\n        right_start_(right_start),\n        adds_(),\n        removes_(),\n        common_() {}\n\n  void PushLine(char edit, const char* line) {\n    switch (edit) {\n      case ' ':\n        ++common_;\n        FlushEdits();\n        hunk_.push_back(std::make_pair(' ', line));\n        break;\n      case '-':\n        ++removes_;\n        hunk_removes_.push_back(std::make_pair('-', line));\n        break;\n      case '+':\n        ++adds_;\n        hunk_adds_.push_back(std::make_pair('+', line));\n        break;\n    }\n  }\n\n  void PrintTo(std::ostream* os) {\n    PrintHeader(os);\n    FlushEdits();\n    for (std::list<std::pair<char, const char*> >::const_iterator it =\n             hunk_.begin();\n         it != hunk_.end(); ++it) {\n      *os << it->first << it->second << \"\\n\";\n    }\n  }\n\n  bool has_edits() const { return adds_ || removes_; }\n\n private:\n  void FlushEdits() {\n    hunk_.splice(hunk_.end(), hunk_removes_);\n    hunk_.splice(hunk_.end(), hunk_adds_);\n  }\n\n  // Print a unified diff header for one hunk.\n  // The format is\n  //   \"@@ -<left_start>,<left_length> +<right_start>,<right_length> @@\"\n  // where the left/right parts are omitted if unnecessary.\n  void PrintHeader(std::ostream* ss) const {\n    *ss << \"@@ \";\n    if (removes_) {\n      *ss << \"-\" << left_start_ << \",\" << (removes_ + common_);\n    }\n    if (removes_ && adds_) {\n      *ss << \" \";\n    }\n    if (adds_) {\n      *ss << \"+\" << right_start_ << \",\" << (adds_ + common_);\n    }\n    *ss << \" @@\\n\";\n  }\n\n  size_t left_start_, right_start_;\n  size_t adds_, removes_, common_;\n  std::list<std::pair<char, const char*> > hunk_, hunk_adds_, hunk_removes_;\n};\n\n}  // namespace\n\n// Create a list of diff hunks in Unified diff format.\n// Each hunk has a header generated by PrintHeader above plus a body with\n// lines prefixed with ' ' for no change, '-' for deletion and '+' for\n// addition.\n// 'context' represents the desired unchanged prefix/suffix around the diff.\n// If two hunks are close enough that their contexts overlap, then they are\n// joined into one hunk.\nstd::string CreateUnifiedDiff(const std::vector<std::string>& left,\n                              const std::vector<std::string>& right,\n                              size_t context) {\n  const std::vector<EditType> edits = CalculateOptimalEdits(left, right);\n\n  size_t l_i = 0, r_i = 0, edit_i = 0;\n  std::stringstream ss;\n  while (edit_i < edits.size()) {\n    // Find first edit.\n    while (edit_i < edits.size() && edits[edit_i] == kMatch) {\n      ++l_i;\n      ++r_i;\n      ++edit_i;\n    }\n\n    // Find the first line to include in the hunk.\n    const size_t prefix_context = std::min(l_i, context);\n    Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);\n    for (size_t i = prefix_context; i > 0; --i) {\n      hunk.PushLine(' ', left[l_i - i].c_str());\n    }\n\n    // Iterate the edits until we found enough suffix for the hunk or the input\n    // is over.\n    size_t n_suffix = 0;\n    for (; edit_i < edits.size(); ++edit_i) {\n      if (n_suffix >= context) {\n        // Continue only if the next hunk is very close.\n        auto it = edits.begin() + static_cast<int>(edit_i);\n        while (it != edits.end() && *it == kMatch) ++it;\n        if (it == edits.end() ||\n            static_cast<size_t>(it - edits.begin()) - edit_i >= context) {\n          // There is no next edit or it is too far away.\n          break;\n        }\n      }\n\n      EditType edit = edits[edit_i];\n      // Reset count when a non match is found.\n      n_suffix = edit == kMatch ? n_suffix + 1 : 0;\n\n      if (edit == kMatch || edit == kRemove || edit == kReplace) {\n        hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());\n      }\n      if (edit == kAdd || edit == kReplace) {\n        hunk.PushLine('+', right[r_i].c_str());\n      }\n\n      // Advance indices, depending on edit type.\n      l_i += edit != kAdd;\n      r_i += edit != kRemove;\n    }\n\n    if (!hunk.has_edits()) {\n      // We are done. We don't want this hunk.\n      break;\n    }\n\n    hunk.PrintTo(&ss);\n  }\n  return ss.str();\n}\n\n}  // namespace edit_distance\n\nnamespace {\n\n// The string representation of the values received in EqFailure() are already\n// escaped. Split them on escaped '\\n' boundaries. Leave all other escaped\n// characters the same.\nstd::vector<std::string> SplitEscapedString(const std::string& str) {\n  std::vector<std::string> lines;\n  size_t start = 0, end = str.size();\n  if (end > 2 && str[0] == '\"' && str[end - 1] == '\"') {\n    ++start;\n    --end;\n  }\n  bool escaped = false;\n  for (size_t i = start; i + 1 < end; ++i) {\n    if (escaped) {\n      escaped = false;\n      if (str[i] == 'n') {\n        lines.push_back(str.substr(start, i - start - 1));\n        start = i + 1;\n      }\n    } else {\n      escaped = str[i] == '\\\\';\n    }\n  }\n  lines.push_back(str.substr(start, end - start));\n  return lines;\n}\n\n}  // namespace\n\n// Constructs and returns the message for an equality assertion\n// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.\n//\n// The first four parameters are the expressions used in the assertion\n// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)\n// where foo is 5 and bar is 6, we have:\n//\n//   lhs_expression: \"foo\"\n//   rhs_expression: \"bar\"\n//   lhs_value:      \"5\"\n//   rhs_value:      \"6\"\n//\n// The ignoring_case parameter is true if and only if the assertion is a\n// *_STRCASEEQ*.  When it's true, the string \"Ignoring case\" will\n// be inserted into the message.\nAssertionResult EqFailure(const char* lhs_expression,\n                          const char* rhs_expression,\n                          const std::string& lhs_value,\n                          const std::string& rhs_value,\n                          bool ignoring_case) {\n  Message msg;\n  msg << \"Expected equality of these values:\";\n  msg << \"\\n  \" << lhs_expression;\n  if (lhs_value != lhs_expression) {\n    msg << \"\\n    Which is: \" << lhs_value;\n  }\n  msg << \"\\n  \" << rhs_expression;\n  if (rhs_value != rhs_expression) {\n    msg << \"\\n    Which is: \" << rhs_value;\n  }\n\n  if (ignoring_case) {\n    msg << \"\\nIgnoring case\";\n  }\n\n  if (!lhs_value.empty() && !rhs_value.empty()) {\n    const std::vector<std::string> lhs_lines =\n        SplitEscapedString(lhs_value);\n    const std::vector<std::string> rhs_lines =\n        SplitEscapedString(rhs_value);\n    if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {\n      msg << \"\\nWith diff:\\n\"\n          << edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);\n    }\n  }\n\n  return AssertionFailure() << msg;\n}\n\n// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.\nstd::string GetBoolAssertionFailureMessage(\n    const AssertionResult& assertion_result,\n    const char* expression_text,\n    const char* actual_predicate_value,\n    const char* expected_predicate_value) {\n  const char* actual_message = assertion_result.message();\n  Message msg;\n  msg << \"Value of: \" << expression_text\n      << \"\\n  Actual: \" << actual_predicate_value;\n  if (actual_message[0] != '\\0')\n    msg << \" (\" << actual_message << \")\";\n  msg << \"\\nExpected: \" << expected_predicate_value;\n  return msg.GetString();\n}\n\n// Helper function for implementing ASSERT_NEAR.\nAssertionResult DoubleNearPredFormat(const char* expr1,\n                                     const char* expr2,\n                                     const char* abs_error_expr,\n                                     double val1,\n                                     double val2,\n                                     double abs_error) {\n  const double diff = fabs(val1 - val2);\n  if (diff <= abs_error) return AssertionSuccess();\n\n  // Find the value which is closest to zero.\n  const double min_abs = std::min(fabs(val1), fabs(val2));\n  // Find the distance to the next double from that value.\n  const double epsilon =\n      nextafter(min_abs, std::numeric_limits<double>::infinity()) - min_abs;\n  // Detect the case where abs_error is so small that EXPECT_NEAR is\n  // effectively the same as EXPECT_EQUAL, and give an informative error\n  // message so that the situation can be more easily understood without\n  // requiring exotic floating-point knowledge.\n  // Don't do an epsilon check if abs_error is zero because that implies\n  // that an equality check was actually intended.\n  if (!(std::isnan)(val1) && !(std::isnan)(val2) && abs_error > 0 &&\n      abs_error < epsilon) {\n    return AssertionFailure()\n           << \"The difference between \" << expr1 << \" and \" << expr2 << \" is \"\n           << diff << \", where\\n\"\n           << expr1 << \" evaluates to \" << val1 << \",\\n\"\n           << expr2 << \" evaluates to \" << val2 << \".\\nThe abs_error parameter \"\n           << abs_error_expr << \" evaluates to \" << abs_error\n           << \" which is smaller than the minimum distance between doubles for \"\n              \"numbers of this magnitude which is \"\n           << epsilon\n           << \", thus making this EXPECT_NEAR check equivalent to \"\n              \"EXPECT_EQUAL. Consider using EXPECT_DOUBLE_EQ instead.\";\n  }\n  return AssertionFailure()\n      << \"The difference between \" << expr1 << \" and \" << expr2\n      << \" is \" << diff << \", which exceeds \" << abs_error_expr << \", where\\n\"\n      << expr1 << \" evaluates to \" << val1 << \",\\n\"\n      << expr2 << \" evaluates to \" << val2 << \", and\\n\"\n      << abs_error_expr << \" evaluates to \" << abs_error << \".\";\n}\n\n\n// Helper template for implementing FloatLE() and DoubleLE().\ntemplate <typename RawType>\nAssertionResult FloatingPointLE(const char* expr1,\n                                const char* expr2,\n                                RawType val1,\n                                RawType val2) {\n  // Returns success if val1 is less than val2,\n  if (val1 < val2) {\n    return AssertionSuccess();\n  }\n\n  // or if val1 is almost equal to val2.\n  const FloatingPoint<RawType> lhs(val1), rhs(val2);\n  if (lhs.AlmostEquals(rhs)) {\n    return AssertionSuccess();\n  }\n\n  // Note that the above two checks will both fail if either val1 or\n  // val2 is NaN, as the IEEE floating-point standard requires that\n  // any predicate involving a NaN must return false.\n\n  ::std::stringstream val1_ss;\n  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n          << val1;\n\n  ::std::stringstream val2_ss;\n  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n          << val2;\n\n  return AssertionFailure()\n      << \"Expected: (\" << expr1 << \") <= (\" << expr2 << \")\\n\"\n      << \"  Actual: \" << StringStreamToString(&val1_ss) << \" vs \"\n      << StringStreamToString(&val2_ss);\n}\n\n}  // namespace internal\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nAssertionResult FloatLE(const char* expr1, const char* expr2,\n                        float val1, float val2) {\n  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);\n}\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nAssertionResult DoubleLE(const char* expr1, const char* expr2,\n                         double val1, double val2) {\n  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);\n}\n\nnamespace internal {\n\n// The helper function for {ASSERT|EXPECT}_STREQ.\nAssertionResult CmpHelperSTREQ(const char* lhs_expression,\n                               const char* rhs_expression,\n                               const char* lhs,\n                               const char* rhs) {\n  if (String::CStringEquals(lhs, rhs)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   PrintToString(lhs),\n                   PrintToString(rhs),\n                   false);\n}\n\n// The helper function for {ASSERT|EXPECT}_STRCASEEQ.\nAssertionResult CmpHelperSTRCASEEQ(const char* lhs_expression,\n                                   const char* rhs_expression,\n                                   const char* lhs,\n                                   const char* rhs) {\n  if (String::CaseInsensitiveCStringEquals(lhs, rhs)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   PrintToString(lhs),\n                   PrintToString(rhs),\n                   true);\n}\n\n// The helper function for {ASSERT|EXPECT}_STRNE.\nAssertionResult CmpHelperSTRNE(const char* s1_expression,\n                               const char* s2_expression,\n                               const char* s1,\n                               const char* s2) {\n  if (!String::CStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  } else {\n    return AssertionFailure() << \"Expected: (\" << s1_expression << \") != (\"\n                              << s2_expression << \"), actual: \\\"\"\n                              << s1 << \"\\\" vs \\\"\" << s2 << \"\\\"\";\n  }\n}\n\n// The helper function for {ASSERT|EXPECT}_STRCASENE.\nAssertionResult CmpHelperSTRCASENE(const char* s1_expression,\n                                   const char* s2_expression,\n                                   const char* s1,\n                                   const char* s2) {\n  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  } else {\n    return AssertionFailure()\n        << \"Expected: (\" << s1_expression << \") != (\"\n        << s2_expression << \") (ignoring case), actual: \\\"\"\n        << s1 << \"\\\" vs \\\"\" << s2 << \"\\\"\";\n  }\n}\n\n}  // namespace internal\n\nnamespace {\n\n// Helper functions for implementing IsSubString() and IsNotSubstring().\n\n// This group of overloaded functions return true if and only if needle\n// is a substring of haystack.  NULL is considered a substring of\n// itself only.\n\nbool IsSubstringPred(const char* needle, const char* haystack) {\n  if (needle == nullptr || haystack == nullptr) return needle == haystack;\n\n  return strstr(haystack, needle) != nullptr;\n}\n\nbool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {\n  if (needle == nullptr || haystack == nullptr) return needle == haystack;\n\n  return wcsstr(haystack, needle) != nullptr;\n}\n\n// StringType here can be either ::std::string or ::std::wstring.\ntemplate <typename StringType>\nbool IsSubstringPred(const StringType& needle,\n                     const StringType& haystack) {\n  return haystack.find(needle) != StringType::npos;\n}\n\n// This function implements either IsSubstring() or IsNotSubstring(),\n// depending on the value of the expected_to_be_substring parameter.\n// StringType here can be const char*, const wchar_t*, ::std::string,\n// or ::std::wstring.\ntemplate <typename StringType>\nAssertionResult IsSubstringImpl(\n    bool expected_to_be_substring,\n    const char* needle_expr, const char* haystack_expr,\n    const StringType& needle, const StringType& haystack) {\n  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)\n    return AssertionSuccess();\n\n  const bool is_wide_string = sizeof(needle[0]) > 1;\n  const char* const begin_string_quote = is_wide_string ? \"L\\\"\" : \"\\\"\";\n  return AssertionFailure()\n      << \"Value of: \" << needle_expr << \"\\n\"\n      << \"  Actual: \" << begin_string_quote << needle << \"\\\"\\n\"\n      << \"Expected: \" << (expected_to_be_substring ? \"\" : \"not \")\n      << \"a substring of \" << haystack_expr << \"\\n\"\n      << \"Which is: \" << begin_string_quote << haystack << \"\\\"\";\n}\n\n}  // namespace\n\n// IsSubstring() and IsNotSubstring() check whether needle is a\n// substring of haystack (NULL is considered a substring of itself\n// only), and return an appropriate error message when they fail.\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\n#if GTEST_HAS_STD_WSTRING\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\nnamespace internal {\n\n#if GTEST_OS_WINDOWS\n\nnamespace {\n\n// Helper function for IsHRESULT{SuccessFailure} predicates\nAssertionResult HRESULTFailureHelper(const char* expr,\n                                     const char* expected,\n                                     long hr) {  // NOLINT\n# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE\n\n  // Windows CE doesn't support FormatMessage.\n  const char error_text[] = \"\";\n\n# else\n\n  // Looks up the human-readable system message for the HRESULT code\n  // and since we're not passing any params to FormatMessage, we don't\n  // want inserts expanded.\n  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |\n                       FORMAT_MESSAGE_IGNORE_INSERTS;\n  const DWORD kBufSize = 4096;\n  // Gets the system's human readable message string for this HRESULT.\n  char error_text[kBufSize] = { '\\0' };\n  DWORD message_length = ::FormatMessageA(kFlags,\n                                          0,   // no source, we're asking system\n                                          static_cast<DWORD>(hr),  // the error\n                                          0,   // no line width restrictions\n                                          error_text,  // output buffer\n                                          kBufSize,    // buf size\n                                          nullptr);  // no arguments for inserts\n  // Trims tailing white space (FormatMessage leaves a trailing CR-LF)\n  for (; message_length && IsSpace(error_text[message_length - 1]);\n          --message_length) {\n    error_text[message_length - 1] = '\\0';\n  }\n\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n  const std::string error_hex(\"0x\" + String::FormatHexInt(hr));\n  return ::testing::AssertionFailure()\n      << \"Expected: \" << expr << \" \" << expected << \".\\n\"\n      << \"  Actual: \" << error_hex << \" \" << error_text << \"\\n\";\n}\n\n}  // namespace\n\nAssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT\n  if (SUCCEEDED(hr)) {\n    return AssertionSuccess();\n  }\n  return HRESULTFailureHelper(expr, \"succeeds\", hr);\n}\n\nAssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT\n  if (FAILED(hr)) {\n    return AssertionSuccess();\n  }\n  return HRESULTFailureHelper(expr, \"fails\", hr);\n}\n\n#endif  // GTEST_OS_WINDOWS\n\n// Utility functions for encoding Unicode text (wide strings) in\n// UTF-8.\n\n// A Unicode code-point can have up to 21 bits, and is encoded in UTF-8\n// like this:\n//\n// Code-point length   Encoding\n//   0 -  7 bits       0xxxxxxx\n//   8 - 11 bits       110xxxxx 10xxxxxx\n//  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx\n//  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx\n\n// The maximum code-point a one-byte UTF-8 sequence can represent.\nconstexpr uint32_t kMaxCodePoint1 = (static_cast<uint32_t>(1) <<  7) - 1;\n\n// The maximum code-point a two-byte UTF-8 sequence can represent.\nconstexpr uint32_t kMaxCodePoint2 = (static_cast<uint32_t>(1) << (5 + 6)) - 1;\n\n// The maximum code-point a three-byte UTF-8 sequence can represent.\nconstexpr uint32_t kMaxCodePoint3 = (static_cast<uint32_t>(1) << (4 + 2*6)) - 1;\n\n// The maximum code-point a four-byte UTF-8 sequence can represent.\nconstexpr uint32_t kMaxCodePoint4 = (static_cast<uint32_t>(1) << (3 + 3*6)) - 1;\n\n// Chops off the n lowest bits from a bit pattern.  Returns the n\n// lowest bits.  As a side effect, the original bit pattern will be\n// shifted to the right by n bits.\ninline uint32_t ChopLowBits(uint32_t* bits, int n) {\n  const uint32_t low_bits = *bits & ((static_cast<uint32_t>(1) << n) - 1);\n  *bits >>= n;\n  return low_bits;\n}\n\n// Converts a Unicode code point to a narrow string in UTF-8 encoding.\n// code_point parameter is of type uint32_t because wchar_t may not be\n// wide enough to contain a code point.\n// If the code_point is not a valid Unicode code point\n// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted\n// to \"(Invalid Unicode 0xXXXXXXXX)\".\nstd::string CodePointToUtf8(uint32_t code_point) {\n  if (code_point > kMaxCodePoint4) {\n    return \"(Invalid Unicode 0x\" + String::FormatHexUInt32(code_point) + \")\";\n  }\n\n  char str[5];  // Big enough for the largest valid code point.\n  if (code_point <= kMaxCodePoint1) {\n    str[1] = '\\0';\n    str[0] = static_cast<char>(code_point);                          // 0xxxxxxx\n  } else if (code_point <= kMaxCodePoint2) {\n    str[2] = '\\0';\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx\n  } else if (code_point <= kMaxCodePoint3) {\n    str[3] = '\\0';\n    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx\n  } else {  // code_point <= kMaxCodePoint4\n    str[4] = '\\0';\n    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx\n  }\n  return str;\n}\n\n// The following two functions only make sense if the system\n// uses UTF-16 for wide string encoding. All supported systems\n// with 16 bit wchar_t (Windows, Cygwin) do use UTF-16.\n\n// Determines if the arguments constitute UTF-16 surrogate pair\n// and thus should be combined into a single Unicode code point\n// using CreateCodePointFromUtf16SurrogatePair.\ninline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {\n  return sizeof(wchar_t) == 2 &&\n      (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;\n}\n\n// Creates a Unicode code point from UTF16 surrogate pair.\ninline uint32_t CreateCodePointFromUtf16SurrogatePair(wchar_t first,\n                                                      wchar_t second) {\n  const auto first_u = static_cast<uint32_t>(first);\n  const auto second_u = static_cast<uint32_t>(second);\n  const uint32_t mask = (1 << 10) - 1;\n  return (sizeof(wchar_t) == 2)\n             ? (((first_u & mask) << 10) | (second_u & mask)) + 0x10000\n             :\n             // This function should not be called when the condition is\n             // false, but we provide a sensible default in case it is.\n             first_u;\n}\n\n// Converts a wide string to a narrow string in UTF-8 encoding.\n// The wide string is assumed to have the following encoding:\n//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin)\n//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)\n// Parameter str points to a null-terminated wide string.\n// Parameter num_chars may additionally limit the number\n// of wchar_t characters processed. -1 is used when the entire string\n// should be processed.\n// If the string contains code points that are not valid Unicode code points\n// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output\n// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding\n// and contains invalid UTF-16 surrogate pairs, values in those pairs\n// will be encoded as individual Unicode characters from Basic Normal Plane.\nstd::string WideStringToUtf8(const wchar_t* str, int num_chars) {\n  if (num_chars == -1)\n    num_chars = static_cast<int>(wcslen(str));\n\n  ::std::stringstream stream;\n  for (int i = 0; i < num_chars; ++i) {\n    uint32_t unicode_code_point;\n\n    if (str[i] == L'\\0') {\n      break;\n    } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {\n      unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],\n                                                                 str[i + 1]);\n      i++;\n    } else {\n      unicode_code_point = static_cast<uint32_t>(str[i]);\n    }\n\n    stream << CodePointToUtf8(unicode_code_point);\n  }\n  return StringStreamToString(&stream);\n}\n\n// Converts a wide C string to an std::string using the UTF-8 encoding.\n// NULL will be converted to \"(null)\".\nstd::string String::ShowWideCString(const wchar_t * wide_c_str) {\n  if (wide_c_str == nullptr) return \"(null)\";\n\n  return internal::WideStringToUtf8(wide_c_str, -1);\n}\n\n// Compares two wide C strings.  Returns true if and only if they have the\n// same content.\n//\n// Unlike wcscmp(), this function can handle NULL argument(s).  A NULL\n// C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {\n  if (lhs == nullptr) return rhs == nullptr;\n\n  if (rhs == nullptr) return false;\n\n  return wcscmp(lhs, rhs) == 0;\n}\n\n// Helper function for *_STREQ on wide strings.\nAssertionResult CmpHelperSTREQ(const char* lhs_expression,\n                               const char* rhs_expression,\n                               const wchar_t* lhs,\n                               const wchar_t* rhs) {\n  if (String::WideCStringEquals(lhs, rhs)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   PrintToString(lhs),\n                   PrintToString(rhs),\n                   false);\n}\n\n// Helper function for *_STRNE on wide strings.\nAssertionResult CmpHelperSTRNE(const char* s1_expression,\n                               const char* s2_expression,\n                               const wchar_t* s1,\n                               const wchar_t* s2) {\n  if (!String::WideCStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  }\n\n  return AssertionFailure() << \"Expected: (\" << s1_expression << \") != (\"\n                            << s2_expression << \"), actual: \"\n                            << PrintToString(s1)\n                            << \" vs \" << PrintToString(s2);\n}\n\n// Compares two C strings, ignoring case.  Returns true if and only if they have\n// the same content.\n//\n// Unlike strcasecmp(), this function can handle NULL argument(s).  A\n// NULL C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {\n  if (lhs == nullptr) return rhs == nullptr;\n  if (rhs == nullptr) return false;\n  return posix::StrCaseCmp(lhs, rhs) == 0;\n}\n\n// Compares two wide C strings, ignoring case.  Returns true if and only if they\n// have the same content.\n//\n// Unlike wcscasecmp(), this function can handle NULL argument(s).\n// A NULL C string is considered different to any non-NULL wide C string,\n// including the empty string.\n// NB: The implementations on different platforms slightly differ.\n// On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n// environment variable. On GNU platform this method uses wcscasecmp\n// which compares according to LC_CTYPE category of the current locale.\n// On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n// current locale.\nbool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n                                              const wchar_t* rhs) {\n  if (lhs == nullptr) return rhs == nullptr;\n\n  if (rhs == nullptr) return false;\n\n#if GTEST_OS_WINDOWS\n  return _wcsicmp(lhs, rhs) == 0;\n#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID\n  return wcscasecmp(lhs, rhs) == 0;\n#else\n  // Android, Mac OS X and Cygwin don't define wcscasecmp.\n  // Other unknown OSes may not define it either.\n  wint_t left, right;\n  do {\n    left = towlower(static_cast<wint_t>(*lhs++));\n    right = towlower(static_cast<wint_t>(*rhs++));\n  } while (left && left == right);\n  return left == right;\n#endif  // OS selector\n}\n\n// Returns true if and only if str ends with the given suffix, ignoring case.\n// Any string is considered to end with an empty suffix.\nbool String::EndsWithCaseInsensitive(\n    const std::string& str, const std::string& suffix) {\n  const size_t str_len = str.length();\n  const size_t suffix_len = suffix.length();\n  return (str_len >= suffix_len) &&\n         CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,\n                                      suffix.c_str());\n}\n\n// Formats an int value as \"%02d\".\nstd::string String::FormatIntWidth2(int value) {\n  return FormatIntWidthN(value, 2);\n}\n\n// Formats an int value to given width with leading zeros.\nstd::string String::FormatIntWidthN(int value, int width) {\n  std::stringstream ss;\n  ss << std::setfill('0') << std::setw(width) << value;\n  return ss.str();\n}\n\n// Formats an int value as \"%X\".\nstd::string String::FormatHexUInt32(uint32_t value) {\n  std::stringstream ss;\n  ss << std::hex << std::uppercase << value;\n  return ss.str();\n}\n\n// Formats an int value as \"%X\".\nstd::string String::FormatHexInt(int value) {\n  return FormatHexUInt32(static_cast<uint32_t>(value));\n}\n\n// Formats a byte as \"%02X\".\nstd::string String::FormatByte(unsigned char value) {\n  std::stringstream ss;\n  ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase\n     << static_cast<unsigned int>(value);\n  return ss.str();\n}\n\n// Converts the buffer in a stringstream to an std::string, converting NUL\n// bytes to \"\\\\0\" along the way.\nstd::string StringStreamToString(::std::stringstream* ss) {\n  const ::std::string& str = ss->str();\n  const char* const start = str.c_str();\n  const char* const end = start + str.length();\n\n  std::string result;\n  result.reserve(static_cast<size_t>(2 * (end - start)));\n  for (const char* ch = start; ch != end; ++ch) {\n    if (*ch == '\\0') {\n      result += \"\\\\0\";  // Replaces NUL with \"\\\\0\";\n    } else {\n      result += *ch;\n    }\n  }\n\n  return result;\n}\n\n// Appends the user-supplied message to the Google-Test-generated message.\nstd::string AppendUserMessage(const std::string& gtest_msg,\n                              const Message& user_msg) {\n  // Appends the user message if it's non-empty.\n  const std::string user_msg_string = user_msg.GetString();\n  if (user_msg_string.empty()) {\n    return gtest_msg;\n  }\n  if (gtest_msg.empty()) {\n    return user_msg_string;\n  }\n  return gtest_msg + \"\\n\" + user_msg_string;\n}\n\n}  // namespace internal\n\n// class TestResult\n\n// Creates an empty TestResult.\nTestResult::TestResult()\n    : death_test_count_(0), start_timestamp_(0), elapsed_time_(0) {}\n\n// D'tor.\nTestResult::~TestResult() {\n}\n\n// Returns the i-th test part result among all the results. i can\n// range from 0 to total_part_count() - 1. If i is not in that range,\n// aborts the program.\nconst TestPartResult& TestResult::GetTestPartResult(int i) const {\n  if (i < 0 || i >= total_part_count())\n    internal::posix::Abort();\n  return test_part_results_.at(static_cast<size_t>(i));\n}\n\n// Returns the i-th test property. i can range from 0 to\n// test_property_count() - 1. If i is not in that range, aborts the\n// program.\nconst TestProperty& TestResult::GetTestProperty(int i) const {\n  if (i < 0 || i >= test_property_count())\n    internal::posix::Abort();\n  return test_properties_.at(static_cast<size_t>(i));\n}\n\n// Clears the test part results.\nvoid TestResult::ClearTestPartResults() {\n  test_part_results_.clear();\n}\n\n// Adds a test part result to the list.\nvoid TestResult::AddTestPartResult(const TestPartResult& test_part_result) {\n  test_part_results_.push_back(test_part_result);\n}\n\n// Adds a test property to the list. If a property with the same key as the\n// supplied property is already represented, the value of this test_property\n// replaces the old value for that key.\nvoid TestResult::RecordProperty(const std::string& xml_element,\n                                const TestProperty& test_property) {\n  if (!ValidateTestProperty(xml_element, test_property)) {\n    return;\n  }\n  internal::MutexLock lock(&test_properties_mutex_);\n  const std::vector<TestProperty>::iterator property_with_matching_key =\n      std::find_if(test_properties_.begin(), test_properties_.end(),\n                   internal::TestPropertyKeyIs(test_property.key()));\n  if (property_with_matching_key == test_properties_.end()) {\n    test_properties_.push_back(test_property);\n    return;\n  }\n  property_with_matching_key->SetValue(test_property.value());\n}\n\n// The list of reserved attributes used in the <testsuites> element of XML\n// output.\nstatic const char* const kReservedTestSuitesAttributes[] = {\n  \"disabled\",\n  \"errors\",\n  \"failures\",\n  \"name\",\n  \"random_seed\",\n  \"tests\",\n  \"time\",\n  \"timestamp\"\n};\n\n// The list of reserved attributes used in the <testsuite> element of XML\n// output.\nstatic const char* const kReservedTestSuiteAttributes[] = {\n    \"disabled\", \"errors\", \"failures\",  \"name\",\n    \"tests\",    \"time\",   \"timestamp\", \"skipped\"};\n\n// The list of reserved attributes used in the <testcase> element of XML output.\nstatic const char* const kReservedTestCaseAttributes[] = {\n    \"classname\",   \"name\", \"status\", \"time\",  \"type_param\",\n    \"value_param\", \"file\", \"line\"};\n\n// Use a slightly different set for allowed output to ensure existing tests can\n// still RecordProperty(\"result\") or \"RecordProperty(timestamp\")\nstatic const char* const kReservedOutputTestCaseAttributes[] = {\n    \"classname\",   \"name\", \"status\", \"time\",   \"type_param\",\n    \"value_param\", \"file\", \"line\",   \"result\", \"timestamp\"};\n\ntemplate <size_t kSize>\nstd::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {\n  return std::vector<std::string>(array, array + kSize);\n}\n\nstatic std::vector<std::string> GetReservedAttributesForElement(\n    const std::string& xml_element) {\n  if (xml_element == \"testsuites\") {\n    return ArrayAsVector(kReservedTestSuitesAttributes);\n  } else if (xml_element == \"testsuite\") {\n    return ArrayAsVector(kReservedTestSuiteAttributes);\n  } else if (xml_element == \"testcase\") {\n    return ArrayAsVector(kReservedTestCaseAttributes);\n  } else {\n    GTEST_CHECK_(false) << \"Unrecognized xml_element provided: \" << xml_element;\n  }\n  // This code is unreachable but some compilers may not realizes that.\n  return std::vector<std::string>();\n}\n\n// TODO(jdesprez): Merge the two getReserved attributes once skip is improved\nstatic std::vector<std::string> GetReservedOutputAttributesForElement(\n    const std::string& xml_element) {\n  if (xml_element == \"testsuites\") {\n    return ArrayAsVector(kReservedTestSuitesAttributes);\n  } else if (xml_element == \"testsuite\") {\n    return ArrayAsVector(kReservedTestSuiteAttributes);\n  } else if (xml_element == \"testcase\") {\n    return ArrayAsVector(kReservedOutputTestCaseAttributes);\n  } else {\n    GTEST_CHECK_(false) << \"Unrecognized xml_element provided: \" << xml_element;\n  }\n  // This code is unreachable but some compilers may not realizes that.\n  return std::vector<std::string>();\n}\n\nstatic std::string FormatWordList(const std::vector<std::string>& words) {\n  Message word_list;\n  for (size_t i = 0; i < words.size(); ++i) {\n    if (i > 0 && words.size() > 2) {\n      word_list << \", \";\n    }\n    if (i == words.size() - 1) {\n      word_list << \"and \";\n    }\n    word_list << \"'\" << words[i] << \"'\";\n  }\n  return word_list.GetString();\n}\n\nstatic bool ValidateTestPropertyName(\n    const std::string& property_name,\n    const std::vector<std::string>& reserved_names) {\n  if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=\n          reserved_names.end()) {\n    ADD_FAILURE() << \"Reserved key used in RecordProperty(): \" << property_name\n                  << \" (\" << FormatWordList(reserved_names)\n                  << \" are reserved by \" << GTEST_NAME_ << \")\";\n    return false;\n  }\n  return true;\n}\n\n// Adds a failure if the key is a reserved attribute of the element named\n// xml_element.  Returns true if the property is valid.\nbool TestResult::ValidateTestProperty(const std::string& xml_element,\n                                      const TestProperty& test_property) {\n  return ValidateTestPropertyName(test_property.key(),\n                                  GetReservedAttributesForElement(xml_element));\n}\n\n// Clears the object.\nvoid TestResult::Clear() {\n  test_part_results_.clear();\n  test_properties_.clear();\n  death_test_count_ = 0;\n  elapsed_time_ = 0;\n}\n\n// Returns true off the test part was skipped.\nstatic bool TestPartSkipped(const TestPartResult& result) {\n  return result.skipped();\n}\n\n// Returns true if and only if the test was skipped.\nbool TestResult::Skipped() const {\n  return !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0;\n}\n\n// Returns true if and only if the test failed.\nbool TestResult::Failed() const {\n  for (int i = 0; i < total_part_count(); ++i) {\n    if (GetTestPartResult(i).failed())\n      return true;\n  }\n  return false;\n}\n\n// Returns true if and only if the test part fatally failed.\nstatic bool TestPartFatallyFailed(const TestPartResult& result) {\n  return result.fatally_failed();\n}\n\n// Returns true if and only if the test fatally failed.\nbool TestResult::HasFatalFailure() const {\n  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;\n}\n\n// Returns true if and only if the test part non-fatally failed.\nstatic bool TestPartNonfatallyFailed(const TestPartResult& result) {\n  return result.nonfatally_failed();\n}\n\n// Returns true if and only if the test has a non-fatal failure.\nbool TestResult::HasNonfatalFailure() const {\n  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;\n}\n\n// Gets the number of all test parts.  This is the sum of the number\n// of successful test parts and the number of failed test parts.\nint TestResult::total_part_count() const {\n  return static_cast<int>(test_part_results_.size());\n}\n\n// Returns the number of the test properties.\nint TestResult::test_property_count() const {\n  return static_cast<int>(test_properties_.size());\n}\n\n// class Test\n\n// Creates a Test object.\n\n// The c'tor saves the states of all flags.\nTest::Test()\n    : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {\n}\n\n// The d'tor restores the states of all flags.  The actual work is\n// done by the d'tor of the gtest_flag_saver_ field, and thus not\n// visible here.\nTest::~Test() {\n}\n\n// Sets up the test fixture.\n//\n// A sub-class may override this.\nvoid Test::SetUp() {\n}\n\n// Tears down the test fixture.\n//\n// A sub-class may override this.\nvoid Test::TearDown() {\n}\n\n// Allows user supplied key value pairs to be recorded for later output.\nvoid Test::RecordProperty(const std::string& key, const std::string& value) {\n  UnitTest::GetInstance()->RecordProperty(key, value);\n}\n\n// Allows user supplied key value pairs to be recorded for later output.\nvoid Test::RecordProperty(const std::string& key, int value) {\n  Message value_message;\n  value_message << value;\n  RecordProperty(key, value_message.GetString().c_str());\n}\n\nnamespace internal {\n\nvoid ReportFailureInUnknownLocation(TestPartResult::Type result_type,\n                                    const std::string& message) {\n  // This function is a friend of UnitTest and as such has access to\n  // AddTestPartResult.\n  UnitTest::GetInstance()->AddTestPartResult(\n      result_type,\n      nullptr,  // No info about the source file where the exception occurred.\n      -1,       // We have no info on which line caused the exception.\n      message,\n      \"\");  // No stack trace, either.\n}\n\n}  // namespace internal\n\n// Google Test requires all tests in the same test suite to use the same test\n// fixture class.  This function checks if the current test has the\n// same fixture class as the first test in the current test suite.  If\n// yes, it returns true; otherwise it generates a Google Test failure and\n// returns false.\nbool Test::HasSameFixtureClass() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  const TestSuite* const test_suite = impl->current_test_suite();\n\n  // Info about the first test in the current test suite.\n  const TestInfo* const first_test_info = test_suite->test_info_list()[0];\n  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;\n  const char* const first_test_name = first_test_info->name();\n\n  // Info about the current test.\n  const TestInfo* const this_test_info = impl->current_test_info();\n  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;\n  const char* const this_test_name = this_test_info->name();\n\n  if (this_fixture_id != first_fixture_id) {\n    // Is the first test defined using TEST?\n    const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();\n    // Is this test defined using TEST?\n    const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();\n\n    if (first_is_TEST || this_is_TEST) {\n      // Both TEST and TEST_F appear in same test suite, which is incorrect.\n      // Tell the user how to fix this.\n\n      // Gets the name of the TEST and the name of the TEST_F.  Note\n      // that first_is_TEST and this_is_TEST cannot both be true, as\n      // the fixture IDs are different for the two tests.\n      const char* const TEST_name =\n          first_is_TEST ? first_test_name : this_test_name;\n      const char* const TEST_F_name =\n          first_is_TEST ? this_test_name : first_test_name;\n\n      ADD_FAILURE()\n          << \"All tests in the same test suite must use the same test fixture\\n\"\n          << \"class, so mixing TEST_F and TEST in the same test suite is\\n\"\n          << \"illegal.  In test suite \" << this_test_info->test_suite_name()\n          << \",\\n\"\n          << \"test \" << TEST_F_name << \" is defined using TEST_F but\\n\"\n          << \"test \" << TEST_name << \" is defined using TEST.  You probably\\n\"\n          << \"want to change the TEST to TEST_F or move it to another test\\n\"\n          << \"case.\";\n    } else {\n      // Two fixture classes with the same name appear in two different\n      // namespaces, which is not allowed. Tell the user how to fix this.\n      ADD_FAILURE()\n          << \"All tests in the same test suite must use the same test fixture\\n\"\n          << \"class.  However, in test suite \"\n          << this_test_info->test_suite_name() << \",\\n\"\n          << \"you defined test \" << first_test_name << \" and test \"\n          << this_test_name << \"\\n\"\n          << \"using two different test fixture classes.  This can happen if\\n\"\n          << \"the two classes are from different namespaces or translation\\n\"\n          << \"units and have the same name.  You should probably rename one\\n\"\n          << \"of the classes to put the tests into different test suites.\";\n    }\n    return false;\n  }\n\n  return true;\n}\n\n#if GTEST_HAS_SEH\n\n// Adds an \"exception thrown\" fatal failure to the current test.  This\n// function returns its result via an output parameter pointer because VC++\n// prohibits creation of objects with destructors on stack in functions\n// using __try (see error C2712).\nstatic std::string* FormatSehExceptionMessage(DWORD exception_code,\n                                              const char* location) {\n  Message message;\n  message << \"SEH exception with code 0x\" << std::setbase(16) <<\n    exception_code << std::setbase(10) << \" thrown in \" << location << \".\";\n\n  return new std::string(message.GetString());\n}\n\n#endif  // GTEST_HAS_SEH\n\nnamespace internal {\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Adds an \"exception thrown\" fatal failure to the current test.\nstatic std::string FormatCxxExceptionMessage(const char* description,\n                                             const char* location) {\n  Message message;\n  if (description != nullptr) {\n    message << \"C++ exception with description \\\"\" << description << \"\\\"\";\n  } else {\n    message << \"Unknown C++ exception\";\n  }\n  message << \" thrown in \" << location << \".\";\n\n  return message.GetString();\n}\n\nstatic std::string PrintTestPartResultToString(\n    const TestPartResult& test_part_result);\n\nGoogleTestFailureException::GoogleTestFailureException(\n    const TestPartResult& failure)\n    : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// We put these helper functions in the internal namespace as IBM's xlC\n// compiler rejects the code if they were declared static.\n\n// Runs the given method and handles SEH exceptions it throws, when\n// SEH is supported; returns the 0-value for type Result in case of an\n// SEH exception.  (Microsoft compilers cannot handle SEH and C++\n// exceptions in the same function.  Therefore, we provide a separate\n// wrapper function for handling SEH exceptions.)\ntemplate <class T, typename Result>\nResult HandleSehExceptionsInMethodIfSupported(\n    T* object, Result (T::*method)(), const char* location) {\n#if GTEST_HAS_SEH\n  __try {\n    return (object->*method)();\n  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT\n      GetExceptionCode())) {\n    // We create the exception message on the heap because VC++ prohibits\n    // creation of objects with destructors on stack in functions using __try\n    // (see error C2712).\n    std::string* exception_message = FormatSehExceptionMessage(\n        GetExceptionCode(), location);\n    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,\n                                             *exception_message);\n    delete exception_message;\n    return static_cast<Result>(0);\n  }\n#else\n  (void)location;\n  return (object->*method)();\n#endif  // GTEST_HAS_SEH\n}\n\n// Runs the given method and catches and reports C++ and/or SEH-style\n// exceptions, if they are supported; returns the 0-value for type\n// Result in case of an SEH exception.\ntemplate <class T, typename Result>\nResult HandleExceptionsInMethodIfSupported(\n    T* object, Result (T::*method)(), const char* location) {\n  // NOTE: The user code can affect the way in which Google Test handles\n  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before\n  // RUN_ALL_TESTS() starts. It is technically possible to check the flag\n  // after the exception is caught and either report or re-throw the\n  // exception based on the flag's value:\n  //\n  // try {\n  //   // Perform the test method.\n  // } catch (...) {\n  //   if (GTEST_FLAG(catch_exceptions))\n  //     // Report the exception as failure.\n  //   else\n  //     throw;  // Re-throws the original exception.\n  // }\n  //\n  // However, the purpose of this flag is to allow the program to drop into\n  // the debugger when the exception is thrown. On most platforms, once the\n  // control enters the catch block, the exception origin information is\n  // lost and the debugger will stop the program at the point of the\n  // re-throw in this function -- instead of at the point of the original\n  // throw statement in the code under test.  For this reason, we perform\n  // the check early, sacrificing the ability to affect Google Test's\n  // exception handling in the method where the exception is thrown.\n  if (internal::GetUnitTestImpl()->catch_exceptions()) {\n#if GTEST_HAS_EXCEPTIONS\n    try {\n      return HandleSehExceptionsInMethodIfSupported(object, method, location);\n    } catch (const AssertionException&) {  // NOLINT\n      // This failure was reported already.\n    } catch (const internal::GoogleTestFailureException&) {  // NOLINT\n      // This exception type can only be thrown by a failed Google\n      // Test assertion with the intention of letting another testing\n      // framework catch it.  Therefore we just re-throw it.\n      throw;\n    } catch (const std::exception& e) {  // NOLINT\n      internal::ReportFailureInUnknownLocation(\n          TestPartResult::kFatalFailure,\n          FormatCxxExceptionMessage(e.what(), location));\n    } catch (...) {  // NOLINT\n      internal::ReportFailureInUnknownLocation(\n          TestPartResult::kFatalFailure,\n          FormatCxxExceptionMessage(nullptr, location));\n    }\n    return static_cast<Result>(0);\n#else\n    return HandleSehExceptionsInMethodIfSupported(object, method, location);\n#endif  // GTEST_HAS_EXCEPTIONS\n  } else {\n    return (object->*method)();\n  }\n}\n\n}  // namespace internal\n\n// Runs the test and updates the test result.\nvoid Test::Run() {\n  if (!HasSameFixtureClass()) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, \"SetUp()\");\n  // We will run the test only if SetUp() was successful and didn't call\n  // GTEST_SKIP().\n  if (!HasFatalFailure() && !IsSkipped()) {\n    impl->os_stack_trace_getter()->UponLeavingGTest();\n    internal::HandleExceptionsInMethodIfSupported(\n        this, &Test::TestBody, \"the test body\");\n  }\n\n  // However, we want to clean up as much as possible.  Hence we will\n  // always call TearDown(), even if SetUp() or the test body has\n  // failed.\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &Test::TearDown, \"TearDown()\");\n}\n\n// Returns true if and only if the current test has a fatal failure.\nbool Test::HasFatalFailure() {\n  return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();\n}\n\n// Returns true if and only if the current test has a non-fatal failure.\nbool Test::HasNonfatalFailure() {\n  return internal::GetUnitTestImpl()->current_test_result()->\n      HasNonfatalFailure();\n}\n\n// Returns true if and only if the current test was skipped.\nbool Test::IsSkipped() {\n  return internal::GetUnitTestImpl()->current_test_result()->Skipped();\n}\n\n// class TestInfo\n\n// Constructs a TestInfo object. It assumes ownership of the test factory\n// object.\nTestInfo::TestInfo(const std::string& a_test_suite_name,\n                   const std::string& a_name, const char* a_type_param,\n                   const char* a_value_param,\n                   internal::CodeLocation a_code_location,\n                   internal::TypeId fixture_class_id,\n                   internal::TestFactoryBase* factory)\n    : test_suite_name_(a_test_suite_name),\n      name_(a_name),\n      type_param_(a_type_param ? new std::string(a_type_param) : nullptr),\n      value_param_(a_value_param ? new std::string(a_value_param) : nullptr),\n      location_(a_code_location),\n      fixture_class_id_(fixture_class_id),\n      should_run_(false),\n      is_disabled_(false),\n      matches_filter_(false),\n      is_in_another_shard_(false),\n      factory_(factory),\n      result_() {}\n\n// Destructs a TestInfo object.\nTestInfo::~TestInfo() { delete factory_; }\n\nnamespace internal {\n\n// Creates a new TestInfo object and registers it with Google Test;\n// returns the created object.\n//\n// Arguments:\n//\n//   test_suite_name:  name of the test suite\n//   name:             name of the test\n//   type_param:       the name of the test's type parameter, or NULL if\n//                     this is not a typed or a type-parameterized test.\n//   value_param:      text representation of the test's value parameter,\n//                     or NULL if this is not a value-parameterized test.\n//   code_location:    code location where the test is defined\n//   fixture_class_id: ID of the test fixture class\n//   set_up_tc:        pointer to the function that sets up the test suite\n//   tear_down_tc:     pointer to the function that tears down the test suite\n//   factory:          pointer to the factory that creates a test object.\n//                     The newly created TestInfo instance will assume\n//                     ownership of the factory object.\nTestInfo* MakeAndRegisterTestInfo(\n    const char* test_suite_name, const char* name, const char* type_param,\n    const char* value_param, CodeLocation code_location,\n    TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,\n    TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory) {\n  TestInfo* const test_info =\n      new TestInfo(test_suite_name, name, type_param, value_param,\n                   code_location, fixture_class_id, factory);\n  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);\n  return test_info;\n}\n\nvoid ReportInvalidTestSuiteType(const char* test_suite_name,\n                                CodeLocation code_location) {\n  Message errors;\n  errors\n      << \"Attempted redefinition of test suite \" << test_suite_name << \".\\n\"\n      << \"All tests in the same test suite must use the same test fixture\\n\"\n      << \"class.  However, in test suite \" << test_suite_name << \", you tried\\n\"\n      << \"to define a test using a fixture class different from the one\\n\"\n      << \"used earlier. This can happen if the two fixture classes are\\n\"\n      << \"from different namespaces and have the same name. You should\\n\"\n      << \"probably rename one of the classes to put the tests into different\\n\"\n      << \"test suites.\";\n\n  GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(),\n                                          code_location.line)\n                    << \" \" << errors.GetString();\n}\n}  // namespace internal\n\nnamespace {\n\n// A predicate that checks the test name of a TestInfo against a known\n// value.\n//\n// This is used for implementation of the TestSuite class only.  We put\n// it in the anonymous namespace to prevent polluting the outer\n// namespace.\n//\n// TestNameIs is copyable.\nclass TestNameIs {\n public:\n  // Constructor.\n  //\n  // TestNameIs has NO default constructor.\n  explicit TestNameIs(const char* name)\n      : name_(name) {}\n\n  // Returns true if and only if the test name of test_info matches name_.\n  bool operator()(const TestInfo * test_info) const {\n    return test_info && test_info->name() == name_;\n  }\n\n private:\n  std::string name_;\n};\n\n}  // namespace\n\nnamespace internal {\n\n// This method expands all parameterized tests registered with macros TEST_P\n// and INSTANTIATE_TEST_SUITE_P into regular tests and registers those.\n// This will be done just once during the program runtime.\nvoid UnitTestImpl::RegisterParameterizedTests() {\n  if (!parameterized_tests_registered_) {\n    parameterized_test_registry_.RegisterTests();\n    type_parameterized_test_registry_.CheckForInstantiations();\n    parameterized_tests_registered_ = true;\n  }\n}\n\n}  // namespace internal\n\n// Creates the test object, runs it, records its result, and then\n// deletes it.\nvoid TestInfo::Run() {\n  if (!should_run_) return;\n\n  // Tells UnitTest where to store test result.\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_info(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  // Notifies the unit test event listeners that a test is about to start.\n  repeater->OnTestStart(*this);\n\n  result_.set_start_timestamp(internal::GetTimeInMillis());\n  internal::Timer timer;\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n\n  // Creates the test object.\n  Test* const test = internal::HandleExceptionsInMethodIfSupported(\n      factory_, &internal::TestFactoryBase::CreateTest,\n      \"the test fixture's constructor\");\n\n  // Runs the test if the constructor didn't generate a fatal failure or invoke\n  // GTEST_SKIP().\n  // Note that the object will not be null\n  if (!Test::HasFatalFailure() && !Test::IsSkipped()) {\n    // This doesn't throw as all user code that can throw are wrapped into\n    // exception handling code.\n    test->Run();\n  }\n\n  if (test != nullptr) {\n    // Deletes the test object.\n    impl->os_stack_trace_getter()->UponLeavingGTest();\n    internal::HandleExceptionsInMethodIfSupported(\n        test, &Test::DeleteSelf_, \"the test fixture's destructor\");\n  }\n\n  result_.set_elapsed_time(timer.Elapsed());\n\n  // Notifies the unit test event listener that a test has just finished.\n  repeater->OnTestEnd(*this);\n\n  // Tells UnitTest to stop associating assertion results to this\n  // test.\n  impl->set_current_test_info(nullptr);\n}\n\n// Skip and records a skipped test result for this object.\nvoid TestInfo::Skip() {\n  if (!should_run_) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_info(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  // Notifies the unit test event listeners that a test is about to start.\n  repeater->OnTestStart(*this);\n\n  const TestPartResult test_part_result =\n      TestPartResult(TestPartResult::kSkip, this->file(), this->line(), \"\");\n  impl->GetTestPartResultReporterForCurrentThread()->ReportTestPartResult(\n      test_part_result);\n\n  // Notifies the unit test event listener that a test has just finished.\n  repeater->OnTestEnd(*this);\n  impl->set_current_test_info(nullptr);\n}\n\n// class TestSuite\n\n// Gets the number of successful tests in this test suite.\nint TestSuite::successful_test_count() const {\n  return CountIf(test_info_list_, TestPassed);\n}\n\n// Gets the number of successful tests in this test suite.\nint TestSuite::skipped_test_count() const {\n  return CountIf(test_info_list_, TestSkipped);\n}\n\n// Gets the number of failed tests in this test suite.\nint TestSuite::failed_test_count() const {\n  return CountIf(test_info_list_, TestFailed);\n}\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint TestSuite::reportable_disabled_test_count() const {\n  return CountIf(test_info_list_, TestReportableDisabled);\n}\n\n// Gets the number of disabled tests in this test suite.\nint TestSuite::disabled_test_count() const {\n  return CountIf(test_info_list_, TestDisabled);\n}\n\n// Gets the number of tests to be printed in the XML report.\nint TestSuite::reportable_test_count() const {\n  return CountIf(test_info_list_, TestReportable);\n}\n\n// Get the number of tests in this test suite that should run.\nint TestSuite::test_to_run_count() const {\n  return CountIf(test_info_list_, ShouldRunTest);\n}\n\n// Gets the number of all tests.\nint TestSuite::total_test_count() const {\n  return static_cast<int>(test_info_list_.size());\n}\n\n// Creates a TestSuite with the given name.\n//\n// Arguments:\n//\n//   a_name:       name of the test suite\n//   a_type_param: the name of the test suite's type parameter, or NULL if\n//                 this is not a typed or a type-parameterized test suite.\n//   set_up_tc:    pointer to the function that sets up the test suite\n//   tear_down_tc: pointer to the function that tears down the test suite\nTestSuite::TestSuite(const char* a_name, const char* a_type_param,\n                     internal::SetUpTestSuiteFunc set_up_tc,\n                     internal::TearDownTestSuiteFunc tear_down_tc)\n    : name_(a_name),\n      type_param_(a_type_param ? new std::string(a_type_param) : nullptr),\n      set_up_tc_(set_up_tc),\n      tear_down_tc_(tear_down_tc),\n      should_run_(false),\n      start_timestamp_(0),\n      elapsed_time_(0) {}\n\n// Destructor of TestSuite.\nTestSuite::~TestSuite() {\n  // Deletes every Test in the collection.\n  ForEach(test_info_list_, internal::Delete<TestInfo>);\n}\n\n// Returns the i-th test among all the tests. i can range from 0 to\n// total_test_count() - 1. If i is not in that range, returns NULL.\nconst TestInfo* TestSuite::GetTestInfo(int i) const {\n  const int index = GetElementOr(test_indices_, i, -1);\n  return index < 0 ? nullptr : test_info_list_[static_cast<size_t>(index)];\n}\n\n// Returns the i-th test among all the tests. i can range from 0 to\n// total_test_count() - 1. If i is not in that range, returns NULL.\nTestInfo* TestSuite::GetMutableTestInfo(int i) {\n  const int index = GetElementOr(test_indices_, i, -1);\n  return index < 0 ? nullptr : test_info_list_[static_cast<size_t>(index)];\n}\n\n// Adds a test to this test suite.  Will delete the test upon\n// destruction of the TestSuite object.\nvoid TestSuite::AddTestInfo(TestInfo* test_info) {\n  test_info_list_.push_back(test_info);\n  test_indices_.push_back(static_cast<int>(test_indices_.size()));\n}\n\n// Runs every test in this TestSuite.\nvoid TestSuite::Run() {\n  if (!should_run_) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_suite(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  // Call both legacy and the new API\n  repeater->OnTestSuiteStart(*this);\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  repeater->OnTestCaseStart(*this);\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &TestSuite::RunSetUpTestSuite, \"SetUpTestSuite()\");\n\n  start_timestamp_ = internal::GetTimeInMillis();\n  internal::Timer timer;\n  for (int i = 0; i < total_test_count(); i++) {\n    GetMutableTestInfo(i)->Run();\n    if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {\n      for (int j = i + 1; j < total_test_count(); j++) {\n        GetMutableTestInfo(j)->Skip();\n      }\n      break;\n    }\n  }\n  elapsed_time_ = timer.Elapsed();\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &TestSuite::RunTearDownTestSuite, \"TearDownTestSuite()\");\n\n  // Call both legacy and the new API\n  repeater->OnTestSuiteEnd(*this);\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  repeater->OnTestCaseEnd(*this);\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  impl->set_current_test_suite(nullptr);\n}\n\n// Skips all tests under this TestSuite.\nvoid TestSuite::Skip() {\n  if (!should_run_) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_suite(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  // Call both legacy and the new API\n  repeater->OnTestSuiteStart(*this);\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  repeater->OnTestCaseStart(*this);\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  for (int i = 0; i < total_test_count(); i++) {\n    GetMutableTestInfo(i)->Skip();\n  }\n\n  // Call both legacy and the new API\n  repeater->OnTestSuiteEnd(*this);\n  // Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  repeater->OnTestCaseEnd(*this);\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  impl->set_current_test_suite(nullptr);\n}\n\n// Clears the results of all tests in this test suite.\nvoid TestSuite::ClearResult() {\n  ad_hoc_test_result_.Clear();\n  ForEach(test_info_list_, TestInfo::ClearTestResult);\n}\n\n// Shuffles the tests in this test suite.\nvoid TestSuite::ShuffleTests(internal::Random* random) {\n  Shuffle(random, &test_indices_);\n}\n\n// Restores the test order to before the first shuffle.\nvoid TestSuite::UnshuffleTests() {\n  for (size_t i = 0; i < test_indices_.size(); i++) {\n    test_indices_[i] = static_cast<int>(i);\n  }\n}\n\n// Formats a countable noun.  Depending on its quantity, either the\n// singular form or the plural form is used. e.g.\n//\n// FormatCountableNoun(1, \"formula\", \"formuli\") returns \"1 formula\".\n// FormatCountableNoun(5, \"book\", \"books\") returns \"5 books\".\nstatic std::string FormatCountableNoun(int count,\n                                       const char * singular_form,\n                                       const char * plural_form) {\n  return internal::StreamableToString(count) + \" \" +\n      (count == 1 ? singular_form : plural_form);\n}\n\n// Formats the count of tests.\nstatic std::string FormatTestCount(int test_count) {\n  return FormatCountableNoun(test_count, \"test\", \"tests\");\n}\n\n// Formats the count of test suites.\nstatic std::string FormatTestSuiteCount(int test_suite_count) {\n  return FormatCountableNoun(test_suite_count, \"test suite\", \"test suites\");\n}\n\n// Converts a TestPartResult::Type enum to human-friendly string\n// representation.  Both kNonFatalFailure and kFatalFailure are translated\n// to \"Failure\", as the user usually doesn't care about the difference\n// between the two when viewing the test result.\nstatic const char * TestPartResultTypeToString(TestPartResult::Type type) {\n  switch (type) {\n    case TestPartResult::kSkip:\n      return \"Skipped\\n\";\n    case TestPartResult::kSuccess:\n      return \"Success\";\n\n    case TestPartResult::kNonFatalFailure:\n    case TestPartResult::kFatalFailure:\n#ifdef _MSC_VER\n      return \"error: \";\n#else\n      return \"Failure\\n\";\n#endif\n    default:\n      return \"Unknown result type\";\n  }\n}\n\nnamespace internal {\nnamespace {\nenum class GTestColor { kDefault, kRed, kGreen, kYellow };\n}  // namespace\n\n// Prints a TestPartResult to an std::string.\nstatic std::string PrintTestPartResultToString(\n    const TestPartResult& test_part_result) {\n  return (Message()\n          << internal::FormatFileLocation(test_part_result.file_name(),\n                                          test_part_result.line_number())\n          << \" \" << TestPartResultTypeToString(test_part_result.type())\n          << test_part_result.message()).GetString();\n}\n\n// Prints a TestPartResult.\nstatic void PrintTestPartResult(const TestPartResult& test_part_result) {\n  const std::string& result =\n      PrintTestPartResultToString(test_part_result);\n  printf(\"%s\\n\", result.c_str());\n  fflush(stdout);\n  // If the test program runs in Visual Studio or a debugger, the\n  // following statements add the test part result message to the Output\n  // window such that the user can double-click on it to jump to the\n  // corresponding source code location; otherwise they do nothing.\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  // We don't call OutputDebugString*() on Windows Mobile, as printing\n  // to stdout is done by OutputDebugString() there already - we don't\n  // want the same message printed twice.\n  ::OutputDebugStringA(result.c_str());\n  ::OutputDebugStringA(\"\\n\");\n#endif\n}\n\n// class PrettyUnitTestResultPrinter\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \\\n    !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW\n\n// Returns the character attribute for the given color.\nstatic WORD GetColorAttribute(GTestColor color) {\n  switch (color) {\n    case GTestColor::kRed:\n      return FOREGROUND_RED;\n    case GTestColor::kGreen:\n      return FOREGROUND_GREEN;\n    case GTestColor::kYellow:\n      return FOREGROUND_RED | FOREGROUND_GREEN;\n    default:           return 0;\n  }\n}\n\nstatic int GetBitOffset(WORD color_mask) {\n  if (color_mask == 0) return 0;\n\n  int bitOffset = 0;\n  while ((color_mask & 1) == 0) {\n    color_mask >>= 1;\n    ++bitOffset;\n  }\n  return bitOffset;\n}\n\nstatic WORD GetNewColor(GTestColor color, WORD old_color_attrs) {\n  // Let's reuse the BG\n  static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |\n                                      BACKGROUND_RED | BACKGROUND_INTENSITY;\n  static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |\n                                      FOREGROUND_RED | FOREGROUND_INTENSITY;\n  const WORD existing_bg = old_color_attrs & background_mask;\n\n  WORD new_color =\n      GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;\n  static const int bg_bitOffset = GetBitOffset(background_mask);\n  static const int fg_bitOffset = GetBitOffset(foreground_mask);\n\n  if (((new_color & background_mask) >> bg_bitOffset) ==\n      ((new_color & foreground_mask) >> fg_bitOffset)) {\n    new_color ^= FOREGROUND_INTENSITY;  // invert intensity\n  }\n  return new_color;\n}\n\n#else\n\n// Returns the ANSI color code for the given color. GTestColor::kDefault is\n// an invalid input.\nstatic const char* GetAnsiColorCode(GTestColor color) {\n  switch (color) {\n    case GTestColor::kRed:\n      return \"1\";\n    case GTestColor::kGreen:\n      return \"2\";\n    case GTestColor::kYellow:\n      return \"3\";\n    default:\n      return nullptr;\n  }\n}\n\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n\n// Returns true if and only if Google Test should use colors in the output.\nbool ShouldUseColor(bool stdout_is_tty) {\n  const char* const gtest_color = GTEST_FLAG(color).c_str();\n\n  if (String::CaseInsensitiveCStringEquals(gtest_color, \"auto\")) {\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW\n    // On Windows the TERM variable is usually not set, but the\n    // console there does support colors.\n    return stdout_is_tty;\n#else\n    // On non-Windows platforms, we rely on the TERM variable.\n    const char* const term = posix::GetEnv(\"TERM\");\n    const bool term_supports_color =\n        String::CStringEquals(term, \"xterm\") ||\n        String::CStringEquals(term, \"xterm-color\") ||\n        String::CStringEquals(term, \"xterm-256color\") ||\n        String::CStringEquals(term, \"screen\") ||\n        String::CStringEquals(term, \"screen-256color\") ||\n        String::CStringEquals(term, \"tmux\") ||\n        String::CStringEquals(term, \"tmux-256color\") ||\n        String::CStringEquals(term, \"rxvt-unicode\") ||\n        String::CStringEquals(term, \"rxvt-unicode-256color\") ||\n        String::CStringEquals(term, \"linux\") ||\n        String::CStringEquals(term, \"cygwin\");\n    return stdout_is_tty && term_supports_color;\n#endif  // GTEST_OS_WINDOWS\n  }\n\n  return String::CaseInsensitiveCStringEquals(gtest_color, \"yes\") ||\n      String::CaseInsensitiveCStringEquals(gtest_color, \"true\") ||\n      String::CaseInsensitiveCStringEquals(gtest_color, \"t\") ||\n      String::CStringEquals(gtest_color, \"1\");\n  // We take \"yes\", \"true\", \"t\", and \"1\" as meaning \"yes\".  If the\n  // value is neither one of these nor \"auto\", we treat it as \"no\" to\n  // be conservative.\n}\n\n// Helpers for printing colored strings to stdout. Note that on Windows, we\n// cannot simply emit special characters and have the terminal change colors.\n// This routine must actually emit the characters rather than return a string\n// that would be colored when printed, as can be done on Linux.\n\nGTEST_ATTRIBUTE_PRINTF_(2, 3)\nstatic void ColoredPrintf(GTestColor color, const char *fmt, ...) {\n  va_list args;\n  va_start(args, fmt);\n\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \\\n    GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM)\n  const bool use_color = AlwaysFalse();\n#else\n  static const bool in_color_mode =\n      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);\n  const bool use_color = in_color_mode && (color != GTestColor::kDefault);\n#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS\n\n  if (!use_color) {\n    vprintf(fmt, args);\n    va_end(args);\n    return;\n  }\n\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \\\n    !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW\n  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);\n\n  // Gets the current text color.\n  CONSOLE_SCREEN_BUFFER_INFO buffer_info;\n  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);\n  const WORD old_color_attrs = buffer_info.wAttributes;\n  const WORD new_color = GetNewColor(color, old_color_attrs);\n\n  // We need to flush the stream buffers into the console before each\n  // SetConsoleTextAttribute call lest it affect the text that is already\n  // printed but has not yet reached the console.\n  fflush(stdout);\n  SetConsoleTextAttribute(stdout_handle, new_color);\n\n  vprintf(fmt, args);\n\n  fflush(stdout);\n  // Restores the text color.\n  SetConsoleTextAttribute(stdout_handle, old_color_attrs);\n#else\n  printf(\"\\033[0;3%sm\", GetAnsiColorCode(color));\n  vprintf(fmt, args);\n  printf(\"\\033[m\");  // Resets the terminal to default.\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  va_end(args);\n}\n\n// Text printed in Google Test's text output and --gtest_list_tests\n// output to label the type parameter and value parameter for a test.\nstatic const char kTypeParamLabel[] = \"TypeParam\";\nstatic const char kValueParamLabel[] = \"GetParam()\";\n\nstatic void PrintFullTestCommentIfPresent(const TestInfo& test_info) {\n  const char* const type_param = test_info.type_param();\n  const char* const value_param = test_info.value_param();\n\n  if (type_param != nullptr || value_param != nullptr) {\n    printf(\", where \");\n    if (type_param != nullptr) {\n      printf(\"%s = %s\", kTypeParamLabel, type_param);\n      if (value_param != nullptr) printf(\" and \");\n    }\n    if (value_param != nullptr) {\n      printf(\"%s = %s\", kValueParamLabel, value_param);\n    }\n  }\n}\n\n// This class implements the TestEventListener interface.\n//\n// Class PrettyUnitTestResultPrinter is copyable.\nclass PrettyUnitTestResultPrinter : public TestEventListener {\n public:\n  PrettyUnitTestResultPrinter() {}\n  static void PrintTestName(const char* test_suite, const char* test) {\n    printf(\"%s.%s\", test_suite, test);\n  }\n\n  // The following methods override what's in the TestEventListener class.\n  void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}\n  void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;\n  void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;\n  void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseStart(const TestCase& test_case) override;\n#else\n  void OnTestSuiteStart(const TestSuite& test_suite) override;\n#endif  // OnTestCaseStart\n\n  void OnTestStart(const TestInfo& test_info) override;\n\n  void OnTestPartResult(const TestPartResult& result) override;\n  void OnTestEnd(const TestInfo& test_info) override;\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseEnd(const TestCase& test_case) override;\n#else\n  void OnTestSuiteEnd(const TestSuite& test_suite) override;\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;\n  void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}\n  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;\n  void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}\n\n private:\n  static void PrintFailedTests(const UnitTest& unit_test);\n  static void PrintFailedTestSuites(const UnitTest& unit_test);\n  static void PrintSkippedTests(const UnitTest& unit_test);\n};\n\n  // Fired before each iteration of tests starts.\nvoid PrettyUnitTestResultPrinter::OnTestIterationStart(\n    const UnitTest& unit_test, int iteration) {\n  if (GTEST_FLAG(repeat) != 1)\n    printf(\"\\nRepeating all tests (iteration %d) . . .\\n\\n\", iteration + 1);\n\n  const char* const filter = GTEST_FLAG(filter).c_str();\n\n  // Prints the filter if it's not *.  This reminds the user that some\n  // tests may be skipped.\n  if (!String::CStringEquals(filter, kUniversalFilter)) {\n    ColoredPrintf(GTestColor::kYellow, \"Note: %s filter = %s\\n\", GTEST_NAME_,\n                  filter);\n  }\n\n  if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {\n    const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);\n    ColoredPrintf(GTestColor::kYellow, \"Note: This is test shard %d of %s.\\n\",\n                  static_cast<int>(shard_index) + 1,\n                  internal::posix::GetEnv(kTestTotalShards));\n  }\n\n  if (GTEST_FLAG(shuffle)) {\n    ColoredPrintf(GTestColor::kYellow,\n                  \"Note: Randomizing tests' orders with a seed of %d .\\n\",\n                  unit_test.random_seed());\n  }\n\n  ColoredPrintf(GTestColor::kGreen, \"[==========] \");\n  printf(\"Running %s from %s.\\n\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(\n    const UnitTest& /*unit_test*/) {\n  ColoredPrintf(GTestColor::kGreen, \"[----------] \");\n  printf(\"Global test environment set-up.\\n\");\n  fflush(stdout);\n}\n\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nvoid PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {\n  const std::string counts =\n      FormatCountableNoun(test_case.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(GTestColor::kGreen, \"[----------] \");\n  printf(\"%s from %s\", counts.c_str(), test_case.name());\n  if (test_case.type_param() == nullptr) {\n    printf(\"\\n\");\n  } else {\n    printf(\", where %s = %s\\n\", kTypeParamLabel, test_case.type_param());\n  }\n  fflush(stdout);\n}\n#else\nvoid PrettyUnitTestResultPrinter::OnTestSuiteStart(\n    const TestSuite& test_suite) {\n  const std::string counts =\n      FormatCountableNoun(test_suite.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(GTestColor::kGreen, \"[----------] \");\n  printf(\"%s from %s\", counts.c_str(), test_suite.name());\n  if (test_suite.type_param() == nullptr) {\n    printf(\"\\n\");\n  } else {\n    printf(\", where %s = %s\\n\", kTypeParamLabel, test_suite.type_param());\n  }\n  fflush(stdout);\n}\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\nvoid PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {\n  ColoredPrintf(GTestColor::kGreen, \"[ RUN      ] \");\n  PrintTestName(test_info.test_suite_name(), test_info.name());\n  printf(\"\\n\");\n  fflush(stdout);\n}\n\n// Called after an assertion failure.\nvoid PrettyUnitTestResultPrinter::OnTestPartResult(\n    const TestPartResult& result) {\n  switch (result.type()) {\n    // If the test part succeeded, we don't need to do anything.\n    case TestPartResult::kSuccess:\n      return;\n    default:\n      // Print failure message from the assertion\n      // (e.g. expected this and got that).\n      PrintTestPartResult(result);\n      fflush(stdout);\n  }\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {\n  if (test_info.result()->Passed()) {\n    ColoredPrintf(GTestColor::kGreen, \"[       OK ] \");\n  } else if (test_info.result()->Skipped()) {\n    ColoredPrintf(GTestColor::kGreen, \"[  SKIPPED ] \");\n  } else {\n    ColoredPrintf(GTestColor::kRed, \"[  FAILED  ] \");\n  }\n  PrintTestName(test_info.test_suite_name(), test_info.name());\n  if (test_info.result()->Failed())\n    PrintFullTestCommentIfPresent(test_info);\n\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms)\\n\", internal::StreamableToString(\n           test_info.result()->elapsed_time()).c_str());\n  } else {\n    printf(\"\\n\");\n  }\n  fflush(stdout);\n}\n\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nvoid PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {\n  if (!GTEST_FLAG(print_time)) return;\n\n  const std::string counts =\n      FormatCountableNoun(test_case.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(GTestColor::kGreen, \"[----------] \");\n  printf(\"%s from %s (%s ms total)\\n\\n\", counts.c_str(), test_case.name(),\n         internal::StreamableToString(test_case.elapsed_time()).c_str());\n  fflush(stdout);\n}\n#else\nvoid PrettyUnitTestResultPrinter::OnTestSuiteEnd(const TestSuite& test_suite) {\n  if (!GTEST_FLAG(print_time)) return;\n\n  const std::string counts =\n      FormatCountableNoun(test_suite.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(GTestColor::kGreen, \"[----------] \");\n  printf(\"%s from %s (%s ms total)\\n\\n\", counts.c_str(), test_suite.name(),\n         internal::StreamableToString(test_suite.elapsed_time()).c_str());\n  fflush(stdout);\n}\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\nvoid PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(\n    const UnitTest& /*unit_test*/) {\n  ColoredPrintf(GTestColor::kGreen, \"[----------] \");\n  printf(\"Global test environment tear-down\\n\");\n  fflush(stdout);\n}\n\n// Internal helper for printing the list of failed tests.\nvoid PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {\n  const int failed_test_count = unit_test.failed_test_count();\n  ColoredPrintf(GTestColor::kRed, \"[  FAILED  ] \");\n  printf(\"%s, listed below:\\n\", FormatTestCount(failed_test_count).c_str());\n\n  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {\n    const TestSuite& test_suite = *unit_test.GetTestSuite(i);\n    if (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {\n      continue;\n    }\n    for (int j = 0; j < test_suite.total_test_count(); ++j) {\n      const TestInfo& test_info = *test_suite.GetTestInfo(j);\n      if (!test_info.should_run() || !test_info.result()->Failed()) {\n        continue;\n      }\n      ColoredPrintf(GTestColor::kRed, \"[  FAILED  ] \");\n      printf(\"%s.%s\", test_suite.name(), test_info.name());\n      PrintFullTestCommentIfPresent(test_info);\n      printf(\"\\n\");\n    }\n  }\n  printf(\"\\n%2d FAILED %s\\n\", failed_test_count,\n         failed_test_count == 1 ? \"TEST\" : \"TESTS\");\n}\n\n// Internal helper for printing the list of test suite failures not covered by\n// PrintFailedTests.\nvoid PrettyUnitTestResultPrinter::PrintFailedTestSuites(\n    const UnitTest& unit_test) {\n  int suite_failure_count = 0;\n  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {\n    const TestSuite& test_suite = *unit_test.GetTestSuite(i);\n    if (!test_suite.should_run()) {\n      continue;\n    }\n    if (test_suite.ad_hoc_test_result().Failed()) {\n      ColoredPrintf(GTestColor::kRed, \"[  FAILED  ] \");\n      printf(\"%s: SetUpTestSuite or TearDownTestSuite\\n\", test_suite.name());\n      ++suite_failure_count;\n    }\n  }\n  if (suite_failure_count > 0) {\n    printf(\"\\n%2d FAILED TEST %s\\n\", suite_failure_count,\n           suite_failure_count == 1 ? \"SUITE\" : \"SUITES\");\n  }\n}\n\n// Internal helper for printing the list of skipped tests.\nvoid PrettyUnitTestResultPrinter::PrintSkippedTests(const UnitTest& unit_test) {\n  const int skipped_test_count = unit_test.skipped_test_count();\n  if (skipped_test_count == 0) {\n    return;\n  }\n\n  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {\n    const TestSuite& test_suite = *unit_test.GetTestSuite(i);\n    if (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {\n      continue;\n    }\n    for (int j = 0; j < test_suite.total_test_count(); ++j) {\n      const TestInfo& test_info = *test_suite.GetTestInfo(j);\n      if (!test_info.should_run() || !test_info.result()->Skipped()) {\n        continue;\n      }\n      ColoredPrintf(GTestColor::kGreen, \"[  SKIPPED ] \");\n      printf(\"%s.%s\", test_suite.name(), test_info.name());\n      printf(\"\\n\");\n    }\n  }\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                     int /*iteration*/) {\n  ColoredPrintf(GTestColor::kGreen, \"[==========] \");\n  printf(\"%s from %s ran.\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms total)\",\n           internal::StreamableToString(unit_test.elapsed_time()).c_str());\n  }\n  printf(\"\\n\");\n  ColoredPrintf(GTestColor::kGreen, \"[  PASSED  ] \");\n  printf(\"%s.\\n\", FormatTestCount(unit_test.successful_test_count()).c_str());\n\n  const int skipped_test_count = unit_test.skipped_test_count();\n  if (skipped_test_count > 0) {\n    ColoredPrintf(GTestColor::kGreen, \"[  SKIPPED ] \");\n    printf(\"%s, listed below:\\n\", FormatTestCount(skipped_test_count).c_str());\n    PrintSkippedTests(unit_test);\n  }\n\n  if (!unit_test.Passed()) {\n    PrintFailedTests(unit_test);\n    PrintFailedTestSuites(unit_test);\n  }\n\n  int num_disabled = unit_test.reportable_disabled_test_count();\n  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {\n    if (unit_test.Passed()) {\n      printf(\"\\n\");  // Add a spacer if no FAILURE banner is displayed.\n    }\n    ColoredPrintf(GTestColor::kYellow, \"  YOU HAVE %d DISABLED %s\\n\\n\",\n                  num_disabled, num_disabled == 1 ? \"TEST\" : \"TESTS\");\n  }\n  // Ensure that Google Test output is printed before, e.g., heapchecker output.\n  fflush(stdout);\n}\n\n// End PrettyUnitTestResultPrinter\n\n// This class implements the TestEventListener interface.\n//\n// Class BriefUnitTestResultPrinter is copyable.\nclass BriefUnitTestResultPrinter : public TestEventListener {\n public:\n  BriefUnitTestResultPrinter() {}\n  static void PrintTestName(const char* test_suite, const char* test) {\n    printf(\"%s.%s\", test_suite, test);\n  }\n\n  // The following methods override what's in the TestEventListener class.\n  void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}\n  void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                            int /*iteration*/) override {}\n  void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}\n  void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseStart(const TestCase& /*test_case*/) override {}\n#else\n  void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {}\n#endif  // OnTestCaseStart\n\n  void OnTestStart(const TestInfo& /*test_info*/) override {}\n\n  void OnTestPartResult(const TestPartResult& result) override;\n  void OnTestEnd(const TestInfo& test_info) override;\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseEnd(const TestCase& /*test_case*/) override {}\n#else\n  void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}\n  void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}\n  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;\n  void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}\n};\n\n// Called after an assertion failure.\nvoid BriefUnitTestResultPrinter::OnTestPartResult(\n    const TestPartResult& result) {\n  switch (result.type()) {\n    // If the test part succeeded, we don't need to do anything.\n    case TestPartResult::kSuccess:\n      return;\n    default:\n      // Print failure message from the assertion\n      // (e.g. expected this and got that).\n      PrintTestPartResult(result);\n      fflush(stdout);\n  }\n}\n\nvoid BriefUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {\n  if (test_info.result()->Failed()) {\n    ColoredPrintf(GTestColor::kRed, \"[  FAILED  ] \");\n    PrintTestName(test_info.test_suite_name(), test_info.name());\n    PrintFullTestCommentIfPresent(test_info);\n\n    if (GTEST_FLAG(print_time)) {\n      printf(\" (%s ms)\\n\",\n             internal::StreamableToString(test_info.result()->elapsed_time())\n                 .c_str());\n    } else {\n      printf(\"\\n\");\n    }\n    fflush(stdout);\n  }\n}\n\nvoid BriefUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                    int /*iteration*/) {\n  ColoredPrintf(GTestColor::kGreen, \"[==========] \");\n  printf(\"%s from %s ran.\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms total)\",\n           internal::StreamableToString(unit_test.elapsed_time()).c_str());\n  }\n  printf(\"\\n\");\n  ColoredPrintf(GTestColor::kGreen, \"[  PASSED  ] \");\n  printf(\"%s.\\n\", FormatTestCount(unit_test.successful_test_count()).c_str());\n\n  const int skipped_test_count = unit_test.skipped_test_count();\n  if (skipped_test_count > 0) {\n    ColoredPrintf(GTestColor::kGreen, \"[  SKIPPED ] \");\n    printf(\"%s.\\n\", FormatTestCount(skipped_test_count).c_str());\n  }\n\n  int num_disabled = unit_test.reportable_disabled_test_count();\n  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {\n    if (unit_test.Passed()) {\n      printf(\"\\n\");  // Add a spacer if no FAILURE banner is displayed.\n    }\n    ColoredPrintf(GTestColor::kYellow, \"  YOU HAVE %d DISABLED %s\\n\\n\",\n                  num_disabled, num_disabled == 1 ? \"TEST\" : \"TESTS\");\n  }\n  // Ensure that Google Test output is printed before, e.g., heapchecker output.\n  fflush(stdout);\n}\n\n// End BriefUnitTestResultPrinter\n\n// class TestEventRepeater\n//\n// This class forwards events to other event listeners.\nclass TestEventRepeater : public TestEventListener {\n public:\n  TestEventRepeater() : forwarding_enabled_(true) {}\n  ~TestEventRepeater() override;\n  void Append(TestEventListener *listener);\n  TestEventListener* Release(TestEventListener* listener);\n\n  // Controls whether events will be forwarded to listeners_. Set to false\n  // in death test child processes.\n  bool forwarding_enabled() const { return forwarding_enabled_; }\n  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }\n\n  void OnTestProgramStart(const UnitTest& unit_test) override;\n  void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;\n  void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;\n  void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override;\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseStart(const TestSuite& parameter) override;\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestSuiteStart(const TestSuite& parameter) override;\n  void OnTestStart(const TestInfo& test_info) override;\n  void OnTestPartResult(const TestPartResult& result) override;\n  void OnTestEnd(const TestInfo& test_info) override;\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseEnd(const TestCase& parameter) override;\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestSuiteEnd(const TestSuite& parameter) override;\n  void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;\n  void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override;\n  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;\n  void OnTestProgramEnd(const UnitTest& unit_test) override;\n\n private:\n  // Controls whether events will be forwarded to listeners_. Set to false\n  // in death test child processes.\n  bool forwarding_enabled_;\n  // The list of listeners that receive events.\n  std::vector<TestEventListener*> listeners_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);\n};\n\nTestEventRepeater::~TestEventRepeater() {\n  ForEach(listeners_, Delete<TestEventListener>);\n}\n\nvoid TestEventRepeater::Append(TestEventListener *listener) {\n  listeners_.push_back(listener);\n}\n\nTestEventListener* TestEventRepeater::Release(TestEventListener *listener) {\n  for (size_t i = 0; i < listeners_.size(); ++i) {\n    if (listeners_[i] == listener) {\n      listeners_.erase(listeners_.begin() + static_cast<int>(i));\n      return listener;\n    }\n  }\n\n  return nullptr;\n}\n\n// Since most methods are very similar, use macros to reduce boilerplate.\n// This defines a member that forwards the call to all listeners.\n#define GTEST_REPEATER_METHOD_(Name, Type) \\\nvoid TestEventRepeater::Name(const Type& parameter) { \\\n  if (forwarding_enabled_) { \\\n    for (size_t i = 0; i < listeners_.size(); i++) { \\\n      listeners_[i]->Name(parameter); \\\n    } \\\n  } \\\n}\n// This defines a member that forwards the call to all listeners in reverse\n// order.\n#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)      \\\n  void TestEventRepeater::Name(const Type& parameter) { \\\n    if (forwarding_enabled_) {                          \\\n      for (size_t i = listeners_.size(); i != 0; i--) { \\\n        listeners_[i - 1]->Name(parameter);             \\\n      }                                                 \\\n    }                                                   \\\n  }\n\nGTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)\nGTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nGTEST_REPEATER_METHOD_(OnTestCaseStart, TestSuite)\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nGTEST_REPEATER_METHOD_(OnTestSuiteStart, TestSuite)\nGTEST_REPEATER_METHOD_(OnTestStart, TestInfo)\nGTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)\nGTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nGTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestSuite)\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nGTEST_REVERSE_REPEATER_METHOD_(OnTestSuiteEnd, TestSuite)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)\n\n#undef GTEST_REPEATER_METHOD_\n#undef GTEST_REVERSE_REPEATER_METHOD_\n\nvoid TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,\n                                             int iteration) {\n  if (forwarding_enabled_) {\n    for (size_t i = 0; i < listeners_.size(); i++) {\n      listeners_[i]->OnTestIterationStart(unit_test, iteration);\n    }\n  }\n}\n\nvoid TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,\n                                           int iteration) {\n  if (forwarding_enabled_) {\n    for (size_t i = listeners_.size(); i > 0; i--) {\n      listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);\n    }\n  }\n}\n\n// End TestEventRepeater\n\n// This class generates an XML output file.\nclass XmlUnitTestResultPrinter : public EmptyTestEventListener {\n public:\n  explicit XmlUnitTestResultPrinter(const char* output_file);\n\n  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;\n  void ListTestsMatchingFilter(const std::vector<TestSuite*>& test_suites);\n\n  // Prints an XML summary of all unit tests.\n  static void PrintXmlTestsList(std::ostream* stream,\n                                const std::vector<TestSuite*>& test_suites);\n\n private:\n  // Is c a whitespace character that is normalized to a space character\n  // when it appears in an XML attribute value?\n  static bool IsNormalizableWhitespace(char c) {\n    return c == 0x9 || c == 0xA || c == 0xD;\n  }\n\n  // May c appear in a well-formed XML document?\n  static bool IsValidXmlCharacter(char c) {\n    return IsNormalizableWhitespace(c) || c >= 0x20;\n  }\n\n  // Returns an XML-escaped copy of the input string str.  If\n  // is_attribute is true, the text is meant to appear as an attribute\n  // value, and normalizable whitespace is preserved by replacing it\n  // with character references.\n  static std::string EscapeXml(const std::string& str, bool is_attribute);\n\n  // Returns the given string with all characters invalid in XML removed.\n  static std::string RemoveInvalidXmlCharacters(const std::string& str);\n\n  // Convenience wrapper around EscapeXml when str is an attribute value.\n  static std::string EscapeXmlAttribute(const std::string& str) {\n    return EscapeXml(str, true);\n  }\n\n  // Convenience wrapper around EscapeXml when str is not an attribute value.\n  static std::string EscapeXmlText(const char* str) {\n    return EscapeXml(str, false);\n  }\n\n  // Verifies that the given attribute belongs to the given element and\n  // streams the attribute as XML.\n  static void OutputXmlAttribute(std::ostream* stream,\n                                 const std::string& element_name,\n                                 const std::string& name,\n                                 const std::string& value);\n\n  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.\n  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);\n\n  // Streams a test suite XML stanza containing the given test result.\n  //\n  // Requires: result.Failed()\n  static void OutputXmlTestSuiteForTestResult(::std::ostream* stream,\n                                              const TestResult& result);\n\n  // Streams an XML representation of a TestResult object.\n  static void OutputXmlTestResult(::std::ostream* stream,\n                                  const TestResult& result);\n\n  // Streams an XML representation of a TestInfo object.\n  static void OutputXmlTestInfo(::std::ostream* stream,\n                                const char* test_suite_name,\n                                const TestInfo& test_info);\n\n  // Prints an XML representation of a TestSuite object\n  static void PrintXmlTestSuite(::std::ostream* stream,\n                                const TestSuite& test_suite);\n\n  // Prints an XML summary of unit_test to output stream out.\n  static void PrintXmlUnitTest(::std::ostream* stream,\n                               const UnitTest& unit_test);\n\n  // Produces a string representing the test properties in a result as space\n  // delimited XML attributes based on the property key=\"value\" pairs.\n  // When the std::string is not empty, it includes a space at the beginning,\n  // to delimit this attribute from prior attributes.\n  static std::string TestPropertiesAsXmlAttributes(const TestResult& result);\n\n  // Streams an XML representation of the test properties of a TestResult\n  // object.\n  static void OutputXmlTestProperties(std::ostream* stream,\n                                      const TestResult& result);\n\n  // The output file.\n  const std::string output_file_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);\n};\n\n// Creates a new XmlUnitTestResultPrinter.\nXmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)\n    : output_file_(output_file) {\n  if (output_file_.empty()) {\n    GTEST_LOG_(FATAL) << \"XML output file may not be null\";\n  }\n}\n\n// Called after the unit test ends.\nvoid XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                  int /*iteration*/) {\n  FILE* xmlout = OpenFileForWriting(output_file_);\n  std::stringstream stream;\n  PrintXmlUnitTest(&stream, unit_test);\n  fprintf(xmlout, \"%s\", StringStreamToString(&stream).c_str());\n  fclose(xmlout);\n}\n\nvoid XmlUnitTestResultPrinter::ListTestsMatchingFilter(\n    const std::vector<TestSuite*>& test_suites) {\n  FILE* xmlout = OpenFileForWriting(output_file_);\n  std::stringstream stream;\n  PrintXmlTestsList(&stream, test_suites);\n  fprintf(xmlout, \"%s\", StringStreamToString(&stream).c_str());\n  fclose(xmlout);\n}\n\n// Returns an XML-escaped copy of the input string str.  If is_attribute\n// is true, the text is meant to appear as an attribute value, and\n// normalizable whitespace is preserved by replacing it with character\n// references.\n//\n// Invalid XML characters in str, if any, are stripped from the output.\n// It is expected that most, if not all, of the text processed by this\n// module will consist of ordinary English text.\n// If this module is ever modified to produce version 1.1 XML output,\n// most invalid characters can be retained using character references.\nstd::string XmlUnitTestResultPrinter::EscapeXml(\n    const std::string& str, bool is_attribute) {\n  Message m;\n\n  for (size_t i = 0; i < str.size(); ++i) {\n    const char ch = str[i];\n    switch (ch) {\n      case '<':\n        m << \"&lt;\";\n        break;\n      case '>':\n        m << \"&gt;\";\n        break;\n      case '&':\n        m << \"&amp;\";\n        break;\n      case '\\'':\n        if (is_attribute)\n          m << \"&apos;\";\n        else\n          m << '\\'';\n        break;\n      case '\"':\n        if (is_attribute)\n          m << \"&quot;\";\n        else\n          m << '\"';\n        break;\n      default:\n        if (IsValidXmlCharacter(ch)) {\n          if (is_attribute && IsNormalizableWhitespace(ch))\n            m << \"&#x\" << String::FormatByte(static_cast<unsigned char>(ch))\n              << \";\";\n          else\n            m << ch;\n        }\n        break;\n    }\n  }\n\n  return m.GetString();\n}\n\n// Returns the given string with all characters invalid in XML removed.\n// Currently invalid characters are dropped from the string. An\n// alternative is to replace them with certain characters such as . or ?.\nstd::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(\n    const std::string& str) {\n  std::string output;\n  output.reserve(str.size());\n  for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)\n    if (IsValidXmlCharacter(*it))\n      output.push_back(*it);\n\n  return output;\n}\n\n// The following routines generate an XML representation of a UnitTest\n// object.\n// GOOGLETEST_CM0009 DO NOT DELETE\n//\n// This is how Google Test concepts map to the DTD:\n//\n// <testsuites name=\"AllTests\">        <-- corresponds to a UnitTest object\n//   <testsuite name=\"testcase-name\">  <-- corresponds to a TestSuite object\n//     <testcase name=\"test-name\">     <-- corresponds to a TestInfo object\n//       <failure message=\"...\">...</failure>\n//       <failure message=\"...\">...</failure>\n//       <failure message=\"...\">...</failure>\n//                                     <-- individual assertion failures\n//     </testcase>\n//   </testsuite>\n// </testsuites>\n\n// Formats the given time in milliseconds as seconds.\nstd::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {\n  ::std::stringstream ss;\n  ss << (static_cast<double>(ms) * 1e-3);\n  return ss.str();\n}\n\nstatic bool PortableLocaltime(time_t seconds, struct tm* out) {\n#if defined(_MSC_VER)\n  return localtime_s(out, &seconds) == 0;\n#elif defined(__MINGW32__) || defined(__MINGW64__)\n  // MINGW <time.h> provides neither localtime_r nor localtime_s, but uses\n  // Windows' localtime(), which has a thread-local tm buffer.\n  struct tm* tm_ptr = localtime(&seconds);  // NOLINT\n  if (tm_ptr == nullptr) return false;\n  *out = *tm_ptr;\n  return true;\n#elif defined(__STDC_LIB_EXT1__)\n  // Uses localtime_s when available as localtime_r is only available from\n  // C23 standard.\n  return localtime_s(&seconds, out) != nullptr;\n#else\n  return localtime_r(&seconds, out) != nullptr;\n#endif\n}\n\n// Converts the given epoch time in milliseconds to a date string in the ISO\n// 8601 format, without the timezone information.\nstd::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {\n  struct tm time_struct;\n  if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))\n    return \"\";\n  // YYYY-MM-DDThh:mm:ss.sss\n  return StreamableToString(time_struct.tm_year + 1900) + \"-\" +\n      String::FormatIntWidth2(time_struct.tm_mon + 1) + \"-\" +\n      String::FormatIntWidth2(time_struct.tm_mday) + \"T\" +\n      String::FormatIntWidth2(time_struct.tm_hour) + \":\" +\n      String::FormatIntWidth2(time_struct.tm_min) + \":\" +\n      String::FormatIntWidth2(time_struct.tm_sec) + \".\" +\n      String::FormatIntWidthN(static_cast<int>(ms % 1000), 3);\n}\n\n// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.\nvoid XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,\n                                                     const char* data) {\n  const char* segment = data;\n  *stream << \"<![CDATA[\";\n  for (;;) {\n    const char* const next_segment = strstr(segment, \"]]>\");\n    if (next_segment != nullptr) {\n      stream->write(\n          segment, static_cast<std::streamsize>(next_segment - segment));\n      *stream << \"]]>]]&gt;<![CDATA[\";\n      segment = next_segment + strlen(\"]]>\");\n    } else {\n      *stream << segment;\n      break;\n    }\n  }\n  *stream << \"]]>\";\n}\n\nvoid XmlUnitTestResultPrinter::OutputXmlAttribute(\n    std::ostream* stream,\n    const std::string& element_name,\n    const std::string& name,\n    const std::string& value) {\n  const std::vector<std::string>& allowed_names =\n      GetReservedOutputAttributesForElement(element_name);\n\n  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=\n                   allowed_names.end())\n      << \"Attribute \" << name << \" is not allowed for element <\" << element_name\n      << \">.\";\n\n  *stream << \" \" << name << \"=\\\"\" << EscapeXmlAttribute(value) << \"\\\"\";\n}\n\n// Streams a test suite XML stanza containing the given test result.\nvoid XmlUnitTestResultPrinter::OutputXmlTestSuiteForTestResult(\n    ::std::ostream* stream, const TestResult& result) {\n  // Output the boilerplate for a minimal test suite with one test.\n  *stream << \"  <testsuite\";\n  OutputXmlAttribute(stream, \"testsuite\", \"name\", \"NonTestSuiteFailure\");\n  OutputXmlAttribute(stream, \"testsuite\", \"tests\", \"1\");\n  OutputXmlAttribute(stream, \"testsuite\", \"failures\", \"1\");\n  OutputXmlAttribute(stream, \"testsuite\", \"disabled\", \"0\");\n  OutputXmlAttribute(stream, \"testsuite\", \"skipped\", \"0\");\n  OutputXmlAttribute(stream, \"testsuite\", \"errors\", \"0\");\n  OutputXmlAttribute(stream, \"testsuite\", \"time\",\n                     FormatTimeInMillisAsSeconds(result.elapsed_time()));\n  OutputXmlAttribute(\n      stream, \"testsuite\", \"timestamp\",\n      FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));\n  *stream << \">\";\n\n  // Output the boilerplate for a minimal test case with a single test.\n  *stream << \"    <testcase\";\n  OutputXmlAttribute(stream, \"testcase\", \"name\", \"\");\n  OutputXmlAttribute(stream, \"testcase\", \"status\", \"run\");\n  OutputXmlAttribute(stream, \"testcase\", \"result\", \"completed\");\n  OutputXmlAttribute(stream, \"testcase\", \"classname\", \"\");\n  OutputXmlAttribute(stream, \"testcase\", \"time\",\n                     FormatTimeInMillisAsSeconds(result.elapsed_time()));\n  OutputXmlAttribute(\n      stream, \"testcase\", \"timestamp\",\n      FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));\n\n  // Output the actual test result.\n  OutputXmlTestResult(stream, result);\n\n  // Complete the test suite.\n  *stream << \"  </testsuite>\\n\";\n}\n\n// Prints an XML representation of a TestInfo object.\nvoid XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,\n                                                 const char* test_suite_name,\n                                                 const TestInfo& test_info) {\n  const TestResult& result = *test_info.result();\n  const std::string kTestsuite = \"testcase\";\n\n  if (test_info.is_in_another_shard()) {\n    return;\n  }\n\n  *stream << \"    <testcase\";\n  OutputXmlAttribute(stream, kTestsuite, \"name\", test_info.name());\n\n  if (test_info.value_param() != nullptr) {\n    OutputXmlAttribute(stream, kTestsuite, \"value_param\",\n                       test_info.value_param());\n  }\n  if (test_info.type_param() != nullptr) {\n    OutputXmlAttribute(stream, kTestsuite, \"type_param\",\n                       test_info.type_param());\n  }\n  if (GTEST_FLAG(list_tests)) {\n    OutputXmlAttribute(stream, kTestsuite, \"file\", test_info.file());\n    OutputXmlAttribute(stream, kTestsuite, \"line\",\n                       StreamableToString(test_info.line()));\n    *stream << \" />\\n\";\n    return;\n  }\n\n  OutputXmlAttribute(stream, kTestsuite, \"status\",\n                     test_info.should_run() ? \"run\" : \"notrun\");\n  OutputXmlAttribute(stream, kTestsuite, \"result\",\n                     test_info.should_run()\n                         ? (result.Skipped() ? \"skipped\" : \"completed\")\n                         : \"suppressed\");\n  OutputXmlAttribute(stream, kTestsuite, \"time\",\n                     FormatTimeInMillisAsSeconds(result.elapsed_time()));\n  OutputXmlAttribute(\n      stream, kTestsuite, \"timestamp\",\n      FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));\n  OutputXmlAttribute(stream, kTestsuite, \"classname\", test_suite_name);\n\n  OutputXmlTestResult(stream, result);\n}\n\nvoid XmlUnitTestResultPrinter::OutputXmlTestResult(::std::ostream* stream,\n                                                   const TestResult& result) {\n  int failures = 0;\n  int skips = 0;\n  for (int i = 0; i < result.total_part_count(); ++i) {\n    const TestPartResult& part = result.GetTestPartResult(i);\n    if (part.failed()) {\n      if (++failures == 1 && skips == 0) {\n        *stream << \">\\n\";\n      }\n      const std::string location =\n          internal::FormatCompilerIndependentFileLocation(part.file_name(),\n                                                          part.line_number());\n      const std::string summary = location + \"\\n\" + part.summary();\n      *stream << \"      <failure message=\\\"\"\n              << EscapeXmlAttribute(summary)\n              << \"\\\" type=\\\"\\\">\";\n      const std::string detail = location + \"\\n\" + part.message();\n      OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());\n      *stream << \"</failure>\\n\";\n    } else if (part.skipped()) {\n      if (++skips == 1 && failures == 0) {\n        *stream << \">\\n\";\n      }\n      const std::string location =\n          internal::FormatCompilerIndependentFileLocation(part.file_name(),\n                                                          part.line_number());\n      const std::string summary = location + \"\\n\" + part.summary();\n      *stream << \"      <skipped message=\\\"\"\n              << EscapeXmlAttribute(summary.c_str()) << \"\\\">\";\n      const std::string detail = location + \"\\n\" + part.message();\n      OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());\n      *stream << \"</skipped>\\n\";\n    }\n  }\n\n  if (failures == 0 && skips == 0 && result.test_property_count() == 0) {\n    *stream << \" />\\n\";\n  } else {\n    if (failures == 0 && skips == 0) {\n      *stream << \">\\n\";\n    }\n    OutputXmlTestProperties(stream, result);\n    *stream << \"    </testcase>\\n\";\n  }\n}\n\n// Prints an XML representation of a TestSuite object\nvoid XmlUnitTestResultPrinter::PrintXmlTestSuite(std::ostream* stream,\n                                                 const TestSuite& test_suite) {\n  const std::string kTestsuite = \"testsuite\";\n  *stream << \"  <\" << kTestsuite;\n  OutputXmlAttribute(stream, kTestsuite, \"name\", test_suite.name());\n  OutputXmlAttribute(stream, kTestsuite, \"tests\",\n                     StreamableToString(test_suite.reportable_test_count()));\n  if (!GTEST_FLAG(list_tests)) {\n    OutputXmlAttribute(stream, kTestsuite, \"failures\",\n                       StreamableToString(test_suite.failed_test_count()));\n    OutputXmlAttribute(\n        stream, kTestsuite, \"disabled\",\n        StreamableToString(test_suite.reportable_disabled_test_count()));\n    OutputXmlAttribute(stream, kTestsuite, \"skipped\",\n                       StreamableToString(test_suite.skipped_test_count()));\n\n    OutputXmlAttribute(stream, kTestsuite, \"errors\", \"0\");\n\n    OutputXmlAttribute(stream, kTestsuite, \"time\",\n                       FormatTimeInMillisAsSeconds(test_suite.elapsed_time()));\n    OutputXmlAttribute(\n        stream, kTestsuite, \"timestamp\",\n        FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp()));\n    *stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());\n  }\n  *stream << \">\\n\";\n  for (int i = 0; i < test_suite.total_test_count(); ++i) {\n    if (test_suite.GetTestInfo(i)->is_reportable())\n      OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));\n  }\n  *stream << \"  </\" << kTestsuite << \">\\n\";\n}\n\n// Prints an XML summary of unit_test to output stream out.\nvoid XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,\n                                                const UnitTest& unit_test) {\n  const std::string kTestsuites = \"testsuites\";\n\n  *stream << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n  *stream << \"<\" << kTestsuites;\n\n  OutputXmlAttribute(stream, kTestsuites, \"tests\",\n                     StreamableToString(unit_test.reportable_test_count()));\n  OutputXmlAttribute(stream, kTestsuites, \"failures\",\n                     StreamableToString(unit_test.failed_test_count()));\n  OutputXmlAttribute(\n      stream, kTestsuites, \"disabled\",\n      StreamableToString(unit_test.reportable_disabled_test_count()));\n  OutputXmlAttribute(stream, kTestsuites, \"errors\", \"0\");\n  OutputXmlAttribute(stream, kTestsuites, \"time\",\n                     FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));\n  OutputXmlAttribute(\n      stream, kTestsuites, \"timestamp\",\n      FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));\n\n  if (GTEST_FLAG(shuffle)) {\n    OutputXmlAttribute(stream, kTestsuites, \"random_seed\",\n                       StreamableToString(unit_test.random_seed()));\n  }\n  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());\n\n  OutputXmlAttribute(stream, kTestsuites, \"name\", \"AllTests\");\n  *stream << \">\\n\";\n\n  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {\n    if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)\n      PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));\n  }\n\n  // If there was a test failure outside of one of the test suites (like in a\n  // test environment) include that in the output.\n  if (unit_test.ad_hoc_test_result().Failed()) {\n    OutputXmlTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());\n  }\n\n  *stream << \"</\" << kTestsuites << \">\\n\";\n}\n\nvoid XmlUnitTestResultPrinter::PrintXmlTestsList(\n    std::ostream* stream, const std::vector<TestSuite*>& test_suites) {\n  const std::string kTestsuites = \"testsuites\";\n\n  *stream << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n  *stream << \"<\" << kTestsuites;\n\n  int total_tests = 0;\n  for (auto test_suite : test_suites) {\n    total_tests += test_suite->total_test_count();\n  }\n  OutputXmlAttribute(stream, kTestsuites, \"tests\",\n                     StreamableToString(total_tests));\n  OutputXmlAttribute(stream, kTestsuites, \"name\", \"AllTests\");\n  *stream << \">\\n\";\n\n  for (auto test_suite : test_suites) {\n    PrintXmlTestSuite(stream, *test_suite);\n  }\n  *stream << \"</\" << kTestsuites << \">\\n\";\n}\n\n// Produces a string representing the test properties in a result as space\n// delimited XML attributes based on the property key=\"value\" pairs.\nstd::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(\n    const TestResult& result) {\n  Message attributes;\n  for (int i = 0; i < result.test_property_count(); ++i) {\n    const TestProperty& property = result.GetTestProperty(i);\n    attributes << \" \" << property.key() << \"=\"\n        << \"\\\"\" << EscapeXmlAttribute(property.value()) << \"\\\"\";\n  }\n  return attributes.GetString();\n}\n\nvoid XmlUnitTestResultPrinter::OutputXmlTestProperties(\n    std::ostream* stream, const TestResult& result) {\n  const std::string kProperties = \"properties\";\n  const std::string kProperty = \"property\";\n\n  if (result.test_property_count() <= 0) {\n    return;\n  }\n\n  *stream << \"<\" << kProperties << \">\\n\";\n  for (int i = 0; i < result.test_property_count(); ++i) {\n    const TestProperty& property = result.GetTestProperty(i);\n    *stream << \"<\" << kProperty;\n    *stream << \" name=\\\"\" << EscapeXmlAttribute(property.key()) << \"\\\"\";\n    *stream << \" value=\\\"\" << EscapeXmlAttribute(property.value()) << \"\\\"\";\n    *stream << \"/>\\n\";\n  }\n  *stream << \"</\" << kProperties << \">\\n\";\n}\n\n// End XmlUnitTestResultPrinter\n\n// This class generates an JSON output file.\nclass JsonUnitTestResultPrinter : public EmptyTestEventListener {\n public:\n  explicit JsonUnitTestResultPrinter(const char* output_file);\n\n  void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;\n\n  // Prints an JSON summary of all unit tests.\n  static void PrintJsonTestList(::std::ostream* stream,\n                                const std::vector<TestSuite*>& test_suites);\n\n private:\n  // Returns an JSON-escaped copy of the input string str.\n  static std::string EscapeJson(const std::string& str);\n\n  //// Verifies that the given attribute belongs to the given element and\n  //// streams the attribute as JSON.\n  static void OutputJsonKey(std::ostream* stream,\n                            const std::string& element_name,\n                            const std::string& name,\n                            const std::string& value,\n                            const std::string& indent,\n                            bool comma = true);\n  static void OutputJsonKey(std::ostream* stream,\n                            const std::string& element_name,\n                            const std::string& name,\n                            int value,\n                            const std::string& indent,\n                            bool comma = true);\n\n  // Streams a test suite JSON stanza containing the given test result.\n  //\n  // Requires: result.Failed()\n  static void OutputJsonTestSuiteForTestResult(::std::ostream* stream,\n                                               const TestResult& result);\n\n  // Streams a JSON representation of a TestResult object.\n  static void OutputJsonTestResult(::std::ostream* stream,\n                                   const TestResult& result);\n\n  // Streams a JSON representation of a TestInfo object.\n  static void OutputJsonTestInfo(::std::ostream* stream,\n                                 const char* test_suite_name,\n                                 const TestInfo& test_info);\n\n  // Prints a JSON representation of a TestSuite object\n  static void PrintJsonTestSuite(::std::ostream* stream,\n                                 const TestSuite& test_suite);\n\n  // Prints a JSON summary of unit_test to output stream out.\n  static void PrintJsonUnitTest(::std::ostream* stream,\n                                const UnitTest& unit_test);\n\n  // Produces a string representing the test properties in a result as\n  // a JSON dictionary.\n  static std::string TestPropertiesAsJson(const TestResult& result,\n                                          const std::string& indent);\n\n  // The output file.\n  const std::string output_file_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter);\n};\n\n// Creates a new JsonUnitTestResultPrinter.\nJsonUnitTestResultPrinter::JsonUnitTestResultPrinter(const char* output_file)\n    : output_file_(output_file) {\n  if (output_file_.empty()) {\n    GTEST_LOG_(FATAL) << \"JSON output file may not be null\";\n  }\n}\n\nvoid JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                  int /*iteration*/) {\n  FILE* jsonout = OpenFileForWriting(output_file_);\n  std::stringstream stream;\n  PrintJsonUnitTest(&stream, unit_test);\n  fprintf(jsonout, \"%s\", StringStreamToString(&stream).c_str());\n  fclose(jsonout);\n}\n\n// Returns an JSON-escaped copy of the input string str.\nstd::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) {\n  Message m;\n\n  for (size_t i = 0; i < str.size(); ++i) {\n    const char ch = str[i];\n    switch (ch) {\n      case '\\\\':\n      case '\"':\n      case '/':\n        m << '\\\\' << ch;\n        break;\n      case '\\b':\n        m << \"\\\\b\";\n        break;\n      case '\\t':\n        m << \"\\\\t\";\n        break;\n      case '\\n':\n        m << \"\\\\n\";\n        break;\n      case '\\f':\n        m << \"\\\\f\";\n        break;\n      case '\\r':\n        m << \"\\\\r\";\n        break;\n      default:\n        if (ch < ' ') {\n          m << \"\\\\u00\" << String::FormatByte(static_cast<unsigned char>(ch));\n        } else {\n          m << ch;\n        }\n        break;\n    }\n  }\n\n  return m.GetString();\n}\n\n// The following routines generate an JSON representation of a UnitTest\n// object.\n\n// Formats the given time in milliseconds as seconds.\nstatic std::string FormatTimeInMillisAsDuration(TimeInMillis ms) {\n  ::std::stringstream ss;\n  ss << (static_cast<double>(ms) * 1e-3) << \"s\";\n  return ss.str();\n}\n\n// Converts the given epoch time in milliseconds to a date string in the\n// RFC3339 format, without the timezone information.\nstatic std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms) {\n  struct tm time_struct;\n  if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))\n    return \"\";\n  // YYYY-MM-DDThh:mm:ss\n  return StreamableToString(time_struct.tm_year + 1900) + \"-\" +\n      String::FormatIntWidth2(time_struct.tm_mon + 1) + \"-\" +\n      String::FormatIntWidth2(time_struct.tm_mday) + \"T\" +\n      String::FormatIntWidth2(time_struct.tm_hour) + \":\" +\n      String::FormatIntWidth2(time_struct.tm_min) + \":\" +\n      String::FormatIntWidth2(time_struct.tm_sec) + \"Z\";\n}\n\nstatic inline std::string Indent(size_t width) {\n  return std::string(width, ' ');\n}\n\nvoid JsonUnitTestResultPrinter::OutputJsonKey(\n    std::ostream* stream,\n    const std::string& element_name,\n    const std::string& name,\n    const std::string& value,\n    const std::string& indent,\n    bool comma) {\n  const std::vector<std::string>& allowed_names =\n      GetReservedOutputAttributesForElement(element_name);\n\n  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=\n                   allowed_names.end())\n      << \"Key \\\"\" << name << \"\\\" is not allowed for value \\\"\" << element_name\n      << \"\\\".\";\n\n  *stream << indent << \"\\\"\" << name << \"\\\": \\\"\" << EscapeJson(value) << \"\\\"\";\n  if (comma)\n    *stream << \",\\n\";\n}\n\nvoid JsonUnitTestResultPrinter::OutputJsonKey(\n    std::ostream* stream,\n    const std::string& element_name,\n    const std::string& name,\n    int value,\n    const std::string& indent,\n    bool comma) {\n  const std::vector<std::string>& allowed_names =\n      GetReservedOutputAttributesForElement(element_name);\n\n  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=\n                   allowed_names.end())\n      << \"Key \\\"\" << name << \"\\\" is not allowed for value \\\"\" << element_name\n      << \"\\\".\";\n\n  *stream << indent << \"\\\"\" << name << \"\\\": \" << StreamableToString(value);\n  if (comma)\n    *stream << \",\\n\";\n}\n\n// Streams a test suite JSON stanza containing the given test result.\nvoid JsonUnitTestResultPrinter::OutputJsonTestSuiteForTestResult(\n    ::std::ostream* stream, const TestResult& result) {\n  // Output the boilerplate for a new test suite.\n  *stream << Indent(4) << \"{\\n\";\n  OutputJsonKey(stream, \"testsuite\", \"name\", \"NonTestSuiteFailure\", Indent(6));\n  OutputJsonKey(stream, \"testsuite\", \"tests\", 1, Indent(6));\n  if (!GTEST_FLAG(list_tests)) {\n    OutputJsonKey(stream, \"testsuite\", \"failures\", 1, Indent(6));\n    OutputJsonKey(stream, \"testsuite\", \"disabled\", 0, Indent(6));\n    OutputJsonKey(stream, \"testsuite\", \"skipped\", 0, Indent(6));\n    OutputJsonKey(stream, \"testsuite\", \"errors\", 0, Indent(6));\n    OutputJsonKey(stream, \"testsuite\", \"time\",\n                  FormatTimeInMillisAsDuration(result.elapsed_time()),\n                  Indent(6));\n    OutputJsonKey(stream, \"testsuite\", \"timestamp\",\n                  FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),\n                  Indent(6));\n  }\n  *stream << Indent(6) << \"\\\"testsuite\\\": [\\n\";\n\n  // Output the boilerplate for a new test case.\n  *stream << Indent(8) << \"{\\n\";\n  OutputJsonKey(stream, \"testcase\", \"name\", \"\", Indent(10));\n  OutputJsonKey(stream, \"testcase\", \"status\", \"RUN\", Indent(10));\n  OutputJsonKey(stream, \"testcase\", \"result\", \"COMPLETED\", Indent(10));\n  OutputJsonKey(stream, \"testcase\", \"timestamp\",\n                FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),\n                Indent(10));\n  OutputJsonKey(stream, \"testcase\", \"time\",\n                FormatTimeInMillisAsDuration(result.elapsed_time()),\n                Indent(10));\n  OutputJsonKey(stream, \"testcase\", \"classname\", \"\", Indent(10), false);\n  *stream << TestPropertiesAsJson(result, Indent(10));\n\n  // Output the actual test result.\n  OutputJsonTestResult(stream, result);\n\n  // Finish the test suite.\n  *stream << \"\\n\" << Indent(6) << \"]\\n\" << Indent(4) << \"}\";\n}\n\n// Prints a JSON representation of a TestInfo object.\nvoid JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,\n                                                   const char* test_suite_name,\n                                                   const TestInfo& test_info) {\n  const TestResult& result = *test_info.result();\n  const std::string kTestsuite = \"testcase\";\n  const std::string kIndent = Indent(10);\n\n  *stream << Indent(8) << \"{\\n\";\n  OutputJsonKey(stream, kTestsuite, \"name\", test_info.name(), kIndent);\n\n  if (test_info.value_param() != nullptr) {\n    OutputJsonKey(stream, kTestsuite, \"value_param\", test_info.value_param(),\n                  kIndent);\n  }\n  if (test_info.type_param() != nullptr) {\n    OutputJsonKey(stream, kTestsuite, \"type_param\", test_info.type_param(),\n                  kIndent);\n  }\n  if (GTEST_FLAG(list_tests)) {\n    OutputJsonKey(stream, kTestsuite, \"file\", test_info.file(), kIndent);\n    OutputJsonKey(stream, kTestsuite, \"line\", test_info.line(), kIndent, false);\n    *stream << \"\\n\" << Indent(8) << \"}\";\n    return;\n  }\n\n  OutputJsonKey(stream, kTestsuite, \"status\",\n                test_info.should_run() ? \"RUN\" : \"NOTRUN\", kIndent);\n  OutputJsonKey(stream, kTestsuite, \"result\",\n                test_info.should_run()\n                    ? (result.Skipped() ? \"SKIPPED\" : \"COMPLETED\")\n                    : \"SUPPRESSED\",\n                kIndent);\n  OutputJsonKey(stream, kTestsuite, \"timestamp\",\n                FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),\n                kIndent);\n  OutputJsonKey(stream, kTestsuite, \"time\",\n                FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent);\n  OutputJsonKey(stream, kTestsuite, \"classname\", test_suite_name, kIndent,\n                false);\n  *stream << TestPropertiesAsJson(result, kIndent);\n\n  OutputJsonTestResult(stream, result);\n}\n\nvoid JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,\n                                                     const TestResult& result) {\n  const std::string kIndent = Indent(10);\n\n  int failures = 0;\n  for (int i = 0; i < result.total_part_count(); ++i) {\n    const TestPartResult& part = result.GetTestPartResult(i);\n    if (part.failed()) {\n      *stream << \",\\n\";\n      if (++failures == 1) {\n        *stream << kIndent << \"\\\"\" << \"failures\" << \"\\\": [\\n\";\n      }\n      const std::string location =\n          internal::FormatCompilerIndependentFileLocation(part.file_name(),\n                                                          part.line_number());\n      const std::string message = EscapeJson(location + \"\\n\" + part.message());\n      *stream << kIndent << \"  {\\n\"\n              << kIndent << \"    \\\"failure\\\": \\\"\" << message << \"\\\",\\n\"\n              << kIndent << \"    \\\"type\\\": \\\"\\\"\\n\"\n              << kIndent << \"  }\";\n    }\n  }\n\n  if (failures > 0)\n    *stream << \"\\n\" << kIndent << \"]\";\n  *stream << \"\\n\" << Indent(8) << \"}\";\n}\n\n// Prints an JSON representation of a TestSuite object\nvoid JsonUnitTestResultPrinter::PrintJsonTestSuite(\n    std::ostream* stream, const TestSuite& test_suite) {\n  const std::string kTestsuite = \"testsuite\";\n  const std::string kIndent = Indent(6);\n\n  *stream << Indent(4) << \"{\\n\";\n  OutputJsonKey(stream, kTestsuite, \"name\", test_suite.name(), kIndent);\n  OutputJsonKey(stream, kTestsuite, \"tests\", test_suite.reportable_test_count(),\n                kIndent);\n  if (!GTEST_FLAG(list_tests)) {\n    OutputJsonKey(stream, kTestsuite, \"failures\",\n                  test_suite.failed_test_count(), kIndent);\n    OutputJsonKey(stream, kTestsuite, \"disabled\",\n                  test_suite.reportable_disabled_test_count(), kIndent);\n    OutputJsonKey(stream, kTestsuite, \"errors\", 0, kIndent);\n    OutputJsonKey(\n        stream, kTestsuite, \"timestamp\",\n        FormatEpochTimeInMillisAsRFC3339(test_suite.start_timestamp()),\n        kIndent);\n    OutputJsonKey(stream, kTestsuite, \"time\",\n                  FormatTimeInMillisAsDuration(test_suite.elapsed_time()),\n                  kIndent, false);\n    *stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent)\n            << \",\\n\";\n  }\n\n  *stream << kIndent << \"\\\"\" << kTestsuite << \"\\\": [\\n\";\n\n  bool comma = false;\n  for (int i = 0; i < test_suite.total_test_count(); ++i) {\n    if (test_suite.GetTestInfo(i)->is_reportable()) {\n      if (comma) {\n        *stream << \",\\n\";\n      } else {\n        comma = true;\n      }\n      OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));\n    }\n  }\n  *stream << \"\\n\" << kIndent << \"]\\n\" << Indent(4) << \"}\";\n}\n\n// Prints a JSON summary of unit_test to output stream out.\nvoid JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream,\n                                                  const UnitTest& unit_test) {\n  const std::string kTestsuites = \"testsuites\";\n  const std::string kIndent = Indent(2);\n  *stream << \"{\\n\";\n\n  OutputJsonKey(stream, kTestsuites, \"tests\", unit_test.reportable_test_count(),\n                kIndent);\n  OutputJsonKey(stream, kTestsuites, \"failures\", unit_test.failed_test_count(),\n                kIndent);\n  OutputJsonKey(stream, kTestsuites, \"disabled\",\n                unit_test.reportable_disabled_test_count(), kIndent);\n  OutputJsonKey(stream, kTestsuites, \"errors\", 0, kIndent);\n  if (GTEST_FLAG(shuffle)) {\n    OutputJsonKey(stream, kTestsuites, \"random_seed\", unit_test.random_seed(),\n                  kIndent);\n  }\n  OutputJsonKey(stream, kTestsuites, \"timestamp\",\n                FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()),\n                kIndent);\n  OutputJsonKey(stream, kTestsuites, \"time\",\n                FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent,\n                false);\n\n  *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent)\n          << \",\\n\";\n\n  OutputJsonKey(stream, kTestsuites, \"name\", \"AllTests\", kIndent);\n  *stream << kIndent << \"\\\"\" << kTestsuites << \"\\\": [\\n\";\n\n  bool comma = false;\n  for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {\n    if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {\n      if (comma) {\n        *stream << \",\\n\";\n      } else {\n        comma = true;\n      }\n      PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));\n    }\n  }\n\n  // If there was a test failure outside of one of the test suites (like in a\n  // test environment) include that in the output.\n  if (unit_test.ad_hoc_test_result().Failed()) {\n    OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());\n  }\n\n  *stream << \"\\n\" << kIndent << \"]\\n\" << \"}\\n\";\n}\n\nvoid JsonUnitTestResultPrinter::PrintJsonTestList(\n    std::ostream* stream, const std::vector<TestSuite*>& test_suites) {\n  const std::string kTestsuites = \"testsuites\";\n  const std::string kIndent = Indent(2);\n  *stream << \"{\\n\";\n  int total_tests = 0;\n  for (auto test_suite : test_suites) {\n    total_tests += test_suite->total_test_count();\n  }\n  OutputJsonKey(stream, kTestsuites, \"tests\", total_tests, kIndent);\n\n  OutputJsonKey(stream, kTestsuites, \"name\", \"AllTests\", kIndent);\n  *stream << kIndent << \"\\\"\" << kTestsuites << \"\\\": [\\n\";\n\n  for (size_t i = 0; i < test_suites.size(); ++i) {\n    if (i != 0) {\n      *stream << \",\\n\";\n    }\n    PrintJsonTestSuite(stream, *test_suites[i]);\n  }\n\n  *stream << \"\\n\"\n          << kIndent << \"]\\n\"\n          << \"}\\n\";\n}\n// Produces a string representing the test properties in a result as\n// a JSON dictionary.\nstd::string JsonUnitTestResultPrinter::TestPropertiesAsJson(\n    const TestResult& result, const std::string& indent) {\n  Message attributes;\n  for (int i = 0; i < result.test_property_count(); ++i) {\n    const TestProperty& property = result.GetTestProperty(i);\n    attributes << \",\\n\" << indent << \"\\\"\" << property.key() << \"\\\": \"\n               << \"\\\"\" << EscapeJson(property.value()) << \"\\\"\";\n  }\n  return attributes.GetString();\n}\n\n// End JsonUnitTestResultPrinter\n\n#if GTEST_CAN_STREAM_RESULTS_\n\n// Checks if str contains '=', '&', '%' or '\\n' characters. If yes,\n// replaces them by \"%xx\" where xx is their hexadecimal value. For\n// example, replaces \"=\" with \"%3D\".  This algorithm is O(strlen(str))\n// in both time and space -- important as the input str may contain an\n// arbitrarily long test failure message and stack trace.\nstd::string StreamingListener::UrlEncode(const char* str) {\n  std::string result;\n  result.reserve(strlen(str) + 1);\n  for (char ch = *str; ch != '\\0'; ch = *++str) {\n    switch (ch) {\n      case '%':\n      case '=':\n      case '&':\n      case '\\n':\n        result.append(\"%\" + String::FormatByte(static_cast<unsigned char>(ch)));\n        break;\n      default:\n        result.push_back(ch);\n        break;\n    }\n  }\n  return result;\n}\n\nvoid StreamingListener::SocketWriter::MakeConnection() {\n  GTEST_CHECK_(sockfd_ == -1)\n      << \"MakeConnection() can't be called when there is already a connection.\";\n\n  addrinfo hints;\n  memset(&hints, 0, sizeof(hints));\n  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.\n  hints.ai_socktype = SOCK_STREAM;\n  addrinfo* servinfo = nullptr;\n\n  // Use the getaddrinfo() to get a linked list of IP addresses for\n  // the given host name.\n  const int error_num = getaddrinfo(\n      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);\n  if (error_num != 0) {\n    GTEST_LOG_(WARNING) << \"stream_result_to: getaddrinfo() failed: \"\n                        << gai_strerror(error_num);\n  }\n\n  // Loop through all the results and connect to the first we can.\n  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != nullptr;\n       cur_addr = cur_addr->ai_next) {\n    sockfd_ = socket(\n        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);\n    if (sockfd_ != -1) {\n      // Connect the client socket to the server socket.\n      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {\n        close(sockfd_);\n        sockfd_ = -1;\n      }\n    }\n  }\n\n  freeaddrinfo(servinfo);  // all done with this structure\n\n  if (sockfd_ == -1) {\n    GTEST_LOG_(WARNING) << \"stream_result_to: failed to connect to \"\n                        << host_name_ << \":\" << port_num_;\n  }\n}\n\n// End of class Streaming Listener\n#endif  // GTEST_CAN_STREAM_RESULTS__\n\n// class OsStackTraceGetter\n\nconst char* const OsStackTraceGetterInterface::kElidedFramesMarker =\n    \"... \" GTEST_NAME_ \" internal frames ...\";\n\nstd::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count)\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n#if GTEST_HAS_ABSL\n  std::string result;\n\n  if (max_depth <= 0) {\n    return result;\n  }\n\n  max_depth = std::min(max_depth, kMaxStackTraceDepth);\n\n  std::vector<void*> raw_stack(max_depth);\n  // Skips the frames requested by the caller, plus this function.\n  const int raw_stack_size =\n      absl::GetStackTrace(&raw_stack[0], max_depth, skip_count + 1);\n\n  void* caller_frame = nullptr;\n  {\n    MutexLock lock(&mutex_);\n    caller_frame = caller_frame_;\n  }\n\n  for (int i = 0; i < raw_stack_size; ++i) {\n    if (raw_stack[i] == caller_frame &&\n        !GTEST_FLAG(show_internal_stack_frames)) {\n      // Add a marker to the trace and stop adding frames.\n      absl::StrAppend(&result, kElidedFramesMarker, \"\\n\");\n      break;\n    }\n\n    char tmp[1024];\n    const char* symbol = \"(unknown)\";\n    if (absl::Symbolize(raw_stack[i], tmp, sizeof(tmp))) {\n      symbol = tmp;\n    }\n\n    char line[1024];\n    snprintf(line, sizeof(line), \"  %p: %s\\n\", raw_stack[i], symbol);\n    result += line;\n  }\n\n  return result;\n\n#else  // !GTEST_HAS_ABSL\n  static_cast<void>(max_depth);\n  static_cast<void>(skip_count);\n  return \"\";\n#endif  // GTEST_HAS_ABSL\n}\n\nvoid OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {\n#if GTEST_HAS_ABSL\n  void* caller_frame = nullptr;\n  if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) {\n    caller_frame = nullptr;\n  }\n\n  MutexLock lock(&mutex_);\n  caller_frame_ = caller_frame;\n#endif  // GTEST_HAS_ABSL\n}\n\n// A helper class that creates the premature-exit file in its\n// constructor and deletes the file in its destructor.\nclass ScopedPrematureExitFile {\n public:\n  explicit ScopedPrematureExitFile(const char* premature_exit_filepath)\n      : premature_exit_filepath_(premature_exit_filepath ?\n                                 premature_exit_filepath : \"\") {\n    // If a path to the premature-exit file is specified...\n    if (!premature_exit_filepath_.empty()) {\n      // create the file with a single \"0\" character in it.  I/O\n      // errors are ignored as there's nothing better we can do and we\n      // don't want to fail the test because of this.\n      FILE* pfile = posix::FOpen(premature_exit_filepath, \"w\");\n      fwrite(\"0\", 1, 1, pfile);\n      fclose(pfile);\n    }\n  }\n\n  ~ScopedPrematureExitFile() {\n#if !defined GTEST_OS_ESP8266\n    if (!premature_exit_filepath_.empty()) {\n      int retval = remove(premature_exit_filepath_.c_str());\n      if (retval) {\n        GTEST_LOG_(ERROR) << \"Failed to remove premature exit filepath \\\"\"\n                          << premature_exit_filepath_ << \"\\\" with error \"\n                          << retval;\n      }\n    }\n#endif\n  }\n\n private:\n  const std::string premature_exit_filepath_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);\n};\n\n}  // namespace internal\n\n// class TestEventListeners\n\nTestEventListeners::TestEventListeners()\n    : repeater_(new internal::TestEventRepeater()),\n      default_result_printer_(nullptr),\n      default_xml_generator_(nullptr) {}\n\nTestEventListeners::~TestEventListeners() { delete repeater_; }\n\n// Returns the standard listener responsible for the default console\n// output.  Can be removed from the listeners list to shut down default\n// console output.  Note that removing this object from the listener list\n// with Release transfers its ownership to the user.\nvoid TestEventListeners::Append(TestEventListener* listener) {\n  repeater_->Append(listener);\n}\n\n// Removes the given event listener from the list and returns it.  It then\n// becomes the caller's responsibility to delete the listener. Returns\n// NULL if the listener is not found in the list.\nTestEventListener* TestEventListeners::Release(TestEventListener* listener) {\n  if (listener == default_result_printer_)\n    default_result_printer_ = nullptr;\n  else if (listener == default_xml_generator_)\n    default_xml_generator_ = nullptr;\n  return repeater_->Release(listener);\n}\n\n// Returns repeater that broadcasts the TestEventListener events to all\n// subscribers.\nTestEventListener* TestEventListeners::repeater() { return repeater_; }\n\n// Sets the default_result_printer attribute to the provided listener.\n// The listener is also added to the listener list and previous\n// default_result_printer is removed from it and deleted. The listener can\n// also be NULL in which case it will not be added to the list. Does\n// nothing if the previous and the current listener objects are the same.\nvoid TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {\n  if (default_result_printer_ != listener) {\n    // It is an error to pass this method a listener that is already in the\n    // list.\n    delete Release(default_result_printer_);\n    default_result_printer_ = listener;\n    if (listener != nullptr) Append(listener);\n  }\n}\n\n// Sets the default_xml_generator attribute to the provided listener.  The\n// listener is also added to the listener list and previous\n// default_xml_generator is removed from it and deleted. The listener can\n// also be NULL in which case it will not be added to the list. Does\n// nothing if the previous and the current listener objects are the same.\nvoid TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {\n  if (default_xml_generator_ != listener) {\n    // It is an error to pass this method a listener that is already in the\n    // list.\n    delete Release(default_xml_generator_);\n    default_xml_generator_ = listener;\n    if (listener != nullptr) Append(listener);\n  }\n}\n\n// Controls whether events will be forwarded by the repeater to the\n// listeners in the list.\nbool TestEventListeners::EventForwardingEnabled() const {\n  return repeater_->forwarding_enabled();\n}\n\nvoid TestEventListeners::SuppressEventForwarding() {\n  repeater_->set_forwarding_enabled(false);\n}\n\n// class UnitTest\n\n// Gets the singleton UnitTest object.  The first time this method is\n// called, a UnitTest object is constructed and returned.  Consecutive\n// calls will return the same object.\n//\n// We don't protect this under mutex_ as a user is not supposed to\n// call this before main() starts, from which point on the return\n// value will never change.\nUnitTest* UnitTest::GetInstance() {\n  // CodeGear C++Builder insists on a public destructor for the\n  // default implementation.  Use this implementation to keep good OO\n  // design with private destructor.\n\n#if defined(__BORLANDC__)\n  static UnitTest* const instance = new UnitTest;\n  return instance;\n#else\n  static UnitTest instance;\n  return &instance;\n#endif  // defined(__BORLANDC__)\n}\n\n// Gets the number of successful test suites.\nint UnitTest::successful_test_suite_count() const {\n  return impl()->successful_test_suite_count();\n}\n\n// Gets the number of failed test suites.\nint UnitTest::failed_test_suite_count() const {\n  return impl()->failed_test_suite_count();\n}\n\n// Gets the number of all test suites.\nint UnitTest::total_test_suite_count() const {\n  return impl()->total_test_suite_count();\n}\n\n// Gets the number of all test suites that contain at least one test\n// that should run.\nint UnitTest::test_suite_to_run_count() const {\n  return impl()->test_suite_to_run_count();\n}\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nint UnitTest::successful_test_case_count() const {\n  return impl()->successful_test_suite_count();\n}\nint UnitTest::failed_test_case_count() const {\n  return impl()->failed_test_suite_count();\n}\nint UnitTest::total_test_case_count() const {\n  return impl()->total_test_suite_count();\n}\nint UnitTest::test_case_to_run_count() const {\n  return impl()->test_suite_to_run_count();\n}\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n// Gets the number of successful tests.\nint UnitTest::successful_test_count() const {\n  return impl()->successful_test_count();\n}\n\n// Gets the number of skipped tests.\nint UnitTest::skipped_test_count() const {\n  return impl()->skipped_test_count();\n}\n\n// Gets the number of failed tests.\nint UnitTest::failed_test_count() const { return impl()->failed_test_count(); }\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint UnitTest::reportable_disabled_test_count() const {\n  return impl()->reportable_disabled_test_count();\n}\n\n// Gets the number of disabled tests.\nint UnitTest::disabled_test_count() const {\n  return impl()->disabled_test_count();\n}\n\n// Gets the number of tests to be printed in the XML report.\nint UnitTest::reportable_test_count() const {\n  return impl()->reportable_test_count();\n}\n\n// Gets the number of all tests.\nint UnitTest::total_test_count() const { return impl()->total_test_count(); }\n\n// Gets the number of tests that should run.\nint UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }\n\n// Gets the time of the test program start, in ms from the start of the\n// UNIX epoch.\ninternal::TimeInMillis UnitTest::start_timestamp() const {\n    return impl()->start_timestamp();\n}\n\n// Gets the elapsed time, in milliseconds.\ninternal::TimeInMillis UnitTest::elapsed_time() const {\n  return impl()->elapsed_time();\n}\n\n// Returns true if and only if the unit test passed (i.e. all test suites\n// passed).\nbool UnitTest::Passed() const { return impl()->Passed(); }\n\n// Returns true if and only if the unit test failed (i.e. some test suite\n// failed or something outside of all tests failed).\nbool UnitTest::Failed() const { return impl()->Failed(); }\n\n// Gets the i-th test suite among all the test suites. i can range from 0 to\n// total_test_suite_count() - 1. If i is not in that range, returns NULL.\nconst TestSuite* UnitTest::GetTestSuite(int i) const {\n  return impl()->GetTestSuite(i);\n}\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nconst TestCase* UnitTest::GetTestCase(int i) const {\n  return impl()->GetTestCase(i);\n}\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n// Returns the TestResult containing information on test failures and\n// properties logged outside of individual test suites.\nconst TestResult& UnitTest::ad_hoc_test_result() const {\n  return *impl()->ad_hoc_test_result();\n}\n\n// Gets the i-th test suite among all the test suites. i can range from 0 to\n// total_test_suite_count() - 1. If i is not in that range, returns NULL.\nTestSuite* UnitTest::GetMutableTestSuite(int i) {\n  return impl()->GetMutableSuiteCase(i);\n}\n\n// Returns the list of event listeners that can be used to track events\n// inside Google Test.\nTestEventListeners& UnitTest::listeners() {\n  return *impl()->listeners();\n}\n\n// Registers and returns a global test environment.  When a test\n// program is run, all global test environments will be set-up in the\n// order they were registered.  After all tests in the program have\n// finished, all global test environments will be torn-down in the\n// *reverse* order they were registered.\n//\n// The UnitTest object takes ownership of the given environment.\n//\n// We don't protect this under mutex_, as we only support calling it\n// from the main thread.\nEnvironment* UnitTest::AddEnvironment(Environment* env) {\n  if (env == nullptr) {\n    return nullptr;\n  }\n\n  impl_->environments().push_back(env);\n  return env;\n}\n\n// Adds a TestPartResult to the current TestResult object.  All Google Test\n// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call\n// this to report their results.  The user code should use the\n// assertion macros instead of calling this directly.\nvoid UnitTest::AddTestPartResult(\n    TestPartResult::Type result_type,\n    const char* file_name,\n    int line_number,\n    const std::string& message,\n    const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {\n  Message msg;\n  msg << message;\n\n  internal::MutexLock lock(&mutex_);\n  if (impl_->gtest_trace_stack().size() > 0) {\n    msg << \"\\n\" << GTEST_NAME_ << \" trace:\";\n\n    for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {\n      const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];\n      msg << \"\\n\" << internal::FormatFileLocation(trace.file, trace.line)\n          << \" \" << trace.message;\n    }\n  }\n\n  if (os_stack_trace.c_str() != nullptr && !os_stack_trace.empty()) {\n    msg << internal::kStackTraceMarker << os_stack_trace;\n  }\n\n  const TestPartResult result = TestPartResult(\n      result_type, file_name, line_number, msg.GetString().c_str());\n  impl_->GetTestPartResultReporterForCurrentThread()->\n      ReportTestPartResult(result);\n\n  if (result_type != TestPartResult::kSuccess &&\n      result_type != TestPartResult::kSkip) {\n    // gtest_break_on_failure takes precedence over\n    // gtest_throw_on_failure.  This allows a user to set the latter\n    // in the code (perhaps in order to use Google Test assertions\n    // with another testing framework) and specify the former on the\n    // command line for debugging.\n    if (GTEST_FLAG(break_on_failure)) {\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n      // Using DebugBreak on Windows allows gtest to still break into a debugger\n      // when a failure happens and both the --gtest_break_on_failure and\n      // the --gtest_catch_exceptions flags are specified.\n      DebugBreak();\n#elif (!defined(__native_client__)) &&            \\\n    ((defined(__clang__) || defined(__GNUC__)) && \\\n     (defined(__x86_64__) || defined(__i386__)))\n      // with clang/gcc we can achieve the same effect on x86 by invoking int3\n      asm(\"int3\");\n#else\n      // Dereference nullptr through a volatile pointer to prevent the compiler\n      // from removing. We use this rather than abort() or __builtin_trap() for\n      // portability: some debuggers don't correctly trap abort().\n      *static_cast<volatile int*>(nullptr) = 1;\n#endif  // GTEST_OS_WINDOWS\n    } else if (GTEST_FLAG(throw_on_failure)) {\n#if GTEST_HAS_EXCEPTIONS\n      throw internal::GoogleTestFailureException(result);\n#else\n      // We cannot call abort() as it generates a pop-up in debug mode\n      // that cannot be suppressed in VC 7.1 or below.\n      exit(1);\n#endif\n    }\n  }\n}\n\n// Adds a TestProperty to the current TestResult object when invoked from\n// inside a test, to current TestSuite's ad_hoc_test_result_ when invoked\n// from SetUpTestSuite or TearDownTestSuite, or to the global property set\n// when invoked elsewhere.  If the result already contains a property with\n// the same key, the value will be updated.\nvoid UnitTest::RecordProperty(const std::string& key,\n                              const std::string& value) {\n  impl_->RecordProperty(TestProperty(key, value));\n}\n\n// Runs all tests in this UnitTest object and prints the result.\n// Returns 0 if successful, or 1 otherwise.\n//\n// We don't protect this under mutex_, as we only support calling it\n// from the main thread.\nint UnitTest::Run() {\n  const bool in_death_test_child_process =\n      internal::GTEST_FLAG(internal_run_death_test).length() > 0;\n\n  // Google Test implements this protocol for catching that a test\n  // program exits before returning control to Google Test:\n  //\n  //   1. Upon start, Google Test creates a file whose absolute path\n  //      is specified by the environment variable\n  //      TEST_PREMATURE_EXIT_FILE.\n  //   2. When Google Test has finished its work, it deletes the file.\n  //\n  // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before\n  // running a Google-Test-based test program and check the existence\n  // of the file at the end of the test execution to see if it has\n  // exited prematurely.\n\n  // If we are in the child process of a death test, don't\n  // create/delete the premature exit file, as doing so is unnecessary\n  // and will confuse the parent process.  Otherwise, create/delete\n  // the file upon entering/leaving this function.  If the program\n  // somehow exits before this function has a chance to return, the\n  // premature-exit file will be left undeleted, causing a test runner\n  // that understands the premature-exit-file protocol to report the\n  // test as having failed.\n  const internal::ScopedPrematureExitFile premature_exit_file(\n      in_death_test_child_process\n          ? nullptr\n          : internal::posix::GetEnv(\"TEST_PREMATURE_EXIT_FILE\"));\n\n  // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be\n  // used for the duration of the program.\n  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));\n\n#if GTEST_OS_WINDOWS\n  // Either the user wants Google Test to catch exceptions thrown by the\n  // tests or this is executing in the context of death test child\n  // process. In either case the user does not want to see pop-up dialogs\n  // about crashes - they are expected.\n  if (impl()->catch_exceptions() || in_death_test_child_process) {\n# if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n    // SetErrorMode doesn't exist on CE.\n    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |\n                 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);\n# endif  // !GTEST_OS_WINDOWS_MOBILE\n\n# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE\n    // Death test children can be terminated with _abort().  On Windows,\n    // _abort() can show a dialog with a warning message.  This forces the\n    // abort message to go to stderr instead.\n    _set_error_mode(_OUT_TO_STDERR);\n# endif\n\n# if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE\n    // In the debug version, Visual Studio pops up a separate dialog\n    // offering a choice to debug the aborted program. We need to suppress\n    // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement\n    // executed. Google Test will notify the user of any unexpected\n    // failure via stderr.\n    if (!GTEST_FLAG(break_on_failure))\n      _set_abort_behavior(\n          0x0,                                    // Clear the following flags:\n          _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.\n\n    // In debug mode, the Windows CRT can crash with an assertion over invalid\n    // input (e.g. passing an invalid file descriptor).  The default handling\n    // for these assertions is to pop up a dialog and wait for user input.\n    // Instead ask the CRT to dump such assertions to stderr non-interactively.\n    if (!IsDebuggerPresent()) {\n      (void)_CrtSetReportMode(_CRT_ASSERT,\n                              _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);\n      (void)_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);\n    }\n# endif\n  }\n#endif  // GTEST_OS_WINDOWS\n\n  return internal::HandleExceptionsInMethodIfSupported(\n      impl(),\n      &internal::UnitTestImpl::RunAllTests,\n      \"auxiliary test code (environments or event listeners)\") ? 0 : 1;\n}\n\n// Returns the working directory when the first TEST() or TEST_F() was\n// executed.\nconst char* UnitTest::original_working_dir() const {\n  return impl_->original_working_dir_.c_str();\n}\n\n// Returns the TestSuite object for the test that's currently running,\n// or NULL if no test is running.\nconst TestSuite* UnitTest::current_test_suite() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_suite();\n}\n\n// Legacy API is still available but deprecated\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nconst TestCase* UnitTest::current_test_case() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_suite();\n}\n#endif\n\n// Returns the TestInfo object for the test that's currently running,\n// or NULL if no test is running.\nconst TestInfo* UnitTest::current_test_info() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_info();\n}\n\n// Returns the random seed used at the start of the current test run.\nint UnitTest::random_seed() const { return impl_->random_seed(); }\n\n// Returns ParameterizedTestSuiteRegistry object used to keep track of\n// value-parameterized tests and instantiate and register them.\ninternal::ParameterizedTestSuiteRegistry&\nUnitTest::parameterized_test_registry() GTEST_LOCK_EXCLUDED_(mutex_) {\n  return impl_->parameterized_test_registry();\n}\n\n// Creates an empty UnitTest.\nUnitTest::UnitTest() {\n  impl_ = new internal::UnitTestImpl(this);\n}\n\n// Destructor of UnitTest.\nUnitTest::~UnitTest() {\n  delete impl_;\n}\n\n// Pushes a trace defined by SCOPED_TRACE() on to the per-thread\n// Google Test trace stack.\nvoid UnitTest::PushGTestTrace(const internal::TraceInfo& trace)\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  impl_->gtest_trace_stack().push_back(trace);\n}\n\n// Pops a trace from the per-thread Google Test trace stack.\nvoid UnitTest::PopGTestTrace()\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  impl_->gtest_trace_stack().pop_back();\n}\n\nnamespace internal {\n\nUnitTestImpl::UnitTestImpl(UnitTest* parent)\n    : parent_(parent),\n      GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */)\n          default_global_test_part_result_reporter_(this),\n      default_per_thread_test_part_result_reporter_(this),\n      GTEST_DISABLE_MSC_WARNINGS_POP_() global_test_part_result_repoter_(\n          &default_global_test_part_result_reporter_),\n      per_thread_test_part_result_reporter_(\n          &default_per_thread_test_part_result_reporter_),\n      parameterized_test_registry_(),\n      parameterized_tests_registered_(false),\n      last_death_test_suite_(-1),\n      current_test_suite_(nullptr),\n      current_test_info_(nullptr),\n      ad_hoc_test_result_(),\n      os_stack_trace_getter_(nullptr),\n      post_flag_parse_init_performed_(false),\n      random_seed_(0),  // Will be overridden by the flag before first use.\n      random_(0),       // Will be reseeded before first use.\n      start_timestamp_(0),\n      elapsed_time_(0),\n#if GTEST_HAS_DEATH_TEST\n      death_test_factory_(new DefaultDeathTestFactory),\n#endif\n      // Will be overridden by the flag before first use.\n      catch_exceptions_(false) {\n  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);\n}\n\nUnitTestImpl::~UnitTestImpl() {\n  // Deletes every TestSuite.\n  ForEach(test_suites_, internal::Delete<TestSuite>);\n\n  // Deletes every Environment.\n  ForEach(environments_, internal::Delete<Environment>);\n\n  delete os_stack_trace_getter_;\n}\n\n// Adds a TestProperty to the current TestResult object when invoked in a\n// context of a test, to current test suite's ad_hoc_test_result when invoke\n// from SetUpTestSuite/TearDownTestSuite, or to the global property set\n// otherwise.  If the result already contains a property with the same key,\n// the value will be updated.\nvoid UnitTestImpl::RecordProperty(const TestProperty& test_property) {\n  std::string xml_element;\n  TestResult* test_result;  // TestResult appropriate for property recording.\n\n  if (current_test_info_ != nullptr) {\n    xml_element = \"testcase\";\n    test_result = &(current_test_info_->result_);\n  } else if (current_test_suite_ != nullptr) {\n    xml_element = \"testsuite\";\n    test_result = &(current_test_suite_->ad_hoc_test_result_);\n  } else {\n    xml_element = \"testsuites\";\n    test_result = &ad_hoc_test_result_;\n  }\n  test_result->RecordProperty(xml_element, test_property);\n}\n\n#if GTEST_HAS_DEATH_TEST\n// Disables event forwarding if the control is currently in a death test\n// subprocess. Must not be called before InitGoogleTest.\nvoid UnitTestImpl::SuppressTestEventsIfInSubprocess() {\n  if (internal_run_death_test_flag_.get() != nullptr)\n    listeners()->SuppressEventForwarding();\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Initializes event listeners performing XML output as specified by\n// UnitTestOptions. Must not be called before InitGoogleTest.\nvoid UnitTestImpl::ConfigureXmlOutput() {\n  const std::string& output_format = UnitTestOptions::GetOutputFormat();\n  if (output_format == \"xml\") {\n    listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(\n        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));\n  } else if (output_format == \"json\") {\n    listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(\n        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));\n  } else if (output_format != \"\") {\n    GTEST_LOG_(WARNING) << \"WARNING: unrecognized output format \\\"\"\n                        << output_format << \"\\\" ignored.\";\n  }\n}\n\n#if GTEST_CAN_STREAM_RESULTS_\n// Initializes event listeners for streaming test results in string form.\n// Must not be called before InitGoogleTest.\nvoid UnitTestImpl::ConfigureStreamingOutput() {\n  const std::string& target = GTEST_FLAG(stream_result_to);\n  if (!target.empty()) {\n    const size_t pos = target.find(':');\n    if (pos != std::string::npos) {\n      listeners()->Append(new StreamingListener(target.substr(0, pos),\n                                                target.substr(pos+1)));\n    } else {\n      GTEST_LOG_(WARNING) << \"unrecognized streaming target \\\"\" << target\n                          << \"\\\" ignored.\";\n    }\n  }\n}\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n// Performs initialization dependent upon flag values obtained in\n// ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to\n// ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest\n// this function is also called from RunAllTests.  Since this function can be\n// called more than once, it has to be idempotent.\nvoid UnitTestImpl::PostFlagParsingInit() {\n  // Ensures that this function does not execute more than once.\n  if (!post_flag_parse_init_performed_) {\n    post_flag_parse_init_performed_ = true;\n\n#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)\n    // Register to send notifications about key process state changes.\n    listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());\n#endif  // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)\n\n#if GTEST_HAS_DEATH_TEST\n    InitDeathTestSubprocessControlInfo();\n    SuppressTestEventsIfInSubprocess();\n#endif  // GTEST_HAS_DEATH_TEST\n\n    // Registers parameterized tests. This makes parameterized tests\n    // available to the UnitTest reflection API without running\n    // RUN_ALL_TESTS.\n    RegisterParameterizedTests();\n\n    // Configures listeners for XML output. This makes it possible for users\n    // to shut down the default XML output before invoking RUN_ALL_TESTS.\n    ConfigureXmlOutput();\n\n    if (GTEST_FLAG(brief)) {\n      listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);\n    }\n\n#if GTEST_CAN_STREAM_RESULTS_\n    // Configures listeners for streaming test results to the specified server.\n    ConfigureStreamingOutput();\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n#if GTEST_HAS_ABSL\n    if (GTEST_FLAG(install_failure_signal_handler)) {\n      absl::FailureSignalHandlerOptions options;\n      absl::InstallFailureSignalHandler(options);\n    }\n#endif  // GTEST_HAS_ABSL\n  }\n}\n\n// A predicate that checks the name of a TestSuite against a known\n// value.\n//\n// This is used for implementation of the UnitTest class only.  We put\n// it in the anonymous namespace to prevent polluting the outer\n// namespace.\n//\n// TestSuiteNameIs is copyable.\nclass TestSuiteNameIs {\n public:\n  // Constructor.\n  explicit TestSuiteNameIs(const std::string& name) : name_(name) {}\n\n  // Returns true if and only if the name of test_suite matches name_.\n  bool operator()(const TestSuite* test_suite) const {\n    return test_suite != nullptr &&\n           strcmp(test_suite->name(), name_.c_str()) == 0;\n  }\n\n private:\n  std::string name_;\n};\n\n// Finds and returns a TestSuite with the given name.  If one doesn't\n// exist, creates one and returns it.  It's the CALLER'S\n// RESPONSIBILITY to ensure that this function is only called WHEN THE\n// TESTS ARE NOT SHUFFLED.\n//\n// Arguments:\n//\n//   test_suite_name: name of the test suite\n//   type_param:      the name of the test suite's type parameter, or NULL if\n//                    this is not a typed or a type-parameterized test suite.\n//   set_up_tc:       pointer to the function that sets up the test suite\n//   tear_down_tc:    pointer to the function that tears down the test suite\nTestSuite* UnitTestImpl::GetTestSuite(\n    const char* test_suite_name, const char* type_param,\n    internal::SetUpTestSuiteFunc set_up_tc,\n    internal::TearDownTestSuiteFunc tear_down_tc) {\n  // Can we find a TestSuite with the given name?\n  const auto test_suite =\n      std::find_if(test_suites_.rbegin(), test_suites_.rend(),\n                   TestSuiteNameIs(test_suite_name));\n\n  if (test_suite != test_suites_.rend()) return *test_suite;\n\n  // No.  Let's create one.\n  auto* const new_test_suite =\n      new TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);\n\n  // Is this a death test suite?\n  if (internal::UnitTestOptions::MatchesFilter(test_suite_name,\n                                               kDeathTestSuiteFilter)) {\n    // Yes.  Inserts the test suite after the last death test suite\n    // defined so far.  This only works when the test suites haven't\n    // been shuffled.  Otherwise we may end up running a death test\n    // after a non-death test.\n    ++last_death_test_suite_;\n    test_suites_.insert(test_suites_.begin() + last_death_test_suite_,\n                        new_test_suite);\n  } else {\n    // No.  Appends to the end of the list.\n    test_suites_.push_back(new_test_suite);\n  }\n\n  test_suite_indices_.push_back(static_cast<int>(test_suite_indices_.size()));\n  return new_test_suite;\n}\n\n// Helpers for setting up / tearing down the given environment.  They\n// are for use in the ForEach() function.\nstatic void SetUpEnvironment(Environment* env) { env->SetUp(); }\nstatic void TearDownEnvironment(Environment* env) { env->TearDown(); }\n\n// Runs all tests in this UnitTest object, prints the result, and\n// returns true if all tests are successful.  If any exception is\n// thrown during a test, the test is considered to be failed, but the\n// rest of the tests will still be run.\n//\n// When parameterized tests are enabled, it expands and registers\n// parameterized tests first in RegisterParameterizedTests().\n// All other functions called from RunAllTests() may safely assume that\n// parameterized tests are ready to be counted and run.\nbool UnitTestImpl::RunAllTests() {\n  // True if and only if Google Test is initialized before RUN_ALL_TESTS() is\n  // called.\n  const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();\n\n  // Do not run any test if the --help flag was specified.\n  if (g_help_flag)\n    return true;\n\n  // Repeats the call to the post-flag parsing initialization in case the\n  // user didn't call InitGoogleTest.\n  PostFlagParsingInit();\n\n  // Even if sharding is not on, test runners may want to use the\n  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding\n  // protocol.\n  internal::WriteToShardStatusFileIfNeeded();\n\n  // True if and only if we are in a subprocess for running a thread-safe-style\n  // death test.\n  bool in_subprocess_for_death_test = false;\n\n#if GTEST_HAS_DEATH_TEST\n  in_subprocess_for_death_test =\n      (internal_run_death_test_flag_.get() != nullptr);\n# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)\n  if (in_subprocess_for_death_test) {\n    GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();\n  }\n# endif  // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)\n#endif  // GTEST_HAS_DEATH_TEST\n\n  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,\n                                        in_subprocess_for_death_test);\n\n  // Compares the full test names with the filter to decide which\n  // tests to run.\n  const bool has_tests_to_run = FilterTests(should_shard\n                                              ? HONOR_SHARDING_PROTOCOL\n                                              : IGNORE_SHARDING_PROTOCOL) > 0;\n\n  // Lists the tests and exits if the --gtest_list_tests flag was specified.\n  if (GTEST_FLAG(list_tests)) {\n    // This must be called *after* FilterTests() has been called.\n    ListTestsMatchingFilter();\n    return true;\n  }\n\n  random_seed_ = GTEST_FLAG(shuffle) ?\n      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;\n\n  // True if and only if at least one test has failed.\n  bool failed = false;\n\n  TestEventListener* repeater = listeners()->repeater();\n\n  start_timestamp_ = GetTimeInMillis();\n  repeater->OnTestProgramStart(*parent_);\n\n  // How many times to repeat the tests?  We don't want to repeat them\n  // when we are inside the subprocess of a death test.\n  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);\n  // Repeats forever if the repeat count is negative.\n  const bool gtest_repeat_forever = repeat < 0;\n  for (int i = 0; gtest_repeat_forever || i != repeat; i++) {\n    // We want to preserve failures generated by ad-hoc test\n    // assertions executed before RUN_ALL_TESTS().\n    ClearNonAdHocTestResult();\n\n    Timer timer;\n\n    // Shuffles test suites and tests if requested.\n    if (has_tests_to_run && GTEST_FLAG(shuffle)) {\n      random()->Reseed(static_cast<uint32_t>(random_seed_));\n      // This should be done before calling OnTestIterationStart(),\n      // such that a test event listener can see the actual test order\n      // in the event.\n      ShuffleTests();\n    }\n\n    // Tells the unit test event listeners that the tests are about to start.\n    repeater->OnTestIterationStart(*parent_, i);\n\n    // Runs each test suite if there is at least one test to run.\n    if (has_tests_to_run) {\n      // Sets up all environments beforehand.\n      repeater->OnEnvironmentsSetUpStart(*parent_);\n      ForEach(environments_, SetUpEnvironment);\n      repeater->OnEnvironmentsSetUpEnd(*parent_);\n\n      // Runs the tests only if there was no fatal failure or skip triggered\n      // during global set-up.\n      if (Test::IsSkipped()) {\n        // Emit diagnostics when global set-up calls skip, as it will not be\n        // emitted by default.\n        TestResult& test_result =\n            *internal::GetUnitTestImpl()->current_test_result();\n        for (int j = 0; j < test_result.total_part_count(); ++j) {\n          const TestPartResult& test_part_result =\n              test_result.GetTestPartResult(j);\n          if (test_part_result.type() == TestPartResult::kSkip) {\n            const std::string& result = test_part_result.message();\n            printf(\"%s\\n\", result.c_str());\n          }\n        }\n        fflush(stdout);\n      } else if (!Test::HasFatalFailure()) {\n        for (int test_index = 0; test_index < total_test_suite_count();\n             test_index++) {\n          GetMutableSuiteCase(test_index)->Run();\n          if (GTEST_FLAG(fail_fast) &&\n              GetMutableSuiteCase(test_index)->Failed()) {\n            for (int j = test_index + 1; j < total_test_suite_count(); j++) {\n              GetMutableSuiteCase(j)->Skip();\n            }\n            break;\n          }\n        }\n      } else if (Test::HasFatalFailure()) {\n        // If there was a fatal failure during the global setup then we know we\n        // aren't going to run any tests. Explicitly mark all of the tests as\n        // skipped to make this obvious in the output.\n        for (int test_index = 0; test_index < total_test_suite_count();\n             test_index++) {\n          GetMutableSuiteCase(test_index)->Skip();\n        }\n      }\n\n      // Tears down all environments in reverse order afterwards.\n      repeater->OnEnvironmentsTearDownStart(*parent_);\n      std::for_each(environments_.rbegin(), environments_.rend(),\n                    TearDownEnvironment);\n      repeater->OnEnvironmentsTearDownEnd(*parent_);\n    }\n\n    elapsed_time_ = timer.Elapsed();\n\n    // Tells the unit test event listener that the tests have just finished.\n    repeater->OnTestIterationEnd(*parent_, i);\n\n    // Gets the result and clears it.\n    if (!Passed()) {\n      failed = true;\n    }\n\n    // Restores the original test order after the iteration.  This\n    // allows the user to quickly repro a failure that happens in the\n    // N-th iteration without repeating the first (N - 1) iterations.\n    // This is not enclosed in \"if (GTEST_FLAG(shuffle)) { ... }\", in\n    // case the user somehow changes the value of the flag somewhere\n    // (it's always safe to unshuffle the tests).\n    UnshuffleTests();\n\n    if (GTEST_FLAG(shuffle)) {\n      // Picks a new random seed for each iteration.\n      random_seed_ = GetNextRandomSeed(random_seed_);\n    }\n  }\n\n  repeater->OnTestProgramEnd(*parent_);\n\n  if (!gtest_is_initialized_before_run_all_tests) {\n    ColoredPrintf(\n        GTestColor::kRed,\n        \"\\nIMPORTANT NOTICE - DO NOT IGNORE:\\n\"\n        \"This test program did NOT call \" GTEST_INIT_GOOGLE_TEST_NAME_\n        \"() before calling RUN_ALL_TESTS(). This is INVALID. Soon \" GTEST_NAME_\n        \" will start to enforce the valid usage. \"\n        \"Please fix it ASAP, or IT WILL START TO FAIL.\\n\");  // NOLINT\n#if GTEST_FOR_GOOGLE_\n    ColoredPrintf(GTestColor::kRed,\n                  \"For more details, see http://wiki/Main/ValidGUnitMain.\\n\");\n#endif  // GTEST_FOR_GOOGLE_\n  }\n\n  return !failed;\n}\n\n// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file\n// if the variable is present. If a file already exists at this location, this\n// function will write over it. If the variable is present, but the file cannot\n// be created, prints an error and exits.\nvoid WriteToShardStatusFileIfNeeded() {\n  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);\n  if (test_shard_file != nullptr) {\n    FILE* const file = posix::FOpen(test_shard_file, \"w\");\n    if (file == nullptr) {\n      ColoredPrintf(GTestColor::kRed,\n                    \"Could not write to the test shard status file \\\"%s\\\" \"\n                    \"specified by the %s environment variable.\\n\",\n                    test_shard_file, kTestShardStatusFile);\n      fflush(stdout);\n      exit(EXIT_FAILURE);\n    }\n    fclose(file);\n  }\n}\n\n// Checks whether sharding is enabled by examining the relevant\n// environment variable values. If the variables are present,\n// but inconsistent (i.e., shard_index >= total_shards), prints\n// an error and exits. If in_subprocess_for_death_test, sharding is\n// disabled because it must only be applied to the original test\n// process. Otherwise, we could filter out death tests we intended to execute.\nbool ShouldShard(const char* total_shards_env,\n                 const char* shard_index_env,\n                 bool in_subprocess_for_death_test) {\n  if (in_subprocess_for_death_test) {\n    return false;\n  }\n\n  const int32_t total_shards = Int32FromEnvOrDie(total_shards_env, -1);\n  const int32_t shard_index = Int32FromEnvOrDie(shard_index_env, -1);\n\n  if (total_shards == -1 && shard_index == -1) {\n    return false;\n  } else if (total_shards == -1 && shard_index != -1) {\n    const Message msg = Message()\n      << \"Invalid environment variables: you have \"\n      << kTestShardIndex << \" = \" << shard_index\n      << \", but have left \" << kTestTotalShards << \" unset.\\n\";\n    ColoredPrintf(GTestColor::kRed, \"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  } else if (total_shards != -1 && shard_index == -1) {\n    const Message msg = Message()\n      << \"Invalid environment variables: you have \"\n      << kTestTotalShards << \" = \" << total_shards\n      << \", but have left \" << kTestShardIndex << \" unset.\\n\";\n    ColoredPrintf(GTestColor::kRed, \"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  } else if (shard_index < 0 || shard_index >= total_shards) {\n    const Message msg = Message()\n      << \"Invalid environment variables: we require 0 <= \"\n      << kTestShardIndex << \" < \" << kTestTotalShards\n      << \", but you have \" << kTestShardIndex << \"=\" << shard_index\n      << \", \" << kTestTotalShards << \"=\" << total_shards << \".\\n\";\n    ColoredPrintf(GTestColor::kRed, \"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  }\n\n  return total_shards > 1;\n}\n\n// Parses the environment variable var as an Int32. If it is unset,\n// returns default_val. If it is not an Int32, prints an error\n// and aborts.\nint32_t Int32FromEnvOrDie(const char* var, int32_t default_val) {\n  const char* str_val = posix::GetEnv(var);\n  if (str_val == nullptr) {\n    return default_val;\n  }\n\n  int32_t result;\n  if (!ParseInt32(Message() << \"The value of environment variable \" << var,\n                  str_val, &result)) {\n    exit(EXIT_FAILURE);\n  }\n  return result;\n}\n\n// Given the total number of shards, the shard index, and the test id,\n// returns true if and only if the test should be run on this shard. The test id\n// is some arbitrary but unique non-negative integer assigned to each test\n// method. Assumes that 0 <= shard_index < total_shards.\nbool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {\n  return (test_id % total_shards) == shard_index;\n}\n\n// Compares the name of each test with the user-specified filter to\n// decide whether the test should be run, then records the result in\n// each TestSuite and TestInfo object.\n// If shard_tests == true, further filters tests based on sharding\n// variables in the environment - see\n// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md\n// . Returns the number of tests that should run.\nint UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {\n  const int32_t total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?\n      Int32FromEnvOrDie(kTestTotalShards, -1) : -1;\n  const int32_t shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?\n      Int32FromEnvOrDie(kTestShardIndex, -1) : -1;\n\n  // num_runnable_tests are the number of tests that will\n  // run across all shards (i.e., match filter and are not disabled).\n  // num_selected_tests are the number of tests to be run on\n  // this shard.\n  int num_runnable_tests = 0;\n  int num_selected_tests = 0;\n  for (auto* test_suite : test_suites_) {\n    const std::string& test_suite_name = test_suite->name();\n    test_suite->set_should_run(false);\n\n    for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {\n      TestInfo* const test_info = test_suite->test_info_list()[j];\n      const std::string test_name(test_info->name());\n      // A test is disabled if test suite name or test name matches\n      // kDisableTestFilter.\n      const bool is_disabled = internal::UnitTestOptions::MatchesFilter(\n                                   test_suite_name, kDisableTestFilter) ||\n                               internal::UnitTestOptions::MatchesFilter(\n                                   test_name, kDisableTestFilter);\n      test_info->is_disabled_ = is_disabled;\n\n      const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(\n          test_suite_name, test_name);\n      test_info->matches_filter_ = matches_filter;\n\n      const bool is_runnable =\n          (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&\n          matches_filter;\n\n      const bool is_in_another_shard =\n          shard_tests != IGNORE_SHARDING_PROTOCOL &&\n          !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);\n      test_info->is_in_another_shard_ = is_in_another_shard;\n      const bool is_selected = is_runnable && !is_in_another_shard;\n\n      num_runnable_tests += is_runnable;\n      num_selected_tests += is_selected;\n\n      test_info->should_run_ = is_selected;\n      test_suite->set_should_run(test_suite->should_run() || is_selected);\n    }\n  }\n  return num_selected_tests;\n}\n\n// Prints the given C-string on a single line by replacing all '\\n'\n// characters with string \"\\\\n\".  If the output takes more than\n// max_length characters, only prints the first max_length characters\n// and \"...\".\nstatic void PrintOnOneLine(const char* str, int max_length) {\n  if (str != nullptr) {\n    for (int i = 0; *str != '\\0'; ++str) {\n      if (i >= max_length) {\n        printf(\"...\");\n        break;\n      }\n      if (*str == '\\n') {\n        printf(\"\\\\n\");\n        i += 2;\n      } else {\n        printf(\"%c\", *str);\n        ++i;\n      }\n    }\n  }\n}\n\n// Prints the names of the tests matching the user-specified filter flag.\nvoid UnitTestImpl::ListTestsMatchingFilter() {\n  // Print at most this many characters for each type/value parameter.\n  const int kMaxParamLength = 250;\n\n  for (auto* test_suite : test_suites_) {\n    bool printed_test_suite_name = false;\n\n    for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {\n      const TestInfo* const test_info = test_suite->test_info_list()[j];\n      if (test_info->matches_filter_) {\n        if (!printed_test_suite_name) {\n          printed_test_suite_name = true;\n          printf(\"%s.\", test_suite->name());\n          if (test_suite->type_param() != nullptr) {\n            printf(\"  # %s = \", kTypeParamLabel);\n            // We print the type parameter on a single line to make\n            // the output easy to parse by a program.\n            PrintOnOneLine(test_suite->type_param(), kMaxParamLength);\n          }\n          printf(\"\\n\");\n        }\n        printf(\"  %s\", test_info->name());\n        if (test_info->value_param() != nullptr) {\n          printf(\"  # %s = \", kValueParamLabel);\n          // We print the value parameter on a single line to make the\n          // output easy to parse by a program.\n          PrintOnOneLine(test_info->value_param(), kMaxParamLength);\n        }\n        printf(\"\\n\");\n      }\n    }\n  }\n  fflush(stdout);\n  const std::string& output_format = UnitTestOptions::GetOutputFormat();\n  if (output_format == \"xml\" || output_format == \"json\") {\n    FILE* fileout = OpenFileForWriting(\n        UnitTestOptions::GetAbsolutePathToOutputFile().c_str());\n    std::stringstream stream;\n    if (output_format == \"xml\") {\n      XmlUnitTestResultPrinter(\n          UnitTestOptions::GetAbsolutePathToOutputFile().c_str())\n          .PrintXmlTestsList(&stream, test_suites_);\n    } else if (output_format == \"json\") {\n      JsonUnitTestResultPrinter(\n          UnitTestOptions::GetAbsolutePathToOutputFile().c_str())\n          .PrintJsonTestList(&stream, test_suites_);\n    }\n    fprintf(fileout, \"%s\", StringStreamToString(&stream).c_str());\n    fclose(fileout);\n  }\n}\n\n// Sets the OS stack trace getter.\n//\n// Does nothing if the input and the current OS stack trace getter are\n// the same; otherwise, deletes the old getter and makes the input the\n// current getter.\nvoid UnitTestImpl::set_os_stack_trace_getter(\n    OsStackTraceGetterInterface* getter) {\n  if (os_stack_trace_getter_ != getter) {\n    delete os_stack_trace_getter_;\n    os_stack_trace_getter_ = getter;\n  }\n}\n\n// Returns the current OS stack trace getter if it is not NULL;\n// otherwise, creates an OsStackTraceGetter, makes it the current\n// getter, and returns it.\nOsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {\n  if (os_stack_trace_getter_ == nullptr) {\n#ifdef GTEST_OS_STACK_TRACE_GETTER_\n    os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;\n#else\n    os_stack_trace_getter_ = new OsStackTraceGetter;\n#endif  // GTEST_OS_STACK_TRACE_GETTER_\n  }\n\n  return os_stack_trace_getter_;\n}\n\n// Returns the most specific TestResult currently running.\nTestResult* UnitTestImpl::current_test_result() {\n  if (current_test_info_ != nullptr) {\n    return &current_test_info_->result_;\n  }\n  if (current_test_suite_ != nullptr) {\n    return &current_test_suite_->ad_hoc_test_result_;\n  }\n  return &ad_hoc_test_result_;\n}\n\n// Shuffles all test suites, and the tests within each test suite,\n// making sure that death tests are still run first.\nvoid UnitTestImpl::ShuffleTests() {\n  // Shuffles the death test suites.\n  ShuffleRange(random(), 0, last_death_test_suite_ + 1, &test_suite_indices_);\n\n  // Shuffles the non-death test suites.\n  ShuffleRange(random(), last_death_test_suite_ + 1,\n               static_cast<int>(test_suites_.size()), &test_suite_indices_);\n\n  // Shuffles the tests inside each test suite.\n  for (auto& test_suite : test_suites_) {\n    test_suite->ShuffleTests(random());\n  }\n}\n\n// Restores the test suites and tests to their order before the first shuffle.\nvoid UnitTestImpl::UnshuffleTests() {\n  for (size_t i = 0; i < test_suites_.size(); i++) {\n    // Unshuffles the tests in each test suite.\n    test_suites_[i]->UnshuffleTests();\n    // Resets the index of each test suite.\n    test_suite_indices_[i] = static_cast<int>(i);\n  }\n}\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\nstd::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,\n                                            int skip_count) {\n  // We pass skip_count + 1 to skip this wrapper function in addition\n  // to what the user really wants to skip.\n  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);\n}\n\n// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to\n// suppress unreachable code warnings.\nnamespace {\nclass ClassUniqueToAlwaysTrue {};\n}\n\nbool IsTrue(bool condition) { return condition; }\n\nbool AlwaysTrue() {\n#if GTEST_HAS_EXCEPTIONS\n  // This condition is always false so AlwaysTrue() never actually throws,\n  // but it makes the compiler think that it may throw.\n  if (IsTrue(false))\n    throw ClassUniqueToAlwaysTrue();\n#endif  // GTEST_HAS_EXCEPTIONS\n  return true;\n}\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n// and returns false.  None of pstr, *pstr, and prefix can be NULL.\nbool SkipPrefix(const char* prefix, const char** pstr) {\n  const size_t prefix_len = strlen(prefix);\n  if (strncmp(*pstr, prefix, prefix_len) == 0) {\n    *pstr += prefix_len;\n    return true;\n  }\n  return false;\n}\n\n// Parses a string as a command line flag.  The string should have\n// the format \"--flag=value\".  When def_optional is true, the \"=value\"\n// part can be omitted.\n//\n// Returns the value of the flag, or NULL if the parsing failed.\nstatic const char* ParseFlagValue(const char* str, const char* flag,\n                                  bool def_optional) {\n  // str and flag must not be NULL.\n  if (str == nullptr || flag == nullptr) return nullptr;\n\n  // The flag must start with \"--\" followed by GTEST_FLAG_PREFIX_.\n  const std::string flag_str = std::string(\"--\") + GTEST_FLAG_PREFIX_ + flag;\n  const size_t flag_len = flag_str.length();\n  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;\n\n  // Skips the flag name.\n  const char* flag_end = str + flag_len;\n\n  // When def_optional is true, it's OK to not have a \"=value\" part.\n  if (def_optional && (flag_end[0] == '\\0')) {\n    return flag_end;\n  }\n\n  // If def_optional is true and there are more characters after the\n  // flag name, or if def_optional is false, there must be a '=' after\n  // the flag name.\n  if (flag_end[0] != '=') return nullptr;\n\n  // Returns the string after \"=\".\n  return flag_end + 1;\n}\n\n// Parses a string for a bool flag, in the form of either\n// \"--flag=value\" or \"--flag\".\n//\n// In the former case, the value is taken as true as long as it does\n// not start with '0', 'f', or 'F'.\n//\n// In the latter case, the value is taken as true.\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nstatic bool ParseBoolFlag(const char* str, const char* flag, bool* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, true);\n\n  // Aborts if the parsing failed.\n  if (value_str == nullptr) return false;\n\n  // Converts the string value to a bool.\n  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');\n  return true;\n}\n\n// Parses a string for an int32_t flag, in the form of \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == nullptr) return false;\n\n  // Sets *value to the value of the flag.\n  return ParseInt32(Message() << \"The value of flag --\" << flag,\n                    value_str, value);\n}\n\n// Parses a string for a string flag, in the form of \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\ntemplate <typename String>\nstatic bool ParseStringFlag(const char* str, const char* flag, String* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == nullptr) return false;\n\n  // Sets *value to the value of the flag.\n  *value = value_str;\n  return true;\n}\n\n// Determines whether a string has a prefix that Google Test uses for its\n// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.\n// If Google Test detects that a command line flag has its prefix but is not\n// recognized, it will print its help message. Flags starting with\n// GTEST_INTERNAL_PREFIX_ followed by \"internal_\" are considered Google Test\n// internal flags and do not trigger the help message.\nstatic bool HasGoogleTestFlagPrefix(const char* str) {\n  return (SkipPrefix(\"--\", &str) ||\n          SkipPrefix(\"-\", &str) ||\n          SkipPrefix(\"/\", &str)) &&\n         !SkipPrefix(GTEST_FLAG_PREFIX_ \"internal_\", &str) &&\n         (SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||\n          SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));\n}\n\n// Prints a string containing code-encoded text.  The following escape\n// sequences can be used in the string to control the text color:\n//\n//   @@    prints a single '@' character.\n//   @R    changes the color to red.\n//   @G    changes the color to green.\n//   @Y    changes the color to yellow.\n//   @D    changes to the default terminal text color.\n//\nstatic void PrintColorEncoded(const char* str) {\n  GTestColor color = GTestColor::kDefault;  // The current color.\n\n  // Conceptually, we split the string into segments divided by escape\n  // sequences.  Then we print one segment at a time.  At the end of\n  // each iteration, the str pointer advances to the beginning of the\n  // next segment.\n  for (;;) {\n    const char* p = strchr(str, '@');\n    if (p == nullptr) {\n      ColoredPrintf(color, \"%s\", str);\n      return;\n    }\n\n    ColoredPrintf(color, \"%s\", std::string(str, p).c_str());\n\n    const char ch = p[1];\n    str = p + 2;\n    if (ch == '@') {\n      ColoredPrintf(color, \"@\");\n    } else if (ch == 'D') {\n      color = GTestColor::kDefault;\n    } else if (ch == 'R') {\n      color = GTestColor::kRed;\n    } else if (ch == 'G') {\n      color = GTestColor::kGreen;\n    } else if (ch == 'Y') {\n      color = GTestColor::kYellow;\n    } else {\n      --str;\n    }\n  }\n}\n\nstatic const char kColorEncodedHelpMessage[] =\n    \"This program contains tests written using \" GTEST_NAME_\n    \". You can use the\\n\"\n    \"following command line flags to control its behavior:\\n\"\n    \"\\n\"\n    \"Test Selection:\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"list_tests@D\\n\"\n    \"      List the names of all tests instead of running them. The name of\\n\"\n    \"      TEST(Foo, Bar) is \\\"Foo.Bar\\\".\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"filter=@YPOSITIVE_PATTERNS\"\n    \"[@G-@YNEGATIVE_PATTERNS]@D\\n\"\n    \"      Run only the tests whose name matches one of the positive patterns \"\n    \"but\\n\"\n    \"      none of the negative patterns. '?' matches any single character; \"\n    \"'*'\\n\"\n    \"      matches any substring; ':' separates two patterns.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"also_run_disabled_tests@D\\n\"\n    \"      Run all disabled tests too.\\n\"\n    \"\\n\"\n    \"Test Execution:\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"repeat=@Y[COUNT]@D\\n\"\n    \"      Run the tests repeatedly; use a negative count to repeat forever.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"shuffle@D\\n\"\n    \"      Randomize tests' orders on every iteration.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"random_seed=@Y[NUMBER]@D\\n\"\n    \"      Random number seed to use for shuffling test orders (between 1 and\\n\"\n    \"      99999, or 0 to use a seed based on the current time).\\n\"\n    \"\\n\"\n    \"Test Output:\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\\n\"\n    \"      Enable/disable colored output. The default is @Gauto@D.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"brief=1@D\\n\"\n    \"      Only print test failures.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"print_time=0@D\\n\"\n    \"      Don't print the elapsed time of each test.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G\" GTEST_PATH_SEP_\n    \"@Y|@G:@YFILE_PATH]@D\\n\"\n    \"      Generate a JSON or XML report in the given directory or with the \"\n    \"given\\n\"\n    \"      file name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\\n\"\n# if GTEST_CAN_STREAM_RESULTS_\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"stream_result_to=@YHOST@G:@YPORT@D\\n\"\n    \"      Stream test results to the given server.\\n\"\n# endif  // GTEST_CAN_STREAM_RESULTS_\n    \"\\n\"\n    \"Assertion Behavior:\\n\"\n# if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\\n\"\n    \"      Set the default death test style.\\n\"\n# endif  // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"break_on_failure@D\\n\"\n    \"      Turn assertion failures into debugger break-points.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"throw_on_failure@D\\n\"\n    \"      Turn assertion failures into C++ exceptions for use by an external\\n\"\n    \"      test framework.\\n\"\n    \"  @G--\" GTEST_FLAG_PREFIX_\n    \"catch_exceptions=0@D\\n\"\n    \"      Do not report exceptions as test failures. Instead, allow them\\n\"\n    \"      to crash the program or throw a pop-up (on Windows).\\n\"\n    \"\\n\"\n    \"Except for @G--\" GTEST_FLAG_PREFIX_\n    \"list_tests@D, you can alternatively set \"\n    \"the corresponding\\n\"\n    \"environment variable of a flag (all letters in upper-case). For example, \"\n    \"to\\n\"\n    \"disable colored text output, you can either specify \"\n    \"@G--\" GTEST_FLAG_PREFIX_\n    \"color=no@D or set\\n\"\n    \"the @G\" GTEST_FLAG_PREFIX_UPPER_\n    \"COLOR@D environment variable to @Gno@D.\\n\"\n    \"\\n\"\n    \"For more information, please read the \" GTEST_NAME_\n    \" documentation at\\n\"\n    \"@G\" GTEST_PROJECT_URL_ \"@D. If you find a bug in \" GTEST_NAME_\n    \"\\n\"\n    \"(not one in your own code or tests), please report it to\\n\"\n    \"@G<\" GTEST_DEV_EMAIL_ \">@D.\\n\";\n\nstatic bool ParseGoogleTestFlag(const char* const arg) {\n  return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,\n                       &GTEST_FLAG(also_run_disabled_tests)) ||\n         ParseBoolFlag(arg, kBreakOnFailureFlag,\n                       &GTEST_FLAG(break_on_failure)) ||\n         ParseBoolFlag(arg, kCatchExceptionsFlag,\n                       &GTEST_FLAG(catch_exceptions)) ||\n         ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) ||\n         ParseStringFlag(arg, kDeathTestStyleFlag,\n                         &GTEST_FLAG(death_test_style)) ||\n         ParseBoolFlag(arg, kDeathTestUseFork,\n                       &GTEST_FLAG(death_test_use_fork)) ||\n         ParseBoolFlag(arg, kFailFast, &GTEST_FLAG(fail_fast)) ||\n         ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||\n         ParseStringFlag(arg, kInternalRunDeathTestFlag,\n                         &GTEST_FLAG(internal_run_death_test)) ||\n         ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||\n         ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||\n         ParseBoolFlag(arg, kBriefFlag, &GTEST_FLAG(brief)) ||\n         ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||\n         ParseBoolFlag(arg, kPrintUTF8Flag, &GTEST_FLAG(print_utf8)) ||\n         ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||\n         ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||\n         ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||\n         ParseInt32Flag(arg, kStackTraceDepthFlag,\n                        &GTEST_FLAG(stack_trace_depth)) ||\n         ParseStringFlag(arg, kStreamResultToFlag,\n                         &GTEST_FLAG(stream_result_to)) ||\n         ParseBoolFlag(arg, kThrowOnFailureFlag, &GTEST_FLAG(throw_on_failure));\n}\n\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\nstatic void LoadFlagsFromFile(const std::string& path) {\n  FILE* flagfile = posix::FOpen(path.c_str(), \"r\");\n  if (!flagfile) {\n    GTEST_LOG_(FATAL) << \"Unable to open file \\\"\" << GTEST_FLAG(flagfile)\n                      << \"\\\"\";\n  }\n  std::string contents(ReadEntireFile(flagfile));\n  posix::FClose(flagfile);\n  std::vector<std::string> lines;\n  SplitString(contents, '\\n', &lines);\n  for (size_t i = 0; i < lines.size(); ++i) {\n    if (lines[i].empty())\n      continue;\n    if (!ParseGoogleTestFlag(lines[i].c_str()))\n      g_help_flag = true;\n  }\n}\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.  The type parameter CharType can be\n// instantiated to either char or wchar_t.\ntemplate <typename CharType>\nvoid ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {\n  for (int i = 1; i < *argc; i++) {\n    const std::string arg_string = StreamableToString(argv[i]);\n    const char* const arg = arg_string.c_str();\n\n    using internal::ParseBoolFlag;\n    using internal::ParseInt32Flag;\n    using internal::ParseStringFlag;\n\n    bool remove_flag = false;\n    if (ParseGoogleTestFlag(arg)) {\n      remove_flag = true;\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\n    } else if (ParseStringFlag(arg, kFlagfileFlag, &GTEST_FLAG(flagfile))) {\n      LoadFlagsFromFile(GTEST_FLAG(flagfile));\n      remove_flag = true;\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n    } else if (arg_string == \"--help\" || arg_string == \"-h\" ||\n               arg_string == \"-?\" || arg_string == \"/?\" ||\n               HasGoogleTestFlagPrefix(arg)) {\n      // Both help flag and unrecognized Google Test flags (excluding\n      // internal ones) trigger help display.\n      g_help_flag = true;\n    }\n\n    if (remove_flag) {\n      // Shift the remainder of the argv list left by one.  Note\n      // that argv has (*argc + 1) elements, the last one always being\n      // NULL.  The following loop moves the trailing NULL element as\n      // well.\n      for (int j = i; j != *argc; j++) {\n        argv[j] = argv[j + 1];\n      }\n\n      // Decrements the argument count.\n      (*argc)--;\n\n      // We also need to decrement the iterator as we just removed\n      // an element.\n      i--;\n    }\n  }\n\n  if (g_help_flag) {\n    // We print the help here instead of in RUN_ALL_TESTS(), as the\n    // latter may not be called at all if the user is using Google\n    // Test with another testing framework.\n    PrintColorEncoded(kColorEncodedHelpMessage);\n  }\n}\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.\nvoid ParseGoogleTestFlagsOnly(int* argc, char** argv) {\n  ParseGoogleTestFlagsOnlyImpl(argc, argv);\n\n  // Fix the value of *_NSGetArgc() on macOS, but if and only if\n  // *_NSGetArgv() == argv\n  // Only applicable to char** version of argv\n#if GTEST_OS_MAC\n#ifndef GTEST_OS_IOS\n  if (*_NSGetArgv() == argv) {\n    *_NSGetArgc() = *argc;\n  }\n#endif\n#endif\n}\nvoid ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {\n  ParseGoogleTestFlagsOnlyImpl(argc, argv);\n}\n\n// The internal implementation of InitGoogleTest().\n//\n// The type parameter CharType can be instantiated to either char or\n// wchar_t.\ntemplate <typename CharType>\nvoid InitGoogleTestImpl(int* argc, CharType** argv) {\n  // We don't want to run the initialization code twice.\n  if (GTestIsInitialized()) return;\n\n  if (*argc <= 0) return;\n\n  g_argvs.clear();\n  for (int i = 0; i != *argc; i++) {\n    g_argvs.push_back(StreamableToString(argv[i]));\n  }\n\n#if GTEST_HAS_ABSL\n  absl::InitializeSymbolizer(g_argvs[0].c_str());\n#endif  // GTEST_HAS_ABSL\n\n  ParseGoogleTestFlagsOnly(argc, argv);\n  GetUnitTestImpl()->PostFlagParsingInit();\n}\n\n}  // namespace internal\n\n// Initializes Google Test.  This must be called before calling\n// RUN_ALL_TESTS().  In particular, it parses a command line for the\n// flags that Google Test recognizes.  Whenever a Google Test flag is\n// seen, it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Test flag variables are\n// updated.\n//\n// Calling the function for the second time has no user-visible effect.\nvoid InitGoogleTest(int* argc, char** argv) {\n#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);\n#else  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  internal::InitGoogleTestImpl(argc, argv);\n#endif  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n}\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nvoid InitGoogleTest(int* argc, wchar_t** argv) {\n#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);\n#else  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  internal::InitGoogleTestImpl(argc, argv);\n#endif  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n}\n\n// This overloaded version can be used on Arduino/embedded platforms where\n// there is no argc/argv.\nvoid InitGoogleTest() {\n  // Since Arduino doesn't have a command line, fake out the argc/argv arguments\n  int argc = 1;\n  const auto arg0 = \"dummy\";\n  char* argv0 = const_cast<char*>(arg0);\n  char** argv = &argv0;\n\n#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(&argc, argv);\n#else  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n  internal::InitGoogleTestImpl(&argc, argv);\n#endif  // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)\n}\n\nstd::string TempDir() {\n#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)\n  return GTEST_CUSTOM_TEMPDIR_FUNCTION_();\n#elif GTEST_OS_WINDOWS_MOBILE\n  return \"\\\\temp\\\\\";\n#elif GTEST_OS_WINDOWS\n  const char* temp_dir = internal::posix::GetEnv(\"TEMP\");\n  if (temp_dir == nullptr || temp_dir[0] == '\\0') {\n    return \"\\\\temp\\\\\";\n  } else if (temp_dir[strlen(temp_dir) - 1] == '\\\\') {\n    return temp_dir;\n  } else {\n    return std::string(temp_dir) + \"\\\\\";\n  }\n#elif GTEST_OS_LINUX_ANDROID\n  const char* temp_dir = internal::posix::GetEnv(\"TEST_TMPDIR\");\n  if (temp_dir == nullptr || temp_dir[0] == '\\0') {\n    return \"/data/local/tmp/\";\n  } else {\n    return temp_dir;\n  }\n#elif GTEST_OS_LINUX\n  const char* temp_dir = internal::posix::GetEnv(\"TEST_TMPDIR\");\n  if (temp_dir == nullptr || temp_dir[0] == '\\0') {\n    return \"/tmp/\";\n  } else {\n    return temp_dir;\n  }\n#else\n  return \"/tmp/\";\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Class ScopedTrace\n\n// Pushes the given source file location and message onto a per-thread\n// trace stack maintained by Google Test.\nvoid ScopedTrace::PushTrace(const char* file, int line, std::string message) {\n  internal::TraceInfo trace;\n  trace.file = file;\n  trace.line = line;\n  trace.message.swap(message);\n\n  UnitTest::GetInstance()->PushGTestTrace(trace);\n}\n\n// Pops the info pushed by the c'tor.\nScopedTrace::~ScopedTrace()\n    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {\n  UnitTest::GetInstance()->PopGTestTrace();\n}\n\n}  // namespace testing\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// This file implements death tests.\n\n\n#include <functional>\n#include <utility>\n\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_OS_MAC\n#  include <crt_externs.h>\n# endif  // GTEST_OS_MAC\n\n# include <errno.h>\n# include <fcntl.h>\n# include <limits.h>\n\n# if GTEST_OS_LINUX\n#  include <signal.h>\n# endif  // GTEST_OS_LINUX\n\n# include <stdarg.h>\n\n# if GTEST_OS_WINDOWS\n#  include <windows.h>\n# else\n#  include <sys/mman.h>\n#  include <sys/wait.h>\n# endif  // GTEST_OS_WINDOWS\n\n# if GTEST_OS_QNX\n#  include <spawn.h>\n# endif  // GTEST_OS_QNX\n\n# if GTEST_OS_FUCHSIA\n#  include <lib/fdio/fd.h>\n#  include <lib/fdio/io.h>\n#  include <lib/fdio/spawn.h>\n#  include <lib/zx/channel.h>\n#  include <lib/zx/port.h>\n#  include <lib/zx/process.h>\n#  include <lib/zx/socket.h>\n#  include <zircon/processargs.h>\n#  include <zircon/syscalls.h>\n#  include <zircon/syscalls/policy.h>\n#  include <zircon/syscalls/port.h>\n# endif  // GTEST_OS_FUCHSIA\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n\nnamespace testing {\n\n// Constants.\n\n// The default death test style.\n//\n// This is defined in internal/gtest-port.h as \"fast\", but can be overridden by\n// a definition in internal/custom/gtest-port.h. The recommended value, which is\n// used internally at Google, is \"threadsafe\".\nstatic const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE;\n\nGTEST_DEFINE_string_(\n    death_test_style,\n    internal::StringFromGTestEnv(\"death_test_style\", kDefaultDeathTestStyle),\n    \"Indicates how to run a death test in a forked child process: \"\n    \"\\\"threadsafe\\\" (child process re-executes the test binary \"\n    \"from the beginning, running only the specific death test) or \"\n    \"\\\"fast\\\" (child process runs the death test immediately \"\n    \"after forking).\");\n\nGTEST_DEFINE_bool_(\n    death_test_use_fork,\n    internal::BoolFromGTestEnv(\"death_test_use_fork\", false),\n    \"Instructs to use fork()/_exit() instead of clone() in death tests. \"\n    \"Ignored and always uses fork() on POSIX systems where clone() is not \"\n    \"implemented. Useful when running under valgrind or similar tools if \"\n    \"those do not support clone(). Valgrind 3.3.1 will just fail if \"\n    \"it sees an unsupported combination of clone() flags. \"\n    \"It is not recommended to use this flag w/o valgrind though it will \"\n    \"work in 99% of the cases. Once valgrind is fixed, this flag will \"\n    \"most likely be removed.\");\n\nnamespace internal {\nGTEST_DEFINE_string_(\n    internal_run_death_test, \"\",\n    \"Indicates the file, line number, temporal index of \"\n    \"the single death test to run, and a file descriptor to \"\n    \"which a success code may be sent, all separated by \"\n    \"the '|' characters.  This flag is specified if and only if the \"\n    \"current process is a sub-process launched for running a thread-safe \"\n    \"death test.  FOR INTERNAL USE ONLY.\");\n}  // namespace internal\n\n#if GTEST_HAS_DEATH_TEST\n\nnamespace internal {\n\n// Valid only for fast death tests. Indicates the code is running in the\n// child process of a fast style death test.\n# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA\nstatic bool g_in_fast_death_test_child = false;\n# endif\n\n// Returns a Boolean value indicating whether the caller is currently\n// executing in the context of the death test child process.  Tools such as\n// Valgrind heap checkers may need this to modify their behavior in death\n// tests.  IMPORTANT: This is an internal utility.  Using it may break the\n// implementation of death tests.  User code MUST NOT use it.\nbool InDeathTestChild() {\n# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA\n\n  // On Windows and Fuchsia, death tests are thread-safe regardless of the value\n  // of the death_test_style flag.\n  return !GTEST_FLAG(internal_run_death_test).empty();\n\n# else\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\")\n    return !GTEST_FLAG(internal_run_death_test).empty();\n  else\n    return g_in_fast_death_test_child;\n#endif\n}\n\n}  // namespace internal\n\n// ExitedWithCode constructor.\nExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {\n}\n\n// ExitedWithCode function-call operator.\nbool ExitedWithCode::operator()(int exit_status) const {\n# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA\n\n  return exit_status == exit_code_;\n\n# else\n\n  return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;\n\n# endif  // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA\n}\n\n# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA\n// KilledBySignal constructor.\nKilledBySignal::KilledBySignal(int signum) : signum_(signum) {\n}\n\n// KilledBySignal function-call operator.\nbool KilledBySignal::operator()(int exit_status) const {\n#  if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)\n  {\n    bool result;\n    if (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) {\n      return result;\n    }\n  }\n#  endif  // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_)\n  return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;\n}\n# endif  // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA\n\nnamespace internal {\n\n// Utilities needed for death tests.\n\n// Generates a textual description of a given exit code, in the format\n// specified by wait(2).\nstatic std::string ExitSummary(int exit_code) {\n  Message m;\n\n# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA\n\n  m << \"Exited with exit status \" << exit_code;\n\n# else\n\n  if (WIFEXITED(exit_code)) {\n    m << \"Exited with exit status \" << WEXITSTATUS(exit_code);\n  } else if (WIFSIGNALED(exit_code)) {\n    m << \"Terminated by signal \" << WTERMSIG(exit_code);\n  }\n#  ifdef WCOREDUMP\n  if (WCOREDUMP(exit_code)) {\n    m << \" (core dumped)\";\n  }\n#  endif\n# endif  // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA\n\n  return m.GetString();\n}\n\n// Returns true if exit_status describes a process that was terminated\n// by a signal, or exited normally with a nonzero exit code.\nbool ExitedUnsuccessfully(int exit_status) {\n  return !ExitedWithCode(0)(exit_status);\n}\n\n# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA\n// Generates a textual failure message when a death test finds more than\n// one thread running, or cannot determine the number of threads, prior\n// to executing the given statement.  It is the responsibility of the\n// caller not to pass a thread_count of 1.\nstatic std::string DeathTestThreadWarning(size_t thread_count) {\n  Message msg;\n  msg << \"Death tests use fork(), which is unsafe particularly\"\n      << \" in a threaded context. For this test, \" << GTEST_NAME_ << \" \";\n  if (thread_count == 0) {\n    msg << \"couldn't detect the number of threads.\";\n  } else {\n    msg << \"detected \" << thread_count << \" threads.\";\n  }\n  msg << \" See \"\n         \"https://github.com/google/googletest/blob/master/docs/\"\n         \"advanced.md#death-tests-and-threads\"\n      << \" for more explanation and suggested solutions, especially if\"\n      << \" this is the last message you see before your test times out.\";\n  return msg.GetString();\n}\n# endif  // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA\n\n// Flag characters for reporting a death test that did not die.\nstatic const char kDeathTestLived = 'L';\nstatic const char kDeathTestReturned = 'R';\nstatic const char kDeathTestThrew = 'T';\nstatic const char kDeathTestInternalError = 'I';\n\n#if GTEST_OS_FUCHSIA\n\n// File descriptor used for the pipe in the child process.\nstatic const int kFuchsiaReadPipeFd = 3;\n\n#endif\n\n// An enumeration describing all of the possible ways that a death test can\n// conclude.  DIED means that the process died while executing the test\n// code; LIVED means that process lived beyond the end of the test code;\n// RETURNED means that the test statement attempted to execute a return\n// statement, which is not allowed; THREW means that the test statement\n// returned control by throwing an exception.  IN_PROGRESS means the test\n// has not yet concluded.\nenum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };\n\n// Routine for aborting the program which is safe to call from an\n// exec-style death test child process, in which case the error\n// message is propagated back to the parent process.  Otherwise, the\n// message is simply printed to stderr.  In either case, the program\n// then exits with status 1.\nstatic void DeathTestAbort(const std::string& message) {\n  // On a POSIX system, this function may be called from a threadsafe-style\n  // death test child process, which operates on a very small stack.  Use\n  // the heap for any additional non-minuscule memory requirements.\n  const InternalRunDeathTestFlag* const flag =\n      GetUnitTestImpl()->internal_run_death_test_flag();\n  if (flag != nullptr) {\n    FILE* parent = posix::FDOpen(flag->write_fd(), \"w\");\n    fputc(kDeathTestInternalError, parent);\n    fprintf(parent, \"%s\", message.c_str());\n    fflush(parent);\n    _exit(1);\n  } else {\n    fprintf(stderr, \"%s\", message.c_str());\n    fflush(stderr);\n    posix::Abort();\n  }\n}\n\n// A replacement for CHECK that calls DeathTestAbort if the assertion\n// fails.\n# define GTEST_DEATH_TEST_CHECK_(expression) \\\n  do { \\\n    if (!::testing::internal::IsTrue(expression)) { \\\n      DeathTestAbort( \\\n          ::std::string(\"CHECK failed: File \") + __FILE__ +  \", line \" \\\n          + ::testing::internal::StreamableToString(__LINE__) + \": \" \\\n          + #expression); \\\n    } \\\n  } while (::testing::internal::AlwaysFalse())\n\n// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for\n// evaluating any system call that fulfills two conditions: it must return\n// -1 on failure, and set errno to EINTR when it is interrupted and\n// should be tried again.  The macro expands to a loop that repeatedly\n// evaluates the expression as long as it evaluates to -1 and sets\n// errno to EINTR.  If the expression evaluates to -1 but errno is\n// something other than EINTR, DeathTestAbort is called.\n# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \\\n  do { \\\n    int gtest_retval; \\\n    do { \\\n      gtest_retval = (expression); \\\n    } while (gtest_retval == -1 && errno == EINTR); \\\n    if (gtest_retval == -1) { \\\n      DeathTestAbort( \\\n          ::std::string(\"CHECK failed: File \") + __FILE__ + \", line \" \\\n          + ::testing::internal::StreamableToString(__LINE__) + \": \" \\\n          + #expression + \" != -1\"); \\\n    } \\\n  } while (::testing::internal::AlwaysFalse())\n\n// Returns the message describing the last system error in errno.\nstd::string GetLastErrnoDescription() {\n    return errno == 0 ? \"\" : posix::StrError(errno);\n}\n\n// This is called from a death test parent process to read a failure\n// message from the death test child process and log it with the FATAL\n// severity. On Windows, the message is read from a pipe handle. On other\n// platforms, it is read from a file descriptor.\nstatic void FailFromInternalError(int fd) {\n  Message error;\n  char buffer[256];\n  int num_read;\n\n  do {\n    while ((num_read = posix::Read(fd, buffer, 255)) > 0) {\n      buffer[num_read] = '\\0';\n      error << buffer;\n    }\n  } while (num_read == -1 && errno == EINTR);\n\n  if (num_read == 0) {\n    GTEST_LOG_(FATAL) << error.GetString();\n  } else {\n    const int last_error = errno;\n    GTEST_LOG_(FATAL) << \"Error while reading death test internal: \"\n                      << GetLastErrnoDescription() << \" [\" << last_error << \"]\";\n  }\n}\n\n// Death test constructor.  Increments the running death test count\n// for the current test.\nDeathTest::DeathTest() {\n  TestInfo* const info = GetUnitTestImpl()->current_test_info();\n  if (info == nullptr) {\n    DeathTestAbort(\"Cannot run a death test outside of a TEST or \"\n                   \"TEST_F construct\");\n  }\n}\n\n// Creates and returns a death test by dispatching to the current\n// death test factory.\nbool DeathTest::Create(const char* statement,\n                       Matcher<const std::string&> matcher, const char* file,\n                       int line, DeathTest** test) {\n  return GetUnitTestImpl()->death_test_factory()->Create(\n      statement, std::move(matcher), file, line, test);\n}\n\nconst char* DeathTest::LastMessage() {\n  return last_death_test_message_.c_str();\n}\n\nvoid DeathTest::set_last_death_test_message(const std::string& message) {\n  last_death_test_message_ = message;\n}\n\nstd::string DeathTest::last_death_test_message_;\n\n// Provides cross platform implementation for some death functionality.\nclass DeathTestImpl : public DeathTest {\n protected:\n  DeathTestImpl(const char* a_statement, Matcher<const std::string&> matcher)\n      : statement_(a_statement),\n        matcher_(std::move(matcher)),\n        spawned_(false),\n        status_(-1),\n        outcome_(IN_PROGRESS),\n        read_fd_(-1),\n        write_fd_(-1) {}\n\n  // read_fd_ is expected to be closed and cleared by a derived class.\n  ~DeathTestImpl() override { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }\n\n  void Abort(AbortReason reason) override;\n  bool Passed(bool status_ok) override;\n\n  const char* statement() const { return statement_; }\n  bool spawned() const { return spawned_; }\n  void set_spawned(bool is_spawned) { spawned_ = is_spawned; }\n  int status() const { return status_; }\n  void set_status(int a_status) { status_ = a_status; }\n  DeathTestOutcome outcome() const { return outcome_; }\n  void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }\n  int read_fd() const { return read_fd_; }\n  void set_read_fd(int fd) { read_fd_ = fd; }\n  int write_fd() const { return write_fd_; }\n  void set_write_fd(int fd) { write_fd_ = fd; }\n\n  // Called in the parent process only. Reads the result code of the death\n  // test child process via a pipe, interprets it to set the outcome_\n  // member, and closes read_fd_.  Outputs diagnostics and terminates in\n  // case of unexpected codes.\n  void ReadAndInterpretStatusByte();\n\n  // Returns stderr output from the child process.\n  virtual std::string GetErrorLogs();\n\n private:\n  // The textual content of the code this object is testing.  This class\n  // doesn't own this string and should not attempt to delete it.\n  const char* const statement_;\n  // A matcher that's expected to match the stderr output by the child process.\n  Matcher<const std::string&> matcher_;\n  // True if the death test child process has been successfully spawned.\n  bool spawned_;\n  // The exit status of the child process.\n  int status_;\n  // How the death test concluded.\n  DeathTestOutcome outcome_;\n  // Descriptor to the read end of the pipe to the child process.  It is\n  // always -1 in the child process.  The child keeps its write end of the\n  // pipe in write_fd_.\n  int read_fd_;\n  // Descriptor to the child's write end of the pipe to the parent process.\n  // It is always -1 in the parent process.  The parent keeps its end of the\n  // pipe in read_fd_.\n  int write_fd_;\n};\n\n// Called in the parent process only. Reads the result code of the death\n// test child process via a pipe, interprets it to set the outcome_\n// member, and closes read_fd_.  Outputs diagnostics and terminates in\n// case of unexpected codes.\nvoid DeathTestImpl::ReadAndInterpretStatusByte() {\n  char flag;\n  int bytes_read;\n\n  // The read() here blocks until data is available (signifying the\n  // failure of the death test) or until the pipe is closed (signifying\n  // its success), so it's okay to call this in the parent before\n  // the child process has exited.\n  do {\n    bytes_read = posix::Read(read_fd(), &flag, 1);\n  } while (bytes_read == -1 && errno == EINTR);\n\n  if (bytes_read == 0) {\n    set_outcome(DIED);\n  } else if (bytes_read == 1) {\n    switch (flag) {\n      case kDeathTestReturned:\n        set_outcome(RETURNED);\n        break;\n      case kDeathTestThrew:\n        set_outcome(THREW);\n        break;\n      case kDeathTestLived:\n        set_outcome(LIVED);\n        break;\n      case kDeathTestInternalError:\n        FailFromInternalError(read_fd());  // Does not return.\n        break;\n      default:\n        GTEST_LOG_(FATAL) << \"Death test child process reported \"\n                          << \"unexpected status byte (\"\n                          << static_cast<unsigned int>(flag) << \")\";\n    }\n  } else {\n    GTEST_LOG_(FATAL) << \"Read from death test child process failed: \"\n                      << GetLastErrnoDescription();\n  }\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));\n  set_read_fd(-1);\n}\n\nstd::string DeathTestImpl::GetErrorLogs() {\n  return GetCapturedStderr();\n}\n\n// Signals that the death test code which should have exited, didn't.\n// Should be called only in a death test child process.\n// Writes a status byte to the child's status file descriptor, then\n// calls _exit(1).\nvoid DeathTestImpl::Abort(AbortReason reason) {\n  // The parent process considers the death test to be a failure if\n  // it finds any data in our pipe.  So, here we write a single flag byte\n  // to the pipe, then exit.\n  const char status_ch =\n      reason == TEST_DID_NOT_DIE ? kDeathTestLived :\n      reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;\n\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));\n  // We are leaking the descriptor here because on some platforms (i.e.,\n  // when built as Windows DLL), destructors of global objects will still\n  // run after calling _exit(). On such systems, write_fd_ will be\n  // indirectly closed from the destructor of UnitTestImpl, causing double\n  // close if it is also closed here. On debug configurations, double close\n  // may assert. As there are no in-process buffers to flush here, we are\n  // relying on the OS to close the descriptor after the process terminates\n  // when the destructors are not run.\n  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)\n}\n\n// Returns an indented copy of stderr output for a death test.\n// This makes distinguishing death test output lines from regular log lines\n// much easier.\nstatic ::std::string FormatDeathTestOutput(const ::std::string& output) {\n  ::std::string ret;\n  for (size_t at = 0; ; ) {\n    const size_t line_end = output.find('\\n', at);\n    ret += \"[  DEATH   ] \";\n    if (line_end == ::std::string::npos) {\n      ret += output.substr(at);\n      break;\n    }\n    ret += output.substr(at, line_end + 1 - at);\n    at = line_end + 1;\n  }\n  return ret;\n}\n\n// Assesses the success or failure of a death test, using both private\n// members which have previously been set, and one argument:\n//\n// Private data members:\n//   outcome:  An enumeration describing how the death test\n//             concluded: DIED, LIVED, THREW, or RETURNED.  The death test\n//             fails in the latter three cases.\n//   status:   The exit status of the child process. On *nix, it is in the\n//             in the format specified by wait(2). On Windows, this is the\n//             value supplied to the ExitProcess() API or a numeric code\n//             of the exception that terminated the program.\n//   matcher_: A matcher that's expected to match the stderr output by the child\n//             process.\n//\n// Argument:\n//   status_ok: true if exit_status is acceptable in the context of\n//              this particular death test, which fails if it is false\n//\n// Returns true if and only if all of the above conditions are met.  Otherwise,\n// the first failing condition, in the order given above, is the one that is\n// reported. Also sets the last death test message string.\nbool DeathTestImpl::Passed(bool status_ok) {\n  if (!spawned())\n    return false;\n\n  const std::string error_message = GetErrorLogs();\n\n  bool success = false;\n  Message buffer;\n\n  buffer << \"Death test: \" << statement() << \"\\n\";\n  switch (outcome()) {\n    case LIVED:\n      buffer << \"    Result: failed to die.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case THREW:\n      buffer << \"    Result: threw an exception.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case RETURNED:\n      buffer << \"    Result: illegal return in test statement.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case DIED:\n      if (status_ok) {\n        if (matcher_.Matches(error_message)) {\n          success = true;\n        } else {\n          std::ostringstream stream;\n          matcher_.DescribeTo(&stream);\n          buffer << \"    Result: died but not with expected error.\\n\"\n                 << \"  Expected: \" << stream.str() << \"\\n\"\n                 << \"Actual msg:\\n\"\n                 << FormatDeathTestOutput(error_message);\n        }\n      } else {\n        buffer << \"    Result: died but not with expected exit code:\\n\"\n               << \"            \" << ExitSummary(status()) << \"\\n\"\n               << \"Actual msg:\\n\" << FormatDeathTestOutput(error_message);\n      }\n      break;\n    case IN_PROGRESS:\n    default:\n      GTEST_LOG_(FATAL)\n          << \"DeathTest::Passed somehow called before conclusion of test\";\n  }\n\n  DeathTest::set_last_death_test_message(buffer.GetString());\n  return success;\n}\n\n# if GTEST_OS_WINDOWS\n// WindowsDeathTest implements death tests on Windows. Due to the\n// specifics of starting new processes on Windows, death tests there are\n// always threadsafe, and Google Test considers the\n// --gtest_death_test_style=fast setting to be equivalent to\n// --gtest_death_test_style=threadsafe there.\n//\n// A few implementation notes:  Like the Linux version, the Windows\n// implementation uses pipes for child-to-parent communication. But due to\n// the specifics of pipes on Windows, some extra steps are required:\n//\n// 1. The parent creates a communication pipe and stores handles to both\n//    ends of it.\n// 2. The parent starts the child and provides it with the information\n//    necessary to acquire the handle to the write end of the pipe.\n// 3. The child acquires the write end of the pipe and signals the parent\n//    using a Windows event.\n// 4. Now the parent can release the write end of the pipe on its side. If\n//    this is done before step 3, the object's reference count goes down to\n//    0 and it is destroyed, preventing the child from acquiring it. The\n//    parent now has to release it, or read operations on the read end of\n//    the pipe will not return when the child terminates.\n// 5. The parent reads child's output through the pipe (outcome code and\n//    any possible error messages) from the pipe, and its stderr and then\n//    determines whether to fail the test.\n//\n// Note: to distinguish Win32 API calls from the local method and function\n// calls, the former are explicitly resolved in the global namespace.\n//\nclass WindowsDeathTest : public DeathTestImpl {\n public:\n  WindowsDeathTest(const char* a_statement, Matcher<const std::string&> matcher,\n                   const char* file, int line)\n      : DeathTestImpl(a_statement, std::move(matcher)),\n        file_(file),\n        line_(line) {}\n\n  // All of these virtual functions are inherited from DeathTest.\n  virtual int Wait();\n  virtual TestRole AssumeRole();\n\n private:\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n  // Handle to the write end of the pipe to the child process.\n  AutoHandle write_handle_;\n  // Child process handle.\n  AutoHandle child_handle_;\n  // Event the child process uses to signal the parent that it has\n  // acquired the handle to the write end of the pipe. After seeing this\n  // event the parent can release its own handles to make sure its\n  // ReadFile() calls return when the child terminates.\n  AutoHandle event_handle_;\n};\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint WindowsDeathTest::Wait() {\n  if (!spawned())\n    return 0;\n\n  // Wait until the child either signals that it has acquired the write end\n  // of the pipe or it dies.\n  const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };\n  switch (::WaitForMultipleObjects(2,\n                                   wait_handles,\n                                   FALSE,  // Waits for any of the handles.\n                                   INFINITE)) {\n    case WAIT_OBJECT_0:\n    case WAIT_OBJECT_0 + 1:\n      break;\n    default:\n      GTEST_DEATH_TEST_CHECK_(false);  // Should not get here.\n  }\n\n  // The child has acquired the write end of the pipe or exited.\n  // We release the handle on our side and continue.\n  write_handle_.Reset();\n  event_handle_.Reset();\n\n  ReadAndInterpretStatusByte();\n\n  // Waits for the child process to exit if it haven't already. This\n  // returns immediately if the child has already exited, regardless of\n  // whether previous calls to WaitForMultipleObjects synchronized on this\n  // handle or not.\n  GTEST_DEATH_TEST_CHECK_(\n      WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),\n                                             INFINITE));\n  DWORD status_code;\n  GTEST_DEATH_TEST_CHECK_(\n      ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);\n  child_handle_.Reset();\n  set_status(static_cast<int>(status_code));\n  return status();\n}\n\n// The AssumeRole process for a Windows death test.  It creates a child\n// process with the same executable as the current process to run the\n// death test.  The child process is given the --gtest_filter and\n// --gtest_internal_run_death_test flags such that it knows to run the\n// current death test only.\nDeathTest::TestRole WindowsDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != nullptr) {\n    // ParseInternalRunDeathTestFlag() has performed all the necessary\n    // processing.\n    set_write_fd(flag->write_fd());\n    return EXECUTE_TEST;\n  }\n\n  // WindowsDeathTest uses an anonymous pipe to communicate results of\n  // a death test.\n  SECURITY_ATTRIBUTES handles_are_inheritable = {sizeof(SECURITY_ATTRIBUTES),\n                                                 nullptr, TRUE};\n  HANDLE read_handle, write_handle;\n  GTEST_DEATH_TEST_CHECK_(\n      ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,\n                   0)  // Default buffer size.\n      != FALSE);\n  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),\n                                O_RDONLY));\n  write_handle_.Reset(write_handle);\n  event_handle_.Reset(::CreateEvent(\n      &handles_are_inheritable,\n      TRUE,       // The event will automatically reset to non-signaled state.\n      FALSE,      // The initial state is non-signalled.\n      nullptr));  // The even is unnamed.\n  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr);\n  const std::string filter_flag = std::string(\"--\") + GTEST_FLAG_PREFIX_ +\n                                  kFilterFlag + \"=\" + info->test_suite_name() +\n                                  \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag +\n      \"=\" + file_ + \"|\" + StreamableToString(line_) + \"|\" +\n      StreamableToString(death_test_index) + \"|\" +\n      StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +\n      // size_t has the same width as pointers on both 32-bit and 64-bit\n      // Windows platforms.\n      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.\n      \"|\" + StreamableToString(reinterpret_cast<size_t>(write_handle)) +\n      \"|\" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));\n\n  char executable_path[_MAX_PATH + 1];  // NOLINT\n  GTEST_DEATH_TEST_CHECK_(_MAX_PATH + 1 != ::GetModuleFileNameA(nullptr,\n                                                                executable_path,\n                                                                _MAX_PATH));\n\n  std::string command_line =\n      std::string(::GetCommandLineA()) + \" \" + filter_flag + \" \\\"\" +\n      internal_flag + \"\\\"\";\n\n  DeathTest::set_last_death_test_message(\"\");\n\n  CaptureStderr();\n  // Flush the log buffers since the log streams are shared with the child.\n  FlushInfoLog();\n\n  // The child process will share the standard handles with the parent.\n  STARTUPINFOA startup_info;\n  memset(&startup_info, 0, sizeof(STARTUPINFO));\n  startup_info.dwFlags = STARTF_USESTDHANDLES;\n  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);\n  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);\n  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);\n\n  PROCESS_INFORMATION process_info;\n  GTEST_DEATH_TEST_CHECK_(\n      ::CreateProcessA(\n          executable_path, const_cast<char*>(command_line.c_str()),\n          nullptr,  // Retuned process handle is not inheritable.\n          nullptr,  // Retuned thread handle is not inheritable.\n          TRUE,  // Child inherits all inheritable handles (for write_handle_).\n          0x0,   // Default creation flags.\n          nullptr,  // Inherit the parent's environment.\n          UnitTest::GetInstance()->original_working_dir(), &startup_info,\n          &process_info) != FALSE);\n  child_handle_.Reset(process_info.hProcess);\n  ::CloseHandle(process_info.hThread);\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n\n# elif GTEST_OS_FUCHSIA\n\nclass FuchsiaDeathTest : public DeathTestImpl {\n public:\n  FuchsiaDeathTest(const char* a_statement, Matcher<const std::string&> matcher,\n                   const char* file, int line)\n      : DeathTestImpl(a_statement, std::move(matcher)),\n        file_(file),\n        line_(line) {}\n\n  // All of these virtual functions are inherited from DeathTest.\n  int Wait() override;\n  TestRole AssumeRole() override;\n  std::string GetErrorLogs() override;\n\n private:\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n  // The stderr data captured by the child process.\n  std::string captured_stderr_;\n\n  zx::process child_process_;\n  zx::channel exception_channel_;\n  zx::socket stderr_socket_;\n};\n\n// Utility class for accumulating command-line arguments.\nclass Arguments {\n public:\n  Arguments() { args_.push_back(nullptr); }\n\n  ~Arguments() {\n    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();\n         ++i) {\n      free(*i);\n    }\n  }\n  void AddArgument(const char* argument) {\n    args_.insert(args_.end() - 1, posix::StrDup(argument));\n  }\n\n  template <typename Str>\n  void AddArguments(const ::std::vector<Str>& arguments) {\n    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();\n         i != arguments.end();\n         ++i) {\n      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));\n    }\n  }\n  char* const* Argv() {\n    return &args_[0];\n  }\n\n  int size() {\n    return static_cast<int>(args_.size()) - 1;\n  }\n\n private:\n  std::vector<char*> args_;\n};\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint FuchsiaDeathTest::Wait() {\n  const int kProcessKey = 0;\n  const int kSocketKey = 1;\n  const int kExceptionKey = 2;\n\n  if (!spawned())\n    return 0;\n\n  // Create a port to wait for socket/task/exception events.\n  zx_status_t status_zx;\n  zx::port port;\n  status_zx = zx::port::create(0, &port);\n  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n\n  // Register to wait for the child process to terminate.\n  status_zx = child_process_.wait_async(\n      port, kProcessKey, ZX_PROCESS_TERMINATED, 0);\n  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n\n  // Register to wait for the socket to be readable or closed.\n  status_zx = stderr_socket_.wait_async(\n      port, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, 0);\n  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n\n  // Register to wait for an exception.\n  status_zx = exception_channel_.wait_async(\n      port, kExceptionKey, ZX_CHANNEL_READABLE, 0);\n  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n\n  bool process_terminated = false;\n  bool socket_closed = false;\n  do {\n    zx_port_packet_t packet = {};\n    status_zx = port.wait(zx::time::infinite(), &packet);\n    GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n\n    if (packet.key == kExceptionKey) {\n      // Process encountered an exception. Kill it directly rather than\n      // letting other handlers process the event. We will get a kProcessKey\n      // event when the process actually terminates.\n      status_zx = child_process_.kill();\n      GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n    } else if (packet.key == kProcessKey) {\n      // Process terminated.\n      GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type));\n      GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_PROCESS_TERMINATED);\n      process_terminated = true;\n    } else if (packet.key == kSocketKey) {\n      GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type));\n      if (packet.signal.observed & ZX_SOCKET_READABLE) {\n        // Read data from the socket.\n        constexpr size_t kBufferSize = 1024;\n        do {\n          size_t old_length = captured_stderr_.length();\n          size_t bytes_read = 0;\n          captured_stderr_.resize(old_length + kBufferSize);\n          status_zx = stderr_socket_.read(\n              0, &captured_stderr_.front() + old_length, kBufferSize,\n              &bytes_read);\n          captured_stderr_.resize(old_length + bytes_read);\n        } while (status_zx == ZX_OK);\n        if (status_zx == ZX_ERR_PEER_CLOSED) {\n          socket_closed = true;\n        } else {\n          GTEST_DEATH_TEST_CHECK_(status_zx == ZX_ERR_SHOULD_WAIT);\n          status_zx = stderr_socket_.wait_async(\n              port, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, 0);\n          GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n        }\n      } else {\n        GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_SOCKET_PEER_CLOSED);\n        socket_closed = true;\n      }\n    }\n  } while (!process_terminated && !socket_closed);\n\n  ReadAndInterpretStatusByte();\n\n  zx_info_process_v2_t buffer;\n  status_zx = child_process_.get_info(\n      ZX_INFO_PROCESS_V2, &buffer, sizeof(buffer), nullptr, nullptr);\n  GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);\n\n  GTEST_DEATH_TEST_CHECK_(buffer.flags & ZX_INFO_PROCESS_FLAG_EXITED);\n  set_status(static_cast<int>(buffer.return_code));\n  return status();\n}\n\n// The AssumeRole process for a Fuchsia death test.  It creates a child\n// process with the same executable as the current process to run the\n// death test.  The child process is given the --gtest_filter and\n// --gtest_internal_run_death_test flags such that it knows to run the\n// current death test only.\nDeathTest::TestRole FuchsiaDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != nullptr) {\n    // ParseInternalRunDeathTestFlag() has performed all the necessary\n    // processing.\n    set_write_fd(kFuchsiaReadPipeFd);\n    return EXECUTE_TEST;\n  }\n\n  // Flush the log buffers since the log streams are shared with the child.\n  FlushInfoLog();\n\n  // Build the child process command line.\n  const std::string filter_flag = std::string(\"--\") + GTEST_FLAG_PREFIX_ +\n                                  kFilterFlag + \"=\" + info->test_suite_name() +\n                                  \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + \"=\"\n      + file_ + \"|\"\n      + StreamableToString(line_) + \"|\"\n      + StreamableToString(death_test_index);\n  Arguments args;\n  args.AddArguments(GetInjectableArgvs());\n  args.AddArgument(filter_flag.c_str());\n  args.AddArgument(internal_flag.c_str());\n\n  // Build the pipe for communication with the child.\n  zx_status_t status;\n  zx_handle_t child_pipe_handle;\n  int child_pipe_fd;\n  status = fdio_pipe_half(&child_pipe_fd, &child_pipe_handle);\n  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);\n  set_read_fd(child_pipe_fd);\n\n  // Set the pipe handle for the child.\n  fdio_spawn_action_t spawn_actions[2] = {};\n  fdio_spawn_action_t* add_handle_action = &spawn_actions[0];\n  add_handle_action->action = FDIO_SPAWN_ACTION_ADD_HANDLE;\n  add_handle_action->h.id = PA_HND(PA_FD, kFuchsiaReadPipeFd);\n  add_handle_action->h.handle = child_pipe_handle;\n\n  // Create a socket pair will be used to receive the child process' stderr.\n  zx::socket stderr_producer_socket;\n  status =\n      zx::socket::create(0, &stderr_producer_socket, &stderr_socket_);\n  GTEST_DEATH_TEST_CHECK_(status >= 0);\n  int stderr_producer_fd = -1;\n  status =\n      fdio_fd_create(stderr_producer_socket.release(), &stderr_producer_fd);\n  GTEST_DEATH_TEST_CHECK_(status >= 0);\n\n  // Make the stderr socket nonblocking.\n  GTEST_DEATH_TEST_CHECK_(fcntl(stderr_producer_fd, F_SETFL, 0) == 0);\n\n  fdio_spawn_action_t* add_stderr_action = &spawn_actions[1];\n  add_stderr_action->action = FDIO_SPAWN_ACTION_CLONE_FD;\n  add_stderr_action->fd.local_fd = stderr_producer_fd;\n  add_stderr_action->fd.target_fd = STDERR_FILENO;\n\n  // Create a child job.\n  zx_handle_t child_job = ZX_HANDLE_INVALID;\n  status = zx_job_create(zx_job_default(), 0, & child_job);\n  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);\n  zx_policy_basic_t policy;\n  policy.condition = ZX_POL_NEW_ANY;\n  policy.policy = ZX_POL_ACTION_ALLOW;\n  status = zx_job_set_policy(\n      child_job, ZX_JOB_POL_RELATIVE, ZX_JOB_POL_BASIC, &policy, 1);\n  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);\n\n  // Create an exception channel attached to the |child_job|, to allow\n  // us to suppress the system default exception handler from firing.\n  status =\n      zx_task_create_exception_channel(\n          child_job, 0, exception_channel_.reset_and_get_address());\n  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);\n\n  // Spawn the child process.\n  status = fdio_spawn_etc(\n      child_job, FDIO_SPAWN_CLONE_ALL, args.Argv()[0], args.Argv(), nullptr,\n      2, spawn_actions, child_process_.reset_and_get_address(), nullptr);\n  GTEST_DEATH_TEST_CHECK_(status == ZX_OK);\n\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n\nstd::string FuchsiaDeathTest::GetErrorLogs() {\n  return captured_stderr_;\n}\n\n#else  // We are neither on Windows, nor on Fuchsia.\n\n// ForkingDeathTest provides implementations for most of the abstract\n// methods of the DeathTest interface.  Only the AssumeRole method is\n// left undefined.\nclass ForkingDeathTest : public DeathTestImpl {\n public:\n  ForkingDeathTest(const char* statement, Matcher<const std::string&> matcher);\n\n  // All of these virtual functions are inherited from DeathTest.\n  int Wait() override;\n\n protected:\n  void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }\n\n private:\n  // PID of child process during death test; 0 in the child process itself.\n  pid_t child_pid_;\n};\n\n// Constructs a ForkingDeathTest.\nForkingDeathTest::ForkingDeathTest(const char* a_statement,\n                                   Matcher<const std::string&> matcher)\n    : DeathTestImpl(a_statement, std::move(matcher)), child_pid_(-1) {}\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint ForkingDeathTest::Wait() {\n  if (!spawned())\n    return 0;\n\n  ReadAndInterpretStatusByte();\n\n  int status_value;\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));\n  set_status(status_value);\n  return status_value;\n}\n\n// A concrete death test class that forks, then immediately runs the test\n// in the child process.\nclass NoExecDeathTest : public ForkingDeathTest {\n public:\n  NoExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher)\n      : ForkingDeathTest(a_statement, std::move(matcher)) {}\n  TestRole AssumeRole() override;\n};\n\n// The AssumeRole process for a fork-and-run death test.  It implements a\n// straightforward fork, with a simple pipe to transmit the status byte.\nDeathTest::TestRole NoExecDeathTest::AssumeRole() {\n  const size_t thread_count = GetThreadCount();\n  if (thread_count != 1) {\n    GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);\n  }\n\n  int pipe_fd[2];\n  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n\n  DeathTest::set_last_death_test_message(\"\");\n  CaptureStderr();\n  // When we fork the process below, the log file buffers are copied, but the\n  // file descriptors are shared.  We flush all log files here so that closing\n  // the file descriptors in the child process doesn't throw off the\n  // synchronization between descriptors and buffers in the parent process.\n  // This is as close to the fork as possible to avoid a race condition in case\n  // there are multiple threads running before the death test, and another\n  // thread writes to the log file.\n  FlushInfoLog();\n\n  const pid_t child_pid = fork();\n  GTEST_DEATH_TEST_CHECK_(child_pid != -1);\n  set_child_pid(child_pid);\n  if (child_pid == 0) {\n    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));\n    set_write_fd(pipe_fd[1]);\n    // Redirects all logging to stderr in the child process to prevent\n    // concurrent writes to the log files.  We capture stderr in the parent\n    // process and append the child process' output to a log.\n    LogToStderr();\n    // Event forwarding to the listeners of event listener API mush be shut\n    // down in death test subprocesses.\n    GetUnitTestImpl()->listeners()->SuppressEventForwarding();\n    g_in_fast_death_test_child = true;\n    return EXECUTE_TEST;\n  } else {\n    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));\n    set_read_fd(pipe_fd[0]);\n    set_spawned(true);\n    return OVERSEE_TEST;\n  }\n}\n\n// A concrete death test class that forks and re-executes the main\n// program from the beginning, with command-line flags set that cause\n// only this specific death test to be run.\nclass ExecDeathTest : public ForkingDeathTest {\n public:\n  ExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher,\n                const char* file, int line)\n      : ForkingDeathTest(a_statement, std::move(matcher)),\n        file_(file),\n        line_(line) {}\n  TestRole AssumeRole() override;\n\n private:\n  static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() {\n    ::std::vector<std::string> args = GetInjectableArgvs();\n#  if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)\n    ::std::vector<std::string> extra_args =\n        GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_();\n    args.insert(args.end(), extra_args.begin(), extra_args.end());\n#  endif  // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_)\n    return args;\n  }\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n};\n\n// Utility class for accumulating command-line arguments.\nclass Arguments {\n public:\n  Arguments() { args_.push_back(nullptr); }\n\n  ~Arguments() {\n    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();\n         ++i) {\n      free(*i);\n    }\n  }\n  void AddArgument(const char* argument) {\n    args_.insert(args_.end() - 1, posix::StrDup(argument));\n  }\n\n  template <typename Str>\n  void AddArguments(const ::std::vector<Str>& arguments) {\n    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();\n         i != arguments.end();\n         ++i) {\n      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));\n    }\n  }\n  char* const* Argv() {\n    return &args_[0];\n  }\n\n private:\n  std::vector<char*> args_;\n};\n\n// A struct that encompasses the arguments to the child process of a\n// threadsafe-style death test process.\nstruct ExecDeathTestArgs {\n  char* const* argv;  // Command-line arguments for the child's call to exec\n  int close_fd;       // File descriptor to close; the read end of a pipe\n};\n\n#  if GTEST_OS_QNX\nextern \"C\" char** environ;\n#  else  // GTEST_OS_QNX\n// The main function for a threadsafe-style death test child process.\n// This function is called in a clone()-ed process and thus must avoid\n// any potentially unsafe operations like malloc or libc functions.\nstatic int ExecDeathTestChildMain(void* child_arg) {\n  ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));\n\n  // We need to execute the test program in the same environment where\n  // it was originally invoked.  Therefore we change to the original\n  // working directory first.\n  const char* const original_dir =\n      UnitTest::GetInstance()->original_working_dir();\n  // We can safely call chdir() as it's a direct system call.\n  if (chdir(original_dir) != 0) {\n    DeathTestAbort(std::string(\"chdir(\\\"\") + original_dir + \"\\\") failed: \" +\n                   GetLastErrnoDescription());\n    return EXIT_FAILURE;\n  }\n\n  // We can safely call execv() as it's almost a direct system call. We\n  // cannot use execvp() as it's a libc function and thus potentially\n  // unsafe.  Since execv() doesn't search the PATH, the user must\n  // invoke the test program via a valid path that contains at least\n  // one path separator.\n  execv(args->argv[0], args->argv);\n  DeathTestAbort(std::string(\"execv(\") + args->argv[0] + \", ...) in \" +\n                 original_dir + \" failed: \" +\n                 GetLastErrnoDescription());\n  return EXIT_FAILURE;\n}\n#  endif  // GTEST_OS_QNX\n\n#  if GTEST_HAS_CLONE\n// Two utility routines that together determine the direction the stack\n// grows.\n// This could be accomplished more elegantly by a single recursive\n// function, but we want to guard against the unlikely possibility of\n// a smart compiler optimizing the recursion away.\n//\n// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining\n// StackLowerThanAddress into StackGrowsDown, which then doesn't give\n// correct answer.\nstatic void StackLowerThanAddress(const void* ptr,\n                                  bool* result) GTEST_NO_INLINE_;\n// Make sure sanitizers do not tamper with the stack here.\n// Ideally, we want to use `__builtin_frame_address` instead of a local variable\n// address with sanitizer disabled, but it does not work when the\n// compiler optimizes the stack frame out, which happens on PowerPC targets.\n// HWAddressSanitizer add a random tag to the MSB of the local variable address,\n// making comparison result unpredictable.\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\nstatic void StackLowerThanAddress(const void* ptr, bool* result) {\n  int dummy = 0;\n  *result = std::less<const void*>()(&dummy, ptr);\n}\n\n// Make sure AddressSanitizer does not tamper with the stack here.\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\nstatic bool StackGrowsDown() {\n  int dummy = 0;\n  bool result;\n  StackLowerThanAddress(&dummy, &result);\n  return result;\n}\n#  endif  // GTEST_HAS_CLONE\n\n// Spawns a child process with the same executable as the current process in\n// a thread-safe manner and instructs it to run the death test.  The\n// implementation uses fork(2) + exec.  On systems where clone(2) is\n// available, it is used instead, being slightly more thread-safe.  On QNX,\n// fork supports only single-threaded environments, so this function uses\n// spawn(2) there instead.  The function dies with an error message if\n// anything goes wrong.\nstatic pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {\n  ExecDeathTestArgs args = { argv, close_fd };\n  pid_t child_pid = -1;\n\n#  if GTEST_OS_QNX\n  // Obtains the current directory and sets it to be closed in the child\n  // process.\n  const int cwd_fd = open(\".\", O_RDONLY);\n  GTEST_DEATH_TEST_CHECK_(cwd_fd != -1);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC));\n  // We need to execute the test program in the same environment where\n  // it was originally invoked.  Therefore we change to the original\n  // working directory first.\n  const char* const original_dir =\n      UnitTest::GetInstance()->original_working_dir();\n  // We can safely call chdir() as it's a direct system call.\n  if (chdir(original_dir) != 0) {\n    DeathTestAbort(std::string(\"chdir(\\\"\") + original_dir + \"\\\") failed: \" +\n                   GetLastErrnoDescription());\n    return EXIT_FAILURE;\n  }\n\n  int fd_flags;\n  // Set close_fd to be closed after spawn.\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD));\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD,\n                                        fd_flags | FD_CLOEXEC));\n  struct inheritance inherit = {0};\n  // spawn is a system call.\n  child_pid = spawn(args.argv[0], 0, nullptr, &inherit, args.argv, environ);\n  // Restores the current working directory.\n  GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd));\n\n#  else   // GTEST_OS_QNX\n#   if GTEST_OS_LINUX\n  // When a SIGPROF signal is received while fork() or clone() are executing,\n  // the process may hang. To avoid this, we ignore SIGPROF here and re-enable\n  // it after the call to fork()/clone() is complete.\n  struct sigaction saved_sigprof_action;\n  struct sigaction ignore_sigprof_action;\n  memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action));\n  sigemptyset(&ignore_sigprof_action.sa_mask);\n  ignore_sigprof_action.sa_handler = SIG_IGN;\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction(\n      SIGPROF, &ignore_sigprof_action, &saved_sigprof_action));\n#   endif  // GTEST_OS_LINUX\n\n#   if GTEST_HAS_CLONE\n  const bool use_fork = GTEST_FLAG(death_test_use_fork);\n\n  if (!use_fork) {\n    static const bool stack_grows_down = StackGrowsDown();\n    const auto stack_size = static_cast<size_t>(getpagesize() * 2);\n    // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.\n    void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE,\n                             MAP_ANON | MAP_PRIVATE, -1, 0);\n    GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);\n\n    // Maximum stack alignment in bytes:  For a downward-growing stack, this\n    // amount is subtracted from size of the stack space to get an address\n    // that is within the stack space and is aligned on all systems we care\n    // about.  As far as I know there is no ABI with stack alignment greater\n    // than 64.  We assume stack and stack_size already have alignment of\n    // kMaxStackAlignment.\n    const size_t kMaxStackAlignment = 64;\n    void* const stack_top =\n        static_cast<char*>(stack) +\n            (stack_grows_down ? stack_size - kMaxStackAlignment : 0);\n    GTEST_DEATH_TEST_CHECK_(\n        static_cast<size_t>(stack_size) > kMaxStackAlignment &&\n        reinterpret_cast<uintptr_t>(stack_top) % kMaxStackAlignment == 0);\n\n    child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);\n\n    GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);\n  }\n#   else\n  const bool use_fork = true;\n#   endif  // GTEST_HAS_CLONE\n\n  if (use_fork && (child_pid = fork()) == 0) {\n      ExecDeathTestChildMain(&args);\n      _exit(0);\n  }\n#  endif  // GTEST_OS_QNX\n#  if GTEST_OS_LINUX\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(\n      sigaction(SIGPROF, &saved_sigprof_action, nullptr));\n#  endif  // GTEST_OS_LINUX\n\n  GTEST_DEATH_TEST_CHECK_(child_pid != -1);\n  return child_pid;\n}\n\n// The AssumeRole process for a fork-and-exec death test.  It re-executes the\n// main program from the beginning, setting the --gtest_filter\n// and --gtest_internal_run_death_test flags to cause only the current\n// death test to be re-run.\nDeathTest::TestRole ExecDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != nullptr) {\n    set_write_fd(flag->write_fd());\n    return EXECUTE_TEST;\n  }\n\n  int pipe_fd[2];\n  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n  // Clear the close-on-exec flag on the write end of the pipe, lest\n  // it be closed when the child process does an exec:\n  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);\n\n  const std::string filter_flag = std::string(\"--\") + GTEST_FLAG_PREFIX_ +\n                                  kFilterFlag + \"=\" + info->test_suite_name() +\n                                  \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + \"=\"\n      + file_ + \"|\" + StreamableToString(line_) + \"|\"\n      + StreamableToString(death_test_index) + \"|\"\n      + StreamableToString(pipe_fd[1]);\n  Arguments args;\n  args.AddArguments(GetArgvsForDeathTestChildProcess());\n  args.AddArgument(filter_flag.c_str());\n  args.AddArgument(internal_flag.c_str());\n\n  DeathTest::set_last_death_test_message(\"\");\n\n  CaptureStderr();\n  // See the comment in NoExecDeathTest::AssumeRole for why the next line\n  // is necessary.\n  FlushInfoLog();\n\n  const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));\n  set_child_pid(child_pid);\n  set_read_fd(pipe_fd[0]);\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n\n# endif  // !GTEST_OS_WINDOWS\n\n// Creates a concrete DeathTest-derived class that depends on the\n// --gtest_death_test_style flag, and sets the pointer pointed to\n// by the \"test\" argument to its address.  If the test should be\n// skipped, sets that pointer to NULL.  Returns true, unless the\n// flag is set to an invalid value.\nbool DefaultDeathTestFactory::Create(const char* statement,\n                                     Matcher<const std::string&> matcher,\n                                     const char* file, int line,\n                                     DeathTest** test) {\n  UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const int death_test_index = impl->current_test_info()\n      ->increment_death_test_count();\n\n  if (flag != nullptr) {\n    if (death_test_index > flag->index()) {\n      DeathTest::set_last_death_test_message(\n          \"Death test count (\" + StreamableToString(death_test_index)\n          + \") somehow exceeded expected maximum (\"\n          + StreamableToString(flag->index()) + \")\");\n      return false;\n    }\n\n    if (!(flag->file() == file && flag->line() == line &&\n          flag->index() == death_test_index)) {\n      *test = nullptr;\n      return true;\n    }\n  }\n\n# if GTEST_OS_WINDOWS\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\" ||\n      GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new WindowsDeathTest(statement, std::move(matcher), file, line);\n  }\n\n# elif GTEST_OS_FUCHSIA\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\" ||\n      GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new FuchsiaDeathTest(statement, std::move(matcher), file, line);\n  }\n\n# else\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\") {\n    *test = new ExecDeathTest(statement, std::move(matcher), file, line);\n  } else if (GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new NoExecDeathTest(statement, std::move(matcher));\n  }\n\n# endif  // GTEST_OS_WINDOWS\n\n  else {  // NOLINT - this is more readable than unbalanced brackets inside #if.\n    DeathTest::set_last_death_test_message(\n        \"Unknown death test style \\\"\" + GTEST_FLAG(death_test_style)\n        + \"\\\" encountered\");\n    return false;\n  }\n\n  return true;\n}\n\n# if GTEST_OS_WINDOWS\n// Recreates the pipe and event handles from the provided parameters,\n// signals the event, and returns a file descriptor wrapped around the pipe\n// handle. This function is called in the child process only.\nstatic int GetStatusFileDescriptor(unsigned int parent_process_id,\n                            size_t write_handle_as_size_t,\n                            size_t event_handle_as_size_t) {\n  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,\n                                                   FALSE,  // Non-inheritable.\n                                                   parent_process_id));\n  if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {\n    DeathTestAbort(\"Unable to open parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t));\n\n  const HANDLE write_handle =\n      reinterpret_cast<HANDLE>(write_handle_as_size_t);\n  HANDLE dup_write_handle;\n\n  // The newly initialized handle is accessible only in the parent\n  // process. To obtain one accessible within the child, we need to use\n  // DuplicateHandle.\n  if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,\n                         ::GetCurrentProcess(), &dup_write_handle,\n                         0x0,    // Requested privileges ignored since\n                                 // DUPLICATE_SAME_ACCESS is used.\n                         FALSE,  // Request non-inheritable handler.\n                         DUPLICATE_SAME_ACCESS)) {\n    DeathTestAbort(\"Unable to duplicate the pipe handle \" +\n                   StreamableToString(write_handle_as_size_t) +\n                   \" from the parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t);\n  HANDLE dup_event_handle;\n\n  if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,\n                         ::GetCurrentProcess(), &dup_event_handle,\n                         0x0,\n                         FALSE,\n                         DUPLICATE_SAME_ACCESS)) {\n    DeathTestAbort(\"Unable to duplicate the event handle \" +\n                   StreamableToString(event_handle_as_size_t) +\n                   \" from the parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  const int write_fd =\n      ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);\n  if (write_fd == -1) {\n    DeathTestAbort(\"Unable to convert pipe handle \" +\n                   StreamableToString(write_handle_as_size_t) +\n                   \" to a file descriptor\");\n  }\n\n  // Signals the parent that the write end of the pipe has been acquired\n  // so the parent can release its own write end.\n  ::SetEvent(dup_event_handle);\n\n  return write_fd;\n}\n# endif  // GTEST_OS_WINDOWS\n\n// Returns a newly created InternalRunDeathTestFlag object with fields\n// initialized from the GTEST_FLAG(internal_run_death_test) flag if\n// the flag is specified; otherwise returns NULL.\nInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {\n  if (GTEST_FLAG(internal_run_death_test) == \"\") return nullptr;\n\n  // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we\n  // can use it here.\n  int line = -1;\n  int index = -1;\n  ::std::vector< ::std::string> fields;\n  SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);\n  int write_fd = -1;\n\n# if GTEST_OS_WINDOWS\n\n  unsigned int parent_process_id = 0;\n  size_t write_handle_as_size_t = 0;\n  size_t event_handle_as_size_t = 0;\n\n  if (fields.size() != 6\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)\n      || !ParseNaturalNumber(fields[3], &parent_process_id)\n      || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)\n      || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \" +\n                   GTEST_FLAG(internal_run_death_test));\n  }\n  write_fd = GetStatusFileDescriptor(parent_process_id,\n                                     write_handle_as_size_t,\n                                     event_handle_as_size_t);\n\n# elif GTEST_OS_FUCHSIA\n\n  if (fields.size() != 3\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \"\n        + GTEST_FLAG(internal_run_death_test));\n  }\n\n# else\n\n  if (fields.size() != 4\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)\n      || !ParseNaturalNumber(fields[3], &write_fd)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \"\n        + GTEST_FLAG(internal_run_death_test));\n  }\n\n# endif  // GTEST_OS_WINDOWS\n\n  return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);\n}\n\n}  // namespace internal\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n}  // namespace testing\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n#include <stdlib.h>\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>\n#elif GTEST_OS_WINDOWS\n# include <direct.h>\n# include <io.h>\n#else\n# include <limits.h>\n# include <climits>  // Some Linux distributions define PATH_MAX here.\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n\n#if GTEST_OS_WINDOWS\n# define GTEST_PATH_MAX_ _MAX_PATH\n#elif defined(PATH_MAX)\n# define GTEST_PATH_MAX_ PATH_MAX\n#elif defined(_XOPEN_PATH_MAX)\n# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX\n#else\n# define GTEST_PATH_MAX_ _POSIX_PATH_MAX\n#endif  // GTEST_OS_WINDOWS\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_OS_WINDOWS\n// On Windows, '\\\\' is the standard path separator, but many tools and the\n// Windows API also accept '/' as an alternate path separator. Unless otherwise\n// noted, a file path can contain either kind of path separators, or a mixture\n// of them.\nconst char kPathSeparator = '\\\\';\nconst char kAlternatePathSeparator = '/';\nconst char kAlternatePathSeparatorString[] = \"/\";\n# if GTEST_OS_WINDOWS_MOBILE\n// Windows CE doesn't have a current directory. You should not use\n// the current directory in tests on Windows CE, but this at least\n// provides a reasonable fallback.\nconst char kCurrentDirectoryString[] = \"\\\\\";\n// Windows CE doesn't define INVALID_FILE_ATTRIBUTES\nconst DWORD kInvalidFileAttributes = 0xffffffff;\n# else\nconst char kCurrentDirectoryString[] = \".\\\\\";\n# endif  // GTEST_OS_WINDOWS_MOBILE\n#else\nconst char kPathSeparator = '/';\nconst char kCurrentDirectoryString[] = \"./\";\n#endif  // GTEST_OS_WINDOWS\n\n// Returns whether the given character is a valid path separator.\nstatic bool IsPathSeparator(char c) {\n#if GTEST_HAS_ALT_PATH_SEP_\n  return (c == kPathSeparator) || (c == kAlternatePathSeparator);\n#else\n  return c == kPathSeparator;\n#endif\n}\n\n// Returns the current working directory, or \"\" if unsuccessful.\nFilePath FilePath::GetCurrentDir() {\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE ||         \\\n    GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_ESP32 || \\\n    GTEST_OS_XTENSA\n  // These platforms do not have a current directory, so we just return\n  // something reasonable.\n  return FilePath(kCurrentDirectoryString);\n#elif GTEST_OS_WINDOWS\n  char cwd[GTEST_PATH_MAX_ + 1] = { '\\0' };\n  return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? \"\" : cwd);\n#else\n  char cwd[GTEST_PATH_MAX_ + 1] = { '\\0' };\n  char* result = getcwd(cwd, sizeof(cwd));\n# if GTEST_OS_NACL\n  // getcwd will likely fail in NaCl due to the sandbox, so return something\n  // reasonable. The user may have provided a shim implementation for getcwd,\n  // however, so fallback only when failure is detected.\n  return FilePath(result == nullptr ? kCurrentDirectoryString : cwd);\n# endif  // GTEST_OS_NACL\n  return FilePath(result == nullptr ? \"\" : cwd);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Returns a copy of the FilePath with the case-insensitive extension removed.\n// Example: FilePath(\"dir/file.exe\").RemoveExtension(\"EXE\") returns\n// FilePath(\"dir/file\"). If a case-insensitive extension is not\n// found, returns a copy of the original FilePath.\nFilePath FilePath::RemoveExtension(const char* extension) const {\n  const std::string dot_extension = std::string(\".\") + extension;\n  if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {\n    return FilePath(pathname_.substr(\n        0, pathname_.length() - dot_extension.length()));\n  }\n  return *this;\n}\n\n// Returns a pointer to the last occurrence of a valid path separator in\n// the FilePath. On Windows, for example, both '/' and '\\' are valid path\n// separators. Returns NULL if no path separator was found.\nconst char* FilePath::FindLastPathSeparator() const {\n  const char* const last_sep = strrchr(c_str(), kPathSeparator);\n#if GTEST_HAS_ALT_PATH_SEP_\n  const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);\n  // Comparing two pointers of which only one is NULL is undefined.\n  if (last_alt_sep != nullptr &&\n      (last_sep == nullptr || last_alt_sep > last_sep)) {\n    return last_alt_sep;\n  }\n#endif\n  return last_sep;\n}\n\n// Returns a copy of the FilePath with the directory part removed.\n// Example: FilePath(\"path/to/file\").RemoveDirectoryName() returns\n// FilePath(\"file\"). If there is no directory part (\"just_a_file\"), it returns\n// the FilePath unmodified. If there is no file part (\"just_a_dir/\") it\n// returns an empty FilePath (\"\").\n// On Windows platform, '\\' is the path separator, otherwise it is '/'.\nFilePath FilePath::RemoveDirectoryName() const {\n  const char* const last_sep = FindLastPathSeparator();\n  return last_sep ? FilePath(last_sep + 1) : *this;\n}\n\n// RemoveFileName returns the directory path with the filename removed.\n// Example: FilePath(\"path/to/file\").RemoveFileName() returns \"path/to/\".\n// If the FilePath is \"a_file\" or \"/a_file\", RemoveFileName returns\n// FilePath(\"./\") or, on Windows, FilePath(\".\\\\\"). If the filepath does\n// not have a file, like \"just/a/dir/\", it returns the FilePath unmodified.\n// On Windows platform, '\\' is the path separator, otherwise it is '/'.\nFilePath FilePath::RemoveFileName() const {\n  const char* const last_sep = FindLastPathSeparator();\n  std::string dir;\n  if (last_sep) {\n    dir = std::string(c_str(), static_cast<size_t>(last_sep + 1 - c_str()));\n  } else {\n    dir = kCurrentDirectoryString;\n  }\n  return FilePath(dir);\n}\n\n// Helper functions for naming files in a directory for xml output.\n\n// Given directory = \"dir\", base_name = \"test\", number = 0,\n// extension = \"xml\", returns \"dir/test.xml\". If number is greater\n// than zero (e.g., 12), returns \"dir/test_12.xml\".\n// On Windows platform, uses \\ as the separator rather than /.\nFilePath FilePath::MakeFileName(const FilePath& directory,\n                                const FilePath& base_name,\n                                int number,\n                                const char* extension) {\n  std::string file;\n  if (number == 0) {\n    file = base_name.string() + \".\" + extension;\n  } else {\n    file = base_name.string() + \"_\" + StreamableToString(number)\n        + \".\" + extension;\n  }\n  return ConcatPaths(directory, FilePath(file));\n}\n\n// Given directory = \"dir\", relative_path = \"test.xml\", returns \"dir/test.xml\".\n// On Windows, uses \\ as the separator rather than /.\nFilePath FilePath::ConcatPaths(const FilePath& directory,\n                               const FilePath& relative_path) {\n  if (directory.IsEmpty())\n    return relative_path;\n  const FilePath dir(directory.RemoveTrailingPathSeparator());\n  return FilePath(dir.string() + kPathSeparator + relative_path.string());\n}\n\n// Returns true if pathname describes something findable in the file-system,\n// either a file, directory, or whatever.\nbool FilePath::FileOrDirectoryExists() const {\n#if GTEST_OS_WINDOWS_MOBILE\n  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());\n  const DWORD attributes = GetFileAttributes(unicode);\n  delete [] unicode;\n  return attributes != kInvalidFileAttributes;\n#else\n  posix::StatStruct file_stat;\n  return posix::Stat(pathname_.c_str(), &file_stat) == 0;\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Returns true if pathname describes a directory in the file-system\n// that exists.\nbool FilePath::DirectoryExists() const {\n  bool result = false;\n#if GTEST_OS_WINDOWS\n  // Don't strip off trailing separator if path is a root directory on\n  // Windows (like \"C:\\\\\").\n  const FilePath& path(IsRootDirectory() ? *this :\n                                           RemoveTrailingPathSeparator());\n#else\n  const FilePath& path(*this);\n#endif\n\n#if GTEST_OS_WINDOWS_MOBILE\n  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());\n  const DWORD attributes = GetFileAttributes(unicode);\n  delete [] unicode;\n  if ((attributes != kInvalidFileAttributes) &&\n      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {\n    result = true;\n  }\n#else\n  posix::StatStruct file_stat;\n  result = posix::Stat(path.c_str(), &file_stat) == 0 &&\n      posix::IsDir(file_stat);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n  return result;\n}\n\n// Returns true if pathname describes a root directory. (Windows has one\n// root directory per disk drive.)\nbool FilePath::IsRootDirectory() const {\n#if GTEST_OS_WINDOWS\n  return pathname_.length() == 3 && IsAbsolutePath();\n#else\n  return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);\n#endif\n}\n\n// Returns true if pathname describes an absolute path.\nbool FilePath::IsAbsolutePath() const {\n  const char* const name = pathname_.c_str();\n#if GTEST_OS_WINDOWS\n  return pathname_.length() >= 3 &&\n     ((name[0] >= 'a' && name[0] <= 'z') ||\n      (name[0] >= 'A' && name[0] <= 'Z')) &&\n     name[1] == ':' &&\n     IsPathSeparator(name[2]);\n#else\n  return IsPathSeparator(name[0]);\n#endif\n}\n\n// Returns a pathname for a file that does not currently exist. The pathname\n// will be directory/base_name.extension or\n// directory/base_name_<number>.extension if directory/base_name.extension\n// already exists. The number will be incremented until a pathname is found\n// that does not already exist.\n// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.\n// There could be a race condition if two or more processes are calling this\n// function at the same time -- they could both pick the same filename.\nFilePath FilePath::GenerateUniqueFileName(const FilePath& directory,\n                                          const FilePath& base_name,\n                                          const char* extension) {\n  FilePath full_pathname;\n  int number = 0;\n  do {\n    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));\n  } while (full_pathname.FileOrDirectoryExists());\n  return full_pathname;\n}\n\n// Returns true if FilePath ends with a path separator, which indicates that\n// it is intended to represent a directory. Returns false otherwise.\n// This does NOT check that a directory (or file) actually exists.\nbool FilePath::IsDirectory() const {\n  return !pathname_.empty() &&\n         IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);\n}\n\n// Create directories so that path exists. Returns true if successful or if\n// the directories already exist; returns false if unable to create directories\n// for any reason.\nbool FilePath::CreateDirectoriesRecursively() const {\n  if (!this->IsDirectory()) {\n    return false;\n  }\n\n  if (pathname_.length() == 0 || this->DirectoryExists()) {\n    return true;\n  }\n\n  const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());\n  return parent.CreateDirectoriesRecursively() && this->CreateFolder();\n}\n\n// Create the directory so that path exists. Returns true if successful or\n// if the directory already exists; returns false if unable to create the\n// directory for any reason, including if the parent directory does not\n// exist. Not named \"CreateDirectory\" because that's a macro on Windows.\nbool FilePath::CreateFolder() const {\n#if GTEST_OS_WINDOWS_MOBILE\n  FilePath removed_sep(this->RemoveTrailingPathSeparator());\n  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());\n  int result = CreateDirectory(unicode, nullptr) ? 0 : -1;\n  delete [] unicode;\n#elif GTEST_OS_WINDOWS\n  int result = _mkdir(pathname_.c_str());\n#elif GTEST_OS_ESP8266 || GTEST_OS_XTENSA\n  // do nothing\n  int result = 0;\n#else\n  int result = mkdir(pathname_.c_str(), 0777);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n  if (result == -1) {\n    return this->DirectoryExists();  // An error is OK if the directory exists.\n  }\n  return true;  // No error.\n}\n\n// If input name has a trailing separator character, remove it and return the\n// name, otherwise return the name string unmodified.\n// On Windows platform, uses \\ as the separator, other platforms use /.\nFilePath FilePath::RemoveTrailingPathSeparator() const {\n  return IsDirectory()\n      ? FilePath(pathname_.substr(0, pathname_.length() - 1))\n      : *this;\n}\n\n// Removes any redundant separators that might be in the pathname.\n// For example, \"bar///foo\" becomes \"bar/foo\". Does not eliminate other\n// redundancies that might be in a pathname involving \".\" or \"..\".\nvoid FilePath::Normalize() {\n  auto out = pathname_.begin();\n\n  for (const char character : pathname_) {\n    if (!IsPathSeparator(character)) {\n      *(out++) = character;\n    } else if (out == pathname_.begin() || *std::prev(out) != kPathSeparator) {\n      *(out++) = kPathSeparator;\n    } else {\n      continue;\n    }\n  }\n\n  pathname_.erase(out, pathname_.end());\n}\n\n}  // namespace internal\n}  // namespace testing\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This file implements just enough of the matcher interface to allow\n// EXPECT_DEATH and friends to accept a matcher argument.\n\n\n#include <string>\n\nnamespace testing {\n\n// Constructs a matcher that matches a const std::string& whose value is\n// equal to s.\nMatcher<const std::string&>::Matcher(const std::string& s) { *this = Eq(s); }\n\n// Constructs a matcher that matches a const std::string& whose value is\n// equal to s.\nMatcher<const std::string&>::Matcher(const char* s) {\n  *this = Eq(std::string(s));\n}\n\n// Constructs a matcher that matches a std::string whose value is equal to\n// s.\nMatcher<std::string>::Matcher(const std::string& s) { *this = Eq(s); }\n\n// Constructs a matcher that matches a std::string whose value is equal to\n// s.\nMatcher<std::string>::Matcher(const char* s) { *this = Eq(std::string(s)); }\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n// Constructs a matcher that matches a const StringView& whose value is\n// equal to s.\nMatcher<const internal::StringView&>::Matcher(const std::string& s) {\n  *this = Eq(s);\n}\n\n// Constructs a matcher that matches a const StringView& whose value is\n// equal to s.\nMatcher<const internal::StringView&>::Matcher(const char* s) {\n  *this = Eq(std::string(s));\n}\n\n// Constructs a matcher that matches a const StringView& whose value is\n// equal to s.\nMatcher<const internal::StringView&>::Matcher(internal::StringView s) {\n  *this = Eq(std::string(s));\n}\n\n// Constructs a matcher that matches a StringView whose value is equal to\n// s.\nMatcher<internal::StringView>::Matcher(const std::string& s) { *this = Eq(s); }\n\n// Constructs a matcher that matches a StringView whose value is equal to\n// s.\nMatcher<internal::StringView>::Matcher(const char* s) {\n  *this = Eq(std::string(s));\n}\n\n// Constructs a matcher that matches a StringView whose value is equal to\n// s.\nMatcher<internal::StringView>::Matcher(internal::StringView s) {\n  *this = Eq(std::string(s));\n}\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n}  // namespace testing\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n#include <limits.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <cstdint>\n#include <fstream>\n#include <memory>\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>\n# include <io.h>\n# include <sys/stat.h>\n# include <map>  // Used in ThreadLocal.\n# ifdef _MSC_VER\n#  include <crtdbg.h>\n# endif  // _MSC_VER\n#else\n# include <unistd.h>\n#endif  // GTEST_OS_WINDOWS\n\n#if GTEST_OS_MAC\n# include <mach/mach_init.h>\n# include <mach/task.h>\n# include <mach/vm_map.h>\n#endif  // GTEST_OS_MAC\n\n#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \\\n    GTEST_OS_NETBSD || GTEST_OS_OPENBSD\n# include <sys/sysctl.h>\n# if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD\n#  include <sys/user.h>\n# endif\n#endif\n\n#if GTEST_OS_QNX\n# include <devctl.h>\n# include <fcntl.h>\n# include <sys/procfs.h>\n#endif  // GTEST_OS_QNX\n\n#if GTEST_OS_AIX\n# include <procinfo.h>\n# include <sys/types.h>\n#endif  // GTEST_OS_AIX\n\n#if GTEST_OS_FUCHSIA\n# include <zircon/process.h>\n# include <zircon/syscalls.h>\n#endif  // GTEST_OS_FUCHSIA\n\n\nnamespace testing {\nnamespace internal {\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\n// MSVC and C++Builder do not provide a definition of STDERR_FILENO.\nconst int kStdOutFileno = 1;\nconst int kStdErrFileno = 2;\n#else\nconst int kStdOutFileno = STDOUT_FILENO;\nconst int kStdErrFileno = STDERR_FILENO;\n#endif  // _MSC_VER\n\n#if GTEST_OS_LINUX\n\nnamespace {\ntemplate <typename T>\nT ReadProcFileField(const std::string& filename, int field) {\n  std::string dummy;\n  std::ifstream file(filename.c_str());\n  while (field-- > 0) {\n    file >> dummy;\n  }\n  T output = 0;\n  file >> output;\n  return output;\n}\n}  // namespace\n\n// Returns the number of active threads, or 0 when there is an error.\nsize_t GetThreadCount() {\n  const std::string filename =\n      (Message() << \"/proc/\" << getpid() << \"/stat\").GetString();\n  return ReadProcFileField<size_t>(filename, 19);\n}\n\n#elif GTEST_OS_MAC\n\nsize_t GetThreadCount() {\n  const task_t task = mach_task_self();\n  mach_msg_type_number_t thread_count;\n  thread_act_array_t thread_list;\n  const kern_return_t status = task_threads(task, &thread_list, &thread_count);\n  if (status == KERN_SUCCESS) {\n    // task_threads allocates resources in thread_list and we need to free them\n    // to avoid leaks.\n    vm_deallocate(task,\n                  reinterpret_cast<vm_address_t>(thread_list),\n                  sizeof(thread_t) * thread_count);\n    return static_cast<size_t>(thread_count);\n  } else {\n    return 0;\n  }\n}\n\n#elif GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \\\n      GTEST_OS_NETBSD\n\n#if GTEST_OS_NETBSD\n#undef KERN_PROC\n#define KERN_PROC KERN_PROC2\n#define kinfo_proc kinfo_proc2\n#endif\n\n#if GTEST_OS_DRAGONFLY\n#define KP_NLWP(kp) (kp.kp_nthreads)\n#elif GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD\n#define KP_NLWP(kp) (kp.ki_numthreads)\n#elif GTEST_OS_NETBSD\n#define KP_NLWP(kp) (kp.p_nlwps)\n#endif\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nsize_t GetThreadCount() {\n  int mib[] = {\n    CTL_KERN,\n    KERN_PROC,\n    KERN_PROC_PID,\n    getpid(),\n#if GTEST_OS_NETBSD\n    sizeof(struct kinfo_proc),\n    1,\n#endif\n  };\n  u_int miblen = sizeof(mib) / sizeof(mib[0]);\n  struct kinfo_proc info;\n  size_t size = sizeof(info);\n  if (sysctl(mib, miblen, &info, &size, NULL, 0)) {\n    return 0;\n  }\n  return static_cast<size_t>(KP_NLWP(info));\n}\n#elif GTEST_OS_OPENBSD\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nsize_t GetThreadCount() {\n  int mib[] = {\n    CTL_KERN,\n    KERN_PROC,\n    KERN_PROC_PID | KERN_PROC_SHOW_THREADS,\n    getpid(),\n    sizeof(struct kinfo_proc),\n    0,\n  };\n  u_int miblen = sizeof(mib) / sizeof(mib[0]);\n\n  // get number of structs\n  size_t size;\n  if (sysctl(mib, miblen, NULL, &size, NULL, 0)) {\n    return 0;\n  }\n\n  mib[5] = static_cast<int>(size / static_cast<size_t>(mib[4]));\n\n  // populate array of structs\n  struct kinfo_proc info[mib[5]];\n  if (sysctl(mib, miblen, &info, &size, NULL, 0)) {\n    return 0;\n  }\n\n  // exclude empty members\n  size_t nthreads = 0;\n  for (size_t i = 0; i < size / static_cast<size_t>(mib[4]); i++) {\n    if (info[i].p_tid != -1)\n      nthreads++;\n  }\n  return nthreads;\n}\n\n#elif GTEST_OS_QNX\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nsize_t GetThreadCount() {\n  const int fd = open(\"/proc/self/as\", O_RDONLY);\n  if (fd < 0) {\n    return 0;\n  }\n  procfs_info process_info;\n  const int status =\n      devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), nullptr);\n  close(fd);\n  if (status == EOK) {\n    return static_cast<size_t>(process_info.num_threads);\n  } else {\n    return 0;\n  }\n}\n\n#elif GTEST_OS_AIX\n\nsize_t GetThreadCount() {\n  struct procentry64 entry;\n  pid_t pid = getpid();\n  int status = getprocs64(&entry, sizeof(entry), nullptr, 0, &pid, 1);\n  if (status == 1) {\n    return entry.pi_thcount;\n  } else {\n    return 0;\n  }\n}\n\n#elif GTEST_OS_FUCHSIA\n\nsize_t GetThreadCount() {\n  int dummy_buffer;\n  size_t avail;\n  zx_status_t status = zx_object_get_info(\n      zx_process_self(),\n      ZX_INFO_PROCESS_THREADS,\n      &dummy_buffer,\n      0,\n      nullptr,\n      &avail);\n  if (status == ZX_OK) {\n    return avail;\n  } else {\n    return 0;\n  }\n}\n\n#else\n\nsize_t GetThreadCount() {\n  // There's no portable way to detect the number of threads, so we just\n  // return 0 to indicate that we cannot detect it.\n  return 0;\n}\n\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS\n\nvoid SleepMilliseconds(int n) {\n  ::Sleep(static_cast<DWORD>(n));\n}\n\nAutoHandle::AutoHandle()\n    : handle_(INVALID_HANDLE_VALUE) {}\n\nAutoHandle::AutoHandle(Handle handle)\n    : handle_(handle) {}\n\nAutoHandle::~AutoHandle() {\n  Reset();\n}\n\nAutoHandle::Handle AutoHandle::Get() const {\n  return handle_;\n}\n\nvoid AutoHandle::Reset() {\n  Reset(INVALID_HANDLE_VALUE);\n}\n\nvoid AutoHandle::Reset(HANDLE handle) {\n  // Resetting with the same handle we already own is invalid.\n  if (handle_ != handle) {\n    if (IsCloseable()) {\n      ::CloseHandle(handle_);\n    }\n    handle_ = handle;\n  } else {\n    GTEST_CHECK_(!IsCloseable())\n        << \"Resetting a valid handle to itself is likely a programmer error \"\n            \"and thus not allowed.\";\n  }\n}\n\nbool AutoHandle::IsCloseable() const {\n  // Different Windows APIs may use either of these values to represent an\n  // invalid handle.\n  return handle_ != nullptr && handle_ != INVALID_HANDLE_VALUE;\n}\n\nNotification::Notification()\n    : event_(::CreateEvent(nullptr,     // Default security attributes.\n                           TRUE,        // Do not reset automatically.\n                           FALSE,       // Initially unset.\n                           nullptr)) {  // Anonymous event.\n  GTEST_CHECK_(event_.Get() != nullptr);\n}\n\nvoid Notification::Notify() {\n  GTEST_CHECK_(::SetEvent(event_.Get()) != FALSE);\n}\n\nvoid Notification::WaitForNotification() {\n  GTEST_CHECK_(\n      ::WaitForSingleObject(event_.Get(), INFINITE) == WAIT_OBJECT_0);\n}\n\nMutex::Mutex()\n    : owner_thread_id_(0),\n      type_(kDynamic),\n      critical_section_init_phase_(0),\n      critical_section_(new CRITICAL_SECTION) {\n  ::InitializeCriticalSection(critical_section_);\n}\n\nMutex::~Mutex() {\n  // Static mutexes are leaked intentionally. It is not thread-safe to try\n  // to clean them up.\n  if (type_ == kDynamic) {\n    ::DeleteCriticalSection(critical_section_);\n    delete critical_section_;\n    critical_section_ = nullptr;\n  }\n}\n\nvoid Mutex::Lock() {\n  ThreadSafeLazyInit();\n  ::EnterCriticalSection(critical_section_);\n  owner_thread_id_ = ::GetCurrentThreadId();\n}\n\nvoid Mutex::Unlock() {\n  ThreadSafeLazyInit();\n  // We don't protect writing to owner_thread_id_ here, as it's the\n  // caller's responsibility to ensure that the current thread holds the\n  // mutex when this is called.\n  owner_thread_id_ = 0;\n  ::LeaveCriticalSection(critical_section_);\n}\n\n// Does nothing if the current thread holds the mutex. Otherwise, crashes\n// with high probability.\nvoid Mutex::AssertHeld() {\n  ThreadSafeLazyInit();\n  GTEST_CHECK_(owner_thread_id_ == ::GetCurrentThreadId())\n      << \"The current thread is not holding the mutex @\" << this;\n}\n\nnamespace {\n\n#ifdef _MSC_VER\n// Use the RAII idiom to flag mem allocs that are intentionally never\n// deallocated. The motivation is to silence the false positive mem leaks\n// that are reported by the debug version of MS's CRT which can only detect\n// if an alloc is missing a matching deallocation.\n// Example:\n//    MemoryIsNotDeallocated memory_is_not_deallocated;\n//    critical_section_ = new CRITICAL_SECTION;\n//\nclass MemoryIsNotDeallocated\n{\n public:\n  MemoryIsNotDeallocated() : old_crtdbg_flag_(0) {\n    old_crtdbg_flag_ = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);\n    // Set heap allocation block type to _IGNORE_BLOCK so that MS debug CRT\n    // doesn't report mem leak if there's no matching deallocation.\n    _CrtSetDbgFlag(old_crtdbg_flag_ & ~_CRTDBG_ALLOC_MEM_DF);\n  }\n\n  ~MemoryIsNotDeallocated() {\n    // Restore the original _CRTDBG_ALLOC_MEM_DF flag\n    _CrtSetDbgFlag(old_crtdbg_flag_);\n  }\n\n private:\n  int old_crtdbg_flag_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MemoryIsNotDeallocated);\n};\n#endif  // _MSC_VER\n\n}  // namespace\n\n// Initializes owner_thread_id_ and critical_section_ in static mutexes.\nvoid Mutex::ThreadSafeLazyInit() {\n  // Dynamic mutexes are initialized in the constructor.\n  if (type_ == kStatic) {\n    switch (\n        ::InterlockedCompareExchange(&critical_section_init_phase_, 1L, 0L)) {\n      case 0:\n        // If critical_section_init_phase_ was 0 before the exchange, we\n        // are the first to test it and need to perform the initialization.\n        owner_thread_id_ = 0;\n        {\n          // Use RAII to flag that following mem alloc is never deallocated.\n#ifdef _MSC_VER\n          MemoryIsNotDeallocated memory_is_not_deallocated;\n#endif  // _MSC_VER\n          critical_section_ = new CRITICAL_SECTION;\n        }\n        ::InitializeCriticalSection(critical_section_);\n        // Updates the critical_section_init_phase_ to 2 to signal\n        // initialization complete.\n        GTEST_CHECK_(::InterlockedCompareExchange(\n                          &critical_section_init_phase_, 2L, 1L) ==\n                      1L);\n        break;\n      case 1:\n        // Somebody else is already initializing the mutex; spin until they\n        // are done.\n        while (::InterlockedCompareExchange(&critical_section_init_phase_,\n                                            2L,\n                                            2L) != 2L) {\n          // Possibly yields the rest of the thread's time slice to other\n          // threads.\n          ::Sleep(0);\n        }\n        break;\n\n      case 2:\n        break;  // The mutex is already initialized and ready for use.\n\n      default:\n        GTEST_CHECK_(false)\n            << \"Unexpected value of critical_section_init_phase_ \"\n            << \"while initializing a static mutex.\";\n    }\n  }\n}\n\nnamespace {\n\nclass ThreadWithParamSupport : public ThreadWithParamBase {\n public:\n  static HANDLE CreateThread(Runnable* runnable,\n                             Notification* thread_can_start) {\n    ThreadMainParam* param = new ThreadMainParam(runnable, thread_can_start);\n    DWORD thread_id;\n    HANDLE thread_handle = ::CreateThread(\n        nullptr,  // Default security.\n        0,        // Default stack size.\n        &ThreadWithParamSupport::ThreadMain,\n        param,        // Parameter to ThreadMainStatic\n        0x0,          // Default creation flags.\n        &thread_id);  // Need a valid pointer for the call to work under Win98.\n    GTEST_CHECK_(thread_handle != nullptr)\n        << \"CreateThread failed with error \" << ::GetLastError() << \".\";\n    if (thread_handle == nullptr) {\n      delete param;\n    }\n    return thread_handle;\n  }\n\n private:\n  struct ThreadMainParam {\n    ThreadMainParam(Runnable* runnable, Notification* thread_can_start)\n        : runnable_(runnable),\n          thread_can_start_(thread_can_start) {\n    }\n    std::unique_ptr<Runnable> runnable_;\n    // Does not own.\n    Notification* thread_can_start_;\n  };\n\n  static DWORD WINAPI ThreadMain(void* ptr) {\n    // Transfers ownership.\n    std::unique_ptr<ThreadMainParam> param(static_cast<ThreadMainParam*>(ptr));\n    if (param->thread_can_start_ != nullptr)\n      param->thread_can_start_->WaitForNotification();\n    param->runnable_->Run();\n    return 0;\n  }\n\n  // Prohibit instantiation.\n  ThreadWithParamSupport();\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParamSupport);\n};\n\n}  // namespace\n\nThreadWithParamBase::ThreadWithParamBase(Runnable *runnable,\n                                         Notification* thread_can_start)\n      : thread_(ThreadWithParamSupport::CreateThread(runnable,\n                                                     thread_can_start)) {\n}\n\nThreadWithParamBase::~ThreadWithParamBase() {\n  Join();\n}\n\nvoid ThreadWithParamBase::Join() {\n  GTEST_CHECK_(::WaitForSingleObject(thread_.Get(), INFINITE) == WAIT_OBJECT_0)\n      << \"Failed to join the thread with error \" << ::GetLastError() << \".\";\n}\n\n// Maps a thread to a set of ThreadIdToThreadLocals that have values\n// instantiated on that thread and notifies them when the thread exits.  A\n// ThreadLocal instance is expected to persist until all threads it has\n// values on have terminated.\nclass ThreadLocalRegistryImpl {\n public:\n  // Registers thread_local_instance as having value on the current thread.\n  // Returns a value that can be used to identify the thread from other threads.\n  static ThreadLocalValueHolderBase* GetValueOnCurrentThread(\n      const ThreadLocalBase* thread_local_instance) {\n#ifdef _MSC_VER\n    MemoryIsNotDeallocated memory_is_not_deallocated;\n#endif  // _MSC_VER\n    DWORD current_thread = ::GetCurrentThreadId();\n    MutexLock lock(&mutex_);\n    ThreadIdToThreadLocals* const thread_to_thread_locals =\n        GetThreadLocalsMapLocked();\n    ThreadIdToThreadLocals::iterator thread_local_pos =\n        thread_to_thread_locals->find(current_thread);\n    if (thread_local_pos == thread_to_thread_locals->end()) {\n      thread_local_pos = thread_to_thread_locals->insert(\n          std::make_pair(current_thread, ThreadLocalValues())).first;\n      StartWatcherThreadFor(current_thread);\n    }\n    ThreadLocalValues& thread_local_values = thread_local_pos->second;\n    ThreadLocalValues::iterator value_pos =\n        thread_local_values.find(thread_local_instance);\n    if (value_pos == thread_local_values.end()) {\n      value_pos =\n          thread_local_values\n              .insert(std::make_pair(\n                  thread_local_instance,\n                  std::shared_ptr<ThreadLocalValueHolderBase>(\n                      thread_local_instance->NewValueForCurrentThread())))\n              .first;\n    }\n    return value_pos->second.get();\n  }\n\n  static void OnThreadLocalDestroyed(\n      const ThreadLocalBase* thread_local_instance) {\n    std::vector<std::shared_ptr<ThreadLocalValueHolderBase> > value_holders;\n    // Clean up the ThreadLocalValues data structure while holding the lock, but\n    // defer the destruction of the ThreadLocalValueHolderBases.\n    {\n      MutexLock lock(&mutex_);\n      ThreadIdToThreadLocals* const thread_to_thread_locals =\n          GetThreadLocalsMapLocked();\n      for (ThreadIdToThreadLocals::iterator it =\n          thread_to_thread_locals->begin();\n          it != thread_to_thread_locals->end();\n          ++it) {\n        ThreadLocalValues& thread_local_values = it->second;\n        ThreadLocalValues::iterator value_pos =\n            thread_local_values.find(thread_local_instance);\n        if (value_pos != thread_local_values.end()) {\n          value_holders.push_back(value_pos->second);\n          thread_local_values.erase(value_pos);\n          // This 'if' can only be successful at most once, so theoretically we\n          // could break out of the loop here, but we don't bother doing so.\n        }\n      }\n    }\n    // Outside the lock, let the destructor for 'value_holders' deallocate the\n    // ThreadLocalValueHolderBases.\n  }\n\n  static void OnThreadExit(DWORD thread_id) {\n    GTEST_CHECK_(thread_id != 0) << ::GetLastError();\n    std::vector<std::shared_ptr<ThreadLocalValueHolderBase> > value_holders;\n    // Clean up the ThreadIdToThreadLocals data structure while holding the\n    // lock, but defer the destruction of the ThreadLocalValueHolderBases.\n    {\n      MutexLock lock(&mutex_);\n      ThreadIdToThreadLocals* const thread_to_thread_locals =\n          GetThreadLocalsMapLocked();\n      ThreadIdToThreadLocals::iterator thread_local_pos =\n          thread_to_thread_locals->find(thread_id);\n      if (thread_local_pos != thread_to_thread_locals->end()) {\n        ThreadLocalValues& thread_local_values = thread_local_pos->second;\n        for (ThreadLocalValues::iterator value_pos =\n            thread_local_values.begin();\n            value_pos != thread_local_values.end();\n            ++value_pos) {\n          value_holders.push_back(value_pos->second);\n        }\n        thread_to_thread_locals->erase(thread_local_pos);\n      }\n    }\n    // Outside the lock, let the destructor for 'value_holders' deallocate the\n    // ThreadLocalValueHolderBases.\n  }\n\n private:\n  // In a particular thread, maps a ThreadLocal object to its value.\n  typedef std::map<const ThreadLocalBase*,\n                   std::shared_ptr<ThreadLocalValueHolderBase> >\n      ThreadLocalValues;\n  // Stores all ThreadIdToThreadLocals having values in a thread, indexed by\n  // thread's ID.\n  typedef std::map<DWORD, ThreadLocalValues> ThreadIdToThreadLocals;\n\n  // Holds the thread id and thread handle that we pass from\n  // StartWatcherThreadFor to WatcherThreadFunc.\n  typedef std::pair<DWORD, HANDLE> ThreadIdAndHandle;\n\n  static void StartWatcherThreadFor(DWORD thread_id) {\n    // The returned handle will be kept in thread_map and closed by\n    // watcher_thread in WatcherThreadFunc.\n    HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,\n                                 FALSE,\n                                 thread_id);\n    GTEST_CHECK_(thread != nullptr);\n    // We need to pass a valid thread ID pointer into CreateThread for it\n    // to work correctly under Win98.\n    DWORD watcher_thread_id;\n    HANDLE watcher_thread = ::CreateThread(\n        nullptr,  // Default security.\n        0,        // Default stack size\n        &ThreadLocalRegistryImpl::WatcherThreadFunc,\n        reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),\n        CREATE_SUSPENDED, &watcher_thread_id);\n    GTEST_CHECK_(watcher_thread != nullptr);\n    // Give the watcher thread the same priority as ours to avoid being\n    // blocked by it.\n    ::SetThreadPriority(watcher_thread,\n                        ::GetThreadPriority(::GetCurrentThread()));\n    ::ResumeThread(watcher_thread);\n    ::CloseHandle(watcher_thread);\n  }\n\n  // Monitors exit from a given thread and notifies those\n  // ThreadIdToThreadLocals about thread termination.\n  static DWORD WINAPI WatcherThreadFunc(LPVOID param) {\n    const ThreadIdAndHandle* tah =\n        reinterpret_cast<const ThreadIdAndHandle*>(param);\n    GTEST_CHECK_(\n        ::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0);\n    OnThreadExit(tah->first);\n    ::CloseHandle(tah->second);\n    delete tah;\n    return 0;\n  }\n\n  // Returns map of thread local instances.\n  static ThreadIdToThreadLocals* GetThreadLocalsMapLocked() {\n    mutex_.AssertHeld();\n#ifdef _MSC_VER\n    MemoryIsNotDeallocated memory_is_not_deallocated;\n#endif  // _MSC_VER\n    static ThreadIdToThreadLocals* map = new ThreadIdToThreadLocals();\n    return map;\n  }\n\n  // Protects access to GetThreadLocalsMapLocked() and its return value.\n  static Mutex mutex_;\n  // Protects access to GetThreadMapLocked() and its return value.\n  static Mutex thread_map_mutex_;\n};\n\nMutex ThreadLocalRegistryImpl::mutex_(Mutex::kStaticMutex);\nMutex ThreadLocalRegistryImpl::thread_map_mutex_(Mutex::kStaticMutex);\n\nThreadLocalValueHolderBase* ThreadLocalRegistry::GetValueOnCurrentThread(\n      const ThreadLocalBase* thread_local_instance) {\n  return ThreadLocalRegistryImpl::GetValueOnCurrentThread(\n      thread_local_instance);\n}\n\nvoid ThreadLocalRegistry::OnThreadLocalDestroyed(\n      const ThreadLocalBase* thread_local_instance) {\n  ThreadLocalRegistryImpl::OnThreadLocalDestroyed(thread_local_instance);\n}\n\n#endif  // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS\n\n#if GTEST_USES_POSIX_RE\n\n// Implements RE.  Currently only needed for death tests.\n\nRE::~RE() {\n  if (is_valid_) {\n    // regfree'ing an invalid regex might crash because the content\n    // of the regex is undefined. Since the regex's are essentially\n    // the same, one cannot be valid (or invalid) without the other\n    // being so too.\n    regfree(&partial_regex_);\n    regfree(&full_regex_);\n  }\n  free(const_cast<char*>(pattern_));\n}\n\n// Returns true if and only if regular expression re matches the entire str.\nbool RE::FullMatch(const char* str, const RE& re) {\n  if (!re.is_valid_) return false;\n\n  regmatch_t match;\n  return regexec(&re.full_regex_, str, 1, &match, 0) == 0;\n}\n\n// Returns true if and only if regular expression re matches a substring of\n// str (including str itself).\nbool RE::PartialMatch(const char* str, const RE& re) {\n  if (!re.is_valid_) return false;\n\n  regmatch_t match;\n  return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;\n}\n\n// Initializes an RE from its string representation.\nvoid RE::Init(const char* regex) {\n  pattern_ = posix::StrDup(regex);\n\n  // Reserves enough bytes to hold the regular expression used for a\n  // full match.\n  const size_t full_regex_len = strlen(regex) + 10;\n  char* const full_pattern = new char[full_regex_len];\n\n  snprintf(full_pattern, full_regex_len, \"^(%s)$\", regex);\n  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;\n  // We want to call regcomp(&partial_regex_, ...) even if the\n  // previous expression returns false.  Otherwise partial_regex_ may\n  // not be properly initialized can may cause trouble when it's\n  // freed.\n  //\n  // Some implementation of POSIX regex (e.g. on at least some\n  // versions of Cygwin) doesn't accept the empty string as a valid\n  // regex.  We change it to an equivalent form \"()\" to be safe.\n  if (is_valid_) {\n    const char* const partial_regex = (*regex == '\\0') ? \"()\" : regex;\n    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;\n  }\n  EXPECT_TRUE(is_valid_)\n      << \"Regular expression \\\"\" << regex\n      << \"\\\" is not a valid POSIX Extended regular expression.\";\n\n  delete[] full_pattern;\n}\n\n#elif GTEST_USES_SIMPLE_RE\n\n// Returns true if and only if ch appears anywhere in str (excluding the\n// terminating '\\0' character).\nbool IsInSet(char ch, const char* str) {\n  return ch != '\\0' && strchr(str, ch) != nullptr;\n}\n\n// Returns true if and only if ch belongs to the given classification.\n// Unlike similar functions in <ctype.h>, these aren't affected by the\n// current locale.\nbool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }\nbool IsAsciiPunct(char ch) {\n  return IsInSet(ch, \"^-!\\\"#$%&'()*+,./:;<=>?@[\\\\]_`{|}~\");\n}\nbool IsRepeat(char ch) { return IsInSet(ch, \"?*+\"); }\nbool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, \" \\f\\n\\r\\t\\v\"); }\nbool IsAsciiWordChar(char ch) {\n  return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||\n      ('0' <= ch && ch <= '9') || ch == '_';\n}\n\n// Returns true if and only if \"\\\\c\" is a supported escape sequence.\nbool IsValidEscape(char c) {\n  return (IsAsciiPunct(c) || IsInSet(c, \"dDfnrsStvwW\"));\n}\n\n// Returns true if and only if the given atom (specified by escaped and\n// pattern) matches ch.  The result is undefined if the atom is invalid.\nbool AtomMatchesChar(bool escaped, char pattern_char, char ch) {\n  if (escaped) {  // \"\\\\p\" where p is pattern_char.\n    switch (pattern_char) {\n      case 'd': return IsAsciiDigit(ch);\n      case 'D': return !IsAsciiDigit(ch);\n      case 'f': return ch == '\\f';\n      case 'n': return ch == '\\n';\n      case 'r': return ch == '\\r';\n      case 's': return IsAsciiWhiteSpace(ch);\n      case 'S': return !IsAsciiWhiteSpace(ch);\n      case 't': return ch == '\\t';\n      case 'v': return ch == '\\v';\n      case 'w': return IsAsciiWordChar(ch);\n      case 'W': return !IsAsciiWordChar(ch);\n    }\n    return IsAsciiPunct(pattern_char) && pattern_char == ch;\n  }\n\n  return (pattern_char == '.' && ch != '\\n') || pattern_char == ch;\n}\n\n// Helper function used by ValidateRegex() to format error messages.\nstatic std::string FormatRegexSyntaxError(const char* regex, int index) {\n  return (Message() << \"Syntax error at index \" << index\n          << \" in simple regular expression \\\"\" << regex << \"\\\": \").GetString();\n}\n\n// Generates non-fatal failures and returns false if regex is invalid;\n// otherwise returns true.\nbool ValidateRegex(const char* regex) {\n  if (regex == nullptr) {\n    ADD_FAILURE() << \"NULL is not a valid simple regular expression.\";\n    return false;\n  }\n\n  bool is_valid = true;\n\n  // True if and only if ?, *, or + can follow the previous atom.\n  bool prev_repeatable = false;\n  for (int i = 0; regex[i]; i++) {\n    if (regex[i] == '\\\\') {  // An escape sequence\n      i++;\n      if (regex[i] == '\\0') {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)\n                      << \"'\\\\' cannot appear at the end.\";\n        return false;\n      }\n\n      if (!IsValidEscape(regex[i])) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)\n                      << \"invalid escape sequence \\\"\\\\\" << regex[i] << \"\\\".\";\n        is_valid = false;\n      }\n      prev_repeatable = true;\n    } else {  // Not an escape sequence.\n      const char ch = regex[i];\n\n      if (ch == '^' && i > 0) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'^' can only appear at the beginning.\";\n        is_valid = false;\n      } else if (ch == '$' && regex[i + 1] != '\\0') {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'$' can only appear at the end.\";\n        is_valid = false;\n      } else if (IsInSet(ch, \"()[]{}|\")) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'\" << ch << \"' is unsupported.\";\n        is_valid = false;\n      } else if (IsRepeat(ch) && !prev_repeatable) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'\" << ch << \"' can only follow a repeatable token.\";\n        is_valid = false;\n      }\n\n      prev_repeatable = !IsInSet(ch, \"^$?*+\");\n    }\n  }\n\n  return is_valid;\n}\n\n// Matches a repeated regex atom followed by a valid simple regular\n// expression.  The regex atom is defined as c if escaped is false,\n// or \\c otherwise.  repeat is the repetition meta character (?, *,\n// or +).  The behavior is undefined if str contains too many\n// characters to be indexable by size_t, in which case the test will\n// probably time out anyway.  We are fine with this limitation as\n// std::string has it too.\nbool MatchRepetitionAndRegexAtHead(\n    bool escaped, char c, char repeat, const char* regex,\n    const char* str) {\n  const size_t min_count = (repeat == '+') ? 1 : 0;\n  const size_t max_count = (repeat == '?') ? 1 :\n      static_cast<size_t>(-1) - 1;\n  // We cannot call numeric_limits::max() as it conflicts with the\n  // max() macro on Windows.\n\n  for (size_t i = 0; i <= max_count; ++i) {\n    // We know that the atom matches each of the first i characters in str.\n    if (i >= min_count && MatchRegexAtHead(regex, str + i)) {\n      // We have enough matches at the head, and the tail matches too.\n      // Since we only care about *whether* the pattern matches str\n      // (as opposed to *how* it matches), there is no need to find a\n      // greedy match.\n      return true;\n    }\n    if (str[i] == '\\0' || !AtomMatchesChar(escaped, c, str[i]))\n      return false;\n  }\n  return false;\n}\n\n// Returns true if and only if regex matches a prefix of str. regex must\n// be a valid simple regular expression and not start with \"^\", or the\n// result is undefined.\nbool MatchRegexAtHead(const char* regex, const char* str) {\n  if (*regex == '\\0')  // An empty regex matches a prefix of anything.\n    return true;\n\n  // \"$\" only matches the end of a string.  Note that regex being\n  // valid guarantees that there's nothing after \"$\" in it.\n  if (*regex == '$')\n    return *str == '\\0';\n\n  // Is the first thing in regex an escape sequence?\n  const bool escaped = *regex == '\\\\';\n  if (escaped)\n    ++regex;\n  if (IsRepeat(regex[1])) {\n    // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so\n    // here's an indirect recursion.  It terminates as the regex gets\n    // shorter in each recursion.\n    return MatchRepetitionAndRegexAtHead(\n        escaped, regex[0], regex[1], regex + 2, str);\n  } else {\n    // regex isn't empty, isn't \"$\", and doesn't start with a\n    // repetition.  We match the first atom of regex with the first\n    // character of str and recurse.\n    return (*str != '\\0') && AtomMatchesChar(escaped, *regex, *str) &&\n        MatchRegexAtHead(regex + 1, str + 1);\n  }\n}\n\n// Returns true if and only if regex matches any substring of str.  regex must\n// be a valid simple regular expression, or the result is undefined.\n//\n// The algorithm is recursive, but the recursion depth doesn't exceed\n// the regex length, so we won't need to worry about running out of\n// stack space normally.  In rare cases the time complexity can be\n// exponential with respect to the regex length + the string length,\n// but usually it's must faster (often close to linear).\nbool MatchRegexAnywhere(const char* regex, const char* str) {\n  if (regex == nullptr || str == nullptr) return false;\n\n  if (*regex == '^')\n    return MatchRegexAtHead(regex + 1, str);\n\n  // A successful match can be anywhere in str.\n  do {\n    if (MatchRegexAtHead(regex, str))\n      return true;\n  } while (*str++ != '\\0');\n  return false;\n}\n\n// Implements the RE class.\n\nRE::~RE() {\n  free(const_cast<char*>(pattern_));\n  free(const_cast<char*>(full_pattern_));\n}\n\n// Returns true if and only if regular expression re matches the entire str.\nbool RE::FullMatch(const char* str, const RE& re) {\n  return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);\n}\n\n// Returns true if and only if regular expression re matches a substring of\n// str (including str itself).\nbool RE::PartialMatch(const char* str, const RE& re) {\n  return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);\n}\n\n// Initializes an RE from its string representation.\nvoid RE::Init(const char* regex) {\n  pattern_ = full_pattern_ = nullptr;\n  if (regex != nullptr) {\n    pattern_ = posix::StrDup(regex);\n  }\n\n  is_valid_ = ValidateRegex(regex);\n  if (!is_valid_) {\n    // No need to calculate the full pattern when the regex is invalid.\n    return;\n  }\n\n  const size_t len = strlen(regex);\n  // Reserves enough bytes to hold the regular expression used for a\n  // full match: we need space to prepend a '^', append a '$', and\n  // terminate the string with '\\0'.\n  char* buffer = static_cast<char*>(malloc(len + 3));\n  full_pattern_ = buffer;\n\n  if (*regex != '^')\n    *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.\n\n  // We don't use snprintf or strncpy, as they trigger a warning when\n  // compiled with VC++ 8.0.\n  memcpy(buffer, regex, len);\n  buffer += len;\n\n  if (len == 0 || regex[len - 1] != '$')\n    *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.\n\n  *buffer = '\\0';\n}\n\n#endif  // GTEST_USES_POSIX_RE\n\nconst char kUnknownFile[] = \"unknown file\";\n\n// Formats a source file path and a line number as they would appear\n// in an error message from the compiler used to compile this code.\nGTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {\n  const std::string file_name(file == nullptr ? kUnknownFile : file);\n\n  if (line < 0) {\n    return file_name + \":\";\n  }\n#ifdef _MSC_VER\n  return file_name + \"(\" + StreamableToString(line) + \"):\";\n#else\n  return file_name + \":\" + StreamableToString(line) + \":\";\n#endif  // _MSC_VER\n}\n\n// Formats a file location for compiler-independent XML output.\n// Although this function is not platform dependent, we put it next to\n// FormatFileLocation in order to contrast the two functions.\n// Note that FormatCompilerIndependentFileLocation() does NOT append colon\n// to the file location it produces, unlike FormatFileLocation().\nGTEST_API_ ::std::string FormatCompilerIndependentFileLocation(\n    const char* file, int line) {\n  const std::string file_name(file == nullptr ? kUnknownFile : file);\n\n  if (line < 0)\n    return file_name;\n  else\n    return file_name + \":\" + StreamableToString(line);\n}\n\nGTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)\n    : severity_(severity) {\n  const char* const marker =\n      severity == GTEST_INFO ?    \"[  INFO ]\" :\n      severity == GTEST_WARNING ? \"[WARNING]\" :\n      severity == GTEST_ERROR ?   \"[ ERROR ]\" : \"[ FATAL ]\";\n  GetStream() << ::std::endl << marker << \" \"\n              << FormatFileLocation(file, line).c_str() << \": \";\n}\n\n// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.\nGTestLog::~GTestLog() {\n  GetStream() << ::std::endl;\n  if (severity_ == GTEST_FATAL) {\n    fflush(stderr);\n    posix::Abort();\n  }\n}\n\n// Disable Microsoft deprecation warnings for POSIX functions called from\n// this class (creat, dup, dup2, and close)\nGTEST_DISABLE_MSC_DEPRECATED_PUSH_()\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Object that captures an output stream (stdout/stderr).\nclass CapturedStream {\n public:\n  // The ctor redirects the stream to a temporary file.\n  explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {\n# if GTEST_OS_WINDOWS\n    char temp_dir_path[MAX_PATH + 1] = { '\\0' };  // NOLINT\n    char temp_file_path[MAX_PATH + 1] = { '\\0' };  // NOLINT\n\n    ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);\n    const UINT success = ::GetTempFileNameA(temp_dir_path,\n                                            \"gtest_redir\",\n                                            0,  // Generate unique file name.\n                                            temp_file_path);\n    GTEST_CHECK_(success != 0)\n        << \"Unable to create a temporary file in \" << temp_dir_path;\n    const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);\n    GTEST_CHECK_(captured_fd != -1) << \"Unable to open temporary file \"\n                                    << temp_file_path;\n    filename_ = temp_file_path;\n# else\n    // There's no guarantee that a test has write access to the current\n    // directory, so we create the temporary file in the /tmp directory\n    // instead. We use /tmp on most systems, and /sdcard on Android.\n    // That's because Android doesn't have /tmp.\n#  if GTEST_OS_LINUX_ANDROID\n    // Note: Android applications are expected to call the framework's\n    // Context.getExternalStorageDirectory() method through JNI to get\n    // the location of the world-writable SD Card directory. However,\n    // this requires a Context handle, which cannot be retrieved\n    // globally from native code. Doing so also precludes running the\n    // code as part of a regular standalone executable, which doesn't\n    // run in a Dalvik process (e.g. when running it through 'adb shell').\n    //\n    // The location /data/local/tmp is directly accessible from native code.\n    // '/sdcard' and other variants cannot be relied on, as they are not\n    // guaranteed to be mounted, or may have a delay in mounting.\n    char name_template[] = \"/data/local/tmp/gtest_captured_stream.XXXXXX\";\n#  else\n    char name_template[] = \"/tmp/captured_stream.XXXXXX\";\n#  endif  // GTEST_OS_LINUX_ANDROID\n    const int captured_fd = mkstemp(name_template);\n    if (captured_fd == -1) {\n      GTEST_LOG_(WARNING)\n          << \"Failed to create tmp file \" << name_template\n          << \" for test; does the test have access to the /tmp directory?\";\n    }\n    filename_ = name_template;\n# endif  // GTEST_OS_WINDOWS\n    fflush(nullptr);\n    dup2(captured_fd, fd_);\n    close(captured_fd);\n  }\n\n  ~CapturedStream() {\n    remove(filename_.c_str());\n  }\n\n  std::string GetCapturedString() {\n    if (uncaptured_fd_ != -1) {\n      // Restores the original stream.\n      fflush(nullptr);\n      dup2(uncaptured_fd_, fd_);\n      close(uncaptured_fd_);\n      uncaptured_fd_ = -1;\n    }\n\n    FILE* const file = posix::FOpen(filename_.c_str(), \"r\");\n    if (file == nullptr) {\n      GTEST_LOG_(FATAL) << \"Failed to open tmp file \" << filename_\n                        << \" for capturing stream.\";\n    }\n    const std::string content = ReadEntireFile(file);\n    posix::FClose(file);\n    return content;\n  }\n\n private:\n  const int fd_;  // A stream to capture.\n  int uncaptured_fd_;\n  // Name of the temporary file holding the stderr output.\n  ::std::string filename_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);\n};\n\nGTEST_DISABLE_MSC_DEPRECATED_POP_()\n\nstatic CapturedStream* g_captured_stderr = nullptr;\nstatic CapturedStream* g_captured_stdout = nullptr;\n\n// Starts capturing an output stream (stdout/stderr).\nstatic void CaptureStream(int fd, const char* stream_name,\n                          CapturedStream** stream) {\n  if (*stream != nullptr) {\n    GTEST_LOG_(FATAL) << \"Only one \" << stream_name\n                      << \" capturer can exist at a time.\";\n  }\n  *stream = new CapturedStream(fd);\n}\n\n// Stops capturing the output stream and returns the captured string.\nstatic std::string GetCapturedStream(CapturedStream** captured_stream) {\n  const std::string content = (*captured_stream)->GetCapturedString();\n\n  delete *captured_stream;\n  *captured_stream = nullptr;\n\n  return content;\n}\n\n// Starts capturing stdout.\nvoid CaptureStdout() {\n  CaptureStream(kStdOutFileno, \"stdout\", &g_captured_stdout);\n}\n\n// Starts capturing stderr.\nvoid CaptureStderr() {\n  CaptureStream(kStdErrFileno, \"stderr\", &g_captured_stderr);\n}\n\n// Stops capturing stdout and returns the captured string.\nstd::string GetCapturedStdout() {\n  return GetCapturedStream(&g_captured_stdout);\n}\n\n// Stops capturing stderr and returns the captured string.\nstd::string GetCapturedStderr() {\n  return GetCapturedStream(&g_captured_stderr);\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n\n\n\n\nsize_t GetFileSize(FILE* file) {\n  fseek(file, 0, SEEK_END);\n  return static_cast<size_t>(ftell(file));\n}\n\nstd::string ReadEntireFile(FILE* file) {\n  const size_t file_size = GetFileSize(file);\n  char* const buffer = new char[file_size];\n\n  size_t bytes_last_read = 0;  // # of bytes read in the last fread()\n  size_t bytes_read = 0;       // # of bytes read so far\n\n  fseek(file, 0, SEEK_SET);\n\n  // Keeps reading the file until we cannot read further or the\n  // pre-determined file size is reached.\n  do {\n    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);\n    bytes_read += bytes_last_read;\n  } while (bytes_last_read > 0 && bytes_read < file_size);\n\n  const std::string content(buffer, bytes_read);\n  delete[] buffer;\n\n  return content;\n}\n\n#if GTEST_HAS_DEATH_TEST\nstatic const std::vector<std::string>* g_injected_test_argvs =\n    nullptr;  // Owned.\n\nstd::vector<std::string> GetInjectableArgvs() {\n  if (g_injected_test_argvs != nullptr) {\n    return *g_injected_test_argvs;\n  }\n  return GetArgvs();\n}\n\nvoid SetInjectableArgvs(const std::vector<std::string>* new_argvs) {\n  if (g_injected_test_argvs != new_argvs) delete g_injected_test_argvs;\n  g_injected_test_argvs = new_argvs;\n}\n\nvoid SetInjectableArgvs(const std::vector<std::string>& new_argvs) {\n  SetInjectableArgvs(\n      new std::vector<std::string>(new_argvs.begin(), new_argvs.end()));\n}\n\nvoid ClearInjectableArgvs() {\n  delete g_injected_test_argvs;\n  g_injected_test_argvs = nullptr;\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n#if GTEST_OS_WINDOWS_MOBILE\nnamespace posix {\nvoid Abort() {\n  DebugBreak();\n  TerminateProcess(GetCurrentProcess(), 1);\n}\n}  // namespace posix\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Returns the name of the environment variable corresponding to the\n// given flag.  For example, FlagToEnvVar(\"foo\") will return\n// \"GTEST_FOO\" in the open-source version.\nstatic std::string FlagToEnvVar(const char* flag) {\n  const std::string full_flag =\n      (Message() << GTEST_FLAG_PREFIX_ << flag).GetString();\n\n  Message env_var;\n  for (size_t i = 0; i != full_flag.length(); i++) {\n    env_var << ToUpper(full_flag.c_str()[i]);\n  }\n\n  return env_var.GetString();\n}\n\n// Parses 'str' for a 32-bit signed integer.  If successful, writes\n// the result to *value and returns true; otherwise leaves *value\n// unchanged and returns false.\nbool ParseInt32(const Message& src_text, const char* str, int32_t* value) {\n  // Parses the environment variable as a decimal integer.\n  char* end = nullptr;\n  const long long_value = strtol(str, &end, 10);  // NOLINT\n\n  // Has strtol() consumed all characters in the string?\n  if (*end != '\\0') {\n    // No - an invalid character was encountered.\n    Message msg;\n    msg << \"WARNING: \" << src_text\n        << \" is expected to be a 32-bit integer, but actually\"\n        << \" has value \\\"\" << str << \"\\\".\\n\";\n    printf(\"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    return false;\n  }\n\n  // Is the parsed value in the range of an int32_t?\n  const auto result = static_cast<int32_t>(long_value);\n  if (long_value == LONG_MAX || long_value == LONG_MIN ||\n      // The parsed value overflows as a long.  (strtol() returns\n      // LONG_MAX or LONG_MIN when the input overflows.)\n      result != long_value\n      // The parsed value overflows as an int32_t.\n      ) {\n    Message msg;\n    msg << \"WARNING: \" << src_text\n        << \" is expected to be a 32-bit integer, but actually\"\n        << \" has value \" << str << \", which overflows.\\n\";\n    printf(\"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    return false;\n  }\n\n  *value = result;\n  return true;\n}\n\n// Reads and returns the Boolean environment variable corresponding to\n// the given flag; if it's not set, returns default_value.\n//\n// The value is considered true if and only if it's not \"0\".\nbool BoolFromGTestEnv(const char* flag, bool default_value) {\n#if defined(GTEST_GET_BOOL_FROM_ENV_)\n  return GTEST_GET_BOOL_FROM_ENV_(flag, default_value);\n#else\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const string_value = posix::GetEnv(env_var.c_str());\n  return string_value == nullptr ? default_value\n                                 : strcmp(string_value, \"0\") != 0;\n#endif  // defined(GTEST_GET_BOOL_FROM_ENV_)\n}\n\n// Reads and returns a 32-bit integer stored in the environment\n// variable corresponding to the given flag; if it isn't set or\n// doesn't represent a valid 32-bit integer, returns default_value.\nint32_t Int32FromGTestEnv(const char* flag, int32_t default_value) {\n#if defined(GTEST_GET_INT32_FROM_ENV_)\n  return GTEST_GET_INT32_FROM_ENV_(flag, default_value);\n#else\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const string_value = posix::GetEnv(env_var.c_str());\n  if (string_value == nullptr) {\n    // The environment variable is not set.\n    return default_value;\n  }\n\n  int32_t result = default_value;\n  if (!ParseInt32(Message() << \"Environment variable \" << env_var,\n                  string_value, &result)) {\n    printf(\"The default value %s is used.\\n\",\n           (Message() << default_value).GetString().c_str());\n    fflush(stdout);\n    return default_value;\n  }\n\n  return result;\n#endif  // defined(GTEST_GET_INT32_FROM_ENV_)\n}\n\n// As a special case for the 'output' flag, if GTEST_OUTPUT is not\n// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build\n// system.  The value of XML_OUTPUT_FILE is a filename without the\n// \"xml:\" prefix of GTEST_OUTPUT.\n// Note that this is meant to be called at the call site so it does\n// not check that the flag is 'output'\n// In essence this checks an env variable called XML_OUTPUT_FILE\n// and if it is set we prepend \"xml:\" to its value, if it not set we return \"\"\nstd::string OutputFlagAlsoCheckEnvVar(){\n  std::string default_value_for_output_flag = \"\";\n  const char* xml_output_file_env = posix::GetEnv(\"XML_OUTPUT_FILE\");\n  if (nullptr != xml_output_file_env) {\n    default_value_for_output_flag = std::string(\"xml:\") + xml_output_file_env;\n  }\n  return default_value_for_output_flag;\n}\n\n// Reads and returns the string environment variable corresponding to\n// the given flag; if it's not set, returns default_value.\nconst char* StringFromGTestEnv(const char* flag, const char* default_value) {\n#if defined(GTEST_GET_STRING_FROM_ENV_)\n  return GTEST_GET_STRING_FROM_ENV_(flag, default_value);\n#else\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const value = posix::GetEnv(env_var.c_str());\n  return value == nullptr ? default_value : value;\n#endif  // defined(GTEST_GET_STRING_FROM_ENV_)\n}\n\n}  // namespace internal\n}  // namespace testing\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Test - The Google C++ Testing and Mocking Framework\n//\n// This file implements a universal value printer that can print a\n// value of any type T:\n//\n//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);\n//\n// It uses the << operator when possible, and prints the bytes in the\n// object otherwise.  A user can override its behavior for a class\n// type Foo by defining either operator<<(::std::ostream&, const Foo&)\n// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that\n// defines Foo.\n\n\n#include <stdio.h>\n\n#include <cctype>\n#include <cstdint>\n#include <cwchar>\n#include <ostream>  // NOLINT\n#include <string>\n#include <type_traits>\n\n\nnamespace testing {\n\nnamespace {\n\nusing ::std::ostream;\n\n// Prints a segment of bytes in the given object.\nGTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\nvoid PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,\n                                size_t count, ostream* os) {\n  char text[5] = \"\";\n  for (size_t i = 0; i != count; i++) {\n    const size_t j = start + i;\n    if (i != 0) {\n      // Organizes the bytes into groups of 2 for easy parsing by\n      // human.\n      if ((j % 2) == 0)\n        *os << ' ';\n      else\n        *os << '-';\n    }\n    GTEST_SNPRINTF_(text, sizeof(text), \"%02X\", obj_bytes[j]);\n    *os << text;\n  }\n}\n\n// Prints the bytes in the given value to the given ostream.\nvoid PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,\n                              ostream* os) {\n  // Tells the user how big the object is.\n  *os << count << \"-byte object <\";\n\n  const size_t kThreshold = 132;\n  const size_t kChunkSize = 64;\n  // If the object size is bigger than kThreshold, we'll have to omit\n  // some details by printing only the first and the last kChunkSize\n  // bytes.\n  if (count < kThreshold) {\n    PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);\n  } else {\n    PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);\n    *os << \" ... \";\n    // Rounds up to 2-byte boundary.\n    const size_t resume_pos = (count - kChunkSize + 1)/2*2;\n    PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);\n  }\n  *os << \">\";\n}\n\n// Helpers for widening a character to char32_t. Since the standard does not\n// specify if char / wchar_t is signed or unsigned, it is important to first\n// convert it to the unsigned type of the same width before widening it to\n// char32_t.\ntemplate <typename CharType>\nchar32_t ToChar32(CharType in) {\n  return static_cast<char32_t>(\n      static_cast<typename std::make_unsigned<CharType>::type>(in));\n}\n\n}  // namespace\n\nnamespace internal {\n\n// Delegates to PrintBytesInObjectToImpl() to print the bytes in the\n// given object.  The delegation simplifies the implementation, which\n// uses the << operator and thus is easier done outside of the\n// ::testing::internal namespace, which contains a << operator that\n// sometimes conflicts with the one in STL.\nvoid PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,\n                          ostream* os) {\n  PrintBytesInObjectToImpl(obj_bytes, count, os);\n}\n\n// Depending on the value of a char (or wchar_t), we print it in one\n// of three formats:\n//   - as is if it's a printable ASCII (e.g. 'a', '2', ' '),\n//   - as a hexadecimal escape sequence (e.g. '\\x7F'), or\n//   - as a special escape sequence (e.g. '\\r', '\\n').\nenum CharFormat {\n  kAsIs,\n  kHexEscape,\n  kSpecialEscape\n};\n\n// Returns true if c is a printable ASCII character.  We test the\n// value of c directly instead of calling isprint(), which is buggy on\n// Windows Mobile.\ninline bool IsPrintableAscii(char32_t c) { return 0x20 <= c && c <= 0x7E; }\n\n// Prints c (of type char, char8_t, char16_t, char32_t, or wchar_t) as a\n// character literal without the quotes, escaping it when necessary; returns how\n// c was formatted.\ntemplate <typename Char>\nstatic CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {\n  const char32_t u_c = ToChar32(c);\n  switch (u_c) {\n    case L'\\0':\n      *os << \"\\\\0\";\n      break;\n    case L'\\'':\n      *os << \"\\\\'\";\n      break;\n    case L'\\\\':\n      *os << \"\\\\\\\\\";\n      break;\n    case L'\\a':\n      *os << \"\\\\a\";\n      break;\n    case L'\\b':\n      *os << \"\\\\b\";\n      break;\n    case L'\\f':\n      *os << \"\\\\f\";\n      break;\n    case L'\\n':\n      *os << \"\\\\n\";\n      break;\n    case L'\\r':\n      *os << \"\\\\r\";\n      break;\n    case L'\\t':\n      *os << \"\\\\t\";\n      break;\n    case L'\\v':\n      *os << \"\\\\v\";\n      break;\n    default:\n      if (IsPrintableAscii(u_c)) {\n        *os << static_cast<char>(c);\n        return kAsIs;\n      } else {\n        ostream::fmtflags flags = os->flags();\n        *os << \"\\\\x\" << std::hex << std::uppercase << static_cast<int>(u_c);\n        os->flags(flags);\n        return kHexEscape;\n      }\n  }\n  return kSpecialEscape;\n}\n\n// Prints a char32_t c as if it's part of a string literal, escaping it when\n// necessary; returns how c was formatted.\nstatic CharFormat PrintAsStringLiteralTo(char32_t c, ostream* os) {\n  switch (c) {\n    case L'\\'':\n      *os << \"'\";\n      return kAsIs;\n    case L'\"':\n      *os << \"\\\\\\\"\";\n      return kSpecialEscape;\n    default:\n      return PrintAsCharLiteralTo(c, os);\n  }\n}\n\nstatic const char* GetCharWidthPrefix(char) {\n  return \"\";\n}\n\nstatic const char* GetCharWidthPrefix(signed char) {\n  return \"\";\n}\n\nstatic const char* GetCharWidthPrefix(unsigned char) {\n  return \"\";\n}\n\n#ifdef __cpp_char8_t\nstatic const char* GetCharWidthPrefix(char8_t) {\n  return \"u8\";\n}\n#endif\n\nstatic const char* GetCharWidthPrefix(char16_t) {\n  return \"u\";\n}\n\nstatic const char* GetCharWidthPrefix(char32_t) {\n  return \"U\";\n}\n\nstatic const char* GetCharWidthPrefix(wchar_t) {\n  return \"L\";\n}\n\n// Prints a char c as if it's part of a string literal, escaping it when\n// necessary; returns how c was formatted.\nstatic CharFormat PrintAsStringLiteralTo(char c, ostream* os) {\n  return PrintAsStringLiteralTo(ToChar32(c), os);\n}\n\n#ifdef __cpp_char8_t\nstatic CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) {\n  return PrintAsStringLiteralTo(ToChar32(c), os);\n}\n#endif\n\nstatic CharFormat PrintAsStringLiteralTo(char16_t c, ostream* os) {\n  return PrintAsStringLiteralTo(ToChar32(c), os);\n}\n\nstatic CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) {\n  return PrintAsStringLiteralTo(ToChar32(c), os);\n}\n\n// Prints a character c (of type char, char8_t, char16_t, char32_t, or wchar_t)\n// and its code. '\\0' is printed as \"'\\\\0'\", other unprintable characters are\n// also properly escaped using the standard C++ escape sequence.\ntemplate <typename Char>\nvoid PrintCharAndCodeTo(Char c, ostream* os) {\n  // First, print c as a literal in the most readable form we can find.\n  *os << GetCharWidthPrefix(c) << \"'\";\n  const CharFormat format = PrintAsCharLiteralTo(c, os);\n  *os << \"'\";\n\n  // To aid user debugging, we also print c's code in decimal, unless\n  // it's 0 (in which case c was printed as '\\\\0', making the code\n  // obvious).\n  if (c == 0)\n    return;\n  *os << \" (\" << static_cast<int>(c);\n\n  // For more convenience, we print c's code again in hexadecimal,\n  // unless c was already printed in the form '\\x##' or the code is in\n  // [1, 9].\n  if (format == kHexEscape || (1 <= c && c <= 9)) {\n    // Do nothing.\n  } else {\n    *os << \", 0x\" << String::FormatHexInt(static_cast<int>(c));\n  }\n  *os << \")\";\n}\n\nvoid PrintTo(unsigned char c, ::std::ostream* os) { PrintCharAndCodeTo(c, os); }\nvoid PrintTo(signed char c, ::std::ostream* os) { PrintCharAndCodeTo(c, os); }\n\n// Prints a wchar_t as a symbol if it is printable or as its internal\n// code otherwise and also as its code.  L'\\0' is printed as \"L'\\\\0'\".\nvoid PrintTo(wchar_t wc, ostream* os) { PrintCharAndCodeTo(wc, os); }\n\n// TODO(dcheng): Consider making this delegate to PrintCharAndCodeTo() as well.\nvoid PrintTo(char32_t c, ::std::ostream* os) {\n  *os << std::hex << \"U+\" << std::uppercase << std::setfill('0') << std::setw(4)\n      << static_cast<uint32_t>(c);\n}\n\n// Prints the given array of characters to the ostream.  CharType must be either\n// char, char8_t, char16_t, char32_t, or wchar_t.\n// The array starts at begin, the length is len, it may include '\\0' characters\n// and may not be NUL-terminated.\ntemplate <typename CharType>\nGTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\nstatic CharFormat PrintCharsAsStringTo(\n    const CharType* begin, size_t len, ostream* os) {\n  const char* const quote_prefix = GetCharWidthPrefix(*begin);\n  *os << quote_prefix << \"\\\"\";\n  bool is_previous_hex = false;\n  CharFormat print_format = kAsIs;\n  for (size_t index = 0; index < len; ++index) {\n    const CharType cur = begin[index];\n    if (is_previous_hex && IsXDigit(cur)) {\n      // Previous character is of '\\x..' form and this character can be\n      // interpreted as another hexadecimal digit in its number. Break string to\n      // disambiguate.\n      *os << \"\\\" \" << quote_prefix << \"\\\"\";\n    }\n    is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;\n    // Remember if any characters required hex escaping.\n    if (is_previous_hex) {\n      print_format = kHexEscape;\n    }\n  }\n  *os << \"\\\"\";\n  return print_format;\n}\n\n// Prints a (const) char/wchar_t array of 'len' elements, starting at address\n// 'begin'.  CharType must be either char or wchar_t.\ntemplate <typename CharType>\nGTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\nGTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\nGTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\nstatic void UniversalPrintCharArray(\n    const CharType* begin, size_t len, ostream* os) {\n  // The code\n  //   const char kFoo[] = \"foo\";\n  // generates an array of 4, not 3, elements, with the last one being '\\0'.\n  //\n  // Therefore when printing a char array, we don't print the last element if\n  // it's '\\0', such that the output matches the string literal as it's\n  // written in the source code.\n  if (len > 0 && begin[len - 1] == '\\0') {\n    PrintCharsAsStringTo(begin, len - 1, os);\n    return;\n  }\n\n  // If, however, the last element in the array is not '\\0', e.g.\n  //    const char kFoo[] = { 'f', 'o', 'o' };\n  // we must print the entire array.  We also print a message to indicate\n  // that the array is not NUL-terminated.\n  PrintCharsAsStringTo(begin, len, os);\n  *os << \" (no terminating NUL)\";\n}\n\n// Prints a (const) char array of 'len' elements, starting at address 'begin'.\nvoid UniversalPrintArray(const char* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n#ifdef __cpp_char8_t\n// Prints a (const) char8_t array of 'len' elements, starting at address\n// 'begin'.\nvoid UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n#endif\n\n// Prints a (const) char16_t array of 'len' elements, starting at address\n// 'begin'.\nvoid UniversalPrintArray(const char16_t* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n// Prints a (const) char32_t array of 'len' elements, starting at address\n// 'begin'.\nvoid UniversalPrintArray(const char32_t* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n// Prints a (const) wchar_t array of 'len' elements, starting at address\n// 'begin'.\nvoid UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\nnamespace {\n\n// Prints a null-terminated C-style string to the ostream.\ntemplate <typename Char>\nvoid PrintCStringTo(const Char* s, ostream* os) {\n  if (s == nullptr) {\n    *os << \"NULL\";\n  } else {\n    *os << ImplicitCast_<const void*>(s) << \" pointing to \";\n    PrintCharsAsStringTo(s, std::char_traits<Char>::length(s), os);\n  }\n}\n\n}  // anonymous namespace\n\nvoid PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); }\n\n#ifdef __cpp_char8_t\nvoid PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); }\n#endif\n\nvoid PrintTo(const char16_t* s, ostream* os) { PrintCStringTo(s, os); }\n\nvoid PrintTo(const char32_t* s, ostream* os) { PrintCStringTo(s, os); }\n\n// MSVC compiler can be configured to define whar_t as a typedef\n// of unsigned short. Defining an overload for const wchar_t* in that case\n// would cause pointers to unsigned shorts be printed as wide strings,\n// possibly accessing more memory than intended and causing invalid\n// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when\n// wchar_t is implemented as a native type.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n// Prints the given wide C string to the ostream.\nvoid PrintTo(const wchar_t* s, ostream* os) { PrintCStringTo(s, os); }\n#endif  // wchar_t is native\n\nnamespace {\n\nbool ContainsUnprintableControlCodes(const char* str, size_t length) {\n  const unsigned char *s = reinterpret_cast<const unsigned char *>(str);\n\n  for (size_t i = 0; i < length; i++) {\n    unsigned char ch = *s++;\n    if (std::iscntrl(ch)) {\n        switch (ch) {\n        case '\\t':\n        case '\\n':\n        case '\\r':\n          break;\n        default:\n          return true;\n        }\n      }\n  }\n  return false;\n}\n\nbool IsUTF8TrailByte(unsigned char t) { return 0x80 <= t && t<= 0xbf; }\n\nbool IsValidUTF8(const char* str, size_t length) {\n  const unsigned char *s = reinterpret_cast<const unsigned char *>(str);\n\n  for (size_t i = 0; i < length;) {\n    unsigned char lead = s[i++];\n\n    if (lead <= 0x7f) {\n      continue;  // single-byte character (ASCII) 0..7F\n    }\n    if (lead < 0xc2) {\n      return false;  // trail byte or non-shortest form\n    } else if (lead <= 0xdf && (i + 1) <= length && IsUTF8TrailByte(s[i])) {\n      ++i;  // 2-byte character\n    } else if (0xe0 <= lead && lead <= 0xef && (i + 2) <= length &&\n               IsUTF8TrailByte(s[i]) &&\n               IsUTF8TrailByte(s[i + 1]) &&\n               // check for non-shortest form and surrogate\n               (lead != 0xe0 || s[i] >= 0xa0) &&\n               (lead != 0xed || s[i] < 0xa0)) {\n      i += 2;  // 3-byte character\n    } else if (0xf0 <= lead && lead <= 0xf4 && (i + 3) <= length &&\n               IsUTF8TrailByte(s[i]) &&\n               IsUTF8TrailByte(s[i + 1]) &&\n               IsUTF8TrailByte(s[i + 2]) &&\n               // check for non-shortest form\n               (lead != 0xf0 || s[i] >= 0x90) &&\n               (lead != 0xf4 || s[i] < 0x90)) {\n      i += 3;  // 4-byte character\n    } else {\n      return false;\n    }\n  }\n  return true;\n}\n\nvoid ConditionalPrintAsText(const char* str, size_t length, ostream* os) {\n  if (!ContainsUnprintableControlCodes(str, length) &&\n      IsValidUTF8(str, length)) {\n    *os << \"\\n    As Text: \\\"\" << str << \"\\\"\";\n  }\n}\n\n}  // anonymous namespace\n\nvoid PrintStringTo(const ::std::string& s, ostream* os) {\n  if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {\n    if (GTEST_FLAG(print_utf8)) {\n      ConditionalPrintAsText(s.data(), s.size(), os);\n    }\n  }\n}\n\n#ifdef __cpp_char8_t\nvoid PrintU8StringTo(const ::std::u8string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif\n\nvoid PrintU16StringTo(const ::std::u16string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n\nvoid PrintU32StringTo(const ::std::u32string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n\n#if GTEST_HAS_STD_WSTRING\nvoid PrintWideStringTo(const ::std::wstring& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n}  // namespace internal\n\n}  // namespace testing\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n\n\n\nnamespace testing {\n\nusing internal::GetUnitTestImpl;\n\n// Gets the summary of the failure message by omitting the stack trace\n// in it.\nstd::string TestPartResult::ExtractSummary(const char* message) {\n  const char* const stack_trace = strstr(message, internal::kStackTraceMarker);\n  return stack_trace == nullptr ? message : std::string(message, stack_trace);\n}\n\n// Prints a TestPartResult object.\nstd::ostream& operator<<(std::ostream& os, const TestPartResult& result) {\n  return os << internal::FormatFileLocation(result.file_name(),\n                                            result.line_number())\n            << \" \"\n            << (result.type() == TestPartResult::kSuccess\n                    ? \"Success\"\n                    : result.type() == TestPartResult::kSkip\n                          ? \"Skipped\"\n                          : result.type() == TestPartResult::kFatalFailure\n                                ? \"Fatal failure\"\n                                : \"Non-fatal failure\")\n            << \":\\n\"\n            << result.message() << std::endl;\n}\n\n// Appends a TestPartResult to the array.\nvoid TestPartResultArray::Append(const TestPartResult& result) {\n  array_.push_back(result);\n}\n\n// Returns the TestPartResult at the given index (0-based).\nconst TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {\n  if (index < 0 || index >= size()) {\n    printf(\"\\nInvalid index (%d) into TestPartResultArray.\\n\", index);\n    internal::posix::Abort();\n  }\n\n  return array_[static_cast<size_t>(index)];\n}\n\n// Returns the number of TestPartResult objects in the array.\nint TestPartResultArray::size() const {\n  return static_cast<int>(array_.size());\n}\n\nnamespace internal {\n\nHasNewFatalFailureHelper::HasNewFatalFailureHelper()\n    : has_new_fatal_failure_(false),\n      original_reporter_(GetUnitTestImpl()->\n                         GetTestPartResultReporterForCurrentThread()) {\n  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);\n}\n\nHasNewFatalFailureHelper::~HasNewFatalFailureHelper() {\n  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(\n      original_reporter_);\n}\n\nvoid HasNewFatalFailureHelper::ReportTestPartResult(\n    const TestPartResult& result) {\n  if (result.fatally_failed())\n    has_new_fatal_failure_ = true;\n  original_reporter_->ReportTestPartResult(result);\n}\n\n}  // namespace internal\n\n}  // namespace testing\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n\nnamespace testing {\nnamespace internal {\n\n// Skips to the first non-space char in str. Returns an empty string if str\n// contains only whitespace characters.\nstatic const char* SkipSpaces(const char* str) {\n  while (IsSpace(*str))\n    str++;\n  return str;\n}\n\nstatic std::vector<std::string> SplitIntoTestNames(const char* src) {\n  std::vector<std::string> name_vec;\n  src = SkipSpaces(src);\n  for (; src != nullptr; src = SkipComma(src)) {\n    name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src)));\n  }\n  return name_vec;\n}\n\n// Verifies that registered_tests match the test names in\n// registered_tests_; returns registered_tests if successful, or\n// aborts the program otherwise.\nconst char* TypedTestSuitePState::VerifyRegisteredTestNames(\n    const char* test_suite_name, const char* file, int line,\n    const char* registered_tests) {\n  RegisterTypeParameterizedTestSuite(test_suite_name, CodeLocation(file, line));\n\n  typedef RegisteredTestsMap::const_iterator RegisteredTestIter;\n  registered_ = true;\n\n  std::vector<std::string> name_vec = SplitIntoTestNames(registered_tests);\n\n  Message errors;\n\n  std::set<std::string> tests;\n  for (std::vector<std::string>::const_iterator name_it = name_vec.begin();\n       name_it != name_vec.end(); ++name_it) {\n    const std::string& name = *name_it;\n    if (tests.count(name) != 0) {\n      errors << \"Test \" << name << \" is listed more than once.\\n\";\n      continue;\n    }\n\n    if (registered_tests_.count(name) != 0) {\n      tests.insert(name);\n    } else {\n      errors << \"No test named \" << name\n             << \" can be found in this test suite.\\n\";\n    }\n  }\n\n  for (RegisteredTestIter it = registered_tests_.begin();\n       it != registered_tests_.end();\n       ++it) {\n    if (tests.count(it->first) == 0) {\n      errors << \"You forgot to list test \" << it->first << \".\\n\";\n    }\n  }\n\n  const std::string& errors_str = errors.GetString();\n  if (errors_str != \"\") {\n    fprintf(stderr, \"%s %s\", FormatFileLocation(file, line).c_str(),\n            errors_str.c_str());\n    fflush(stderr);\n    posix::Abort();\n  }\n\n  return registered_tests;\n}\n\n}  // namespace internal\n}  // namespace testing\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// Google C++ Mocking Framework (Google Mock)\n//\n// This file #includes all Google Mock implementation .cc files.  The\n// purpose is to allow a user to build Google Mock by compiling this\n// file alone.\n\n// This line ensures that gmock.h can be compiled on its own, even\n// when it's fused.\n#include \"gmock/gmock.h\"\n\n// The following lines pull in the real gmock *.cc files.\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements cardinalities.\n\n\n#include <limits.h>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n\nnamespace testing {\n\nnamespace {\n\n// Implements the Between(m, n) cardinality.\nclass BetweenCardinalityImpl : public CardinalityInterface {\n public:\n  BetweenCardinalityImpl(int min, int max)\n      : min_(min >= 0 ? min : 0),\n        max_(max >= min_ ? max : min_) {\n    std::stringstream ss;\n    if (min < 0) {\n      ss << \"The invocation lower bound must be >= 0, \"\n         << \"but is actually \" << min << \".\";\n      internal::Expect(false, __FILE__, __LINE__, ss.str());\n    } else if (max < 0) {\n      ss << \"The invocation upper bound must be >= 0, \"\n         << \"but is actually \" << max << \".\";\n      internal::Expect(false, __FILE__, __LINE__, ss.str());\n    } else if (min > max) {\n      ss << \"The invocation upper bound (\" << max\n         << \") must be >= the invocation lower bound (\" << min\n         << \").\";\n      internal::Expect(false, __FILE__, __LINE__, ss.str());\n    }\n  }\n\n  // Conservative estimate on the lower/upper bound of the number of\n  // calls allowed.\n  int ConservativeLowerBound() const override { return min_; }\n  int ConservativeUpperBound() const override { return max_; }\n\n  bool IsSatisfiedByCallCount(int call_count) const override {\n    return min_ <= call_count && call_count <= max_;\n  }\n\n  bool IsSaturatedByCallCount(int call_count) const override {\n    return call_count >= max_;\n  }\n\n  void DescribeTo(::std::ostream* os) const override;\n\n private:\n  const int min_;\n  const int max_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl);\n};\n\n// Formats \"n times\" in a human-friendly way.\ninline std::string FormatTimes(int n) {\n  if (n == 1) {\n    return \"once\";\n  } else if (n == 2) {\n    return \"twice\";\n  } else {\n    std::stringstream ss;\n    ss << n << \" times\";\n    return ss.str();\n  }\n}\n\n// Describes the Between(m, n) cardinality in human-friendly text.\nvoid BetweenCardinalityImpl::DescribeTo(::std::ostream* os) const {\n  if (min_ == 0) {\n    if (max_ == 0) {\n      *os << \"never called\";\n    } else if (max_ == INT_MAX) {\n      *os << \"called any number of times\";\n    } else {\n      *os << \"called at most \" << FormatTimes(max_);\n    }\n  } else if (min_ == max_) {\n    *os << \"called \" << FormatTimes(min_);\n  } else if (max_ == INT_MAX) {\n    *os << \"called at least \" << FormatTimes(min_);\n  } else {\n    // 0 < min_ < max_ < INT_MAX\n    *os << \"called between \" << min_ << \" and \" << max_ << \" times\";\n  }\n}\n\n}  // Unnamed namespace\n\n// Describes the given call count to an ostream.\nvoid Cardinality::DescribeActualCallCountTo(int actual_call_count,\n                                            ::std::ostream* os) {\n  if (actual_call_count > 0) {\n    *os << \"called \" << FormatTimes(actual_call_count);\n  } else {\n    *os << \"never called\";\n  }\n}\n\n// Creates a cardinality that allows at least n calls.\nGTEST_API_ Cardinality AtLeast(int n) { return Between(n, INT_MAX); }\n\n// Creates a cardinality that allows at most n calls.\nGTEST_API_ Cardinality AtMost(int n) { return Between(0, n); }\n\n// Creates a cardinality that allows any number of calls.\nGTEST_API_ Cardinality AnyNumber() { return AtLeast(0); }\n\n// Creates a cardinality that allows between min and max calls.\nGTEST_API_ Cardinality Between(int min, int max) {\n  return Cardinality(new BetweenCardinalityImpl(min, max));\n}\n\n// Creates a cardinality that allows exactly n calls.\nGTEST_API_ Cardinality Exactly(int n) { return Between(n, n); }\n\n}  // namespace testing\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file defines some utilities useful for implementing Google\n// Mock.  They are subject to change without notice, so please DO NOT\n// USE THEM IN USER CODE.\n\n\n#include <ctype.h>\n#include <ostream>  // NOLINT\n#include <string>\n\nnamespace testing {\nnamespace internal {\n\n// Joins a vector of strings as if they are fields of a tuple; returns\n// the joined string.\nGTEST_API_ std::string JoinAsTuple(const Strings& fields) {\n  switch (fields.size()) {\n    case 0:\n      return \"\";\n    case 1:\n      return fields[0];\n    default:\n      std::string result = \"(\" + fields[0];\n      for (size_t i = 1; i < fields.size(); i++) {\n        result += \", \";\n        result += fields[i];\n      }\n      result += \")\";\n      return result;\n  }\n}\n\n// Converts an identifier name to a space-separated list of lower-case\n// words.  Each maximum substring of the form [A-Za-z][a-z]*|\\d+ is\n// treated as one word.  For example, both \"FooBar123\" and\n// \"foo_bar_123\" are converted to \"foo bar 123\".\nGTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {\n  std::string result;\n  char prev_char = '\\0';\n  for (const char* p = id_name; *p != '\\0'; prev_char = *(p++)) {\n    // We don't care about the current locale as the input is\n    // guaranteed to be a valid C++ identifier name.\n    const bool starts_new_word = IsUpper(*p) ||\n        (!IsAlpha(prev_char) && IsLower(*p)) ||\n        (!IsDigit(prev_char) && IsDigit(*p));\n\n    if (IsAlNum(*p)) {\n      if (starts_new_word && result != \"\")\n        result += ' ';\n      result += ToLower(*p);\n    }\n  }\n  return result;\n}\n\n// This class reports Google Mock failures as Google Test failures.  A\n// user can define another class in a similar fashion if they intend to\n// use Google Mock with a testing framework other than Google Test.\nclass GoogleTestFailureReporter : public FailureReporterInterface {\n public:\n  void ReportFailure(FailureType type, const char* file, int line,\n                     const std::string& message) override {\n    AssertHelper(type == kFatal ?\n                 TestPartResult::kFatalFailure :\n                 TestPartResult::kNonFatalFailure,\n                 file,\n                 line,\n                 message.c_str()) = Message();\n    if (type == kFatal) {\n      posix::Abort();\n    }\n  }\n};\n\n// Returns the global failure reporter.  Will create a\n// GoogleTestFailureReporter and return it the first time called.\nGTEST_API_ FailureReporterInterface* GetFailureReporter() {\n  // Points to the global failure reporter used by Google Mock.  gcc\n  // guarantees that the following use of failure_reporter is\n  // thread-safe.  We may need to add additional synchronization to\n  // protect failure_reporter if we port Google Mock to other\n  // compilers.\n  static FailureReporterInterface* const failure_reporter =\n      new GoogleTestFailureReporter();\n  return failure_reporter;\n}\n\n// Protects global resources (stdout in particular) used by Log().\nstatic GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);\n\n// Returns true if and only if a log with the given severity is visible\n// according to the --gmock_verbose flag.\nGTEST_API_ bool LogIsVisible(LogSeverity severity) {\n  if (GMOCK_FLAG(verbose) == kInfoVerbosity) {\n    // Always show the log if --gmock_verbose=info.\n    return true;\n  } else if (GMOCK_FLAG(verbose) == kErrorVerbosity) {\n    // Always hide it if --gmock_verbose=error.\n    return false;\n  } else {\n    // If --gmock_verbose is neither \"info\" nor \"error\", we treat it\n    // as \"warning\" (its default value).\n    return severity == kWarning;\n  }\n}\n\n// Prints the given message to stdout if and only if 'severity' >= the level\n// specified by the --gmock_verbose flag.  If stack_frames_to_skip >=\n// 0, also prints the stack trace excluding the top\n// stack_frames_to_skip frames.  In opt mode, any positive\n// stack_frames_to_skip is treated as 0, since we don't know which\n// function calls will be inlined by the compiler and need to be\n// conservative.\nGTEST_API_ void Log(LogSeverity severity, const std::string& message,\n                    int stack_frames_to_skip) {\n  if (!LogIsVisible(severity))\n    return;\n\n  // Ensures that logs from different threads don't interleave.\n  MutexLock l(&g_log_mutex);\n\n  if (severity == kWarning) {\n    // Prints a GMOCK WARNING marker to make the warnings easily searchable.\n    std::cout << \"\\nGMOCK WARNING:\";\n  }\n  // Pre-pends a new-line to message if it doesn't start with one.\n  if (message.empty() || message[0] != '\\n') {\n    std::cout << \"\\n\";\n  }\n  std::cout << message;\n  if (stack_frames_to_skip >= 0) {\n#ifdef NDEBUG\n    // In opt mode, we have to be conservative and skip no stack frame.\n    const int actual_to_skip = 0;\n#else\n    // In dbg mode, we can do what the caller tell us to do (plus one\n    // for skipping this function's stack frame).\n    const int actual_to_skip = stack_frames_to_skip + 1;\n#endif  // NDEBUG\n\n    // Appends a new-line to message if it doesn't end with one.\n    if (!message.empty() && *message.rbegin() != '\\n') {\n      std::cout << \"\\n\";\n    }\n    std::cout << \"Stack trace:\\n\"\n         << ::testing::internal::GetCurrentOsStackTraceExceptTop(\n             ::testing::UnitTest::GetInstance(), actual_to_skip);\n  }\n  std::cout << ::std::flush;\n}\n\nGTEST_API_ WithoutMatchers GetWithoutMatchers() { return WithoutMatchers(); }\n\nGTEST_API_ void IllegalDoDefault(const char* file, int line) {\n  internal::Assert(\n      false, file, line,\n      \"You are using DoDefault() inside a composite action like \"\n      \"DoAll() or WithArgs().  This is not supported for technical \"\n      \"reasons.  Please instead spell out the default action, or \"\n      \"assign the default action to an Action variable and use \"\n      \"the variable in various places.\");\n}\n\n}  // namespace internal\n}  // namespace testing\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements Matcher<const string&>, Matcher<string>, and\n// utilities for defining matchers.\n\n\n#include <string.h>\n#include <iostream>\n#include <sstream>\n#include <string>\n\nnamespace testing {\nnamespace internal {\n\n// Returns the description for a matcher defined using the MATCHER*()\n// macro where the user-supplied description string is \"\", if\n// 'negation' is false; otherwise returns the description of the\n// negation of the matcher.  'param_values' contains a list of strings\n// that are the print-out of the matcher's parameters.\nGTEST_API_ std::string FormatMatcherDescription(bool negation,\n                                                const char* matcher_name,\n                                                const Strings& param_values) {\n  std::string result = ConvertIdentifierNameToWords(matcher_name);\n  if (param_values.size() >= 1) result += \" \" + JoinAsTuple(param_values);\n  return negation ? \"not (\" + result + \")\" : result;\n}\n\n// FindMaxBipartiteMatching and its helper class.\n//\n// Uses the well-known Ford-Fulkerson max flow method to find a maximum\n// bipartite matching. Flow is considered to be from left to right.\n// There is an implicit source node that is connected to all of the left\n// nodes, and an implicit sink node that is connected to all of the\n// right nodes. All edges have unit capacity.\n//\n// Neither the flow graph nor the residual flow graph are represented\n// explicitly. Instead, they are implied by the information in 'graph' and\n// a vector<int> called 'left_' whose elements are initialized to the\n// value kUnused. This represents the initial state of the algorithm,\n// where the flow graph is empty, and the residual flow graph has the\n// following edges:\n//   - An edge from source to each left_ node\n//   - An edge from each right_ node to sink\n//   - An edge from each left_ node to each right_ node, if the\n//     corresponding edge exists in 'graph'.\n//\n// When the TryAugment() method adds a flow, it sets left_[l] = r for some\n// nodes l and r. This induces the following changes:\n//   - The edges (source, l), (l, r), and (r, sink) are added to the\n//     flow graph.\n//   - The same three edges are removed from the residual flow graph.\n//   - The reverse edges (l, source), (r, l), and (sink, r) are added\n//     to the residual flow graph, which is a directional graph\n//     representing unused flow capacity.\n//\n// When the method augments a flow (moving left_[l] from some r1 to some\n// other r2), this can be thought of as \"undoing\" the above steps with\n// respect to r1 and \"redoing\" them with respect to r2.\n//\n// It bears repeating that the flow graph and residual flow graph are\n// never represented explicitly, but can be derived by looking at the\n// information in 'graph' and in left_.\n//\n// As an optimization, there is a second vector<int> called right_ which\n// does not provide any new information. Instead, it enables more\n// efficient queries about edges entering or leaving the right-side nodes\n// of the flow or residual flow graphs. The following invariants are\n// maintained:\n//\n// left[l] == kUnused or right[left[l]] == l\n// right[r] == kUnused or left[right[r]] == r\n//\n// . [ source ]                                        .\n// .   |||                                             .\n// .   |||                                             .\n// .   ||\\--> left[0]=1  ---\\    right[0]=-1 ----\\     .\n// .   ||                   |                    |     .\n// .   |\\---> left[1]=-1    \\--> right[1]=0  ---\\|     .\n// .   |                                        ||     .\n// .   \\----> left[2]=2  ------> right[2]=2  --\\||     .\n// .                                           |||     .\n// .         elements           matchers       vvv     .\n// .                                         [ sink ]  .\n//\n// See Also:\n//   [1] Cormen, et al (2001). \"Section 26.2: The Ford-Fulkerson method\".\n//       \"Introduction to Algorithms (Second ed.)\", pp. 651-664.\n//   [2] \"Ford-Fulkerson algorithm\", Wikipedia,\n//       'http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm'\nclass MaxBipartiteMatchState {\n public:\n  explicit MaxBipartiteMatchState(const MatchMatrix& graph)\n      : graph_(&graph),\n        left_(graph_->LhsSize(), kUnused),\n        right_(graph_->RhsSize(), kUnused) {}\n\n  // Returns the edges of a maximal match, each in the form {left, right}.\n  ElementMatcherPairs Compute() {\n    // 'seen' is used for path finding { 0: unseen, 1: seen }.\n    ::std::vector<char> seen;\n    // Searches the residual flow graph for a path from each left node to\n    // the sink in the residual flow graph, and if one is found, add flow\n    // to the graph. It's okay to search through the left nodes once. The\n    // edge from the implicit source node to each previously-visited left\n    // node will have flow if that left node has any path to the sink\n    // whatsoever. Subsequent augmentations can only add flow to the\n    // network, and cannot take away that previous flow unit from the source.\n    // Since the source-to-left edge can only carry one flow unit (or,\n    // each element can be matched to only one matcher), there is no need\n    // to visit the left nodes more than once looking for augmented paths.\n    // The flow is known to be possible or impossible by looking at the\n    // node once.\n    for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {\n      // Reset the path-marking vector and try to find a path from\n      // source to sink starting at the left_[ilhs] node.\n      GTEST_CHECK_(left_[ilhs] == kUnused)\n          << \"ilhs: \" << ilhs << \", left_[ilhs]: \" << left_[ilhs];\n      // 'seen' initialized to 'graph_->RhsSize()' copies of 0.\n      seen.assign(graph_->RhsSize(), 0);\n      TryAugment(ilhs, &seen);\n    }\n    ElementMatcherPairs result;\n    for (size_t ilhs = 0; ilhs < left_.size(); ++ilhs) {\n      size_t irhs = left_[ilhs];\n      if (irhs == kUnused) continue;\n      result.push_back(ElementMatcherPair(ilhs, irhs));\n    }\n    return result;\n  }\n\n private:\n  static const size_t kUnused = static_cast<size_t>(-1);\n\n  // Perform a depth-first search from left node ilhs to the sink.  If a\n  // path is found, flow is added to the network by linking the left and\n  // right vector elements corresponding each segment of the path.\n  // Returns true if a path to sink was found, which means that a unit of\n  // flow was added to the network. The 'seen' vector elements correspond\n  // to right nodes and are marked to eliminate cycles from the search.\n  //\n  // Left nodes will only be explored at most once because they\n  // are accessible from at most one right node in the residual flow\n  // graph.\n  //\n  // Note that left_[ilhs] is the only element of left_ that TryAugment will\n  // potentially transition from kUnused to another value. Any other\n  // left_ element holding kUnused before TryAugment will be holding it\n  // when TryAugment returns.\n  //\n  bool TryAugment(size_t ilhs, ::std::vector<char>* seen) {\n    for (size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) {\n      if ((*seen)[irhs]) continue;\n      if (!graph_->HasEdge(ilhs, irhs)) continue;\n      // There's an available edge from ilhs to irhs.\n      (*seen)[irhs] = 1;\n      // Next a search is performed to determine whether\n      // this edge is a dead end or leads to the sink.\n      //\n      // right_[irhs] == kUnused means that there is residual flow from\n      // right node irhs to the sink, so we can use that to finish this\n      // flow path and return success.\n      //\n      // Otherwise there is residual flow to some ilhs. We push flow\n      // along that path and call ourselves recursively to see if this\n      // ultimately leads to sink.\n      if (right_[irhs] == kUnused || TryAugment(right_[irhs], seen)) {\n        // Add flow from left_[ilhs] to right_[irhs].\n        left_[ilhs] = irhs;\n        right_[irhs] = ilhs;\n        return true;\n      }\n    }\n    return false;\n  }\n\n  const MatchMatrix* graph_;  // not owned\n  // Each element of the left_ vector represents a left hand side node\n  // (i.e. an element) and each element of right_ is a right hand side\n  // node (i.e. a matcher). The values in the left_ vector indicate\n  // outflow from that node to a node on the right_ side. The values\n  // in the right_ indicate inflow, and specify which left_ node is\n  // feeding that right_ node, if any. For example, left_[3] == 1 means\n  // there's a flow from element #3 to matcher #1. Such a flow would also\n  // be redundantly represented in the right_ vector as right_[1] == 3.\n  // Elements of left_ and right_ are either kUnused or mutually\n  // referent. Mutually referent means that left_[right_[i]] = i and\n  // right_[left_[i]] = i.\n  ::std::vector<size_t> left_;\n  ::std::vector<size_t> right_;\n};\n\nconst size_t MaxBipartiteMatchState::kUnused;\n\nGTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix& g) {\n  return MaxBipartiteMatchState(g).Compute();\n}\n\nstatic void LogElementMatcherPairVec(const ElementMatcherPairs& pairs,\n                                     ::std::ostream* stream) {\n  typedef ElementMatcherPairs::const_iterator Iter;\n  ::std::ostream& os = *stream;\n  os << \"{\";\n  const char* sep = \"\";\n  for (Iter it = pairs.begin(); it != pairs.end(); ++it) {\n    os << sep << \"\\n  (\"\n       << \"element #\" << it->first << \", \"\n       << \"matcher #\" << it->second << \")\";\n    sep = \",\";\n  }\n  os << \"\\n}\";\n}\n\nbool MatchMatrix::NextGraph() {\n  for (size_t ilhs = 0; ilhs < LhsSize(); ++ilhs) {\n    for (size_t irhs = 0; irhs < RhsSize(); ++irhs) {\n      char& b = matched_[SpaceIndex(ilhs, irhs)];\n      if (!b) {\n        b = 1;\n        return true;\n      }\n      b = 0;\n    }\n  }\n  return false;\n}\n\nvoid MatchMatrix::Randomize() {\n  for (size_t ilhs = 0; ilhs < LhsSize(); ++ilhs) {\n    for (size_t irhs = 0; irhs < RhsSize(); ++irhs) {\n      char& b = matched_[SpaceIndex(ilhs, irhs)];\n      b = static_cast<char>(rand() & 1);  // NOLINT\n    }\n  }\n}\n\nstd::string MatchMatrix::DebugString() const {\n  ::std::stringstream ss;\n  const char* sep = \"\";\n  for (size_t i = 0; i < LhsSize(); ++i) {\n    ss << sep;\n    for (size_t j = 0; j < RhsSize(); ++j) {\n      ss << HasEdge(i, j);\n    }\n    sep = \";\";\n  }\n  return ss.str();\n}\n\nvoid UnorderedElementsAreMatcherImplBase::DescribeToImpl(\n    ::std::ostream* os) const {\n  switch (match_flags()) {\n    case UnorderedMatcherRequire::ExactMatch:\n      if (matcher_describers_.empty()) {\n        *os << \"is empty\";\n        return;\n      }\n      if (matcher_describers_.size() == 1) {\n        *os << \"has \" << Elements(1) << \" and that element \";\n        matcher_describers_[0]->DescribeTo(os);\n        return;\n      }\n      *os << \"has \" << Elements(matcher_describers_.size())\n          << \" and there exists some permutation of elements such that:\\n\";\n      break;\n    case UnorderedMatcherRequire::Superset:\n      *os << \"a surjection from elements to requirements exists such that:\\n\";\n      break;\n    case UnorderedMatcherRequire::Subset:\n      *os << \"an injection from elements to requirements exists such that:\\n\";\n      break;\n  }\n\n  const char* sep = \"\";\n  for (size_t i = 0; i != matcher_describers_.size(); ++i) {\n    *os << sep;\n    if (match_flags() == UnorderedMatcherRequire::ExactMatch) {\n      *os << \" - element #\" << i << \" \";\n    } else {\n      *os << \" - an element \";\n    }\n    matcher_describers_[i]->DescribeTo(os);\n    if (match_flags() == UnorderedMatcherRequire::ExactMatch) {\n      sep = \", and\\n\";\n    } else {\n      sep = \"\\n\";\n    }\n  }\n}\n\nvoid UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(\n    ::std::ostream* os) const {\n  switch (match_flags()) {\n    case UnorderedMatcherRequire::ExactMatch:\n      if (matcher_describers_.empty()) {\n        *os << \"isn't empty\";\n        return;\n      }\n      if (matcher_describers_.size() == 1) {\n        *os << \"doesn't have \" << Elements(1) << \", or has \" << Elements(1)\n            << \" that \";\n        matcher_describers_[0]->DescribeNegationTo(os);\n        return;\n      }\n      *os << \"doesn't have \" << Elements(matcher_describers_.size())\n          << \", or there exists no permutation of elements such that:\\n\";\n      break;\n    case UnorderedMatcherRequire::Superset:\n      *os << \"no surjection from elements to requirements exists such that:\\n\";\n      break;\n    case UnorderedMatcherRequire::Subset:\n      *os << \"no injection from elements to requirements exists such that:\\n\";\n      break;\n  }\n  const char* sep = \"\";\n  for (size_t i = 0; i != matcher_describers_.size(); ++i) {\n    *os << sep;\n    if (match_flags() == UnorderedMatcherRequire::ExactMatch) {\n      *os << \" - element #\" << i << \" \";\n    } else {\n      *os << \" - an element \";\n    }\n    matcher_describers_[i]->DescribeTo(os);\n    if (match_flags() == UnorderedMatcherRequire::ExactMatch) {\n      sep = \", and\\n\";\n    } else {\n      sep = \"\\n\";\n    }\n  }\n}\n\n// Checks that all matchers match at least one element, and that all\n// elements match at least one matcher. This enables faster matching\n// and better error reporting.\n// Returns false, writing an explanation to 'listener', if and only\n// if the success criteria are not met.\nbool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(\n    const ::std::vector<std::string>& element_printouts,\n    const MatchMatrix& matrix, MatchResultListener* listener) const {\n  bool result = true;\n  ::std::vector<char> element_matched(matrix.LhsSize(), 0);\n  ::std::vector<char> matcher_matched(matrix.RhsSize(), 0);\n\n  for (size_t ilhs = 0; ilhs < matrix.LhsSize(); ilhs++) {\n    for (size_t irhs = 0; irhs < matrix.RhsSize(); irhs++) {\n      char matched = matrix.HasEdge(ilhs, irhs);\n      element_matched[ilhs] |= matched;\n      matcher_matched[irhs] |= matched;\n    }\n  }\n\n  if (match_flags() & UnorderedMatcherRequire::Superset) {\n    const char* sep =\n        \"where the following matchers don't match any elements:\\n\";\n    for (size_t mi = 0; mi < matcher_matched.size(); ++mi) {\n      if (matcher_matched[mi]) continue;\n      result = false;\n      if (listener->IsInterested()) {\n        *listener << sep << \"matcher #\" << mi << \": \";\n        matcher_describers_[mi]->DescribeTo(listener->stream());\n        sep = \",\\n\";\n      }\n    }\n  }\n\n  if (match_flags() & UnorderedMatcherRequire::Subset) {\n    const char* sep =\n        \"where the following elements don't match any matchers:\\n\";\n    const char* outer_sep = \"\";\n    if (!result) {\n      outer_sep = \"\\nand \";\n    }\n    for (size_t ei = 0; ei < element_matched.size(); ++ei) {\n      if (element_matched[ei]) continue;\n      result = false;\n      if (listener->IsInterested()) {\n        *listener << outer_sep << sep << \"element #\" << ei << \": \"\n                  << element_printouts[ei];\n        sep = \",\\n\";\n        outer_sep = \"\";\n      }\n    }\n  }\n  return result;\n}\n\nbool UnorderedElementsAreMatcherImplBase::FindPairing(\n    const MatchMatrix& matrix, MatchResultListener* listener) const {\n  ElementMatcherPairs matches = FindMaxBipartiteMatching(matrix);\n\n  size_t max_flow = matches.size();\n  if ((match_flags() & UnorderedMatcherRequire::Superset) &&\n      max_flow < matrix.RhsSize()) {\n    if (listener->IsInterested()) {\n      *listener << \"where no permutation of the elements can satisfy all \"\n                   \"matchers, and the closest match is \"\n                << max_flow << \" of \" << matrix.RhsSize()\n                << \" matchers with the pairings:\\n\";\n      LogElementMatcherPairVec(matches, listener->stream());\n    }\n    return false;\n  }\n  if ((match_flags() & UnorderedMatcherRequire::Subset) &&\n      max_flow < matrix.LhsSize()) {\n    if (listener->IsInterested()) {\n      *listener\n          << \"where not all elements can be matched, and the closest match is \"\n          << max_flow << \" of \" << matrix.RhsSize()\n          << \" matchers with the pairings:\\n\";\n      LogElementMatcherPairVec(matches, listener->stream());\n    }\n    return false;\n  }\n\n  if (matches.size() > 1) {\n    if (listener->IsInterested()) {\n      const char* sep = \"where:\\n\";\n      for (size_t mi = 0; mi < matches.size(); ++mi) {\n        *listener << sep << \" - element #\" << matches[mi].first\n                  << \" is matched by matcher #\" << matches[mi].second;\n        sep = \",\\n\";\n      }\n    }\n  }\n  return true;\n}\n\n}  // namespace internal\n}  // namespace testing\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements the spec builder syntax (ON_CALL and\n// EXPECT_CALL).\n\n\n#include <stdlib.h>\n\n#include <iostream>  // NOLINT\n#include <map>\n#include <memory>\n#include <set>\n#include <string>\n#include <unordered_map>\n#include <vector>\n\n\n#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC\n# include <unistd.h>  // NOLINT\n#endif\n\n// Silence C4800 (C4800: 'int *const ': forcing value\n// to bool 'true' or 'false') for MSVC 15\n#ifdef _MSC_VER\n#if _MSC_VER == 1900\n#  pragma warning(push)\n#  pragma warning(disable:4800)\n#endif\n#endif\n\nnamespace testing {\nnamespace internal {\n\n// Protects the mock object registry (in class Mock), all function\n// mockers, and all expectations.\nGTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex);\n\n// Logs a message including file and line number information.\nGTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,\n                                const char* file, int line,\n                                const std::string& message) {\n  ::std::ostringstream s;\n  s << internal::FormatFileLocation(file, line) << \" \" << message\n    << ::std::endl;\n  Log(severity, s.str(), 0);\n}\n\n// Constructs an ExpectationBase object.\nExpectationBase::ExpectationBase(const char* a_file, int a_line,\n                                 const std::string& a_source_text)\n    : file_(a_file),\n      line_(a_line),\n      source_text_(a_source_text),\n      cardinality_specified_(false),\n      cardinality_(Exactly(1)),\n      call_count_(0),\n      retired_(false),\n      extra_matcher_specified_(false),\n      repeated_action_specified_(false),\n      retires_on_saturation_(false),\n      last_clause_(kNone),\n      action_count_checked_(false) {}\n\n// Destructs an ExpectationBase object.\nExpectationBase::~ExpectationBase() {}\n\n// Explicitly specifies the cardinality of this expectation.  Used by\n// the subclasses to implement the .Times() clause.\nvoid ExpectationBase::SpecifyCardinality(const Cardinality& a_cardinality) {\n  cardinality_specified_ = true;\n  cardinality_ = a_cardinality;\n}\n\n// Retires all pre-requisites of this expectation.\nvoid ExpectationBase::RetireAllPreRequisites()\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  if (is_retired()) {\n    // We can take this short-cut as we never retire an expectation\n    // until we have retired all its pre-requisites.\n    return;\n  }\n\n  ::std::vector<ExpectationBase*> expectations(1, this);\n  while (!expectations.empty()) {\n    ExpectationBase* exp = expectations.back();\n    expectations.pop_back();\n\n    for (ExpectationSet::const_iterator it =\n             exp->immediate_prerequisites_.begin();\n         it != exp->immediate_prerequisites_.end(); ++it) {\n      ExpectationBase* next = it->expectation_base().get();\n      if (!next->is_retired()) {\n        next->Retire();\n        expectations.push_back(next);\n      }\n    }\n  }\n}\n\n// Returns true if and only if all pre-requisites of this expectation\n// have been satisfied.\nbool ExpectationBase::AllPrerequisitesAreSatisfied() const\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n  ::std::vector<const ExpectationBase*> expectations(1, this);\n  while (!expectations.empty()) {\n    const ExpectationBase* exp = expectations.back();\n    expectations.pop_back();\n\n    for (ExpectationSet::const_iterator it =\n             exp->immediate_prerequisites_.begin();\n         it != exp->immediate_prerequisites_.end(); ++it) {\n      const ExpectationBase* next = it->expectation_base().get();\n      if (!next->IsSatisfied()) return false;\n      expectations.push_back(next);\n    }\n  }\n  return true;\n}\n\n// Adds unsatisfied pre-requisites of this expectation to 'result'.\nvoid ExpectationBase::FindUnsatisfiedPrerequisites(ExpectationSet* result) const\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n  ::std::vector<const ExpectationBase*> expectations(1, this);\n  while (!expectations.empty()) {\n    const ExpectationBase* exp = expectations.back();\n    expectations.pop_back();\n\n    for (ExpectationSet::const_iterator it =\n             exp->immediate_prerequisites_.begin();\n         it != exp->immediate_prerequisites_.end(); ++it) {\n      const ExpectationBase* next = it->expectation_base().get();\n\n      if (next->IsSatisfied()) {\n        // If *it is satisfied and has a call count of 0, some of its\n        // pre-requisites may not be satisfied yet.\n        if (next->call_count_ == 0) {\n          expectations.push_back(next);\n        }\n      } else {\n        // Now that we know next is unsatisfied, we are not so interested\n        // in whether its pre-requisites are satisfied.  Therefore we\n        // don't iterate into it here.\n        *result += *it;\n      }\n    }\n  }\n}\n\n// Describes how many times a function call matching this\n// expectation has occurred.\nvoid ExpectationBase::DescribeCallCountTo(::std::ostream* os) const\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n\n  // Describes how many times the function is expected to be called.\n  *os << \"         Expected: to be \";\n  cardinality().DescribeTo(os);\n  *os << \"\\n           Actual: \";\n  Cardinality::DescribeActualCallCountTo(call_count(), os);\n\n  // Describes the state of the expectation (e.g. is it satisfied?\n  // is it active?).\n  *os << \" - \" << (IsOverSaturated() ? \"over-saturated\" :\n                   IsSaturated() ? \"saturated\" :\n                   IsSatisfied() ? \"satisfied\" : \"unsatisfied\")\n      << \" and \"\n      << (is_retired() ? \"retired\" : \"active\");\n}\n\n// Checks the action count (i.e. the number of WillOnce() and\n// WillRepeatedly() clauses) against the cardinality if this hasn't\n// been done before.  Prints a warning if there are too many or too\n// few actions.\nvoid ExpectationBase::CheckActionCountIfNotDone() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  bool should_check = false;\n  {\n    MutexLock l(&mutex_);\n    if (!action_count_checked_) {\n      action_count_checked_ = true;\n      should_check = true;\n    }\n  }\n\n  if (should_check) {\n    if (!cardinality_specified_) {\n      // The cardinality was inferred - no need to check the action\n      // count against it.\n      return;\n    }\n\n    // The cardinality was explicitly specified.\n    const int action_count = static_cast<int>(untyped_actions_.size());\n    const int upper_bound = cardinality().ConservativeUpperBound();\n    const int lower_bound = cardinality().ConservativeLowerBound();\n    bool too_many;  // True if there are too many actions, or false\n    // if there are too few.\n    if (action_count > upper_bound ||\n        (action_count == upper_bound && repeated_action_specified_)) {\n      too_many = true;\n    } else if (0 < action_count && action_count < lower_bound &&\n               !repeated_action_specified_) {\n      too_many = false;\n    } else {\n      return;\n    }\n\n    ::std::stringstream ss;\n    DescribeLocationTo(&ss);\n    ss << \"Too \" << (too_many ? \"many\" : \"few\")\n       << \" actions specified in \" << source_text() << \"...\\n\"\n       << \"Expected to be \";\n    cardinality().DescribeTo(&ss);\n    ss << \", but has \" << (too_many ? \"\" : \"only \")\n       << action_count << \" WillOnce()\"\n       << (action_count == 1 ? \"\" : \"s\");\n    if (repeated_action_specified_) {\n      ss << \" and a WillRepeatedly()\";\n    }\n    ss << \".\";\n    Log(kWarning, ss.str(), -1);  // -1 means \"don't print stack trace\".\n  }\n}\n\n// Implements the .Times() clause.\nvoid ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) {\n  if (last_clause_ == kTimes) {\n    ExpectSpecProperty(false,\n                       \".Times() cannot appear \"\n                       \"more than once in an EXPECT_CALL().\");\n  } else {\n    ExpectSpecProperty(last_clause_ < kTimes,\n                       \".Times() cannot appear after \"\n                       \".InSequence(), .WillOnce(), .WillRepeatedly(), \"\n                       \"or .RetiresOnSaturation().\");\n  }\n  last_clause_ = kTimes;\n\n  SpecifyCardinality(a_cardinality);\n}\n\n// Points to the implicit sequence introduced by a living InSequence\n// object (if any) in the current thread or NULL.\nGTEST_API_ ThreadLocal<Sequence*> g_gmock_implicit_sequence;\n\n// Reports an uninteresting call (whose description is in msg) in the\n// manner specified by 'reaction'.\nvoid ReportUninterestingCall(CallReaction reaction, const std::string& msg) {\n  // Include a stack trace only if --gmock_verbose=info is specified.\n  const int stack_frames_to_skip =\n      GMOCK_FLAG(verbose) == kInfoVerbosity ? 3 : -1;\n  switch (reaction) {\n    case kAllow:\n      Log(kInfo, msg, stack_frames_to_skip);\n      break;\n    case kWarn:\n      Log(kWarning,\n          msg +\n              \"\\nNOTE: You can safely ignore the above warning unless this \"\n              \"call should not happen.  Do not suppress it by blindly adding \"\n              \"an EXPECT_CALL() if you don't mean to enforce the call.  \"\n              \"See \"\n              \"https://github.com/google/googletest/blob/master/docs/\"\n              \"gmock_cook_book.md#\"\n              \"knowing-when-to-expect for details.\\n\",\n          stack_frames_to_skip);\n      break;\n    default:  // FAIL\n      Expect(false, nullptr, -1, msg);\n  }\n}\n\nUntypedFunctionMockerBase::UntypedFunctionMockerBase()\n    : mock_obj_(nullptr), name_(\"\") {}\n\nUntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}\n\n// Sets the mock object this mock method belongs to, and registers\n// this information in the global mock registry.  Will be called\n// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock\n// method.\nvoid UntypedFunctionMockerBase::RegisterOwner(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  {\n    MutexLock l(&g_gmock_mutex);\n    mock_obj_ = mock_obj;\n  }\n  Mock::Register(mock_obj, this);\n}\n\n// Sets the mock object this mock method belongs to, and sets the name\n// of the mock function.  Will be called upon each invocation of this\n// mock function.\nvoid UntypedFunctionMockerBase::SetOwnerAndName(const void* mock_obj,\n                                                const char* name)\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  // We protect name_ under g_gmock_mutex in case this mock function\n  // is called from two threads concurrently.\n  MutexLock l(&g_gmock_mutex);\n  mock_obj_ = mock_obj;\n  name_ = name;\n}\n\n// Returns the name of the function being mocked.  Must be called\n// after RegisterOwner() or SetOwnerAndName() has been called.\nconst void* UntypedFunctionMockerBase::MockObject() const\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  const void* mock_obj;\n  {\n    // We protect mock_obj_ under g_gmock_mutex in case this mock\n    // function is called from two threads concurrently.\n    MutexLock l(&g_gmock_mutex);\n    Assert(mock_obj_ != nullptr, __FILE__, __LINE__,\n           \"MockObject() must not be called before RegisterOwner() or \"\n           \"SetOwnerAndName() has been called.\");\n    mock_obj = mock_obj_;\n  }\n  return mock_obj;\n}\n\n// Returns the name of this mock method.  Must be called after\n// SetOwnerAndName() has been called.\nconst char* UntypedFunctionMockerBase::Name() const\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  const char* name;\n  {\n    // We protect name_ under g_gmock_mutex in case this mock\n    // function is called from two threads concurrently.\n    MutexLock l(&g_gmock_mutex);\n    Assert(name_ != nullptr, __FILE__, __LINE__,\n           \"Name() must not be called before SetOwnerAndName() has \"\n           \"been called.\");\n    name = name_;\n  }\n  return name;\n}\n\n// Calculates the result of invoking this mock function with the given\n// arguments, prints it, and returns it.  The caller is responsible\n// for deleting the result.\nUntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(\n    void* const untyped_args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  // See the definition of untyped_expectations_ for why access to it\n  // is unprotected here.\n  if (untyped_expectations_.size() == 0) {\n    // No expectation is set on this mock method - we have an\n    // uninteresting call.\n\n    // We must get Google Mock's reaction on uninteresting calls\n    // made on this mock object BEFORE performing the action,\n    // because the action may DELETE the mock object and make the\n    // following expression meaningless.\n    const CallReaction reaction =\n        Mock::GetReactionOnUninterestingCalls(MockObject());\n\n    // True if and only if we need to print this call's arguments and return\n    // value.  This definition must be kept in sync with\n    // the behavior of ReportUninterestingCall().\n    const bool need_to_report_uninteresting_call =\n        // If the user allows this uninteresting call, we print it\n        // only when they want informational messages.\n        reaction == kAllow ? LogIsVisible(kInfo) :\n                           // If the user wants this to be a warning, we print\n                           // it only when they want to see warnings.\n            reaction == kWarn\n                ? LogIsVisible(kWarning)\n                :\n                // Otherwise, the user wants this to be an error, and we\n                // should always print detailed information in the error.\n                true;\n\n    if (!need_to_report_uninteresting_call) {\n      // Perform the action without printing the call information.\n      return this->UntypedPerformDefaultAction(\n          untyped_args, \"Function call: \" + std::string(Name()));\n    }\n\n    // Warns about the uninteresting call.\n    ::std::stringstream ss;\n    this->UntypedDescribeUninterestingCall(untyped_args, &ss);\n\n    // Calculates the function result.\n    UntypedActionResultHolderBase* const result =\n        this->UntypedPerformDefaultAction(untyped_args, ss.str());\n\n    // Prints the function result.\n    if (result != nullptr) result->PrintAsActionResult(&ss);\n\n    ReportUninterestingCall(reaction, ss.str());\n    return result;\n  }\n\n  bool is_excessive = false;\n  ::std::stringstream ss;\n  ::std::stringstream why;\n  ::std::stringstream loc;\n  const void* untyped_action = nullptr;\n\n  // The UntypedFindMatchingExpectation() function acquires and\n  // releases g_gmock_mutex.\n\n  const ExpectationBase* const untyped_expectation =\n      this->UntypedFindMatchingExpectation(untyped_args, &untyped_action,\n                                           &is_excessive, &ss, &why);\n  const bool found = untyped_expectation != nullptr;\n\n  // True if and only if we need to print the call's arguments\n  // and return value.\n  // This definition must be kept in sync with the uses of Expect()\n  // and Log() in this function.\n  const bool need_to_report_call =\n      !found || is_excessive || LogIsVisible(kInfo);\n  if (!need_to_report_call) {\n    // Perform the action without printing the call information.\n    return untyped_action == nullptr\n               ? this->UntypedPerformDefaultAction(untyped_args, \"\")\n               : this->UntypedPerformAction(untyped_action, untyped_args);\n  }\n\n  ss << \"    Function call: \" << Name();\n  this->UntypedPrintArgs(untyped_args, &ss);\n\n  // In case the action deletes a piece of the expectation, we\n  // generate the message beforehand.\n  if (found && !is_excessive) {\n    untyped_expectation->DescribeLocationTo(&loc);\n  }\n\n  UntypedActionResultHolderBase* result = nullptr;\n\n  auto perform_action = [&, this] {\n    return untyped_action == nullptr\n               ? this->UntypedPerformDefaultAction(untyped_args, ss.str())\n               : this->UntypedPerformAction(untyped_action, untyped_args);\n  };\n  auto handle_failures = [&] {\n    ss << \"\\n\" << why.str();\n\n    if (!found) {\n      // No expectation matches this call - reports a failure.\n      Expect(false, nullptr, -1, ss.str());\n    } else if (is_excessive) {\n      // We had an upper-bound violation and the failure message is in ss.\n      Expect(false, untyped_expectation->file(), untyped_expectation->line(),\n             ss.str());\n    } else {\n      // We had an expected call and the matching expectation is\n      // described in ss.\n      Log(kInfo, loc.str() + ss.str(), 2);\n    }\n  };\n#if GTEST_HAS_EXCEPTIONS\n  try {\n    result = perform_action();\n  } catch (...) {\n    handle_failures();\n    throw;\n  }\n#else\n  result = perform_action();\n#endif\n\n  if (result != nullptr) result->PrintAsActionResult(&ss);\n  handle_failures();\n  return result;\n}\n\n// Returns an Expectation object that references and co-owns exp,\n// which must be an expectation on this mock function.\nExpectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) {\n  // See the definition of untyped_expectations_ for why access to it\n  // is unprotected here.\n  for (UntypedExpectations::const_iterator it =\n           untyped_expectations_.begin();\n       it != untyped_expectations_.end(); ++it) {\n    if (it->get() == exp) {\n      return Expectation(*it);\n    }\n  }\n\n  Assert(false, __FILE__, __LINE__, \"Cannot find expectation.\");\n  return Expectation();\n  // The above statement is just to make the code compile, and will\n  // never be executed.\n}\n\n// Verifies that all expectations on this mock function have been\n// satisfied.  Reports one or more Google Test non-fatal failures\n// and returns false if not.\nbool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n  bool expectations_met = true;\n  for (UntypedExpectations::const_iterator it =\n           untyped_expectations_.begin();\n       it != untyped_expectations_.end(); ++it) {\n    ExpectationBase* const untyped_expectation = it->get();\n    if (untyped_expectation->IsOverSaturated()) {\n      // There was an upper-bound violation.  Since the error was\n      // already reported when it occurred, there is no need to do\n      // anything here.\n      expectations_met = false;\n    } else if (!untyped_expectation->IsSatisfied()) {\n      expectations_met = false;\n      ::std::stringstream ss;\n      ss  << \"Actual function call count doesn't match \"\n          << untyped_expectation->source_text() << \"...\\n\";\n      // No need to show the source file location of the expectation\n      // in the description, as the Expect() call that follows already\n      // takes care of it.\n      untyped_expectation->MaybeDescribeExtraMatcherTo(&ss);\n      untyped_expectation->DescribeCallCountTo(&ss);\n      Expect(false, untyped_expectation->file(),\n             untyped_expectation->line(), ss.str());\n    }\n  }\n\n  // Deleting our expectations may trigger other mock objects to be deleted, for\n  // example if an action contains a reference counted smart pointer to that\n  // mock object, and that is the last reference. So if we delete our\n  // expectations within the context of the global mutex we may deadlock when\n  // this method is called again. Instead, make a copy of the set of\n  // expectations to delete, clear our set within the mutex, and then clear the\n  // copied set outside of it.\n  UntypedExpectations expectations_to_delete;\n  untyped_expectations_.swap(expectations_to_delete);\n\n  g_gmock_mutex.Unlock();\n  expectations_to_delete.clear();\n  g_gmock_mutex.Lock();\n\n  return expectations_met;\n}\n\nCallReaction intToCallReaction(int mock_behavior) {\n  if (mock_behavior >= kAllow && mock_behavior <= kFail) {\n    return static_cast<internal::CallReaction>(mock_behavior);\n  }\n  return kWarn;\n}\n\n}  // namespace internal\n\n// Class Mock.\n\nnamespace {\n\ntypedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers;\n\n// The current state of a mock object.  Such information is needed for\n// detecting leaked mock objects and explicitly verifying a mock's\n// expectations.\nstruct MockObjectState {\n  MockObjectState()\n      : first_used_file(nullptr), first_used_line(-1), leakable(false) {}\n\n  // Where in the source file an ON_CALL or EXPECT_CALL is first\n  // invoked on this mock object.\n  const char* first_used_file;\n  int first_used_line;\n  ::std::string first_used_test_suite;\n  ::std::string first_used_test;\n  bool leakable;  // true if and only if it's OK to leak the object.\n  FunctionMockers function_mockers;  // All registered methods of the object.\n};\n\n// A global registry holding the state of all mock objects that are\n// alive.  A mock object is added to this registry the first time\n// Mock::AllowLeak(), ON_CALL(), or EXPECT_CALL() is called on it.  It\n// is removed from the registry in the mock object's destructor.\nclass MockObjectRegistry {\n public:\n  // Maps a mock object (identified by its address) to its state.\n  typedef std::map<const void*, MockObjectState> StateMap;\n\n  // This destructor will be called when a program exits, after all\n  // tests in it have been run.  By then, there should be no mock\n  // object alive.  Therefore we report any living object as test\n  // failure, unless the user explicitly asked us to ignore it.\n  ~MockObjectRegistry() {\n    if (!GMOCK_FLAG(catch_leaked_mocks))\n      return;\n\n    int leaked_count = 0;\n    for (StateMap::const_iterator it = states_.begin(); it != states_.end();\n         ++it) {\n      if (it->second.leakable)  // The user said it's fine to leak this object.\n        continue;\n\n      // FIXME: Print the type of the leaked object.\n      // This can help the user identify the leaked object.\n      std::cout << \"\\n\";\n      const MockObjectState& state = it->second;\n      std::cout << internal::FormatFileLocation(state.first_used_file,\n                                                state.first_used_line);\n      std::cout << \" ERROR: this mock object\";\n      if (state.first_used_test != \"\") {\n        std::cout << \" (used in test \" << state.first_used_test_suite << \".\"\n                  << state.first_used_test << \")\";\n      }\n      std::cout << \" should be deleted but never is. Its address is @\"\n           << it->first << \".\";\n      leaked_count++;\n    }\n    if (leaked_count > 0) {\n      std::cout << \"\\nERROR: \" << leaked_count << \" leaked mock \"\n                << (leaked_count == 1 ? \"object\" : \"objects\")\n                << \" found at program exit. Expectations on a mock object are \"\n                   \"verified when the object is destructed. Leaking a mock \"\n                   \"means that its expectations aren't verified, which is \"\n                   \"usually a test bug. If you really intend to leak a mock, \"\n                   \"you can suppress this error using \"\n                   \"testing::Mock::AllowLeak(mock_object), or you may use a \"\n                   \"fake or stub instead of a mock.\\n\";\n      std::cout.flush();\n      ::std::cerr.flush();\n      // RUN_ALL_TESTS() has already returned when this destructor is\n      // called.  Therefore we cannot use the normal Google Test\n      // failure reporting mechanism.\n      _exit(1);  // We cannot call exit() as it is not reentrant and\n                 // may already have been called.\n    }\n  }\n\n  StateMap& states() { return states_; }\n\n private:\n  StateMap states_;\n};\n\n// Protected by g_gmock_mutex.\nMockObjectRegistry g_mock_object_registry;\n\n// Maps a mock object to the reaction Google Mock should have when an\n// uninteresting method is called.  Protected by g_gmock_mutex.\nstd::unordered_map<uintptr_t, internal::CallReaction>&\nUninterestingCallReactionMap() {\n  static auto* map = new std::unordered_map<uintptr_t, internal::CallReaction>;\n  return *map;\n}\n\n// Sets the reaction Google Mock should have when an uninteresting\n// method of the given mock object is called.\nvoid SetReactionOnUninterestingCalls(uintptr_t mock_obj,\n                                     internal::CallReaction reaction)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  UninterestingCallReactionMap()[mock_obj] = reaction;\n}\n\n}  // namespace\n\n// Tells Google Mock to allow uninteresting calls on the given mock\n// object.\nvoid Mock::AllowUninterestingCalls(uintptr_t mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  SetReactionOnUninterestingCalls(mock_obj, internal::kAllow);\n}\n\n// Tells Google Mock to warn the user about uninteresting calls on the\n// given mock object.\nvoid Mock::WarnUninterestingCalls(uintptr_t mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  SetReactionOnUninterestingCalls(mock_obj, internal::kWarn);\n}\n\n// Tells Google Mock to fail uninteresting calls on the given mock\n// object.\nvoid Mock::FailUninterestingCalls(uintptr_t mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  SetReactionOnUninterestingCalls(mock_obj, internal::kFail);\n}\n\n// Tells Google Mock the given mock object is being destroyed and its\n// entry in the call-reaction table should be removed.\nvoid Mock::UnregisterCallReaction(uintptr_t mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  UninterestingCallReactionMap().erase(static_cast<uintptr_t>(mock_obj));\n}\n\n// Returns the reaction Google Mock will have on uninteresting calls\n// made on the given mock object.\ninternal::CallReaction Mock::GetReactionOnUninterestingCalls(\n    const void* mock_obj)\n        GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  return (UninterestingCallReactionMap().count(\n              reinterpret_cast<uintptr_t>(mock_obj)) == 0)\n             ? internal::intToCallReaction(\n                   GMOCK_FLAG(default_mock_behavior))\n             : UninterestingCallReactionMap()[reinterpret_cast<uintptr_t>(\n                   mock_obj)];\n}\n\n// Tells Google Mock to ignore mock_obj when checking for leaked mock\n// objects.\nvoid Mock::AllowLeak(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  g_mock_object_registry.states()[mock_obj].leakable = true;\n}\n\n// Verifies and clears all expectations on the given mock object.  If\n// the expectations aren't satisfied, generates one or more Google\n// Test non-fatal failures and returns false.\nbool Mock::VerifyAndClearExpectations(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  return VerifyAndClearExpectationsLocked(mock_obj);\n}\n\n// Verifies all expectations on the given mock object and clears its\n// default actions and expectations.  Returns true if and only if the\n// verification was successful.\nbool Mock::VerifyAndClear(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  ClearDefaultActionsLocked(mock_obj);\n  return VerifyAndClearExpectationsLocked(mock_obj);\n}\n\n// Verifies and clears all expectations on the given mock object.  If\n// the expectations aren't satisfied, generates one or more Google\n// Test non-fatal failures and returns false.\nbool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {\n  internal::g_gmock_mutex.AssertHeld();\n  if (g_mock_object_registry.states().count(mock_obj) == 0) {\n    // No EXPECT_CALL() was set on the given mock object.\n    return true;\n  }\n\n  // Verifies and clears the expectations on each mock method in the\n  // given mock object.\n  bool expectations_met = true;\n  FunctionMockers& mockers =\n      g_mock_object_registry.states()[mock_obj].function_mockers;\n  for (FunctionMockers::const_iterator it = mockers.begin();\n       it != mockers.end(); ++it) {\n    if (!(*it)->VerifyAndClearExpectationsLocked()) {\n      expectations_met = false;\n    }\n  }\n\n  // We don't clear the content of mockers, as they may still be\n  // needed by ClearDefaultActionsLocked().\n  return expectations_met;\n}\n\nbool Mock::IsNaggy(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  return Mock::GetReactionOnUninterestingCalls(mock_obj) == internal::kWarn;\n}\nbool Mock::IsNice(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  return Mock::GetReactionOnUninterestingCalls(mock_obj) == internal::kAllow;\n}\nbool Mock::IsStrict(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  return Mock::GetReactionOnUninterestingCalls(mock_obj) == internal::kFail;\n}\n\n// Registers a mock object and a mock method it owns.\nvoid Mock::Register(const void* mock_obj,\n                    internal::UntypedFunctionMockerBase* mocker)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  g_mock_object_registry.states()[mock_obj].function_mockers.insert(mocker);\n}\n\n// Tells Google Mock where in the source code mock_obj is used in an\n// ON_CALL or EXPECT_CALL.  In case mock_obj is leaked, this\n// information helps the user identify which object it is.\nvoid Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,\n                                           const char* file, int line)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  MockObjectState& state = g_mock_object_registry.states()[mock_obj];\n  if (state.first_used_file == nullptr) {\n    state.first_used_file = file;\n    state.first_used_line = line;\n    const TestInfo* const test_info =\n        UnitTest::GetInstance()->current_test_info();\n    if (test_info != nullptr) {\n      state.first_used_test_suite = test_info->test_suite_name();\n      state.first_used_test = test_info->name();\n    }\n  }\n}\n\n// Unregisters a mock method; removes the owning mock object from the\n// registry when the last mock method associated with it has been\n// unregistered.  This is called only in the destructor of\n// FunctionMockerBase.\nvoid Mock::UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {\n  internal::g_gmock_mutex.AssertHeld();\n  for (MockObjectRegistry::StateMap::iterator it =\n           g_mock_object_registry.states().begin();\n       it != g_mock_object_registry.states().end(); ++it) {\n    FunctionMockers& mockers = it->second.function_mockers;\n    if (mockers.erase(mocker) > 0) {\n      // mocker was in mockers and has been just removed.\n      if (mockers.empty()) {\n        g_mock_object_registry.states().erase(it);\n      }\n      return;\n    }\n  }\n}\n\n// Clears all ON_CALL()s set on the given mock object.\nvoid Mock::ClearDefaultActionsLocked(void* mock_obj)\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {\n  internal::g_gmock_mutex.AssertHeld();\n\n  if (g_mock_object_registry.states().count(mock_obj) == 0) {\n    // No ON_CALL() was set on the given mock object.\n    return;\n  }\n\n  // Clears the default actions for each mock method in the given mock\n  // object.\n  FunctionMockers& mockers =\n      g_mock_object_registry.states()[mock_obj].function_mockers;\n  for (FunctionMockers::const_iterator it = mockers.begin();\n       it != mockers.end(); ++it) {\n    (*it)->ClearDefaultActionsLocked();\n  }\n\n  // We don't clear the content of mockers, as they may still be\n  // needed by VerifyAndClearExpectationsLocked().\n}\n\nExpectation::Expectation() {}\n\nExpectation::Expectation(\n    const std::shared_ptr<internal::ExpectationBase>& an_expectation_base)\n    : expectation_base_(an_expectation_base) {}\n\nExpectation::~Expectation() {}\n\n// Adds an expectation to a sequence.\nvoid Sequence::AddExpectation(const Expectation& expectation) const {\n  if (*last_expectation_ != expectation) {\n    if (last_expectation_->expectation_base() != nullptr) {\n      expectation.expectation_base()->immediate_prerequisites_\n          += *last_expectation_;\n    }\n    *last_expectation_ = expectation;\n  }\n}\n\n// Creates the implicit sequence if there isn't one.\nInSequence::InSequence() {\n  if (internal::g_gmock_implicit_sequence.get() == nullptr) {\n    internal::g_gmock_implicit_sequence.set(new Sequence);\n    sequence_created_ = true;\n  } else {\n    sequence_created_ = false;\n  }\n}\n\n// Deletes the implicit sequence if it was created by the constructor\n// of this object.\nInSequence::~InSequence() {\n  if (sequence_created_) {\n    delete internal::g_gmock_implicit_sequence.get();\n    internal::g_gmock_implicit_sequence.set(nullptr);\n  }\n}\n\n}  // namespace testing\n\n#ifdef _MSC_VER\n#if _MSC_VER == 1900\n#  pragma warning(pop)\n#endif\n#endif\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\nnamespace testing {\n\nGMOCK_DEFINE_bool_(catch_leaked_mocks, true,\n                   \"true if and only if Google Mock should report leaked \"\n                   \"mock objects as failures.\");\n\nGMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity,\n                     \"Controls how verbose Google Mock's output is.\"\n                     \"  Valid values:\\n\"\n                     \"  info    - prints all messages.\\n\"\n                     \"  warning - prints warnings and errors.\\n\"\n                     \"  error   - prints errors only.\");\n\nGMOCK_DEFINE_int32_(default_mock_behavior, 1,\n                    \"Controls the default behavior of mocks.\"\n                    \"  Valid values:\\n\"\n                    \"  0 - by default, mocks act as NiceMocks.\\n\"\n                    \"  1 - by default, mocks act as NaggyMocks.\\n\"\n                    \"  2 - by default, mocks act as StrictMocks.\");\n\nnamespace internal {\n\n// Parses a string as a command line flag.  The string should have the\n// format \"--gmock_flag=value\".  When def_optional is true, the\n// \"=value\" part can be omitted.\n//\n// Returns the value of the flag, or NULL if the parsing failed.\nstatic const char* ParseGoogleMockFlagValue(const char* str,\n                                            const char* flag,\n                                            bool def_optional) {\n  // str and flag must not be NULL.\n  if (str == nullptr || flag == nullptr) return nullptr;\n\n  // The flag must start with \"--gmock_\".\n  const std::string flag_str = std::string(\"--gmock_\") + flag;\n  const size_t flag_len = flag_str.length();\n  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;\n\n  // Skips the flag name.\n  const char* flag_end = str + flag_len;\n\n  // When def_optional is true, it's OK to not have a \"=value\" part.\n  if (def_optional && (flag_end[0] == '\\0')) {\n    return flag_end;\n  }\n\n  // If def_optional is true and there are more characters after the\n  // flag name, or if def_optional is false, there must be a '=' after\n  // the flag name.\n  if (flag_end[0] != '=') return nullptr;\n\n  // Returns the string after \"=\".\n  return flag_end + 1;\n}\n\n// Parses a string for a Google Mock bool flag, in the form of\n// \"--gmock_flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nstatic bool ParseGoogleMockBoolFlag(const char* str, const char* flag,\n                                    bool* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseGoogleMockFlagValue(str, flag, true);\n\n  // Aborts if the parsing failed.\n  if (value_str == nullptr) return false;\n\n  // Converts the string value to a bool.\n  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');\n  return true;\n}\n\n// Parses a string for a Google Mock string flag, in the form of\n// \"--gmock_flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\ntemplate <typename String>\nstatic bool ParseGoogleMockStringFlag(const char* str, const char* flag,\n                                      String* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseGoogleMockFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == nullptr) return false;\n\n  // Sets *value to the value of the flag.\n  *value = value_str;\n  return true;\n}\n\nstatic bool ParseGoogleMockIntFlag(const char* str, const char* flag,\n                                   int32_t* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseGoogleMockFlagValue(str, flag, true);\n\n  // Aborts if the parsing failed.\n  if (value_str == nullptr) return false;\n\n  // Sets *value to the value of the flag.\n  return ParseInt32(Message() << \"The value of flag --\" << flag,\n                    value_str, value);\n}\n\n// The internal implementation of InitGoogleMock().\n//\n// The type parameter CharType can be instantiated to either char or\n// wchar_t.\ntemplate <typename CharType>\nvoid InitGoogleMockImpl(int* argc, CharType** argv) {\n  // Makes sure Google Test is initialized.  InitGoogleTest() is\n  // idempotent, so it's fine if the user has already called it.\n  InitGoogleTest(argc, argv);\n  if (*argc <= 0) return;\n\n  for (int i = 1; i != *argc; i++) {\n    const std::string arg_string = StreamableToString(argv[i]);\n    const char* const arg = arg_string.c_str();\n\n    // Do we see a Google Mock flag?\n    if (ParseGoogleMockBoolFlag(arg, \"catch_leaked_mocks\",\n                                &GMOCK_FLAG(catch_leaked_mocks)) ||\n        ParseGoogleMockStringFlag(arg, \"verbose\", &GMOCK_FLAG(verbose)) ||\n        ParseGoogleMockIntFlag(arg, \"default_mock_behavior\",\n                               &GMOCK_FLAG(default_mock_behavior))) {\n      // Yes.  Shift the remainder of the argv list left by one.  Note\n      // that argv has (*argc + 1) elements, the last one always being\n      // NULL.  The following loop moves the trailing NULL element as\n      // well.\n      for (int j = i; j != *argc; j++) {\n        argv[j] = argv[j + 1];\n      }\n\n      // Decrements the argument count.\n      (*argc)--;\n\n      // We also need to decrement the iterator as we just removed\n      // an element.\n      i--;\n    }\n  }\n}\n\n}  // namespace internal\n\n// Initializes Google Mock.  This must be called before running the\n// tests.  In particular, it parses a command line for the flags that\n// Google Mock recognizes.  Whenever a Google Mock flag is seen, it is\n// removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Mock flag variables are\n// updated.\n//\n// Since Google Test is needed for Google Mock to work, this function\n// also initializes Google Test and parses its flags, if that hasn't\n// been done.\nGTEST_API_ void InitGoogleMock(int* argc, char** argv) {\n  internal::InitGoogleMockImpl(argc, argv);\n}\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv) {\n  internal::InitGoogleMockImpl(argc, argv);\n}\n\n// This overloaded version can be used on Arduino/embedded platforms where\n// there is no argc/argv.\nGTEST_API_ void InitGoogleMock() {\n  // Since Arduino doesn't have a command line, fake out the argc/argv arguments\n  int argc = 1;\n  const auto arg0 = \"dummy\";\n  char* argv0 = const_cast<char*>(arg0);\n  char** argv = &argv0;\n\n  internal::InitGoogleMockImpl(&argc, argv);\n}\n\n}  // namespace testing\n"
  },
  {
    "path": "test/gtest/gtest/gtest-spi.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// Utilities for testing Google Test itself and code that uses Google Test\n// (e.g. frameworks built on top of Google Test).\n\n// GOOGLETEST_CM0004 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_\n\n#include \"gtest/gtest.h\"\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// This helper class can be used to mock out Google Test failure reporting\n// so that we can test Google Test or code that builds on Google Test.\n//\n// An object of this class appends a TestPartResult object to the\n// TestPartResultArray object given in the constructor whenever a Google Test\n// failure is reported. It can either intercept only failures that are\n// generated in the same thread that created this object or it can intercept\n// all generated failures. The scope of this mock object can be controlled with\n// the second argument to the two arguments constructor.\nclass GTEST_API_ ScopedFakeTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  // The two possible mocking modes of this object.\n  enum InterceptMode {\n    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.\n    INTERCEPT_ALL_THREADS           // Intercepts all failures.\n  };\n\n  // The c'tor sets this object as the test part result reporter used\n  // by Google Test.  The 'result' parameter specifies where to report the\n  // results. This reporter will only catch failures generated in the current\n  // thread. DEPRECATED\n  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);\n\n  // Same as above, but you can choose the interception scope of this object.\n  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,\n                                   TestPartResultArray* result);\n\n  // The d'tor restores the previous test part result reporter.\n  ~ScopedFakeTestPartResultReporter() override;\n\n  // Appends the TestPartResult object to the TestPartResultArray\n  // received in the constructor.\n  //\n  // This method is from the TestPartResultReporterInterface\n  // interface.\n  void ReportTestPartResult(const TestPartResult& result) override;\n\n private:\n  void Init();\n\n  const InterceptMode intercept_mode_;\n  TestPartResultReporterInterface* old_reporter_;\n  TestPartResultArray* const result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);\n};\n\nnamespace internal {\n\n// A helper class for implementing EXPECT_FATAL_FAILURE() and\n// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nclass GTEST_API_ SingleFailureChecker {\n public:\n  // The constructor remembers the arguments.\n  SingleFailureChecker(const TestPartResultArray* results,\n                       TestPartResult::Type type, const std::string& substr);\n  ~SingleFailureChecker();\n private:\n  const TestPartResultArray* const results_;\n  const TestPartResult::Type type_;\n  const std::string substr_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n// A set of macros for testing Google Test assertions or code that's expected\n// to generate Google Test fatal failures.  It verifies that the given\n// statement will cause exactly one fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_FATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - 'statement' cannot reference local non-static variables or\n//     non-static members of the current object.\n//   - 'statement' cannot return a value.\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in\n// gtest_unittest.cc will fail to compile if we do that.\n#define EXPECT_FATAL_FAILURE(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ALL_THREADS, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n// A macro for testing Google Test assertions or code that's expected to\n// generate Google Test non-fatal failures.  It asserts that the given\n// statement will cause exactly one non-fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// 'statement' is allowed to reference local variables and members of\n// the current object.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  If we do that, the code won't compile when the user gives\n// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that\n// expands to code containing an unprotected comma.  The\n// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc\n// catches that.\n//\n// For the same reason, we have to write\n//   if (::testing::internal::AlwaysTrue()) { statement; }\n// instead of\n//   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n// to avoid an MSVC warning on unreachable code.\n#define EXPECT_NONFATAL_FAILURE(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \\\n          &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_\n"
  },
  {
    "path": "test/gtest/gtest/gtest.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file defines the public API for Google Test.  It should be\n// included by any test program that uses Google Test.\n//\n// IMPORTANT NOTE: Due to limitation of the C++ language, we have to\n// leave some internal implementation details in this header file.\n// They are clearly marked by comments like this:\n//\n//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n//\n// Such code is NOT meant to be used by a user directly, and is subject\n// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user\n// program!\n//\n// Acknowledgment: Google Test borrowed the idea of automatic test\n// registration from Barthelemy Dagenais' (barthelemy@prologique.com)\n// easyUnit framework.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_H_\n\n#include <cstddef>\n#include <limits>\n#include <memory>\n#include <ostream>\n#include <type_traits>\n#include <vector>\n\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file declares functions and macros used internally by\n// Google Test.  They are subject to change without notice.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Low-level types and utilities for porting Google Test to various\n// platforms.  All macros ending with _ and symbols defined in an\n// internal namespace are subject to change without notice.  Code\n// outside Google Test MUST NOT USE THEM DIRECTLY.  Macros that don't\n// end with _ are part of Google Test's public API and can be used by\n// code outside Google Test.\n//\n// This file is fundamental to Google Test.  All other Google Test source\n// files are expected to #include this.  Therefore, it cannot #include\n// any other Google Test header.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n\n// Environment-describing macros\n// -----------------------------\n//\n// Google Test can be used in many different environments.  Macros in\n// this section tell Google Test what kind of environment it is being\n// used in, such that Google Test can provide environment-specific\n// features and implementations.\n//\n// Google Test tries to automatically detect the properties of its\n// environment, so users usually don't need to worry about these\n// macros.  However, the automatic detection is not perfect.\n// Sometimes it's necessary for a user to define some of the following\n// macros in the build script to override Google Test's decisions.\n//\n// If the user doesn't define a macro in the list, Google Test will\n// provide a default definition.  After this header is #included, all\n// macros in this list will be defined to either 1 or 0.\n//\n// Notes to maintainers:\n//   - Each macro here is a user-tweakable knob; do not grow the list\n//     lightly.\n//   - Use #if to key off these macros.  Don't use #ifdef or \"#if\n//     defined(...)\", which will not work as these macros are ALWAYS\n//     defined.\n//\n//   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)\n//                              is/isn't available.\n//   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions\n//                              are enabled.\n//   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular\n//                              expressions are/aren't available.\n//   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>\n//                              is/isn't available.\n//   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't\n//                              enabled.\n//   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that\n//                              std::wstring does/doesn't work (Google Test can\n//                              be used where std::wstring is unavailable).\n//   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the\n//                              compiler supports Microsoft's \"Structured\n//                              Exception Handling\".\n//   GTEST_HAS_STREAM_REDIRECTION\n//                            - Define it to 1/0 to indicate whether the\n//                              platform supports I/O stream redirection using\n//                              dup() and dup2().\n//   GTEST_LINKED_AS_SHARED_LIBRARY\n//                            - Define to 1 when compiling tests that use\n//                              Google Test as a shared library (known as\n//                              DLL on Windows).\n//   GTEST_CREATE_SHARED_LIBRARY\n//                            - Define to 1 when compiling Google Test itself\n//                              as a shared library.\n//   GTEST_DEFAULT_DEATH_TEST_STYLE\n//                            - The default value of --gtest_death_test_style.\n//                              The legacy default has been \"fast\" in the open\n//                              source version since 2008. The recommended value\n//                              is \"threadsafe\", and can be set in\n//                              custom/gtest-port.h.\n\n// Platform-indicating macros\n// --------------------------\n//\n// Macros indicating the platform on which Google Test is being used\n// (a macro is defined to 1 if compiled on the given platform;\n// otherwise UNDEFINED -- it's never defined to 0.).  Google Test\n// defines these macros automatically.  Code outside Google Test MUST\n// NOT define them.\n//\n//   GTEST_OS_AIX      - IBM AIX\n//   GTEST_OS_CYGWIN   - Cygwin\n//   GTEST_OS_DRAGONFLY - DragonFlyBSD\n//   GTEST_OS_FREEBSD  - FreeBSD\n//   GTEST_OS_FUCHSIA  - Fuchsia\n//   GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD\n//   GTEST_OS_HAIKU    - Haiku\n//   GTEST_OS_HPUX     - HP-UX\n//   GTEST_OS_LINUX    - Linux\n//     GTEST_OS_LINUX_ANDROID - Google Android\n//   GTEST_OS_MAC      - Mac OS X\n//     GTEST_OS_IOS    - iOS\n//   GTEST_OS_NACL     - Google Native Client (NaCl)\n//   GTEST_OS_NETBSD   - NetBSD\n//   GTEST_OS_OPENBSD  - OpenBSD\n//   GTEST_OS_OS2      - OS/2\n//   GTEST_OS_QNX      - QNX\n//   GTEST_OS_SOLARIS  - Sun Solaris\n//   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)\n//     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop\n//     GTEST_OS_WINDOWS_MINGW    - MinGW\n//     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile\n//     GTEST_OS_WINDOWS_PHONE    - Windows Phone\n//     GTEST_OS_WINDOWS_RT       - Windows Store App/WinRT\n//   GTEST_OS_ZOS      - z/OS\n//\n// Among the platforms, Cygwin, Linux, Mac OS X, and Windows have the\n// most stable support.  Since core members of the Google Test project\n// don't have access to other platforms, support for them may be less\n// stable.  If you notice any problems on your platform, please notify\n// googletestframework@googlegroups.com (patches for fixing them are\n// even more welcome!).\n//\n// It is possible that none of the GTEST_OS_* macros are defined.\n\n// Feature-indicating macros\n// -------------------------\n//\n// Macros indicating which Google Test features are available (a macro\n// is defined to 1 if the corresponding feature is supported;\n// otherwise UNDEFINED -- it's never defined to 0.).  Google Test\n// defines these macros automatically.  Code outside Google Test MUST\n// NOT define them.\n//\n// These macros are public so that portable tests can be written.\n// Such tests typically surround code using a feature with an #if\n// which controls that code.  For example:\n//\n// #if GTEST_HAS_DEATH_TEST\n//   EXPECT_DEATH(DoSomethingDeadly());\n// #endif\n//\n//   GTEST_HAS_DEATH_TEST   - death tests\n//   GTEST_HAS_TYPED_TEST   - typed tests\n//   GTEST_HAS_TYPED_TEST_P - type-parameterized tests\n//   GTEST_IS_THREADSAFE    - Google Test is thread-safe.\n//   GOOGLETEST_CM0007 DO NOT DELETE\n//   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with\n//                            GTEST_HAS_POSIX_RE (see above) which users can\n//                            define themselves.\n//   GTEST_USES_SIMPLE_RE   - our own simple regex is used;\n//                            the above RE\\b(s) are mutually exclusive.\n\n// Misc public macros\n// ------------------\n//\n//   GTEST_FLAG(flag_name)  - references the variable corresponding to\n//                            the given Google Test flag.\n\n// Internal utilities\n// ------------------\n//\n// The following macros and utilities are for Google Test's INTERNAL\n// use only.  Code outside Google Test MUST NOT USE THEM DIRECTLY.\n//\n// Macros for basic C++ coding:\n//   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.\n//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a\n//                              variable don't have to be used.\n//   GTEST_DISALLOW_ASSIGN_   - disables copy operator=.\n//   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.\n//   GTEST_DISALLOW_MOVE_ASSIGN_   - disables move operator=.\n//   GTEST_DISALLOW_MOVE_AND_ASSIGN_ - disables move ctor and operator=.\n//   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.\n//   GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is\n//                                        suppressed (constant conditional).\n//   GTEST_INTENTIONAL_CONST_COND_POP_  - finish code section where MSVC C4127\n//                                        is suppressed.\n//   GTEST_INTERNAL_HAS_ANY - for enabling UniversalPrinter<std::any> or\n//                            UniversalPrinter<absl::any> specializations.\n//   GTEST_INTERNAL_HAS_OPTIONAL - for enabling UniversalPrinter<std::optional>\n//   or\n//                                 UniversalPrinter<absl::optional>\n//                                 specializations.\n//   GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher<std::string_view> or\n//                                    Matcher<absl::string_view>\n//                                    specializations.\n//   GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter<std::variant> or\n//                                UniversalPrinter<absl::variant>\n//                                specializations.\n//\n// Synchronization:\n//   Mutex, MutexLock, ThreadLocal, GetThreadCount()\n//                            - synchronization primitives.\n//\n// Regular expressions:\n//   RE             - a simple regular expression class using the POSIX\n//                    Extended Regular Expression syntax on UNIX-like platforms\n//                    GOOGLETEST_CM0008 DO NOT DELETE\n//                    or a reduced regular exception syntax on other\n//                    platforms, including Windows.\n// Logging:\n//   GTEST_LOG_()   - logs messages at the specified severity level.\n//   LogToStderr()  - directs all log messages to stderr.\n//   FlushInfoLog() - flushes informational log messages.\n//\n// Stdout and stderr capturing:\n//   CaptureStdout()     - starts capturing stdout.\n//   GetCapturedStdout() - stops capturing stdout and returns the captured\n//                         string.\n//   CaptureStderr()     - starts capturing stderr.\n//   GetCapturedStderr() - stops capturing stderr and returns the captured\n//                         string.\n//\n// Integer types:\n//   TypeWithSize   - maps an integer to a int type.\n//   TimeInMillis   - integers of known sizes.\n//   BiggestInt     - the biggest signed integer type.\n//\n// Command-line utilities:\n//   GTEST_DECLARE_*()  - declares a flag.\n//   GTEST_DEFINE_*()   - defines a flag.\n//   GetInjectableArgvs() - returns the command line as a vector of strings.\n//\n// Environment variable utilities:\n//   GetEnv()             - gets the value of an environment variable.\n//   BoolFromGTestEnv()   - parses a bool environment variable.\n//   Int32FromGTestEnv()  - parses an int32_t environment variable.\n//   StringFromGTestEnv() - parses a string environment variable.\n//\n// Deprecation warnings:\n//   GTEST_INTERNAL_DEPRECATED(message) - attribute marking a function as\n//                                        deprecated; calling a marked function\n//                                        should generate a compiler warning\n\n#include <ctype.h>   // for isspace, etc\n#include <stddef.h>  // for ptrdiff_t\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <cerrno>\n#include <cstdint>\n#include <limits>\n#include <type_traits>\n\n#ifndef _WIN32_WCE\n# include <sys/types.h>\n# include <sys/stat.h>\n#endif  // !_WIN32_WCE\n\n#if defined __APPLE__\n# include <AvailabilityMacros.h>\n# include <TargetConditionals.h>\n#endif\n\n#include <iostream>  // NOLINT\n#include <locale>\n#include <memory>\n#include <string>  // NOLINT\n#include <tuple>\n#include <vector>  // NOLINT\n\n// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Injection point for custom user configurations. See README for details\n//\n// ** Custom implementation starts here **\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_\n// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file defines the GTEST_OS_* macro.\n// It is separate from gtest-port.h so that custom/gtest-port.h can include it.\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_\n\n// Determines the platform on which Google Test is compiled.\n#ifdef __CYGWIN__\n# define GTEST_OS_CYGWIN 1\n# elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)\n#  define GTEST_OS_WINDOWS_MINGW 1\n#  define GTEST_OS_WINDOWS 1\n#elif defined _WIN32\n# define GTEST_OS_WINDOWS 1\n# ifdef _WIN32_WCE\n#  define GTEST_OS_WINDOWS_MOBILE 1\n# elif defined(WINAPI_FAMILY)\n#  include <winapifamily.h>\n#  if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)\n#   define GTEST_OS_WINDOWS_DESKTOP 1\n#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)\n#   define GTEST_OS_WINDOWS_PHONE 1\n#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)\n#   define GTEST_OS_WINDOWS_RT 1\n#  elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)\n#   define GTEST_OS_WINDOWS_PHONE 1\n#   define GTEST_OS_WINDOWS_TV_TITLE 1\n#  else\n    // WINAPI_FAMILY defined but no known partition matched.\n    // Default to desktop.\n#   define GTEST_OS_WINDOWS_DESKTOP 1\n#  endif\n# else\n#  define GTEST_OS_WINDOWS_DESKTOP 1\n# endif  // _WIN32_WCE\n#elif defined __OS2__\n# define GTEST_OS_OS2 1\n#elif defined __APPLE__\n# define GTEST_OS_MAC 1\n# include <TargetConditionals.h>\n# if TARGET_OS_IPHONE\n#  define GTEST_OS_IOS 1\n# endif\n#elif defined __DragonFly__\n# define GTEST_OS_DRAGONFLY 1\n#elif defined __FreeBSD__\n# define GTEST_OS_FREEBSD 1\n#elif defined __Fuchsia__\n# define GTEST_OS_FUCHSIA 1\n#elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)\n# define GTEST_OS_GNU_KFREEBSD 1\n#elif defined __linux__\n# define GTEST_OS_LINUX 1\n# if defined __ANDROID__\n#  define GTEST_OS_LINUX_ANDROID 1\n# endif\n#elif defined __MVS__\n# define GTEST_OS_ZOS 1\n#elif defined(__sun) && defined(__SVR4)\n# define GTEST_OS_SOLARIS 1\n#elif defined(_AIX)\n# define GTEST_OS_AIX 1\n#elif defined(__hpux)\n# define GTEST_OS_HPUX 1\n#elif defined __native_client__\n# define GTEST_OS_NACL 1\n#elif defined __NetBSD__\n# define GTEST_OS_NETBSD 1\n#elif defined __OpenBSD__\n# define GTEST_OS_OPENBSD 1\n#elif defined __QNX__\n# define GTEST_OS_QNX 1\n#elif defined(__HAIKU__)\n#define GTEST_OS_HAIKU 1\n#elif defined ESP8266\n#define GTEST_OS_ESP8266 1\n#elif defined ESP32\n#define GTEST_OS_ESP32 1\n#elif defined(__XTENSA__)\n#define GTEST_OS_XTENSA 1\n#endif  // __CYGWIN__\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_\n\n#if !defined(GTEST_DEV_EMAIL_)\n# define GTEST_DEV_EMAIL_ \"googletestframework@@googlegroups.com\"\n# define GTEST_FLAG_PREFIX_ \"gtest_\"\n# define GTEST_FLAG_PREFIX_DASH_ \"gtest-\"\n# define GTEST_FLAG_PREFIX_UPPER_ \"GTEST_\"\n# define GTEST_NAME_ \"Google Test\"\n# define GTEST_PROJECT_URL_ \"https://github.com/google/googletest/\"\n#endif  // !defined(GTEST_DEV_EMAIL_)\n\n#if !defined(GTEST_INIT_GOOGLE_TEST_NAME_)\n# define GTEST_INIT_GOOGLE_TEST_NAME_ \"testing::InitGoogleTest\"\n#endif  // !defined(GTEST_INIT_GOOGLE_TEST_NAME_)\n\n// Determines the version of gcc that is used to compile this.\n#ifdef __GNUC__\n// 40302 means version 4.3.2.\n# define GTEST_GCC_VER_ \\\n    (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)\n#endif  // __GNUC__\n\n// Macros for disabling Microsoft Visual C++ warnings.\n//\n//   GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)\n//   /* code that triggers warnings C4800 and C4385 */\n//   GTEST_DISABLE_MSC_WARNINGS_POP_()\n#if defined(_MSC_VER)\n# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \\\n    __pragma(warning(push))                        \\\n    __pragma(warning(disable: warnings))\n# define GTEST_DISABLE_MSC_WARNINGS_POP_()          \\\n    __pragma(warning(pop))\n#else\n// Not all compilers are MSVC\n# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)\n# define GTEST_DISABLE_MSC_WARNINGS_POP_()\n#endif\n\n// Clang on Windows does not understand MSVC's pragma warning.\n// We need clang-specific way to disable function deprecation warning.\n#ifdef __clang__\n# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_()                         \\\n    _Pragma(\"clang diagnostic push\")                                  \\\n    _Pragma(\"clang diagnostic ignored \\\"-Wdeprecated-declarations\\\"\") \\\n    _Pragma(\"clang diagnostic ignored \\\"-Wdeprecated-implementations\\\"\")\n#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \\\n    _Pragma(\"clang diagnostic pop\")\n#else\n# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \\\n    GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)\n# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \\\n    GTEST_DISABLE_MSC_WARNINGS_POP_()\n#endif\n\n// Brings in definitions for functions used in the testing::internal::posix\n// namespace (read, write, close, chdir, isatty, stat). We do not currently\n// use them on Windows Mobile.\n#if GTEST_OS_WINDOWS\n# if !GTEST_OS_WINDOWS_MOBILE\n#  include <direct.h>\n#  include <io.h>\n# endif\n// In order to avoid having to include <windows.h>, use forward declaration\n#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR)\n// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two\n// separate (equivalent) structs, instead of using typedef\ntypedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;\n#else\n// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.\n// This assumption is verified by\n// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.\ntypedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;\n#endif\n#elif GTEST_OS_XTENSA\n#include <unistd.h>\n// Xtensa toolchains define strcasecmp in the string.h header instead of\n// strings.h. string.h is already included.\n#else\n// This assumes that non-Windows OSes provide unistd.h. For OSes where this\n// is not the case, we need to include headers that provide the functions\n// mentioned above.\n# include <unistd.h>\n# include <strings.h>\n#endif  // GTEST_OS_WINDOWS\n\n#if GTEST_OS_LINUX_ANDROID\n// Used to define __ANDROID_API__ matching the target NDK API level.\n#  include <android/api-level.h>  // NOLINT\n#endif\n\n// Defines this to true if and only if Google Test can use POSIX regular\n// expressions.\n#ifndef GTEST_HAS_POSIX_RE\n# if GTEST_OS_LINUX_ANDROID\n// On Android, <regex.h> is only available starting with Gingerbread.\n#  define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)\n# else\n#define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS && !GTEST_OS_XTENSA)\n# endif\n#endif\n\n#if GTEST_USES_PCRE\n// The appropriate headers have already been included.\n\n#elif GTEST_HAS_POSIX_RE\n\n// On some platforms, <regex.h> needs someone to define size_t, and\n// won't compile otherwise.  We can #include it here as we already\n// included <stdlib.h>, which is guaranteed to define size_t through\n// <stddef.h>.\n# include <regex.h>  // NOLINT\n\n# define GTEST_USES_POSIX_RE 1\n\n#elif GTEST_OS_WINDOWS\n\n// <regex.h> is not available on Windows.  Use our own simple regex\n// implementation instead.\n# define GTEST_USES_SIMPLE_RE 1\n\n#else\n\n// <regex.h> may not be available on this platform.  Use our own\n// simple regex implementation instead.\n# define GTEST_USES_SIMPLE_RE 1\n\n#endif  // GTEST_USES_PCRE\n\n#ifndef GTEST_HAS_EXCEPTIONS\n// The user didn't tell us whether exceptions are enabled, so we need\n// to figure it out.\n# if defined(_MSC_VER) && defined(_CPPUNWIND)\n// MSVC defines _CPPUNWIND to 1 if and only if exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__BORLANDC__)\n// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS\n// macro to enable exceptions, so we'll do the same.\n// Assumes that exceptions are enabled by default.\n#  ifndef _HAS_EXCEPTIONS\n#   define _HAS_EXCEPTIONS 1\n#  endif  // _HAS_EXCEPTIONS\n#  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS\n# elif defined(__clang__)\n// clang defines __EXCEPTIONS if and only if exceptions are enabled before clang\n// 220714, but if and only if cleanups are enabled after that. In Obj-C++ files,\n// there can be cleanups for ObjC exceptions which also need cleanups, even if\n// C++ exceptions are disabled. clang has __has_feature(cxx_exceptions) which\n// checks for C++ exceptions starting at clang r206352, but which checked for\n// cleanups prior to that. To reliably check for C++ exception availability with\n// clang, check for\n// __EXCEPTIONS && __has_feature(cxx_exceptions).\n#  define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))\n# elif defined(__GNUC__) && __EXCEPTIONS\n// gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__SUNPRO_CC)\n// Sun Pro CC supports exceptions.  However, there is no compile-time way of\n// detecting whether they are enabled or not.  Therefore, we assume that\n// they are enabled unless the user tells us otherwise.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__IBMCPP__) && __EXCEPTIONS\n// xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__HP_aCC)\n// Exception handling is in effect by default in HP aCC compiler. It has to\n// be turned of by +noeh compiler option if desired.\n#  define GTEST_HAS_EXCEPTIONS 1\n# else\n// For other compilers, we assume exceptions are disabled to be\n// conservative.\n#  define GTEST_HAS_EXCEPTIONS 0\n# endif  // defined(_MSC_VER) || defined(__BORLANDC__)\n#endif  // GTEST_HAS_EXCEPTIONS\n\n#ifndef GTEST_HAS_STD_WSTRING\n// The user didn't tell us whether ::std::wstring is available, so we need\n// to figure it out.\n// Cygwin 1.7 and below doesn't support ::std::wstring.\n// Solaris' libc++ doesn't support it either.  Android has\n// no support for it at least as recent as Froyo (2.2).\n#define GTEST_HAS_STD_WSTRING                                         \\\n  (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \\\n     GTEST_OS_HAIKU || GTEST_OS_ESP32 || GTEST_OS_ESP8266 || GTEST_OS_XTENSA))\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Determines whether RTTI is available.\n#ifndef GTEST_HAS_RTTI\n// The user didn't tell us whether RTTI is enabled, so we need to\n// figure it out.\n\n# ifdef _MSC_VER\n\n#ifdef _CPPRTTI  // MSVC defines this macro if and only if RTTI is enabled.\n#   define GTEST_HAS_RTTI 1\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif\n\n// Starting with version 4.3.2, gcc defines __GXX_RTTI if and only if RTTI is\n// enabled.\n# elif defined(__GNUC__)\n\n#  ifdef __GXX_RTTI\n// When building against STLport with the Android NDK and with\n// -frtti -fno-exceptions, the build fails at link time with undefined\n// references to __cxa_bad_typeid. Note sure if STL or toolchain bug,\n// so disable RTTI when detected.\n#   if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \\\n       !defined(__EXCEPTIONS)\n#    define GTEST_HAS_RTTI 0\n#   else\n#    define GTEST_HAS_RTTI 1\n#   endif  // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif  // __GXX_RTTI\n\n// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends\n// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the\n// first version with C++ support.\n# elif defined(__clang__)\n\n#  define GTEST_HAS_RTTI __has_feature(cxx_rtti)\n\n// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if\n// both the typeid and dynamic_cast features are present.\n# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)\n\n#  ifdef __RTTI_ALL__\n#   define GTEST_HAS_RTTI 1\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif\n\n# else\n\n// For all other compilers, we assume RTTI is enabled.\n#  define GTEST_HAS_RTTI 1\n\n# endif  // _MSC_VER\n\n#endif  // GTEST_HAS_RTTI\n\n// It's this header's responsibility to #include <typeinfo> when RTTI\n// is enabled.\n#if GTEST_HAS_RTTI\n# include <typeinfo>\n#endif\n\n// Determines whether Google Test can use the pthreads library.\n#ifndef GTEST_HAS_PTHREAD\n// The user didn't tell us explicitly, so we make reasonable assumptions about\n// which platforms have pthreads support.\n//\n// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0\n// to your compiler flags.\n#define GTEST_HAS_PTHREAD                                                      \\\n  (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX ||          \\\n   GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \\\n   GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD ||          \\\n   GTEST_OS_HAIKU)\n#endif  // GTEST_HAS_PTHREAD\n\n#if GTEST_HAS_PTHREAD\n// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is\n// true.\n# include <pthread.h>  // NOLINT\n\n// For timespec and nanosleep, used below.\n# include <time.h>  // NOLINT\n#endif\n\n// Determines whether clone(2) is supported.\n// Usually it will only be available on Linux, excluding\n// Linux on the Itanium architecture.\n// Also see http://linux.die.net/man/2/clone.\n#ifndef GTEST_HAS_CLONE\n// The user didn't tell us, so we need to figure it out.\n\n# if GTEST_OS_LINUX && !defined(__ia64__)\n#  if GTEST_OS_LINUX_ANDROID\n// On Android, clone() became available at different API levels for each 32-bit\n// architecture.\n#    if defined(__LP64__) || \\\n        (defined(__arm__) && __ANDROID_API__ >= 9) || \\\n        (defined(__mips__) && __ANDROID_API__ >= 12) || \\\n        (defined(__i386__) && __ANDROID_API__ >= 17)\n#     define GTEST_HAS_CLONE 1\n#    else\n#     define GTEST_HAS_CLONE 0\n#    endif\n#  else\n#   define GTEST_HAS_CLONE 1\n#  endif\n# else\n#  define GTEST_HAS_CLONE 0\n# endif  // GTEST_OS_LINUX && !defined(__ia64__)\n\n#endif  // GTEST_HAS_CLONE\n\n// Determines whether to support stream redirection. This is used to test\n// output correctness and to implement death tests.\n#ifndef GTEST_HAS_STREAM_REDIRECTION\n// By default, we assume that stream redirection is supported on all\n// platforms except known mobile ones.\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \\\n    GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA\n#  define GTEST_HAS_STREAM_REDIRECTION 0\n# else\n#  define GTEST_HAS_STREAM_REDIRECTION 1\n# endif  // !GTEST_OS_WINDOWS_MOBILE\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Determines whether to support death tests.\n// pops up a dialog window that cannot be suppressed programmatically.\n#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS ||             \\\n     (GTEST_OS_MAC && !GTEST_OS_IOS) ||                                   \\\n     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW ||  \\\n     GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \\\n     GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA ||           \\\n     GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU)\n# define GTEST_HAS_DEATH_TEST 1\n#endif\n\n// Determines whether to support type-driven tests.\n\n// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,\n// Sun Pro CC, IBM Visual Age, and HP aCC support.\n#if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \\\n    defined(__IBMCPP__) || defined(__HP_aCC)\n# define GTEST_HAS_TYPED_TEST 1\n# define GTEST_HAS_TYPED_TEST_P 1\n#endif\n\n// Determines whether the system compiler uses UTF-16 for encoding wide strings.\n#define GTEST_WIDE_STRING_USES_UTF16_ \\\n  (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2)\n\n// Determines whether test results can be streamed to a socket.\n#if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \\\n    GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD\n# define GTEST_CAN_STREAM_RESULTS_ 1\n#endif\n\n// Defines some utility macros.\n\n// The GNU compiler emits a warning if nested \"if\" statements are followed by\n// an \"else\" statement and braces are not used to explicitly disambiguate the\n// \"else\" binding.  This leads to problems with code like:\n//\n//   if (gate)\n//     ASSERT_*(condition) << \"Some message\";\n//\n// The \"switch (0) case 0:\" idiom is used to suppress this.\n#ifdef __INTEL_COMPILER\n# define GTEST_AMBIGUOUS_ELSE_BLOCKER_\n#else\n# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT\n#endif\n\n// Use this annotation at the end of a struct/class definition to\n// prevent the compiler from optimizing away instances that are never\n// used.  This is useful when all interesting logic happens inside the\n// c'tor and / or d'tor.  Example:\n//\n//   struct Foo {\n//     Foo() { ... }\n//   } GTEST_ATTRIBUTE_UNUSED_;\n//\n// Also use it after a variable or parameter declaration to tell the\n// compiler the variable/parameter does not have to be used.\n#if defined(__GNUC__) && !defined(COMPILER_ICC)\n# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))\n#elif defined(__clang__)\n# if __has_attribute(unused)\n#  define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))\n# endif\n#endif\n#ifndef GTEST_ATTRIBUTE_UNUSED_\n# define GTEST_ATTRIBUTE_UNUSED_\n#endif\n\n// Use this annotation before a function that takes a printf format string.\n#if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC)\n# if defined(__MINGW_PRINTF_FORMAT)\n// MinGW has two different printf implementations. Ensure the format macro\n// matches the selected implementation. See\n// https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.\n#  define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \\\n       __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \\\n                                 first_to_check)))\n# else\n#  define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \\\n       __attribute__((__format__(__printf__, string_index, first_to_check)))\n# endif\n#else\n# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)\n#endif\n\n\n// A macro to disallow copy operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_ASSIGN_(type) \\\n  type& operator=(type const &) = delete\n\n// A macro to disallow copy constructor and operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \\\n  type(type const&) = delete;                 \\\n  type& operator=(type const&) = delete\n\n// A macro to disallow move operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_MOVE_ASSIGN_(type) \\\n  type& operator=(type &&) noexcept = delete\n\n// A macro to disallow move constructor and operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \\\n  type(type&&) noexcept = delete;             \\\n  type& operator=(type&&) noexcept = delete\n\n// Tell the compiler to warn about unused return values for functions declared\n// with this macro.  The macro should be used on function declarations\n// following the argument list:\n//\n//   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;\n#if defined(__GNUC__) && !defined(COMPILER_ICC)\n# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))\n#else\n# define GTEST_MUST_USE_RESULT_\n#endif  // __GNUC__ && !COMPILER_ICC\n\n// MS C++ compiler emits warning when a conditional expression is compile time\n// constant. In some contexts this warning is false positive and needs to be\n// suppressed. Use the following two macros in such cases:\n//\n// GTEST_INTENTIONAL_CONST_COND_PUSH_()\n// while (true) {\n// GTEST_INTENTIONAL_CONST_COND_POP_()\n// }\n# define GTEST_INTENTIONAL_CONST_COND_PUSH_() \\\n    GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127)\n# define GTEST_INTENTIONAL_CONST_COND_POP_() \\\n    GTEST_DISABLE_MSC_WARNINGS_POP_()\n\n// Determine whether the compiler supports Microsoft's Structured Exception\n// Handling.  This is supported by several Windows compilers but generally\n// does not exist on any other system.\n#ifndef GTEST_HAS_SEH\n// The user didn't tell us, so we need to figure it out.\n\n# if defined(_MSC_VER) || defined(__BORLANDC__)\n// These two compilers are known to support SEH.\n#  define GTEST_HAS_SEH 1\n# else\n// Assume no SEH.\n#  define GTEST_HAS_SEH 0\n# endif\n\n#endif  // GTEST_HAS_SEH\n\n#ifndef GTEST_IS_THREADSAFE\n\n#define GTEST_IS_THREADSAFE                                                 \\\n  (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ ||                                     \\\n   (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \\\n   GTEST_HAS_PTHREAD)\n\n#endif  // GTEST_IS_THREADSAFE\n\n// GTEST_API_ qualifies all symbols that must be exported. The definitions below\n// are guarded by #ifndef to give embedders a chance to define GTEST_API_ in\n// gtest/internal/custom/gtest-port.h\n#ifndef GTEST_API_\n\n#ifdef _MSC_VER\n# if GTEST_LINKED_AS_SHARED_LIBRARY\n#  define GTEST_API_ __declspec(dllimport)\n# elif GTEST_CREATE_SHARED_LIBRARY\n#  define GTEST_API_ __declspec(dllexport)\n# endif\n#elif __GNUC__ >= 4 || defined(__clang__)\n# define GTEST_API_ __attribute__((visibility (\"default\")))\n#endif  // _MSC_VER\n\n#endif  // GTEST_API_\n\n#ifndef GTEST_API_\n# define GTEST_API_\n#endif  // GTEST_API_\n\n#ifndef GTEST_DEFAULT_DEATH_TEST_STYLE\n# define GTEST_DEFAULT_DEATH_TEST_STYLE  \"fast\"\n#endif  // GTEST_DEFAULT_DEATH_TEST_STYLE\n\n#ifdef __GNUC__\n// Ask the compiler to never inline a given function.\n# define GTEST_NO_INLINE_ __attribute__((noinline))\n#else\n# define GTEST_NO_INLINE_\n#endif\n\n// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.\n#if !defined(GTEST_HAS_CXXABI_H_)\n# if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER))\n#  define GTEST_HAS_CXXABI_H_ 1\n# else\n#  define GTEST_HAS_CXXABI_H_ 0\n# endif\n#endif\n\n// A function level attribute to disable checking for use of uninitialized\n// memory when built with MemorySanitizer.\n#if defined(__clang__)\n# if __has_feature(memory_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \\\n       __attribute__((no_sanitize_memory))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\n# endif  // __has_feature(memory_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_\n#endif  // __clang__\n\n// A function level attribute to disable AddressSanitizer instrumentation.\n#if defined(__clang__)\n# if __has_feature(address_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \\\n       __attribute__((no_sanitize_address))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\n# endif  // __has_feature(address_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_\n#endif  // __clang__\n\n// A function level attribute to disable HWAddressSanitizer instrumentation.\n#if defined(__clang__)\n# if __has_feature(hwaddress_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \\\n       __attribute__((no_sanitize(\"hwaddress\")))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\n# endif  // __has_feature(hwaddress_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_\n#endif  // __clang__\n\n// A function level attribute to disable ThreadSanitizer instrumentation.\n#if defined(__clang__)\n# if __has_feature(thread_sanitizer)\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \\\n       __attribute__((no_sanitize_thread))\n# else\n#  define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\n# endif  // __has_feature(thread_sanitizer)\n#else\n# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_\n#endif  // __clang__\n\nnamespace testing {\n\nclass Message;\n\n// Legacy imports for backwards compatibility.\n// New code should use std:: names directly.\nusing std::get;\nusing std::make_tuple;\nusing std::tuple;\nusing std::tuple_element;\nusing std::tuple_size;\n\nnamespace internal {\n\n// A secret type that Google Test users don't know about.  It has no\n// definition on purpose.  Therefore it's impossible to create a\n// Secret object, which is what we want.\nclass Secret;\n\n// The GTEST_COMPILE_ASSERT_ is a legacy macro used to verify that a compile\n// time expression is true (in new code, use static_assert instead). For\n// example, you could use it to verify the size of a static array:\n//\n//   GTEST_COMPILE_ASSERT_(GTEST_ARRAY_SIZE_(names) == NUM_NAMES,\n//                         names_incorrect_size);\n//\n// The second argument to the macro must be a valid C++ identifier. If the\n// expression is false, compiler will issue an error containing this identifier.\n#define GTEST_COMPILE_ASSERT_(expr, msg) static_assert(expr, #msg)\n\n// A helper for suppressing warnings on constant condition.  It just\n// returns 'condition'.\nGTEST_API_ bool IsTrue(bool condition);\n\n// Defines RE.\n\n#if GTEST_USES_PCRE\n// if used, PCRE is injected by custom/gtest-port.h\n#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE\n\n// A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended\n// Regular Expression syntax.\nclass GTEST_API_ RE {\n public:\n  // A copy constructor is required by the Standard to initialize object\n  // references from r-values.\n  RE(const RE& other) { Init(other.pattern()); }\n\n  // Constructs an RE from a string.\n  RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT\n\n  RE(const char* regex) { Init(regex); }  // NOLINT\n  ~RE();\n\n  // Returns the string representation of the regex.\n  const char* pattern() const { return pattern_; }\n\n  // FullMatch(str, re) returns true if and only if regular expression re\n  // matches the entire str.\n  // PartialMatch(str, re) returns true if and only if regular expression re\n  // matches a substring of str (including str itself).\n  static bool FullMatch(const ::std::string& str, const RE& re) {\n    return FullMatch(str.c_str(), re);\n  }\n  static bool PartialMatch(const ::std::string& str, const RE& re) {\n    return PartialMatch(str.c_str(), re);\n  }\n\n  static bool FullMatch(const char* str, const RE& re);\n  static bool PartialMatch(const char* str, const RE& re);\n\n private:\n  void Init(const char* regex);\n  const char* pattern_;\n  bool is_valid_;\n\n# if GTEST_USES_POSIX_RE\n\n  regex_t full_regex_;     // For FullMatch().\n  regex_t partial_regex_;  // For PartialMatch().\n\n# else  // GTEST_USES_SIMPLE_RE\n\n  const char* full_pattern_;  // For FullMatch();\n\n# endif\n};\n\n#endif  // GTEST_USES_PCRE\n\n// Formats a source file path and a line number as they would appear\n// in an error message from the compiler used to compile this code.\nGTEST_API_ ::std::string FormatFileLocation(const char* file, int line);\n\n// Formats a file location for compiler-independent XML output.\n// Although this function is not platform dependent, we put it next to\n// FormatFileLocation in order to contrast the two functions.\nGTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,\n                                                               int line);\n\n// Defines logging utilities:\n//   GTEST_LOG_(severity) - logs messages at the specified severity level. The\n//                          message itself is streamed into the macro.\n//   LogToStderr()  - directs all log messages to stderr.\n//   FlushInfoLog() - flushes informational log messages.\n\nenum GTestLogSeverity {\n  GTEST_INFO,\n  GTEST_WARNING,\n  GTEST_ERROR,\n  GTEST_FATAL\n};\n\n// Formats log entry severity, provides a stream object for streaming the\n// log message, and terminates the message with a newline when going out of\n// scope.\nclass GTEST_API_ GTestLog {\n public:\n  GTestLog(GTestLogSeverity severity, const char* file, int line);\n\n  // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.\n  ~GTestLog();\n\n  ::std::ostream& GetStream() { return ::std::cerr; }\n\n private:\n  const GTestLogSeverity severity_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);\n};\n\n#if !defined(GTEST_LOG_)\n\n# define GTEST_LOG_(severity) \\\n    ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \\\n                                  __FILE__, __LINE__).GetStream()\n\ninline void LogToStderr() {}\ninline void FlushInfoLog() { fflush(nullptr); }\n\n#endif  // !defined(GTEST_LOG_)\n\n#if !defined(GTEST_CHECK_)\n// INTERNAL IMPLEMENTATION - DO NOT USE.\n//\n// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition\n// is not satisfied.\n//  Synopsys:\n//    GTEST_CHECK_(boolean_condition);\n//     or\n//    GTEST_CHECK_(boolean_condition) << \"Additional message\";\n//\n//    This checks the condition and if the condition is not satisfied\n//    it prints message about the condition violation, including the\n//    condition itself, plus additional message streamed into it, if any,\n//    and then it aborts the program. It aborts the program irrespective of\n//    whether it is built in the debug mode or not.\n# define GTEST_CHECK_(condition) \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n    if (::testing::internal::IsTrue(condition)) \\\n      ; \\\n    else \\\n      GTEST_LOG_(FATAL) << \"Condition \" #condition \" failed. \"\n#endif  // !defined(GTEST_CHECK_)\n\n// An all-mode assert to verify that the given POSIX-style function\n// call returns 0 (indicating success).  Known limitation: this\n// doesn't expand to a balanced 'if' statement, so enclose the macro\n// in {} if you need to use it as the only statement in an 'if'\n// branch.\n#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \\\n  if (const int gtest_error = (posix_call)) \\\n    GTEST_LOG_(FATAL) << #posix_call << \"failed with error \" \\\n                      << gtest_error\n\n// Transforms \"T\" into \"const T&\" according to standard reference collapsing\n// rules (this is only needed as a backport for C++98 compilers that do not\n// support reference collapsing). Specifically, it transforms:\n//\n//   char         ==> const char&\n//   const char   ==> const char&\n//   char&        ==> char&\n//   const char&  ==> const char&\n//\n// Note that the non-const reference will not have \"const\" added. This is\n// standard, and necessary so that \"T\" can always bind to \"const T&\".\ntemplate <typename T>\nstruct ConstRef { typedef const T& type; };\ntemplate <typename T>\nstruct ConstRef<T&> { typedef T& type; };\n\n// The argument T must depend on some template parameters.\n#define GTEST_REFERENCE_TO_CONST_(T) \\\n  typename ::testing::internal::ConstRef<T>::type\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Use ImplicitCast_ as a safe version of static_cast for upcasting in\n// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a\n// const Foo*).  When you use ImplicitCast_, the compiler checks that\n// the cast is safe.  Such explicit ImplicitCast_s are necessary in\n// surprisingly many situations where C++ demands an exact type match\n// instead of an argument type convertable to a target type.\n//\n// The syntax for using ImplicitCast_ is the same as for static_cast:\n//\n//   ImplicitCast_<ToType>(expr)\n//\n// ImplicitCast_ would have been part of the C++ standard library,\n// but the proposal was submitted too late.  It will probably make\n// its way into the language in the future.\n//\n// This relatively ugly name is intentional. It prevents clashes with\n// similar functions users may have (e.g., implicit_cast). The internal\n// namespace alone is not enough because the function can be found by ADL.\ntemplate<typename To>\ninline To ImplicitCast_(To x) { return x; }\n\n// When you upcast (that is, cast a pointer from type Foo to type\n// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts\n// always succeed.  When you downcast (that is, cast a pointer from\n// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because\n// how do you know the pointer is really of type SubclassOfFoo?  It\n// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,\n// when you downcast, you should use this macro.  In debug mode, we\n// use dynamic_cast<> to double-check the downcast is legal (we die\n// if it's not).  In normal mode, we do the efficient static_cast<>\n// instead.  Thus, it's important to test in debug mode to make sure\n// the cast is legal!\n//    This is the only place in the code we should use dynamic_cast<>.\n// In particular, you SHOULDN'T be using dynamic_cast<> in order to\n// do RTTI (eg code like this:\n//    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);\n//    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);\n// You should design the code some other way not to need this.\n//\n// This relatively ugly name is intentional. It prevents clashes with\n// similar functions users may have (e.g., down_cast). The internal\n// namespace alone is not enough because the function can be found by ADL.\ntemplate<typename To, typename From>  // use like this: DownCast_<T*>(foo);\ninline To DownCast_(From* f) {  // so we only accept pointers\n  // Ensures that To is a sub-type of From *.  This test is here only\n  // for compile-time type checking, and has no overhead in an\n  // optimized build at run-time, as it will be optimized away\n  // completely.\n  GTEST_INTENTIONAL_CONST_COND_PUSH_()\n  if (false) {\n  GTEST_INTENTIONAL_CONST_COND_POP_()\n  const To to = nullptr;\n  ::testing::internal::ImplicitCast_<From*>(to);\n  }\n\n#if GTEST_HAS_RTTI\n  // RTTI: debug mode only!\n  GTEST_CHECK_(f == nullptr || dynamic_cast<To>(f) != nullptr);\n#endif\n  return static_cast<To>(f);\n}\n\n// Downcasts the pointer of type Base to Derived.\n// Derived must be a subclass of Base. The parameter MUST\n// point to a class of type Derived, not any subclass of it.\n// When RTTI is available, the function performs a runtime\n// check to enforce this.\ntemplate <class Derived, class Base>\nDerived* CheckedDowncastToActualType(Base* base) {\n#if GTEST_HAS_RTTI\n  GTEST_CHECK_(typeid(*base) == typeid(Derived));\n#endif\n\n#if GTEST_HAS_DOWNCAST_\n  return ::down_cast<Derived*>(base);\n#elif GTEST_HAS_RTTI\n  return dynamic_cast<Derived*>(base);  // NOLINT\n#else\n  return static_cast<Derived*>(base);  // Poor man's downcast.\n#endif\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Defines the stderr capturer:\n//   CaptureStdout     - starts capturing stdout.\n//   GetCapturedStdout - stops capturing stdout and returns the captured string.\n//   CaptureStderr     - starts capturing stderr.\n//   GetCapturedStderr - stops capturing stderr and returns the captured string.\n//\nGTEST_API_ void CaptureStdout();\nGTEST_API_ std::string GetCapturedStdout();\nGTEST_API_ void CaptureStderr();\nGTEST_API_ std::string GetCapturedStderr();\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n// Returns the size (in bytes) of a file.\nGTEST_API_ size_t GetFileSize(FILE* file);\n\n// Reads the entire content of a file as a string.\nGTEST_API_ std::string ReadEntireFile(FILE* file);\n\n// All command line arguments.\nGTEST_API_ std::vector<std::string> GetArgvs();\n\n#if GTEST_HAS_DEATH_TEST\n\nstd::vector<std::string> GetInjectableArgvs();\n// Deprecated: pass the args vector by value instead.\nvoid SetInjectableArgvs(const std::vector<std::string>* new_argvs);\nvoid SetInjectableArgvs(const std::vector<std::string>& new_argvs);\nvoid ClearInjectableArgvs();\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Defines synchronization primitives.\n#if GTEST_IS_THREADSAFE\n# if GTEST_HAS_PTHREAD\n// Sleeps for (roughly) n milliseconds.  This function is only for testing\n// Google Test's own constructs.  Don't use it in user tests, either\n// directly or indirectly.\ninline void SleepMilliseconds(int n) {\n  const timespec time = {\n    0,                  // 0 seconds.\n    n * 1000L * 1000L,  // And n ms.\n  };\n  nanosleep(&time, nullptr);\n}\n# endif  // GTEST_HAS_PTHREAD\n\n# if GTEST_HAS_NOTIFICATION_\n// Notification has already been imported into the namespace.\n// Nothing to do here.\n\n# elif GTEST_HAS_PTHREAD\n// Allows a controller thread to pause execution of newly created\n// threads until notified.  Instances of this class must be created\n// and destroyed in the controller thread.\n//\n// This class is only for testing Google Test's own constructs. Do not\n// use it in user tests, either directly or indirectly.\nclass Notification {\n public:\n  Notification() : notified_(false) {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));\n  }\n  ~Notification() {\n    pthread_mutex_destroy(&mutex_);\n  }\n\n  // Notifies all threads created with this notification to start. Must\n  // be called from the controller thread.\n  void Notify() {\n    pthread_mutex_lock(&mutex_);\n    notified_ = true;\n    pthread_mutex_unlock(&mutex_);\n  }\n\n  // Blocks until the controller thread notifies. Must be called from a test\n  // thread.\n  void WaitForNotification() {\n    for (;;) {\n      pthread_mutex_lock(&mutex_);\n      const bool notified = notified_;\n      pthread_mutex_unlock(&mutex_);\n      if (notified)\n        break;\n      SleepMilliseconds(10);\n    }\n  }\n\n private:\n  pthread_mutex_t mutex_;\n  bool notified_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);\n};\n\n# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n\nGTEST_API_ void SleepMilliseconds(int n);\n\n// Provides leak-safe Windows kernel handle ownership.\n// Used in death tests and in threading support.\nclass GTEST_API_ AutoHandle {\n public:\n  // Assume that Win32 HANDLE type is equivalent to void*. Doing so allows us to\n  // avoid including <windows.h> in this header file. Including <windows.h> is\n  // undesirable because it defines a lot of symbols and macros that tend to\n  // conflict with client code. This assumption is verified by\n  // WindowsTypesTest.HANDLEIsVoidStar.\n  typedef void* Handle;\n  AutoHandle();\n  explicit AutoHandle(Handle handle);\n\n  ~AutoHandle();\n\n  Handle Get() const;\n  void Reset();\n  void Reset(Handle handle);\n\n private:\n  // Returns true if and only if the handle is a valid handle object that can be\n  // closed.\n  bool IsCloseable() const;\n\n  Handle handle_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);\n};\n\n// Allows a controller thread to pause execution of newly created\n// threads until notified.  Instances of this class must be created\n// and destroyed in the controller thread.\n//\n// This class is only for testing Google Test's own constructs. Do not\n// use it in user tests, either directly or indirectly.\nclass GTEST_API_ Notification {\n public:\n  Notification();\n  void Notify();\n  void WaitForNotification();\n\n private:\n  AutoHandle event_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);\n};\n# endif  // GTEST_HAS_NOTIFICATION_\n\n// On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD\n// defined, but we don't want to use MinGW's pthreads implementation, which\n// has conformance problems with some versions of the POSIX standard.\n# if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW\n\n// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.\n// Consequently, it cannot select a correct instantiation of ThreadWithParam\n// in order to call its Run(). Introducing ThreadWithParamBase as a\n// non-templated base class for ThreadWithParam allows us to bypass this\n// problem.\nclass ThreadWithParamBase {\n public:\n  virtual ~ThreadWithParamBase() {}\n  virtual void Run() = 0;\n};\n\n// pthread_create() accepts a pointer to a function type with the C linkage.\n// According to the Standard (7.5/1), function types with different linkages\n// are different even if they are otherwise identical.  Some compilers (for\n// example, SunStudio) treat them as different types.  Since class methods\n// cannot be defined with C-linkage we need to define a free C-function to\n// pass into pthread_create().\nextern \"C\" inline void* ThreadFuncWithCLinkage(void* thread) {\n  static_cast<ThreadWithParamBase*>(thread)->Run();\n  return nullptr;\n}\n\n// Helper class for testing Google Test's multi-threading constructs.\n// To use it, write:\n//\n//   void ThreadFunc(int param) { /* Do things with param */ }\n//   Notification thread_can_start;\n//   ...\n//   // The thread_can_start parameter is optional; you can supply NULL.\n//   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);\n//   thread_can_start.Notify();\n//\n// These classes are only for testing Google Test's own constructs. Do\n// not use them in user tests, either directly or indirectly.\ntemplate <typename T>\nclass ThreadWithParam : public ThreadWithParamBase {\n public:\n  typedef void UserThreadFunc(T);\n\n  ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)\n      : func_(func),\n        param_(param),\n        thread_can_start_(thread_can_start),\n        finished_(false) {\n    ThreadWithParamBase* const base = this;\n    // The thread can be created only after all fields except thread_\n    // have been initialized.\n    GTEST_CHECK_POSIX_SUCCESS_(\n        pthread_create(&thread_, nullptr, &ThreadFuncWithCLinkage, base));\n  }\n  ~ThreadWithParam() override { Join(); }\n\n  void Join() {\n    if (!finished_) {\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, nullptr));\n      finished_ = true;\n    }\n  }\n\n  void Run() override {\n    if (thread_can_start_ != nullptr) thread_can_start_->WaitForNotification();\n    func_(param_);\n  }\n\n private:\n  UserThreadFunc* const func_;  // User-supplied thread function.\n  const T param_;  // User-supplied parameter to the thread function.\n  // When non-NULL, used to block execution until the controller thread\n  // notifies.\n  Notification* const thread_can_start_;\n  bool finished_;  // true if and only if we know that the thread function has\n                   // finished.\n  pthread_t thread_;  // The native thread object.\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);\n};\n# endif  // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD ||\n         // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_\n\n# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_\n// Mutex and ThreadLocal have already been imported into the namespace.\n// Nothing to do here.\n\n# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT\n\n// Mutex implements mutex on Windows platforms.  It is used in conjunction\n// with class MutexLock:\n//\n//   Mutex mutex;\n//   ...\n//   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the\n//                            // end of the current scope.\n//\n// A static Mutex *must* be defined or declared using one of the following\n// macros:\n//   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);\n//   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);\n//\n// (A non-static Mutex is defined/declared in the usual way).\nclass GTEST_API_ Mutex {\n public:\n  enum MutexType { kStatic = 0, kDynamic = 1 };\n  // We rely on kStaticMutex being 0 as it is to what the linker initializes\n  // type_ in static mutexes.  critical_section_ will be initialized lazily\n  // in ThreadSafeLazyInit().\n  enum StaticConstructorSelector { kStaticMutex = 0 };\n\n  // This constructor intentionally does nothing.  It relies on type_ being\n  // statically initialized to 0 (effectively setting it to kStatic) and on\n  // ThreadSafeLazyInit() to lazily initialize the rest of the members.\n  explicit Mutex(StaticConstructorSelector /*dummy*/) {}\n\n  Mutex();\n  ~Mutex();\n\n  void Lock();\n\n  void Unlock();\n\n  // Does nothing if the current thread holds the mutex. Otherwise, crashes\n  // with high probability.\n  void AssertHeld();\n\n private:\n  // Initializes owner_thread_id_ and critical_section_ in static mutexes.\n  void ThreadSafeLazyInit();\n\n  // Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503,\n  // we assume that 0 is an invalid value for thread IDs.\n  unsigned int owner_thread_id_;\n\n  // For static mutexes, we rely on these members being initialized to zeros\n  // by the linker.\n  MutexType type_;\n  long critical_section_init_phase_;  // NOLINT\n  GTEST_CRITICAL_SECTION* critical_section_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n};\n\n# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n    extern ::testing::internal::Mutex mutex\n\n# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \\\n    ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex)\n\n// We cannot name this class MutexLock because the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms. That macro is used as a defensive measure to prevent against\n// inadvertent misuses of MutexLock like \"MutexLock(&mu)\" rather than\n// \"MutexLock l(&mu)\".  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(Mutex* mutex)\n      : mutex_(mutex) { mutex_->Lock(); }\n\n  ~GTestMutexLock() { mutex_->Unlock(); }\n\n private:\n  Mutex* const mutex_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);\n};\n\ntypedef GTestMutexLock MutexLock;\n\n// Base class for ValueHolder<T>.  Allows a caller to hold and delete a value\n// without knowing its type.\nclass ThreadLocalValueHolderBase {\n public:\n  virtual ~ThreadLocalValueHolderBase() {}\n};\n\n// Provides a way for a thread to send notifications to a ThreadLocal\n// regardless of its parameter type.\nclass ThreadLocalBase {\n public:\n  // Creates a new ValueHolder<T> object holding a default value passed to\n  // this ThreadLocal<T>'s constructor and returns it.  It is the caller's\n  // responsibility not to call this when the ThreadLocal<T> instance already\n  // has a value on the current thread.\n  virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const = 0;\n\n protected:\n  ThreadLocalBase() {}\n  virtual ~ThreadLocalBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocalBase);\n};\n\n// Maps a thread to a set of ThreadLocals that have values instantiated on that\n// thread and notifies them when the thread exits.  A ThreadLocal instance is\n// expected to persist until all threads it has values on have terminated.\nclass GTEST_API_ ThreadLocalRegistry {\n public:\n  // Registers thread_local_instance as having value on the current thread.\n  // Returns a value that can be used to identify the thread from other threads.\n  static ThreadLocalValueHolderBase* GetValueOnCurrentThread(\n      const ThreadLocalBase* thread_local_instance);\n\n  // Invoked when a ThreadLocal instance is destroyed.\n  static void OnThreadLocalDestroyed(\n      const ThreadLocalBase* thread_local_instance);\n};\n\nclass GTEST_API_ ThreadWithParamBase {\n public:\n  void Join();\n\n protected:\n  class Runnable {\n   public:\n    virtual ~Runnable() {}\n    virtual void Run() = 0;\n  };\n\n  ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start);\n  virtual ~ThreadWithParamBase();\n\n private:\n  AutoHandle thread_;\n};\n\n// Helper class for testing Google Test's multi-threading constructs.\ntemplate <typename T>\nclass ThreadWithParam : public ThreadWithParamBase {\n public:\n  typedef void UserThreadFunc(T);\n\n  ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start)\n      : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {\n  }\n  virtual ~ThreadWithParam() {}\n\n private:\n  class RunnableImpl : public Runnable {\n   public:\n    RunnableImpl(UserThreadFunc* func, T param)\n        : func_(func),\n          param_(param) {\n    }\n    virtual ~RunnableImpl() {}\n    virtual void Run() {\n      func_(param_);\n    }\n\n   private:\n    UserThreadFunc* const func_;\n    const T param_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(RunnableImpl);\n  };\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);\n};\n\n// Implements thread-local storage on Windows systems.\n//\n//   // Thread 1\n//   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.\n//\n//   // Thread 2\n//   tl.set(150);  // Changes the value for thread 2 only.\n//   EXPECT_EQ(150, tl.get());\n//\n//   // Thread 1\n//   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.\n//   tl.set(200);\n//   EXPECT_EQ(200, tl.get());\n//\n// The template type argument T must have a public copy constructor.\n// In addition, the default ThreadLocal constructor requires T to have\n// a public default constructor.\n//\n// The users of a TheadLocal instance have to make sure that all but one\n// threads (including the main one) using that instance have exited before\n// destroying it. Otherwise, the per-thread objects managed for them by the\n// ThreadLocal instance are not guaranteed to be destroyed on all platforms.\n//\n// Google Test only uses global ThreadLocal objects.  That means they\n// will die after main() has returned.  Therefore, no per-thread\n// object managed by Google Test will be leaked as long as all threads\n// using Google Test have exited when main() returns.\ntemplate <typename T>\nclass ThreadLocal : public ThreadLocalBase {\n public:\n  ThreadLocal() : default_factory_(new DefaultValueHolderFactory()) {}\n  explicit ThreadLocal(const T& value)\n      : default_factory_(new InstanceValueHolderFactory(value)) {}\n\n  ~ThreadLocal() { ThreadLocalRegistry::OnThreadLocalDestroyed(this); }\n\n  T* pointer() { return GetOrCreateValue(); }\n  const T* pointer() const { return GetOrCreateValue(); }\n  const T& get() const { return *pointer(); }\n  void set(const T& value) { *pointer() = value; }\n\n private:\n  // Holds a value of T.  Can be deleted via its base class without the caller\n  // knowing the type of T.\n  class ValueHolder : public ThreadLocalValueHolderBase {\n   public:\n    ValueHolder() : value_() {}\n    explicit ValueHolder(const T& value) : value_(value) {}\n\n    T* pointer() { return &value_; }\n\n   private:\n    T value_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);\n  };\n\n\n  T* GetOrCreateValue() const {\n    return static_cast<ValueHolder*>(\n        ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer();\n  }\n\n  virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const {\n    return default_factory_->MakeNewHolder();\n  }\n\n  class ValueHolderFactory {\n   public:\n    ValueHolderFactory() {}\n    virtual ~ValueHolderFactory() {}\n    virtual ValueHolder* MakeNewHolder() const = 0;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);\n  };\n\n  class DefaultValueHolderFactory : public ValueHolderFactory {\n   public:\n    DefaultValueHolderFactory() {}\n    ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);\n  };\n\n  class InstanceValueHolderFactory : public ValueHolderFactory {\n   public:\n    explicit InstanceValueHolderFactory(const T& value) : value_(value) {}\n    ValueHolder* MakeNewHolder() const override {\n      return new ValueHolder(value_);\n    }\n\n   private:\n    const T value_;  // The value for each thread.\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);\n  };\n\n  std::unique_ptr<ValueHolderFactory> default_factory_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);\n};\n\n# elif GTEST_HAS_PTHREAD\n\n// MutexBase and Mutex implement mutex on pthreads-based platforms.\nclass MutexBase {\n public:\n  // Acquires this mutex.\n  void Lock() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));\n    owner_ = pthread_self();\n    has_owner_ = true;\n  }\n\n  // Releases this mutex.\n  void Unlock() {\n    // Since the lock is being released the owner_ field should no longer be\n    // considered valid. We don't protect writing to has_owner_ here, as it's\n    // the caller's responsibility to ensure that the current thread holds the\n    // mutex when this is called.\n    has_owner_ = false;\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));\n  }\n\n  // Does nothing if the current thread holds the mutex. Otherwise, crashes\n  // with high probability.\n  void AssertHeld() const {\n    GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))\n        << \"The current thread is not holding the mutex @\" << this;\n  }\n\n  // A static mutex may be used before main() is entered.  It may even\n  // be used before the dynamic initialization stage.  Therefore we\n  // must be able to initialize a static mutex object at link time.\n  // This means MutexBase has to be a POD and its member variables\n  // have to be public.\n public:\n  pthread_mutex_t mutex_;  // The underlying pthread mutex.\n  // has_owner_ indicates whether the owner_ field below contains a valid thread\n  // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All\n  // accesses to the owner_ field should be protected by a check of this field.\n  // An alternative might be to memset() owner_ to all zeros, but there's no\n  // guarantee that a zero'd pthread_t is necessarily invalid or even different\n  // from pthread_self().\n  bool has_owner_;\n  pthread_t owner_;  // The thread holding the mutex.\n};\n\n// Forward-declares a static mutex.\n#  define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n     extern ::testing::internal::MutexBase mutex\n\n// Defines and statically (i.e. at link time) initializes a static mutex.\n// The initialization list here does not explicitly initialize each field,\n// instead relying on default initialization for the unspecified fields. In\n// particular, the owner_ field (a pthread_t) is not explicitly initialized.\n// This allows initialization to work whether pthread_t is a scalar or struct.\n// The flag -Wmissing-field-initializers must not be specified for this to work.\n#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \\\n  ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}\n\n// The Mutex class can only be used for mutexes created at runtime. It\n// shares its API with MutexBase otherwise.\nclass Mutex : public MutexBase {\n public:\n  Mutex() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr));\n    has_owner_ = false;\n  }\n  ~Mutex() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n};\n\n// We cannot name this class MutexLock because the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms. That macro is used as a defensive measure to prevent against\n// inadvertent misuses of MutexLock like \"MutexLock(&mu)\" rather than\n// \"MutexLock l(&mu)\".  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(MutexBase* mutex)\n      : mutex_(mutex) { mutex_->Lock(); }\n\n  ~GTestMutexLock() { mutex_->Unlock(); }\n\n private:\n  MutexBase* const mutex_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);\n};\n\ntypedef GTestMutexLock MutexLock;\n\n// Helpers for ThreadLocal.\n\n// pthread_key_create() requires DeleteThreadLocalValue() to have\n// C-linkage.  Therefore it cannot be templatized to access\n// ThreadLocal<T>.  Hence the need for class\n// ThreadLocalValueHolderBase.\nclass ThreadLocalValueHolderBase {\n public:\n  virtual ~ThreadLocalValueHolderBase() {}\n};\n\n// Called by pthread to delete thread-local data stored by\n// pthread_setspecific().\nextern \"C\" inline void DeleteThreadLocalValue(void* value_holder) {\n  delete static_cast<ThreadLocalValueHolderBase*>(value_holder);\n}\n\n// Implements thread-local storage on pthreads-based systems.\ntemplate <typename T>\nclass GTEST_API_ ThreadLocal {\n public:\n  ThreadLocal()\n      : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}\n  explicit ThreadLocal(const T& value)\n      : key_(CreateKey()),\n        default_factory_(new InstanceValueHolderFactory(value)) {}\n\n  ~ThreadLocal() {\n    // Destroys the managed object for the current thread, if any.\n    DeleteThreadLocalValue(pthread_getspecific(key_));\n\n    // Releases resources associated with the key.  This will *not*\n    // delete managed objects for other threads.\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));\n  }\n\n  T* pointer() { return GetOrCreateValue(); }\n  const T* pointer() const { return GetOrCreateValue(); }\n  const T& get() const { return *pointer(); }\n  void set(const T& value) { *pointer() = value; }\n\n private:\n  // Holds a value of type T.\n  class ValueHolder : public ThreadLocalValueHolderBase {\n   public:\n    ValueHolder() : value_() {}\n    explicit ValueHolder(const T& value) : value_(value) {}\n\n    T* pointer() { return &value_; }\n\n   private:\n    T value_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);\n  };\n\n  static pthread_key_t CreateKey() {\n    pthread_key_t key;\n    // When a thread exits, DeleteThreadLocalValue() will be called on\n    // the object managed for that thread.\n    GTEST_CHECK_POSIX_SUCCESS_(\n        pthread_key_create(&key, &DeleteThreadLocalValue));\n    return key;\n  }\n\n  T* GetOrCreateValue() const {\n    ThreadLocalValueHolderBase* const holder =\n        static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));\n    if (holder != nullptr) {\n      return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();\n    }\n\n    ValueHolder* const new_holder = default_factory_->MakeNewHolder();\n    ThreadLocalValueHolderBase* const holder_base = new_holder;\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));\n    return new_holder->pointer();\n  }\n\n  class ValueHolderFactory {\n   public:\n    ValueHolderFactory() {}\n    virtual ~ValueHolderFactory() {}\n    virtual ValueHolder* MakeNewHolder() const = 0;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolderFactory);\n  };\n\n  class DefaultValueHolderFactory : public ValueHolderFactory {\n   public:\n    DefaultValueHolderFactory() {}\n    ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultValueHolderFactory);\n  };\n\n  class InstanceValueHolderFactory : public ValueHolderFactory {\n   public:\n    explicit InstanceValueHolderFactory(const T& value) : value_(value) {}\n    ValueHolder* MakeNewHolder() const override {\n      return new ValueHolder(value_);\n    }\n\n   private:\n    const T value_;  // The value for each thread.\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(InstanceValueHolderFactory);\n  };\n\n  // A key pthreads uses for looking up per-thread values.\n  const pthread_key_t key_;\n  std::unique_ptr<ValueHolderFactory> default_factory_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);\n};\n\n# endif  // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_\n\n#else  // GTEST_IS_THREADSAFE\n\n// A dummy implementation of synchronization primitives (mutex, lock,\n// and thread-local variable).  Necessary for compiling Google Test where\n// mutex is not supported - using Google Test in multiple threads is not\n// supported on such platforms.\n\nclass Mutex {\n public:\n  Mutex() {}\n  void Lock() {}\n  void Unlock() {}\n  void AssertHeld() const {}\n};\n\n# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n  extern ::testing::internal::Mutex mutex\n\n# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex\n\n// We cannot name this class MutexLock because the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms. That macro is used as a defensive measure to prevent against\n// inadvertent misuses of MutexLock like \"MutexLock(&mu)\" rather than\n// \"MutexLock l(&mu)\".  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(Mutex*) {}  // NOLINT\n};\n\ntypedef GTestMutexLock MutexLock;\n\ntemplate <typename T>\nclass GTEST_API_ ThreadLocal {\n public:\n  ThreadLocal() : value_() {}\n  explicit ThreadLocal(const T& value) : value_(value) {}\n  T* pointer() { return &value_; }\n  const T* pointer() const { return &value_; }\n  const T& get() const { return value_; }\n  void set(const T& value) { value_ = value; }\n private:\n  T value_;\n};\n\n#endif  // GTEST_IS_THREADSAFE\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nGTEST_API_ size_t GetThreadCount();\n\n#if GTEST_OS_WINDOWS\n# define GTEST_PATH_SEP_ \"\\\\\"\n# define GTEST_HAS_ALT_PATH_SEP_ 1\n#else\n# define GTEST_PATH_SEP_ \"/\"\n# define GTEST_HAS_ALT_PATH_SEP_ 0\n#endif  // GTEST_OS_WINDOWS\n\n// Utilities for char.\n\n// isspace(int ch) and friends accept an unsigned char or EOF.  char\n// may be signed, depending on the compiler (or compiler flags).\n// Therefore we need to cast a char to unsigned char before calling\n// isspace(), etc.\n\ninline bool IsAlpha(char ch) {\n  return isalpha(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsAlNum(char ch) {\n  return isalnum(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsDigit(char ch) {\n  return isdigit(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsLower(char ch) {\n  return islower(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsSpace(char ch) {\n  return isspace(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsUpper(char ch) {\n  return isupper(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsXDigit(char ch) {\n  return isxdigit(static_cast<unsigned char>(ch)) != 0;\n}\n#ifdef __cpp_char8_t\ninline bool IsXDigit(char8_t ch) {\n  return isxdigit(static_cast<unsigned char>(ch)) != 0;\n}\n#endif\ninline bool IsXDigit(char16_t ch) {\n  const unsigned char low_byte = static_cast<unsigned char>(ch);\n  return ch == low_byte && isxdigit(low_byte) != 0;\n}\ninline bool IsXDigit(char32_t ch) {\n  const unsigned char low_byte = static_cast<unsigned char>(ch);\n  return ch == low_byte && isxdigit(low_byte) != 0;\n}\ninline bool IsXDigit(wchar_t ch) {\n  const unsigned char low_byte = static_cast<unsigned char>(ch);\n  return ch == low_byte && isxdigit(low_byte) != 0;\n}\n\ninline char ToLower(char ch) {\n  return static_cast<char>(tolower(static_cast<unsigned char>(ch)));\n}\ninline char ToUpper(char ch) {\n  return static_cast<char>(toupper(static_cast<unsigned char>(ch)));\n}\n\ninline std::string StripTrailingSpaces(std::string str) {\n  std::string::iterator it = str.end();\n  while (it != str.begin() && IsSpace(*--it))\n    it = str.erase(it);\n  return str;\n}\n\n// The testing::internal::posix namespace holds wrappers for common\n// POSIX functions.  These wrappers hide the differences between\n// Windows/MSVC and POSIX systems.  Since some compilers define these\n// standard functions as macros, the wrapper cannot have the same name\n// as the wrapped function.\n\nnamespace posix {\n\n// Functions with a different name on Windows.\n\n#if GTEST_OS_WINDOWS\n\ntypedef struct _stat StatStruct;\n\n# ifdef __BORLANDC__\ninline int DoIsATTY(int fd) { return isatty(fd); }\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return stricmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\n# else  // !__BORLANDC__\n#  if GTEST_OS_WINDOWS_MOBILE\ninline int DoIsATTY(int /* fd */) { return 0; }\n#  else\ninline int DoIsATTY(int fd) { return _isatty(fd); }\n#  endif  // GTEST_OS_WINDOWS_MOBILE\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return _stricmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return _strdup(src); }\n# endif  // __BORLANDC__\n\n# if GTEST_OS_WINDOWS_MOBILE\ninline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }\n// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this\n// time and thus not defined there.\n# else\ninline int FileNo(FILE* file) { return _fileno(file); }\ninline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }\ninline int RmDir(const char* dir) { return _rmdir(dir); }\ninline bool IsDir(const StatStruct& st) {\n  return (_S_IFDIR & st.st_mode) != 0;\n}\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n#elif GTEST_OS_ESP8266\ntypedef struct stat StatStruct;\n\ninline int FileNo(FILE* file) { return fileno(file); }\ninline int DoIsATTY(int fd) { return isatty(fd); }\ninline int Stat(const char* path, StatStruct* buf) {\n  // stat function not implemented on ESP8266\n  return 0;\n}\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return strcasecmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\ninline int RmDir(const char* dir) { return rmdir(dir); }\ninline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }\n\n#else\n\ntypedef struct stat StatStruct;\n\ninline int FileNo(FILE* file) { return fileno(file); }\ninline int DoIsATTY(int fd) { return isatty(fd); }\ninline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return strcasecmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\ninline int RmDir(const char* dir) { return rmdir(dir); }\ninline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }\n\n#endif  // GTEST_OS_WINDOWS\n\ninline int IsATTY(int fd) {\n  // DoIsATTY might change errno (for example ENOTTY in case you redirect stdout\n  // to a file on Linux), which is unexpected, so save the previous value, and\n  // restore it after the call.\n  int savedErrno = errno;\n  int isAttyValue = DoIsATTY(fd);\n  errno = savedErrno;\n\n  return isAttyValue;\n}\n\n// Functions deprecated by MSVC 8.0.\n\nGTEST_DISABLE_MSC_DEPRECATED_PUSH_()\n\n// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and\n// StrError() aren't needed on Windows CE at this time and thus not\n// defined there.\n\n#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \\\n    !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA\ninline int ChDir(const char* dir) { return chdir(dir); }\n#endif\ninline FILE* FOpen(const char* path, const char* mode) {\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW\n  struct wchar_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t> {};\n  std::wstring_convert<wchar_codecvt> converter;\n  std::wstring wide_path = converter.from_bytes(path);\n  std::wstring wide_mode = converter.from_bytes(mode);\n  return _wfopen(wide_path.c_str(), wide_mode.c_str());\n#else  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW\n  return fopen(path, mode);\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW\n}\n#if !GTEST_OS_WINDOWS_MOBILE\ninline FILE *FReopen(const char* path, const char* mode, FILE* stream) {\n  return freopen(path, mode, stream);\n}\ninline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }\n#endif\ninline int FClose(FILE* fp) { return fclose(fp); }\n#if !GTEST_OS_WINDOWS_MOBILE\ninline int Read(int fd, void* buf, unsigned int count) {\n  return static_cast<int>(read(fd, buf, count));\n}\ninline int Write(int fd, const void* buf, unsigned int count) {\n  return static_cast<int>(write(fd, buf, count));\n}\ninline int Close(int fd) { return close(fd); }\ninline const char* StrError(int errnum) { return strerror(errnum); }\n#endif\ninline const char* GetEnv(const char* name) {\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \\\n    GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA\n  // We are on an embedded platform, which has no environment variables.\n  static_cast<void>(name);  // To prevent 'unused argument' warning.\n  return nullptr;\n#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)\n  // Environment variables which we programmatically clear will be set to the\n  // empty string rather than unset (NULL).  Handle that case.\n  const char* const env = getenv(name);\n  return (env != nullptr && env[0] != '\\0') ? env : nullptr;\n#else\n  return getenv(name);\n#endif\n}\n\nGTEST_DISABLE_MSC_DEPRECATED_POP_()\n\n#if GTEST_OS_WINDOWS_MOBILE\n// Windows CE has no C library. The abort() function is used in\n// several places in Google Test. This implementation provides a reasonable\n// imitation of standard behaviour.\n[[noreturn]] void Abort();\n#else\n[[noreturn]] inline void Abort() { abort(); }\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n}  // namespace posix\n\n// MSVC \"deprecates\" snprintf and issues warnings wherever it is used.  In\n// order to avoid these warnings, we need to use _snprintf or _snprintf_s on\n// MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate\n// function in order to achieve that.  We use macro definition here because\n// snprintf is a variadic function.\n#if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE\n// MSVC 2005 and above support variadic macros.\n# define GTEST_SNPRINTF_(buffer, size, format, ...) \\\n     _snprintf_s(buffer, size, size, format, __VA_ARGS__)\n#elif defined(_MSC_VER)\n// Windows CE does not define _snprintf_s\n# define GTEST_SNPRINTF_ _snprintf\n#else\n# define GTEST_SNPRINTF_ snprintf\n#endif\n\n// The biggest signed integer type the compiler supports.\n//\n// long long is guaranteed to be at least 64-bits in C++11.\nusing BiggestInt = long long;  // NOLINT\n\n// The maximum number a BiggestInt can represent.\nconstexpr BiggestInt kMaxBiggestInt = (std::numeric_limits<BiggestInt>::max)();\n\n// This template class serves as a compile-time function from size to\n// type.  It maps a size in bytes to a primitive type with that\n// size. e.g.\n//\n//   TypeWithSize<4>::UInt\n//\n// is typedef-ed to be unsigned int (unsigned integer made up of 4\n// bytes).\n//\n// Such functionality should belong to STL, but I cannot find it\n// there.\n//\n// Google Test uses this class in the implementation of floating-point\n// comparison.\n//\n// For now it only handles UInt (unsigned int) as that's all Google Test\n// needs.  Other types can be easily added in the future if need\n// arises.\ntemplate <size_t size>\nclass TypeWithSize {\n public:\n  // This prevents the user from using TypeWithSize<N> with incorrect\n  // values of N.\n  using UInt = void;\n};\n\n// The specialization for size 4.\ntemplate <>\nclass TypeWithSize<4> {\n public:\n  using Int = std::int32_t;\n  using UInt = std::uint32_t;\n};\n\n// The specialization for size 8.\ntemplate <>\nclass TypeWithSize<8> {\n public:\n  using Int = std::int64_t;\n  using UInt = std::uint64_t;\n};\n\n// Integer types of known sizes.\nusing TimeInMillis = int64_t;  // Represents time in milliseconds.\n\n// Utilities for command line flags and environment variables.\n\n// Macro for referencing flags.\n#if !defined(GTEST_FLAG)\n# define GTEST_FLAG(name) FLAGS_gtest_##name\n#endif  // !defined(GTEST_FLAG)\n\n#if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)\n# define GTEST_USE_OWN_FLAGFILE_FLAG_ 1\n#endif  // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_)\n\n#if !defined(GTEST_DECLARE_bool_)\n# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver\n\n// Macros for declaring flags.\n# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)\n# define GTEST_DECLARE_int32_(name) \\\n    GTEST_API_ extern std::int32_t GTEST_FLAG(name)\n# define GTEST_DECLARE_string_(name) \\\n    GTEST_API_ extern ::std::string GTEST_FLAG(name)\n\n// Macros for defining flags.\n# define GTEST_DEFINE_bool_(name, default_val, doc) \\\n    GTEST_API_ bool GTEST_FLAG(name) = (default_val)\n# define GTEST_DEFINE_int32_(name, default_val, doc) \\\n    GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val)\n# define GTEST_DEFINE_string_(name, default_val, doc) \\\n    GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)\n\n#endif  // !defined(GTEST_DECLARE_bool_)\n\n// Thread annotations\n#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)\n# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)\n# define GTEST_LOCK_EXCLUDED_(locks)\n#endif  // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)\n\n// Parses 'str' for a 32-bit signed integer.  If successful, writes the result\n// to *value and returns true; otherwise leaves *value unchanged and returns\n// false.\nGTEST_API_ bool ParseInt32(const Message& src_text, const char* str,\n                           int32_t* value);\n\n// Parses a bool/int32_t/string from the environment variable\n// corresponding to the given Google Test flag.\nbool BoolFromGTestEnv(const char* flag, bool default_val);\nGTEST_API_ int32_t Int32FromGTestEnv(const char* flag, int32_t default_val);\nstd::string OutputFlagAlsoCheckEnvVar();\nconst char* StringFromGTestEnv(const char* flag, const char* default_val);\n\n}  // namespace internal\n}  // namespace testing\n\n#if !defined(GTEST_INTERNAL_DEPRECATED)\n\n// Internal Macro to mark an API deprecated, for googletest usage only\n// Usage: class GTEST_INTERNAL_DEPRECATED(message) MyClass or\n// GTEST_INTERNAL_DEPRECATED(message) <return_type> myFunction(); Every usage of\n// a deprecated entity will trigger a warning when compiled with\n// `-Wdeprecated-declarations` option (clang, gcc, any __GNUC__ compiler).\n// For msvc /W3 option will need to be used\n// Note that for 'other' compilers this macro evaluates to nothing to prevent\n// compilations errors.\n#if defined(_MSC_VER)\n#define GTEST_INTERNAL_DEPRECATED(message) __declspec(deprecated(message))\n#elif defined(__GNUC__)\n#define GTEST_INTERNAL_DEPRECATED(message) __attribute__((deprecated(message)))\n#else\n#define GTEST_INTERNAL_DEPRECATED(message)\n#endif\n\n#endif  // !defined(GTEST_INTERNAL_DEPRECATED)\n\n#if GTEST_HAS_ABSL\n// Always use absl::any for UniversalPrinter<> specializations if googletest\n// is built with absl support.\n#define GTEST_INTERNAL_HAS_ANY 1\n#include \"absl/types/any.h\"\nnamespace testing {\nnamespace internal {\nusing Any = ::absl::any;\n}  // namespace internal\n}  // namespace testing\n#else\n#ifdef __has_include\n#if __has_include(<any>) && __cplusplus >= 201703L\n// Otherwise for C++17 and higher use std::any for UniversalPrinter<>\n// specializations.\n#define GTEST_INTERNAL_HAS_ANY 1\n#include <any>\nnamespace testing {\nnamespace internal {\nusing Any = ::std::any;\n}  // namespace internal\n}  // namespace testing\n// The case where absl is configured NOT to alias std::any is not\n// supported.\n#endif  // __has_include(<any>) && __cplusplus >= 201703L\n#endif  // __has_include\n#endif  // GTEST_HAS_ABSL\n\n#if GTEST_HAS_ABSL\n// Always use absl::optional for UniversalPrinter<> specializations if\n// googletest is built with absl support.\n#define GTEST_INTERNAL_HAS_OPTIONAL 1\n#include \"absl/types/optional.h\"\nnamespace testing {\nnamespace internal {\ntemplate <typename T>\nusing Optional = ::absl::optional<T>;\n}  // namespace internal\n}  // namespace testing\n#else\n#ifdef __has_include\n#if __has_include(<optional>) && __cplusplus >= 201703L\n// Otherwise for C++17 and higher use std::optional for UniversalPrinter<>\n// specializations.\n#define GTEST_INTERNAL_HAS_OPTIONAL 1\n#include <optional>\nnamespace testing {\nnamespace internal {\ntemplate <typename T>\nusing Optional = ::std::optional<T>;\n}  // namespace internal\n}  // namespace testing\n// The case where absl is configured NOT to alias std::optional is not\n// supported.\n#endif  // __has_include(<optional>) && __cplusplus >= 201703L\n#endif  // __has_include\n#endif  // GTEST_HAS_ABSL\n\n#if GTEST_HAS_ABSL\n// Always use absl::string_view for Matcher<> specializations if googletest\n// is built with absl support.\n# define GTEST_INTERNAL_HAS_STRING_VIEW 1\n#include \"absl/strings/string_view.h\"\nnamespace testing {\nnamespace internal {\nusing StringView = ::absl::string_view;\n}  // namespace internal\n}  // namespace testing\n#else\n# ifdef __has_include\n#   if __has_include(<string_view>) && __cplusplus >= 201703L\n// Otherwise for C++17 and higher use std::string_view for Matcher<>\n// specializations.\n#   define GTEST_INTERNAL_HAS_STRING_VIEW 1\n#include <string_view>\nnamespace testing {\nnamespace internal {\nusing StringView = ::std::string_view;\n}  // namespace internal\n}  // namespace testing\n// The case where absl is configured NOT to alias std::string_view is not\n// supported.\n#  endif  // __has_include(<string_view>) && __cplusplus >= 201703L\n# endif  // __has_include\n#endif  // GTEST_HAS_ABSL\n\n#if GTEST_HAS_ABSL\n// Always use absl::variant for UniversalPrinter<> specializations if googletest\n// is built with absl support.\n#define GTEST_INTERNAL_HAS_VARIANT 1\n#include \"absl/types/variant.h\"\nnamespace testing {\nnamespace internal {\ntemplate <typename... T>\nusing Variant = ::absl::variant<T...>;\n}  // namespace internal\n}  // namespace testing\n#else\n#ifdef __has_include\n#if __has_include(<variant>) && __cplusplus >= 201703L\n// Otherwise for C++17 and higher use std::variant for UniversalPrinter<>\n// specializations.\n#define GTEST_INTERNAL_HAS_VARIANT 1\n#include <variant>\nnamespace testing {\nnamespace internal {\ntemplate <typename... T>\nusing Variant = ::std::variant<T...>;\n}  // namespace internal\n}  // namespace testing\n// The case where absl is configured NOT to alias std::variant is not supported.\n#endif  // __has_include(<variant>) && __cplusplus >= 201703L\n#endif  // __has_include\n#endif  // GTEST_HAS_ABSL\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n\n#if GTEST_OS_LINUX\n# include <stdlib.h>\n# include <sys/types.h>\n# include <sys/wait.h>\n# include <unistd.h>\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n#include <ctype.h>\n#include <float.h>\n#include <string.h>\n#include <cstdint>\n#include <iomanip>\n#include <limits>\n#include <map>\n#include <set>\n#include <string>\n#include <type_traits>\n#include <vector>\n\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file defines the Message class.\n//\n// IMPORTANT NOTE: Due to limitation of the C++ language, we have to\n// leave some internal implementation details in this header file.\n// They are clearly marked by comments like this:\n//\n//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n//\n// Such code is NOT meant to be used by a user directly, and is subject\n// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user\n// program!\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n\n#include <limits>\n#include <memory>\n#include <sstream>\n\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\n// Ensures that there is at least one operator<< in the global namespace.\n// See Message& operator<<(...) below for why.\nvoid operator<<(const testing::internal::Secret&, int);\n\nnamespace testing {\n\n// The Message class works like an ostream repeater.\n//\n// Typical usage:\n//\n//   1. You stream a bunch of values to a Message object.\n//      It will remember the text in a stringstream.\n//   2. Then you stream the Message object to an ostream.\n//      This causes the text in the Message to be streamed\n//      to the ostream.\n//\n// For example;\n//\n//   testing::Message foo;\n//   foo << 1 << \" != \" << 2;\n//   std::cout << foo;\n//\n// will print \"1 != 2\".\n//\n// Message is not intended to be inherited from.  In particular, its\n// destructor is not virtual.\n//\n// Note that stringstream behaves differently in gcc and in MSVC.  You\n// can stream a NULL char pointer to it in the former, but not in the\n// latter (it causes an access violation if you do).  The Message\n// class hides this difference by treating a NULL char pointer as\n// \"(null)\".\nclass GTEST_API_ Message {\n private:\n  // The type of basic IO manipulators (endl, ends, and flush) for\n  // narrow streams.\n  typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);\n\n public:\n  // Constructs an empty Message.\n  Message();\n\n  // Copy constructor.\n  Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT\n    *ss_ << msg.GetString();\n  }\n\n  // Constructs a Message from a C-string.\n  explicit Message(const char* str) : ss_(new ::std::stringstream) {\n    *ss_ << str;\n  }\n\n  // Streams a non-pointer value to this object.\n  template <typename T>\n  inline Message& operator <<(const T& val) {\n    // Some libraries overload << for STL containers.  These\n    // overloads are defined in the global namespace instead of ::std.\n    //\n    // C++'s symbol lookup rule (i.e. Koenig lookup) says that these\n    // overloads are visible in either the std namespace or the global\n    // namespace, but not other namespaces, including the testing\n    // namespace which Google Test's Message class is in.\n    //\n    // To allow STL containers (and other types that has a << operator\n    // defined in the global namespace) to be used in Google Test\n    // assertions, testing::Message must access the custom << operator\n    // from the global namespace.  With this using declaration,\n    // overloads of << defined in the global namespace and those\n    // visible via Koenig lookup are both exposed in this function.\n    using ::operator <<;\n    *ss_ << val;\n    return *this;\n  }\n\n  // Streams a pointer value to this object.\n  //\n  // This function is an overload of the previous one.  When you\n  // stream a pointer to a Message, this definition will be used as it\n  // is more specialized.  (The C++ Standard, section\n  // [temp.func.order].)  If you stream a non-pointer, then the\n  // previous definition will be used.\n  //\n  // The reason for this overload is that streaming a NULL pointer to\n  // ostream is undefined behavior.  Depending on the compiler, you\n  // may get \"0\", \"(nil)\", \"(null)\", or an access violation.  To\n  // ensure consistent result across compilers, we always treat NULL\n  // as \"(null)\".\n  template <typename T>\n  inline Message& operator <<(T* const& pointer) {  // NOLINT\n    if (pointer == nullptr) {\n      *ss_ << \"(null)\";\n    } else {\n      *ss_ << pointer;\n    }\n    return *this;\n  }\n\n  // Since the basic IO manipulators are overloaded for both narrow\n  // and wide streams, we have to provide this specialized definition\n  // of operator <<, even though its body is the same as the\n  // templatized version above.  Without this definition, streaming\n  // endl or other basic IO manipulators to Message will confuse the\n  // compiler.\n  Message& operator <<(BasicNarrowIoManip val) {\n    *ss_ << val;\n    return *this;\n  }\n\n  // Instead of 1/0, we want to see true/false for bool values.\n  Message& operator <<(bool b) {\n    return *this << (b ? \"true\" : \"false\");\n  }\n\n  // These two overloads allow streaming a wide C string to a Message\n  // using the UTF-8 encoding.\n  Message& operator <<(const wchar_t* wide_c_str);\n  Message& operator <<(wchar_t* wide_c_str);\n\n#if GTEST_HAS_STD_WSTRING\n  // Converts the given wide string to a narrow string using the UTF-8\n  // encoding, and streams the result to this Message object.\n  Message& operator <<(const ::std::wstring& wstr);\n#endif  // GTEST_HAS_STD_WSTRING\n\n  // Gets the text streamed to this object so far as an std::string.\n  // Each '\\0' character in the buffer is replaced with \"\\\\0\".\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  std::string GetString() const;\n\n private:\n  // We'll hold the text streamed to this object here.\n  const std::unique_ptr< ::std::stringstream> ss_;\n\n  // We declare (but don't implement) this to prevent the compiler\n  // from implementing the assignment operator.\n  void operator=(const Message&);\n};\n\n// Streams a Message to an ostream.\ninline std::ostream& operator <<(std::ostream& os, const Message& sb) {\n  return os << sb.GetString();\n}\n\nnamespace internal {\n\n// Converts a streamable value to an std::string.  A NULL pointer is\n// converted to \"(null)\".  When the input value is a ::string,\n// ::std::string, ::wstring, or ::std::wstring object, each NUL\n// character in it is replaced with \"\\\\0\".\ntemplate <typename T>\nstd::string StreamableToString(const T& streamable) {\n  return (Message() << streamable).GetString();\n}\n\n}  // namespace internal\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Google Test filepath utilities\n//\n// This header file declares classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included in gtest/internal/gtest-internal.h.\n// Do not include this header file separately!\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file declares the String class and functions used internally by\n// Google Test.  They are subject to change without notice. They should not used\n// by code external to Google Test.\n//\n// This header file is #included by gtest-internal.h.\n// It should not be #included by other files.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n\n#ifdef __BORLANDC__\n// string.h is not guaranteed to provide strcpy on C++ Builder.\n# include <mem.h>\n#endif\n\n#include <string.h>\n#include <cstdint>\n#include <string>\n\n\nnamespace testing {\nnamespace internal {\n\n// String - an abstract class holding static string utilities.\nclass GTEST_API_ String {\n public:\n  // Static utility methods\n\n  // Clones a 0-terminated C string, allocating memory using new.  The\n  // caller is responsible for deleting the return value using\n  // delete[].  Returns the cloned string, or NULL if the input is\n  // NULL.\n  //\n  // This is different from strdup() in string.h, which allocates\n  // memory using malloc().\n  static const char* CloneCString(const char* c_str);\n\n#if GTEST_OS_WINDOWS_MOBILE\n  // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be\n  // able to pass strings to Win32 APIs on CE we need to convert them\n  // to 'Unicode', UTF-16.\n\n  // Creates a UTF-16 wide string from the given ANSI string, allocating\n  // memory using new. The caller is responsible for deleting the return\n  // value using delete[]. Returns the wide string, or NULL if the\n  // input is NULL.\n  //\n  // The wide string is created using the ANSI codepage (CP_ACP) to\n  // match the behaviour of the ANSI versions of Win32 calls and the\n  // C runtime.\n  static LPCWSTR AnsiToUtf16(const char* c_str);\n\n  // Creates an ANSI string from the given wide string, allocating\n  // memory using new. The caller is responsible for deleting the return\n  // value using delete[]. Returns the ANSI string, or NULL if the\n  // input is NULL.\n  //\n  // The returned string is created using the ANSI codepage (CP_ACP) to\n  // match the behaviour of the ANSI versions of Win32 calls and the\n  // C runtime.\n  static const char* Utf16ToAnsi(LPCWSTR utf16_str);\n#endif\n\n  // Compares two C strings.  Returns true if and only if they have the same\n  // content.\n  //\n  // Unlike strcmp(), this function can handle NULL argument(s).  A\n  // NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool CStringEquals(const char* lhs, const char* rhs);\n\n  // Converts a wide C string to a String using the UTF-8 encoding.\n  // NULL will be converted to \"(null)\".  If an error occurred during\n  // the conversion, \"(failed to convert from wide string)\" is\n  // returned.\n  static std::string ShowWideCString(const wchar_t* wide_c_str);\n\n  // Compares two wide C strings.  Returns true if and only if they have the\n  // same content.\n  //\n  // Unlike wcscmp(), this function can handle NULL argument(s).  A\n  // NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);\n\n  // Compares two C strings, ignoring case.  Returns true if and only if\n  // they have the same content.\n  //\n  // Unlike strcasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool CaseInsensitiveCStringEquals(const char* lhs,\n                                           const char* rhs);\n\n  // Compares two wide C strings, ignoring case.  Returns true if and only if\n  // they have the same content.\n  //\n  // Unlike wcscasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL wide C string,\n  // including the empty string.\n  // NB: The implementations on different platforms slightly differ.\n  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n  // environment variable. On GNU platform this method uses wcscasecmp\n  // which compares according to LC_CTYPE category of the current locale.\n  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n  // current locale.\n  static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n                                               const wchar_t* rhs);\n\n  // Returns true if and only if the given string ends with the given suffix,\n  // ignoring case. Any string is considered to end with an empty suffix.\n  static bool EndsWithCaseInsensitive(\n      const std::string& str, const std::string& suffix);\n\n  // Formats an int value as \"%02d\".\n  static std::string FormatIntWidth2(int value);  // \"%02d\" for width == 2\n\n  // Formats an int value to given width with leading zeros.\n  static std::string FormatIntWidthN(int value, int width);\n\n  // Formats an int value as \"%X\".\n  static std::string FormatHexInt(int value);\n\n  // Formats an int value as \"%X\".\n  static std::string FormatHexUInt32(uint32_t value);\n\n  // Formats a byte as \"%02X\".\n  static std::string FormatByte(unsigned char value);\n\n private:\n  String();  // Not meant to be instantiated.\n};  // class String\n\n// Gets the content of the stringstream's buffer as an std::string.  Each '\\0'\n// character in the buffer is replaced with \"\\\\0\".\nGTEST_API_ std::string StringStreamToString(::std::stringstream* stream);\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\nnamespace internal {\n\n// FilePath - a class for file and directory pathname manipulation which\n// handles platform-specific conventions (like the pathname separator).\n// Used for helper functions for naming files in a directory for xml output.\n// Except for Set methods, all methods are const or static, which provides an\n// \"immutable value object\" -- useful for peace of mind.\n// A FilePath with a value ending in a path separator (\"like/this/\") represents\n// a directory, otherwise it is assumed to represent a file. In either case,\n// it may or may not represent an actual file or directory in the file system.\n// Names are NOT checked for syntax correctness -- no checking for illegal\n// characters, malformed paths, etc.\n\nclass GTEST_API_ FilePath {\n public:\n  FilePath() : pathname_(\"\") { }\n  FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }\n\n  explicit FilePath(const std::string& pathname) : pathname_(pathname) {\n    Normalize();\n  }\n\n  FilePath& operator=(const FilePath& rhs) {\n    Set(rhs);\n    return *this;\n  }\n\n  void Set(const FilePath& rhs) {\n    pathname_ = rhs.pathname_;\n  }\n\n  const std::string& string() const { return pathname_; }\n  const char* c_str() const { return pathname_.c_str(); }\n\n  // Returns the current working directory, or \"\" if unsuccessful.\n  static FilePath GetCurrentDir();\n\n  // Given directory = \"dir\", base_name = \"test\", number = 0,\n  // extension = \"xml\", returns \"dir/test.xml\". If number is greater\n  // than zero (e.g., 12), returns \"dir/test_12.xml\".\n  // On Windows platform, uses \\ as the separator rather than /.\n  static FilePath MakeFileName(const FilePath& directory,\n                               const FilePath& base_name,\n                               int number,\n                               const char* extension);\n\n  // Given directory = \"dir\", relative_path = \"test.xml\",\n  // returns \"dir/test.xml\".\n  // On Windows, uses \\ as the separator rather than /.\n  static FilePath ConcatPaths(const FilePath& directory,\n                              const FilePath& relative_path);\n\n  // Returns a pathname for a file that does not currently exist. The pathname\n  // will be directory/base_name.extension or\n  // directory/base_name_<number>.extension if directory/base_name.extension\n  // already exists. The number will be incremented until a pathname is found\n  // that does not already exist.\n  // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.\n  // There could be a race condition if two or more processes are calling this\n  // function at the same time -- they could both pick the same filename.\n  static FilePath GenerateUniqueFileName(const FilePath& directory,\n                                         const FilePath& base_name,\n                                         const char* extension);\n\n  // Returns true if and only if the path is \"\".\n  bool IsEmpty() const { return pathname_.empty(); }\n\n  // If input name has a trailing separator character, removes it and returns\n  // the name, otherwise return the name string unmodified.\n  // On Windows platform, uses \\ as the separator, other platforms use /.\n  FilePath RemoveTrailingPathSeparator() const;\n\n  // Returns a copy of the FilePath with the directory part removed.\n  // Example: FilePath(\"path/to/file\").RemoveDirectoryName() returns\n  // FilePath(\"file\"). If there is no directory part (\"just_a_file\"), it returns\n  // the FilePath unmodified. If there is no file part (\"just_a_dir/\") it\n  // returns an empty FilePath (\"\").\n  // On Windows platform, '\\' is the path separator, otherwise it is '/'.\n  FilePath RemoveDirectoryName() const;\n\n  // RemoveFileName returns the directory path with the filename removed.\n  // Example: FilePath(\"path/to/file\").RemoveFileName() returns \"path/to/\".\n  // If the FilePath is \"a_file\" or \"/a_file\", RemoveFileName returns\n  // FilePath(\"./\") or, on Windows, FilePath(\".\\\\\"). If the filepath does\n  // not have a file, like \"just/a/dir/\", it returns the FilePath unmodified.\n  // On Windows platform, '\\' is the path separator, otherwise it is '/'.\n  FilePath RemoveFileName() const;\n\n  // Returns a copy of the FilePath with the case-insensitive extension removed.\n  // Example: FilePath(\"dir/file.exe\").RemoveExtension(\"EXE\") returns\n  // FilePath(\"dir/file\"). If a case-insensitive extension is not\n  // found, returns a copy of the original FilePath.\n  FilePath RemoveExtension(const char* extension) const;\n\n  // Creates directories so that path exists. Returns true if successful or if\n  // the directories already exist; returns false if unable to create\n  // directories for any reason. Will also return false if the FilePath does\n  // not represent a directory (that is, it doesn't end with a path separator).\n  bool CreateDirectoriesRecursively() const;\n\n  // Create the directory so that path exists. Returns true if successful or\n  // if the directory already exists; returns false if unable to create the\n  // directory for any reason, including if the parent directory does not\n  // exist. Not named \"CreateDirectory\" because that's a macro on Windows.\n  bool CreateFolder() const;\n\n  // Returns true if FilePath describes something in the file-system,\n  // either a file, directory, or whatever, and that something exists.\n  bool FileOrDirectoryExists() const;\n\n  // Returns true if pathname describes a directory in the file-system\n  // that exists.\n  bool DirectoryExists() const;\n\n  // Returns true if FilePath ends with a path separator, which indicates that\n  // it is intended to represent a directory. Returns false otherwise.\n  // This does NOT check that a directory (or file) actually exists.\n  bool IsDirectory() const;\n\n  // Returns true if pathname describes a root directory. (Windows has one\n  // root directory per disk drive.)\n  bool IsRootDirectory() const;\n\n  // Returns true if pathname describes an absolute path.\n  bool IsAbsolutePath() const;\n\n private:\n  // Replaces multiple consecutive separators with a single separator.\n  // For example, \"bar///foo\" becomes \"bar/foo\". Does not eliminate other\n  // redundancies that might be in a pathname involving \".\" or \"..\".\n  //\n  // A pathname with multiple consecutive separators may occur either through\n  // user error or as a result of some scripts or APIs that generate a pathname\n  // with a trailing separator. On other platforms the same API or script\n  // may NOT generate a pathname with a trailing \"/\". Then elsewhere that\n  // pathname may have another \"/\" and pathname components added to it,\n  // without checking for the separator already being there.\n  // The script language and operating system may allow paths like \"foo//bar\"\n  // but some of the functions in FilePath will not handle that correctly. In\n  // particular, RemoveTrailingPathSeparator() only removes one separator, and\n  // it is called in CreateDirectoriesRecursively() assuming that it will change\n  // a pathname from directory syntax (trailing separator) to filename syntax.\n  //\n  // On Windows this method also replaces the alternate path separator '/' with\n  // the primary path separator '\\\\', so that for example \"bar\\\\/\\\\foo\" becomes\n  // \"bar\\\\foo\".\n\n  void Normalize();\n\n  // Returns a pointer to the last occurrence of a valid path separator in\n  // the FilePath. On Windows, for example, both '/' and '\\' are valid path\n  // separators. Returns NULL if no path separator was found.\n  const char* FindLastPathSeparator() const;\n\n  std::string pathname_;\n};  // class FilePath\n\n}  // namespace internal\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Type utilities needed for implementing typed and type-parameterized\n// tests.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n\n\n// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using\n// libstdc++ (which is where cxxabi.h comes from).\n# if GTEST_HAS_CXXABI_H_\n#  include <cxxabi.h>\n# elif defined(__HP_aCC)\n#  include <acxx_demangle.h>\n# endif  // GTEST_HASH_CXXABI_H_\n\nnamespace testing {\nnamespace internal {\n\n// Canonicalizes a given name with respect to the Standard C++ Library.\n// This handles removing the inline namespace within `std` that is\n// used by various standard libraries (e.g., `std::__1`).  Names outside\n// of namespace std are returned unmodified.\ninline std::string CanonicalizeForStdLibVersioning(std::string s) {\n  static const char prefix[] = \"std::__\";\n  if (s.compare(0, strlen(prefix), prefix) == 0) {\n    std::string::size_type end = s.find(\"::\", strlen(prefix));\n    if (end != s.npos) {\n      // Erase everything between the initial `std` and the second `::`.\n      s.erase(strlen(\"std\"), end - strlen(\"std\"));\n    }\n  }\n  return s;\n}\n\n#if GTEST_HAS_RTTI\n// GetTypeName(const std::type_info&) returns a human-readable name of type T.\ninline std::string GetTypeName(const std::type_info& type) {\n  const char* const name = type.name();\n#if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)\n  int status = 0;\n  // gcc's implementation of typeid(T).name() mangles the type name,\n  // so we have to demangle it.\n#if GTEST_HAS_CXXABI_H_\n  using abi::__cxa_demangle;\n#endif  // GTEST_HAS_CXXABI_H_\n  char* const readable_name = __cxa_demangle(name, nullptr, nullptr, &status);\n  const std::string name_str(status == 0 ? readable_name : name);\n  free(readable_name);\n  return CanonicalizeForStdLibVersioning(name_str);\n#else\n  return name;\n#endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC\n}\n#endif  // GTEST_HAS_RTTI\n\n// GetTypeName<T>() returns a human-readable name of type T if and only if\n// RTTI is enabled, otherwise it returns a dummy type name.\n// NB: This function is also used in Google Mock, so don't move it inside of\n// the typed-test-only section below.\ntemplate <typename T>\nstd::string GetTypeName() {\n#if GTEST_HAS_RTTI\n  return GetTypeName(typeid(T));\n#else\n  return \"<type>\";\n#endif  // GTEST_HAS_RTTI\n}\n\n// A unique type indicating an empty node\nstruct None {};\n\n# define GTEST_TEMPLATE_ template <typename T> class\n\n// The template \"selector\" struct TemplateSel<Tmpl> is used to\n// represent Tmpl, which must be a class template with one type\n// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined\n// as the type Tmpl<T>.  This allows us to actually instantiate the\n// template \"selected\" by TemplateSel<Tmpl>.\n//\n// This trick is necessary for simulating typedef for class templates,\n// which C++ doesn't support directly.\ntemplate <GTEST_TEMPLATE_ Tmpl>\nstruct TemplateSel {\n  template <typename T>\n  struct Bind {\n    typedef Tmpl<T> type;\n  };\n};\n\n# define GTEST_BIND_(TmplSel, T) \\\n  TmplSel::template Bind<T>::type\n\ntemplate <GTEST_TEMPLATE_ Head_, GTEST_TEMPLATE_... Tail_>\nstruct Templates {\n  using Head = TemplateSel<Head_>;\n  using Tail = Templates<Tail_...>;\n};\n\ntemplate <GTEST_TEMPLATE_ Head_>\nstruct Templates<Head_> {\n  using Head = TemplateSel<Head_>;\n  using Tail = None;\n};\n\n// Tuple-like type lists\ntemplate <typename Head_, typename... Tail_>\nstruct Types {\n  using Head = Head_;\n  using Tail = Types<Tail_...>;\n};\n\ntemplate <typename Head_>\nstruct Types<Head_> {\n  using Head = Head_;\n  using Tail = None;\n};\n\n// Helper metafunctions to tell apart a single type from types\n// generated by ::testing::Types\ntemplate <typename... Ts>\nstruct ProxyTypeList {\n  using type = Types<Ts...>;\n};\n\ntemplate <typename>\nstruct is_proxy_type_list : std::false_type {};\n\ntemplate <typename... Ts>\nstruct is_proxy_type_list<ProxyTypeList<Ts...>> : std::true_type {};\n\n// Generator which conditionally creates type lists.\n// It recognizes if a requested type list should be created\n// and prevents creating a new type list nested within another one.\ntemplate <typename T>\nstruct GenerateTypeList {\n private:\n  using proxy = typename std::conditional<is_proxy_type_list<T>::value, T,\n                                          ProxyTypeList<T>>::type;\n\n public:\n  using type = typename proxy::type;\n};\n\n}  // namespace internal\n\ntemplate <typename... Ts>\nusing Types = internal::ProxyTypeList<Ts...>;\n\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n\n// Due to C++ preprocessor weirdness, we need double indirection to\n// concatenate two tokens when one of them is __LINE__.  Writing\n//\n//   foo ## __LINE__\n//\n// will result in the token foo__LINE__, instead of foo followed by\n// the current line number.  For more details, see\n// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6\n#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)\n#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar\n\n// Stringifies its argument.\n// Work around a bug in visual studio which doesn't accept code like this:\n//\n//   #define GTEST_STRINGIFY_(name) #name\n//   #define MACRO(a, b, c) ... GTEST_STRINGIFY_(a) ...\n//   MACRO(, x, y)\n//\n// Complaining about the argument to GTEST_STRINGIFY_ being empty.\n// This is allowed by the spec.\n#define GTEST_STRINGIFY_HELPER_(name, ...) #name\n#define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, )\n\nnamespace proto2 {\nclass MessageLite;\n}\n\nnamespace testing {\n\n// Forward declarations.\n\nclass AssertionResult;                 // Result of an assertion.\nclass Message;                         // Represents a failure message.\nclass Test;                            // Represents a test.\nclass TestInfo;                        // Information about a test.\nclass TestPartResult;                  // Result of a test part.\nclass UnitTest;                        // A collection of test suites.\n\ntemplate <typename T>\n::std::string PrintToString(const T& value);\n\nnamespace internal {\n\nstruct TraceInfo;                      // Information about a trace point.\nclass TestInfoImpl;                    // Opaque implementation of TestInfo\nclass UnitTestImpl;                    // Opaque implementation of UnitTest\n\n// The text used in failure messages to indicate the start of the\n// stack trace.\nGTEST_API_ extern const char kStackTraceMarker[];\n\n// An IgnoredValue object can be implicitly constructed from ANY value.\nclass IgnoredValue {\n  struct Sink {};\n public:\n  // This constructor template allows any value to be implicitly\n  // converted to IgnoredValue.  The object has no data member and\n  // doesn't try to remember anything about the argument.  We\n  // deliberately omit the 'explicit' keyword in order to allow the\n  // conversion to be implicit.\n  // Disable the conversion if T already has a magical conversion operator.\n  // Otherwise we get ambiguity.\n  template <typename T,\n            typename std::enable_if<!std::is_convertible<T, Sink>::value,\n                                    int>::type = 0>\n  IgnoredValue(const T& /* ignored */) {}  // NOLINT(runtime/explicit)\n};\n\n// Appends the user-supplied message to the Google-Test-generated message.\nGTEST_API_ std::string AppendUserMessage(\n    const std::string& gtest_msg, const Message& user_msg);\n\n#if GTEST_HAS_EXCEPTIONS\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \\\n/* an exported class was derived from a class that was not exported */)\n\n// This exception is thrown by (and only by) a failed Google Test\n// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions\n// are enabled).  We derive it from std::runtime_error, which is for\n// errors presumably detectable only at run time.  Since\n// std::runtime_error inherits from std::exception, many testing\n// frameworks know how to extract and print the message inside it.\nclass GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {\n public:\n  explicit GoogleTestFailureException(const TestPartResult& failure);\n};\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4275\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\nnamespace edit_distance {\n// Returns the optimal edits to go from 'left' to 'right'.\n// All edits cost the same, with replace having lower priority than\n// add/remove.\n// Simple implementation of the Wagner-Fischer algorithm.\n// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm\nenum EditType { kMatch, kAdd, kRemove, kReplace };\nGTEST_API_ std::vector<EditType> CalculateOptimalEdits(\n    const std::vector<size_t>& left, const std::vector<size_t>& right);\n\n// Same as above, but the input is represented as strings.\nGTEST_API_ std::vector<EditType> CalculateOptimalEdits(\n    const std::vector<std::string>& left,\n    const std::vector<std::string>& right);\n\n// Create a diff of the input strings in Unified diff format.\nGTEST_API_ std::string CreateUnifiedDiff(const std::vector<std::string>& left,\n                                         const std::vector<std::string>& right,\n                                         size_t context = 2);\n\n}  // namespace edit_distance\n\n// Calculate the diff between 'left' and 'right' and return it in unified diff\n// format.\n// If not null, stores in 'total_line_count' the total number of lines found\n// in left + right.\nGTEST_API_ std::string DiffStrings(const std::string& left,\n                                   const std::string& right,\n                                   size_t* total_line_count);\n\n// Constructs and returns the message for an equality assertion\n// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.\n//\n// The first four parameters are the expressions used in the assertion\n// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)\n// where foo is 5 and bar is 6, we have:\n//\n//   expected_expression: \"foo\"\n//   actual_expression:   \"bar\"\n//   expected_value:      \"5\"\n//   actual_value:        \"6\"\n//\n// The ignoring_case parameter is true if and only if the assertion is a\n// *_STRCASEEQ*.  When it's true, the string \" (ignoring case)\" will\n// be inserted into the message.\nGTEST_API_ AssertionResult EqFailure(const char* expected_expression,\n                                     const char* actual_expression,\n                                     const std::string& expected_value,\n                                     const std::string& actual_value,\n                                     bool ignoring_case);\n\n// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.\nGTEST_API_ std::string GetBoolAssertionFailureMessage(\n    const AssertionResult& assertion_result,\n    const char* expression_text,\n    const char* actual_predicate_value,\n    const char* expected_predicate_value);\n\n// This template class represents an IEEE floating-point number\n// (either single-precision or double-precision, depending on the\n// template parameters).\n//\n// The purpose of this class is to do more sophisticated number\n// comparison.  (Due to round-off error, etc, it's very unlikely that\n// two floating-points will be equal exactly.  Hence a naive\n// comparison by the == operation often doesn't work.)\n//\n// Format of IEEE floating-point:\n//\n//   The most-significant bit being the leftmost, an IEEE\n//   floating-point looks like\n//\n//     sign_bit exponent_bits fraction_bits\n//\n//   Here, sign_bit is a single bit that designates the sign of the\n//   number.\n//\n//   For float, there are 8 exponent bits and 23 fraction bits.\n//\n//   For double, there are 11 exponent bits and 52 fraction bits.\n//\n//   More details can be found at\n//   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.\n//\n// Template parameter:\n//\n//   RawType: the raw floating-point type (either float or double)\ntemplate <typename RawType>\nclass FloatingPoint {\n public:\n  // Defines the unsigned integer type that has the same size as the\n  // floating point number.\n  typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;\n\n  // Constants.\n\n  // # of bits in a number.\n  static const size_t kBitCount = 8*sizeof(RawType);\n\n  // # of fraction bits in a number.\n  static const size_t kFractionBitCount =\n    std::numeric_limits<RawType>::digits - 1;\n\n  // # of exponent bits in a number.\n  static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;\n\n  // The mask for the sign bit.\n  static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);\n\n  // The mask for the fraction bits.\n  static const Bits kFractionBitMask =\n    ~static_cast<Bits>(0) >> (kExponentBitCount + 1);\n\n  // The mask for the exponent bits.\n  static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);\n\n  // How many ULP's (Units in the Last Place) we want to tolerate when\n  // comparing two numbers.  The larger the value, the more error we\n  // allow.  A 0 value means that two numbers must be exactly the same\n  // to be considered equal.\n  //\n  // The maximum error of a single floating-point operation is 0.5\n  // units in the last place.  On Intel CPU's, all floating-point\n  // calculations are done with 80-bit precision, while double has 64\n  // bits.  Therefore, 4 should be enough for ordinary use.\n  //\n  // See the following article for more details on ULP:\n  // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/\n  static const uint32_t kMaxUlps = 4;\n\n  // Constructs a FloatingPoint from a raw floating-point number.\n  //\n  // On an Intel CPU, passing a non-normalized NAN (Not a Number)\n  // around may change its bits, although the new value is guaranteed\n  // to be also a NAN.  Therefore, don't expect this constructor to\n  // preserve the bits in x when x is a NAN.\n  explicit FloatingPoint(const RawType& x) { u_.value_ = x; }\n\n  // Static methods\n\n  // Reinterprets a bit pattern as a floating-point number.\n  //\n  // This function is needed to test the AlmostEquals() method.\n  static RawType ReinterpretBits(const Bits bits) {\n    FloatingPoint fp(0);\n    fp.u_.bits_ = bits;\n    return fp.u_.value_;\n  }\n\n  // Returns the floating-point number that represent positive infinity.\n  static RawType Infinity() {\n    return ReinterpretBits(kExponentBitMask);\n  }\n\n  // Returns the maximum representable finite floating-point number.\n  static RawType Max();\n\n  // Non-static methods\n\n  // Returns the bits that represents this number.\n  const Bits &bits() const { return u_.bits_; }\n\n  // Returns the exponent bits of this number.\n  Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }\n\n  // Returns the fraction bits of this number.\n  Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }\n\n  // Returns the sign bit of this number.\n  Bits sign_bit() const { return kSignBitMask & u_.bits_; }\n\n  // Returns true if and only if this is NAN (not a number).\n  bool is_nan() const {\n    // It's a NAN if the exponent bits are all ones and the fraction\n    // bits are not entirely zeros.\n    return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);\n  }\n\n  // Returns true if and only if this number is at most kMaxUlps ULP's away\n  // from rhs.  In particular, this function:\n  //\n  //   - returns false if either number is (or both are) NAN.\n  //   - treats really large numbers as almost equal to infinity.\n  //   - thinks +0.0 and -0.0 are 0 DLP's apart.\n  bool AlmostEquals(const FloatingPoint& rhs) const {\n    // The IEEE standard says that any comparison operation involving\n    // a NAN must return false.\n    if (is_nan() || rhs.is_nan()) return false;\n\n    return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)\n        <= kMaxUlps;\n  }\n\n private:\n  // The data type used to store the actual floating-point number.\n  union FloatingPointUnion {\n    RawType value_;  // The raw floating-point number.\n    Bits bits_;      // The bits that represent the number.\n  };\n\n  // Converts an integer from the sign-and-magnitude representation to\n  // the biased representation.  More precisely, let N be 2 to the\n  // power of (kBitCount - 1), an integer x is represented by the\n  // unsigned number x + N.\n  //\n  // For instance,\n  //\n  //   -N + 1 (the most negative number representable using\n  //          sign-and-magnitude) is represented by 1;\n  //   0      is represented by N; and\n  //   N - 1  (the biggest number representable using\n  //          sign-and-magnitude) is represented by 2N - 1.\n  //\n  // Read http://en.wikipedia.org/wiki/Signed_number_representations\n  // for more details on signed number representations.\n  static Bits SignAndMagnitudeToBiased(const Bits &sam) {\n    if (kSignBitMask & sam) {\n      // sam represents a negative number.\n      return ~sam + 1;\n    } else {\n      // sam represents a positive number.\n      return kSignBitMask | sam;\n    }\n  }\n\n  // Given two numbers in the sign-and-magnitude representation,\n  // returns the distance between them as an unsigned number.\n  static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,\n                                                     const Bits &sam2) {\n    const Bits biased1 = SignAndMagnitudeToBiased(sam1);\n    const Bits biased2 = SignAndMagnitudeToBiased(sam2);\n    return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);\n  }\n\n  FloatingPointUnion u_;\n};\n\n// We cannot use std::numeric_limits<T>::max() as it clashes with the max()\n// macro defined by <windows.h>.\ntemplate <>\ninline float FloatingPoint<float>::Max() { return FLT_MAX; }\ntemplate <>\ninline double FloatingPoint<double>::Max() { return DBL_MAX; }\n\n// Typedefs the instances of the FloatingPoint template class that we\n// care to use.\ntypedef FloatingPoint<float> Float;\ntypedef FloatingPoint<double> Double;\n\n// In order to catch the mistake of putting tests that use different\n// test fixture classes in the same test suite, we need to assign\n// unique IDs to fixture classes and compare them.  The TypeId type is\n// used to hold such IDs.  The user should treat TypeId as an opaque\n// type: the only operation allowed on TypeId values is to compare\n// them for equality using the == operator.\ntypedef const void* TypeId;\n\ntemplate <typename T>\nclass TypeIdHelper {\n public:\n  // dummy_ must not have a const type.  Otherwise an overly eager\n  // compiler (e.g. MSVC 7.1 & 8.0) may try to merge\n  // TypeIdHelper<T>::dummy_ for different Ts as an \"optimization\".\n  static bool dummy_;\n};\n\ntemplate <typename T>\nbool TypeIdHelper<T>::dummy_ = false;\n\n// GetTypeId<T>() returns the ID of type T.  Different values will be\n// returned for different types.  Calling the function twice with the\n// same type argument is guaranteed to return the same ID.\ntemplate <typename T>\nTypeId GetTypeId() {\n  // The compiler is required to allocate a different\n  // TypeIdHelper<T>::dummy_ variable for each T used to instantiate\n  // the template.  Therefore, the address of dummy_ is guaranteed to\n  // be unique.\n  return &(TypeIdHelper<T>::dummy_);\n}\n\n// Returns the type ID of ::testing::Test.  Always call this instead\n// of GetTypeId< ::testing::Test>() to get the type ID of\n// ::testing::Test, as the latter may give the wrong result due to a\n// suspected linker bug when compiling Google Test as a Mac OS X\n// framework.\nGTEST_API_ TypeId GetTestTypeId();\n\n// Defines the abstract factory interface that creates instances\n// of a Test object.\nclass TestFactoryBase {\n public:\n  virtual ~TestFactoryBase() {}\n\n  // Creates a test instance to run. The instance is both created and destroyed\n  // within TestInfoImpl::Run()\n  virtual Test* CreateTest() = 0;\n\n protected:\n  TestFactoryBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);\n};\n\n// This class provides implementation of TeastFactoryBase interface.\n// It is used in TEST and TEST_F macros.\ntemplate <class TestClass>\nclass TestFactoryImpl : public TestFactoryBase {\n public:\n  Test* CreateTest() override { return new TestClass; }\n};\n\n#if GTEST_OS_WINDOWS\n\n// Predicate-formatters for implementing the HRESULT checking macros\n// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}\n// We pass a long instead of HRESULT to avoid causing an\n// include dependency for the HRESULT type.\nGTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,\n                                            long hr);  // NOLINT\nGTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,\n                                            long hr);  // NOLINT\n\n#endif  // GTEST_OS_WINDOWS\n\n// Types of SetUpTestSuite() and TearDownTestSuite() functions.\nusing SetUpTestSuiteFunc = void (*)();\nusing TearDownTestSuiteFunc = void (*)();\n\nstruct CodeLocation {\n  CodeLocation(const std::string& a_file, int a_line)\n      : file(a_file), line(a_line) {}\n\n  std::string file;\n  int line;\n};\n\n//  Helper to identify which setup function for TestCase / TestSuite to call.\n//  Only one function is allowed, either TestCase or TestSute but not both.\n\n// Utility functions to help SuiteApiResolver\nusing SetUpTearDownSuiteFuncType = void (*)();\n\ninline SetUpTearDownSuiteFuncType GetNotDefaultOrNull(\n    SetUpTearDownSuiteFuncType a, SetUpTearDownSuiteFuncType def) {\n  return a == def ? nullptr : a;\n}\n\ntemplate <typename T>\n//  Note that SuiteApiResolver inherits from T because\n//  SetUpTestSuite()/TearDownTestSuite() could be protected. Ths way\n//  SuiteApiResolver can access them.\nstruct SuiteApiResolver : T {\n  // testing::Test is only forward declared at this point. So we make it a\n  // dependend class for the compiler to be OK with it.\n  using Test =\n      typename std::conditional<sizeof(T) != 0, ::testing::Test, void>::type;\n\n  static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite(const char* filename,\n                                                        int line_num) {\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n    SetUpTearDownSuiteFuncType test_case_fp =\n        GetNotDefaultOrNull(&T::SetUpTestCase, &Test::SetUpTestCase);\n    SetUpTearDownSuiteFuncType test_suite_fp =\n        GetNotDefaultOrNull(&T::SetUpTestSuite, &Test::SetUpTestSuite);\n\n    GTEST_CHECK_(!test_case_fp || !test_suite_fp)\n        << \"Test can not provide both SetUpTestSuite and SetUpTestCase, please \"\n           \"make sure there is only one present at \"\n        << filename << \":\" << line_num;\n\n    return test_case_fp != nullptr ? test_case_fp : test_suite_fp;\n#else\n    (void)(filename);\n    (void)(line_num);\n    return &T::SetUpTestSuite;\n#endif\n  }\n\n  static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite(const char* filename,\n                                                           int line_num) {\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n    SetUpTearDownSuiteFuncType test_case_fp =\n        GetNotDefaultOrNull(&T::TearDownTestCase, &Test::TearDownTestCase);\n    SetUpTearDownSuiteFuncType test_suite_fp =\n        GetNotDefaultOrNull(&T::TearDownTestSuite, &Test::TearDownTestSuite);\n\n    GTEST_CHECK_(!test_case_fp || !test_suite_fp)\n        << \"Test can not provide both TearDownTestSuite and TearDownTestCase,\"\n           \" please make sure there is only one present at\"\n        << filename << \":\" << line_num;\n\n    return test_case_fp != nullptr ? test_case_fp : test_suite_fp;\n#else\n    (void)(filename);\n    (void)(line_num);\n    return &T::TearDownTestSuite;\n#endif\n  }\n};\n\n// Creates a new TestInfo object and registers it with Google Test;\n// returns the created object.\n//\n// Arguments:\n//\n//   test_suite_name:  name of the test suite\n//   name:             name of the test\n//   type_param:       the name of the test's type parameter, or NULL if\n//                     this is not a typed or a type-parameterized test.\n//   value_param:      text representation of the test's value parameter,\n//                     or NULL if this is not a type-parameterized test.\n//   code_location:    code location where the test is defined\n//   fixture_class_id: ID of the test fixture class\n//   set_up_tc:        pointer to the function that sets up the test suite\n//   tear_down_tc:     pointer to the function that tears down the test suite\n//   factory:          pointer to the factory that creates a test object.\n//                     The newly created TestInfo instance will assume\n//                     ownership of the factory object.\nGTEST_API_ TestInfo* MakeAndRegisterTestInfo(\n    const char* test_suite_name, const char* name, const char* type_param,\n    const char* value_param, CodeLocation code_location,\n    TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,\n    TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n// and returns false.  None of pstr, *pstr, and prefix can be NULL.\nGTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\n// State of the definition of a type-parameterized test suite.\nclass GTEST_API_ TypedTestSuitePState {\n public:\n  TypedTestSuitePState() : registered_(false) {}\n\n  // Adds the given test name to defined_test_names_ and return true\n  // if the test suite hasn't been registered; otherwise aborts the\n  // program.\n  bool AddTestName(const char* file, int line, const char* case_name,\n                   const char* test_name) {\n    if (registered_) {\n      fprintf(stderr,\n              \"%s Test %s must be defined before \"\n              \"REGISTER_TYPED_TEST_SUITE_P(%s, ...).\\n\",\n              FormatFileLocation(file, line).c_str(), test_name, case_name);\n      fflush(stderr);\n      posix::Abort();\n    }\n    registered_tests_.insert(\n        ::std::make_pair(test_name, CodeLocation(file, line)));\n    return true;\n  }\n\n  bool TestExists(const std::string& test_name) const {\n    return registered_tests_.count(test_name) > 0;\n  }\n\n  const CodeLocation& GetCodeLocation(const std::string& test_name) const {\n    RegisteredTestsMap::const_iterator it = registered_tests_.find(test_name);\n    GTEST_CHECK_(it != registered_tests_.end());\n    return it->second;\n  }\n\n  // Verifies that registered_tests match the test names in\n  // defined_test_names_; returns registered_tests if successful, or\n  // aborts the program otherwise.\n  const char* VerifyRegisteredTestNames(const char* test_suite_name,\n                                        const char* file, int line,\n                                        const char* registered_tests);\n\n private:\n  typedef ::std::map<std::string, CodeLocation> RegisteredTestsMap;\n\n  bool registered_;\n  RegisteredTestsMap registered_tests_;\n};\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nusing TypedTestCasePState = TypedTestSuitePState;\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n// Skips to the first non-space char after the first comma in 'str';\n// returns NULL if no comma is found in 'str'.\ninline const char* SkipComma(const char* str) {\n  const char* comma = strchr(str, ',');\n  if (comma == nullptr) {\n    return nullptr;\n  }\n  while (IsSpace(*(++comma))) {}\n  return comma;\n}\n\n// Returns the prefix of 'str' before the first comma in it; returns\n// the entire string if it contains no comma.\ninline std::string GetPrefixUntilComma(const char* str) {\n  const char* comma = strchr(str, ',');\n  return comma == nullptr ? str : std::string(str, comma);\n}\n\n// Splits a given string on a given delimiter, populating a given\n// vector with the fields.\nvoid SplitString(const ::std::string& str, char delimiter,\n                 ::std::vector< ::std::string>* dest);\n\n// The default argument to the template below for the case when the user does\n// not provide a name generator.\nstruct DefaultNameGenerator {\n  template <typename T>\n  static std::string GetName(int i) {\n    return StreamableToString(i);\n  }\n};\n\ntemplate <typename Provided = DefaultNameGenerator>\nstruct NameGeneratorSelector {\n  typedef Provided type;\n};\n\ntemplate <typename NameGenerator>\nvoid GenerateNamesRecursively(internal::None, std::vector<std::string>*, int) {}\n\ntemplate <typename NameGenerator, typename Types>\nvoid GenerateNamesRecursively(Types, std::vector<std::string>* result, int i) {\n  result->push_back(NameGenerator::template GetName<typename Types::Head>(i));\n  GenerateNamesRecursively<NameGenerator>(typename Types::Tail(), result,\n                                          i + 1);\n}\n\ntemplate <typename NameGenerator, typename Types>\nstd::vector<std::string> GenerateNames() {\n  std::vector<std::string> result;\n  GenerateNamesRecursively<NameGenerator>(Types(), &result, 0);\n  return result;\n}\n\n// TypeParameterizedTest<Fixture, TestSel, Types>::Register()\n// registers a list of type-parameterized tests with Google Test.  The\n// return value is insignificant - we just need to return something\n// such that we can call this function in a namespace scope.\n//\n// Implementation note: The GTEST_TEMPLATE_ macro declares a template\n// template parameter.  It's defined in gtest-type-util.h.\ntemplate <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>\nclass TypeParameterizedTest {\n public:\n  // 'index' is the index of the test in the type list 'Types'\n  // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,\n  // Types).  Valid values for 'index' are [0, N - 1] where N is the\n  // length of Types.\n  static bool Register(const char* prefix, const CodeLocation& code_location,\n                       const char* case_name, const char* test_names, int index,\n                       const std::vector<std::string>& type_names =\n                           GenerateNames<DefaultNameGenerator, Types>()) {\n    typedef typename Types::Head Type;\n    typedef Fixture<Type> FixtureClass;\n    typedef typename GTEST_BIND_(TestSel, Type) TestClass;\n\n    // First, registers the first type-parameterized test in the type\n    // list.\n    MakeAndRegisterTestInfo(\n        (std::string(prefix) + (prefix[0] == '\\0' ? \"\" : \"/\") + case_name +\n         \"/\" + type_names[static_cast<size_t>(index)])\n            .c_str(),\n        StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),\n        GetTypeName<Type>().c_str(),\n        nullptr,  // No value parameter.\n        code_location, GetTypeId<FixtureClass>(),\n        SuiteApiResolver<TestClass>::GetSetUpCaseOrSuite(\n            code_location.file.c_str(), code_location.line),\n        SuiteApiResolver<TestClass>::GetTearDownCaseOrSuite(\n            code_location.file.c_str(), code_location.line),\n        new TestFactoryImpl<TestClass>);\n\n    // Next, recurses (at compile time) with the tail of the type list.\n    return TypeParameterizedTest<Fixture, TestSel,\n                                 typename Types::Tail>::Register(prefix,\n                                                                 code_location,\n                                                                 case_name,\n                                                                 test_names,\n                                                                 index + 1,\n                                                                 type_names);\n  }\n};\n\n// The base case for the compile time recursion.\ntemplate <GTEST_TEMPLATE_ Fixture, class TestSel>\nclass TypeParameterizedTest<Fixture, TestSel, internal::None> {\n public:\n  static bool Register(const char* /*prefix*/, const CodeLocation&,\n                       const char* /*case_name*/, const char* /*test_names*/,\n                       int /*index*/,\n                       const std::vector<std::string>& =\n                           std::vector<std::string>() /*type_names*/) {\n    return true;\n  }\n};\n\nGTEST_API_ void RegisterTypeParameterizedTestSuite(const char* test_suite_name,\n                                                   CodeLocation code_location);\nGTEST_API_ void RegisterTypeParameterizedTestSuiteInstantiation(\n    const char* case_name);\n\n// TypeParameterizedTestSuite<Fixture, Tests, Types>::Register()\n// registers *all combinations* of 'Tests' and 'Types' with Google\n// Test.  The return value is insignificant - we just need to return\n// something such that we can call this function in a namespace scope.\ntemplate <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>\nclass TypeParameterizedTestSuite {\n public:\n  static bool Register(const char* prefix, CodeLocation code_location,\n                       const TypedTestSuitePState* state, const char* case_name,\n                       const char* test_names,\n                       const std::vector<std::string>& type_names =\n                           GenerateNames<DefaultNameGenerator, Types>()) {\n    RegisterTypeParameterizedTestSuiteInstantiation(case_name);\n    std::string test_name = StripTrailingSpaces(\n        GetPrefixUntilComma(test_names));\n    if (!state->TestExists(test_name)) {\n      fprintf(stderr, \"Failed to get code location for test %s.%s at %s.\",\n              case_name, test_name.c_str(),\n              FormatFileLocation(code_location.file.c_str(),\n                                 code_location.line).c_str());\n      fflush(stderr);\n      posix::Abort();\n    }\n    const CodeLocation& test_location = state->GetCodeLocation(test_name);\n\n    typedef typename Tests::Head Head;\n\n    // First, register the first test in 'Test' for each type in 'Types'.\n    TypeParameterizedTest<Fixture, Head, Types>::Register(\n        prefix, test_location, case_name, test_names, 0, type_names);\n\n    // Next, recurses (at compile time) with the tail of the test list.\n    return TypeParameterizedTestSuite<Fixture, typename Tests::Tail,\n                                      Types>::Register(prefix, code_location,\n                                                       state, case_name,\n                                                       SkipComma(test_names),\n                                                       type_names);\n  }\n};\n\n// The base case for the compile time recursion.\ntemplate <GTEST_TEMPLATE_ Fixture, typename Types>\nclass TypeParameterizedTestSuite<Fixture, internal::None, Types> {\n public:\n  static bool Register(const char* /*prefix*/, const CodeLocation&,\n                       const TypedTestSuitePState* /*state*/,\n                       const char* /*case_name*/, const char* /*test_names*/,\n                       const std::vector<std::string>& =\n                           std::vector<std::string>() /*type_names*/) {\n    return true;\n  }\n};\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\nGTEST_API_ std::string GetCurrentOsStackTraceExceptTop(\n    UnitTest* unit_test, int skip_count);\n\n// Helpers for suppressing warnings on unreachable code or constant\n// condition.\n\n// Always returns true.\nGTEST_API_ bool AlwaysTrue();\n\n// Always returns false.\ninline bool AlwaysFalse() { return !AlwaysTrue(); }\n\n// Helper for suppressing false warning from Clang on a const char*\n// variable declared in a conditional expression always being NULL in\n// the else branch.\nstruct GTEST_API_ ConstCharPtr {\n  ConstCharPtr(const char* str) : value(str) {}\n  operator bool() const { return true; }\n  const char* value;\n};\n\n// Helper for declaring std::string within 'if' statement\n// in pre C++17 build environment.\nstruct TrueWithString {\n  TrueWithString() = default;\n  explicit TrueWithString(const char* str) : value(str) {}\n  explicit TrueWithString(const std::string& str) : value(str) {}\n  explicit operator bool() const { return true; }\n  std::string value;\n};\n\n// A simple Linear Congruential Generator for generating random\n// numbers with a uniform distribution.  Unlike rand() and srand(), it\n// doesn't use global state (and therefore can't interfere with user\n// code).  Unlike rand_r(), it's portable.  An LCG isn't very random,\n// but it's good enough for our purposes.\nclass GTEST_API_ Random {\n public:\n  static const uint32_t kMaxRange = 1u << 31;\n\n  explicit Random(uint32_t seed) : state_(seed) {}\n\n  void Reseed(uint32_t seed) { state_ = seed; }\n\n  // Generates a random number from [0, range).  Crashes if 'range' is\n  // 0 or greater than kMaxRange.\n  uint32_t Generate(uint32_t range);\n\n private:\n  uint32_t state_;\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);\n};\n\n// Turns const U&, U&, const U, and U all into U.\n#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \\\n  typename std::remove_const<typename std::remove_reference<T>::type>::type\n\n// HasDebugStringAndShortDebugString<T>::value is a compile-time bool constant\n// that's true if and only if T has methods DebugString() and ShortDebugString()\n// that return std::string.\ntemplate <typename T>\nclass HasDebugStringAndShortDebugString {\n private:\n  template <typename C>\n  static auto CheckDebugString(C*) -> typename std::is_same<\n      std::string, decltype(std::declval<const C>().DebugString())>::type;\n  template <typename>\n  static std::false_type CheckDebugString(...);\n\n  template <typename C>\n  static auto CheckShortDebugString(C*) -> typename std::is_same<\n      std::string, decltype(std::declval<const C>().ShortDebugString())>::type;\n  template <typename>\n  static std::false_type CheckShortDebugString(...);\n\n  using HasDebugStringType = decltype(CheckDebugString<T>(nullptr));\n  using HasShortDebugStringType = decltype(CheckShortDebugString<T>(nullptr));\n\n public:\n  static constexpr bool value =\n      HasDebugStringType::value && HasShortDebugStringType::value;\n};\n\ntemplate <typename T>\nconstexpr bool HasDebugStringAndShortDebugString<T>::value;\n\n// When the compiler sees expression IsContainerTest<C>(0), if C is an\n// STL-style container class, the first overload of IsContainerTest\n// will be viable (since both C::iterator* and C::const_iterator* are\n// valid types and NULL can be implicitly converted to them).  It will\n// be picked over the second overload as 'int' is a perfect match for\n// the type of argument 0.  If C::iterator or C::const_iterator is not\n// a valid type, the first overload is not viable, and the second\n// overload will be picked.  Therefore, we can determine whether C is\n// a container class by checking the type of IsContainerTest<C>(0).\n// The value of the expression is insignificant.\n//\n// In C++11 mode we check the existence of a const_iterator and that an\n// iterator is properly implemented for the container.\n//\n// For pre-C++11 that we look for both C::iterator and C::const_iterator.\n// The reason is that C++ injects the name of a class as a member of the\n// class itself (e.g. you can refer to class iterator as either\n// 'iterator' or 'iterator::iterator').  If we look for C::iterator\n// only, for example, we would mistakenly think that a class named\n// iterator is an STL container.\n//\n// Also note that the simpler approach of overloading\n// IsContainerTest(typename C::const_iterator*) and\n// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.\ntypedef int IsContainer;\ntemplate <class C,\n          class Iterator = decltype(::std::declval<const C&>().begin()),\n          class = decltype(::std::declval<const C&>().end()),\n          class = decltype(++::std::declval<Iterator&>()),\n          class = decltype(*::std::declval<Iterator>()),\n          class = typename C::const_iterator>\nIsContainer IsContainerTest(int /* dummy */) {\n  return 0;\n}\n\ntypedef char IsNotContainer;\ntemplate <class C>\nIsNotContainer IsContainerTest(long /* dummy */) { return '\\0'; }\n\n// Trait to detect whether a type T is a hash table.\n// The heuristic used is that the type contains an inner type `hasher` and does\n// not contain an inner type `reverse_iterator`.\n// If the container is iterable in reverse, then order might actually matter.\ntemplate <typename T>\nstruct IsHashTable {\n private:\n  template <typename U>\n  static char test(typename U::hasher*, typename U::reverse_iterator*);\n  template <typename U>\n  static int test(typename U::hasher*, ...);\n  template <typename U>\n  static char test(...);\n\n public:\n  static const bool value = sizeof(test<T>(nullptr, nullptr)) == sizeof(int);\n};\n\ntemplate <typename T>\nconst bool IsHashTable<T>::value;\n\ntemplate <typename C,\n          bool = sizeof(IsContainerTest<C>(0)) == sizeof(IsContainer)>\nstruct IsRecursiveContainerImpl;\n\ntemplate <typename C>\nstruct IsRecursiveContainerImpl<C, false> : public std::false_type {};\n\n// Since the IsRecursiveContainerImpl depends on the IsContainerTest we need to\n// obey the same inconsistencies as the IsContainerTest, namely check if\n// something is a container is relying on only const_iterator in C++11 and\n// is relying on both const_iterator and iterator otherwise\ntemplate <typename C>\nstruct IsRecursiveContainerImpl<C, true> {\n  using value_type = decltype(*std::declval<typename C::const_iterator>());\n  using type =\n      std::is_same<typename std::remove_const<\n                       typename std::remove_reference<value_type>::type>::type,\n                   C>;\n};\n\n// IsRecursiveContainer<Type> is a unary compile-time predicate that\n// evaluates whether C is a recursive container type. A recursive container\n// type is a container type whose value_type is equal to the container type\n// itself. An example for a recursive container type is\n// boost::filesystem::path, whose iterator has a value_type that is equal to\n// boost::filesystem::path.\ntemplate <typename C>\nstruct IsRecursiveContainer : public IsRecursiveContainerImpl<C>::type {};\n\n// Utilities for native arrays.\n\n// ArrayEq() compares two k-dimensional native arrays using the\n// elements' operator==, where k can be any integer >= 0.  When k is\n// 0, ArrayEq() degenerates into comparing a single pair of values.\n\ntemplate <typename T, typename U>\nbool ArrayEq(const T* lhs, size_t size, const U* rhs);\n\n// This generic version is used when k is 0.\ntemplate <typename T, typename U>\ninline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }\n\n// This overload is used when k >= 1.\ntemplate <typename T, typename U, size_t N>\ninline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {\n  return internal::ArrayEq(lhs, N, rhs);\n}\n\n// This helper reduces code bloat.  If we instead put its logic inside\n// the previous ArrayEq() function, arrays with different sizes would\n// lead to different copies of the template code.\ntemplate <typename T, typename U>\nbool ArrayEq(const T* lhs, size_t size, const U* rhs) {\n  for (size_t i = 0; i != size; i++) {\n    if (!internal::ArrayEq(lhs[i], rhs[i]))\n      return false;\n  }\n  return true;\n}\n\n// Finds the first element in the iterator range [begin, end) that\n// equals elem.  Element may be a native array type itself.\ntemplate <typename Iter, typename Element>\nIter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {\n  for (Iter it = begin; it != end; ++it) {\n    if (internal::ArrayEq(*it, elem))\n      return it;\n  }\n  return end;\n}\n\n// CopyArray() copies a k-dimensional native array using the elements'\n// operator=, where k can be any integer >= 0.  When k is 0,\n// CopyArray() degenerates into copying a single value.\n\ntemplate <typename T, typename U>\nvoid CopyArray(const T* from, size_t size, U* to);\n\n// This generic version is used when k is 0.\ntemplate <typename T, typename U>\ninline void CopyArray(const T& from, U* to) { *to = from; }\n\n// This overload is used when k >= 1.\ntemplate <typename T, typename U, size_t N>\ninline void CopyArray(const T(&from)[N], U(*to)[N]) {\n  internal::CopyArray(from, N, *to);\n}\n\n// This helper reduces code bloat.  If we instead put its logic inside\n// the previous CopyArray() function, arrays with different sizes\n// would lead to different copies of the template code.\ntemplate <typename T, typename U>\nvoid CopyArray(const T* from, size_t size, U* to) {\n  for (size_t i = 0; i != size; i++) {\n    internal::CopyArray(from[i], to + i);\n  }\n}\n\n// The relation between an NativeArray object (see below) and the\n// native array it represents.\n// We use 2 different structs to allow non-copyable types to be used, as long\n// as RelationToSourceReference() is passed.\nstruct RelationToSourceReference {};\nstruct RelationToSourceCopy {};\n\n// Adapts a native array to a read-only STL-style container.  Instead\n// of the complete STL container concept, this adaptor only implements\n// members useful for Google Mock's container matchers.  New members\n// should be added as needed.  To simplify the implementation, we only\n// support Element being a raw type (i.e. having no top-level const or\n// reference modifier).  It's the client's responsibility to satisfy\n// this requirement.  Element can be an array type itself (hence\n// multi-dimensional arrays are supported).\ntemplate <typename Element>\nclass NativeArray {\n public:\n  // STL-style container typedefs.\n  typedef Element value_type;\n  typedef Element* iterator;\n  typedef const Element* const_iterator;\n\n  // Constructs from a native array. References the source.\n  NativeArray(const Element* array, size_t count, RelationToSourceReference) {\n    InitRef(array, count);\n  }\n\n  // Constructs from a native array. Copies the source.\n  NativeArray(const Element* array, size_t count, RelationToSourceCopy) {\n    InitCopy(array, count);\n  }\n\n  // Copy constructor.\n  NativeArray(const NativeArray& rhs) {\n    (this->*rhs.clone_)(rhs.array_, rhs.size_);\n  }\n\n  ~NativeArray() {\n    if (clone_ != &NativeArray::InitRef)\n      delete[] array_;\n  }\n\n  // STL-style container methods.\n  size_t size() const { return size_; }\n  const_iterator begin() const { return array_; }\n  const_iterator end() const { return array_ + size_; }\n  bool operator==(const NativeArray& rhs) const {\n    return size() == rhs.size() &&\n        ArrayEq(begin(), size(), rhs.begin());\n  }\n\n private:\n  static_assert(!std::is_const<Element>::value, \"Type must not be const\");\n  static_assert(!std::is_reference<Element>::value,\n                \"Type must not be a reference\");\n\n  // Initializes this object with a copy of the input.\n  void InitCopy(const Element* array, size_t a_size) {\n    Element* const copy = new Element[a_size];\n    CopyArray(array, a_size, copy);\n    array_ = copy;\n    size_ = a_size;\n    clone_ = &NativeArray::InitCopy;\n  }\n\n  // Initializes this object with a reference of the input.\n  void InitRef(const Element* array, size_t a_size) {\n    array_ = array;\n    size_ = a_size;\n    clone_ = &NativeArray::InitRef;\n  }\n\n  const Element* array_;\n  size_t size_;\n  void (NativeArray::*clone_)(const Element*, size_t);\n};\n\n// Backport of std::index_sequence.\ntemplate <size_t... Is>\nstruct IndexSequence {\n  using type = IndexSequence;\n};\n\n// Double the IndexSequence, and one if plus_one is true.\ntemplate <bool plus_one, typename T, size_t sizeofT>\nstruct DoubleSequence;\ntemplate <size_t... I, size_t sizeofT>\nstruct DoubleSequence<true, IndexSequence<I...>, sizeofT> {\n  using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;\n};\ntemplate <size_t... I, size_t sizeofT>\nstruct DoubleSequence<false, IndexSequence<I...>, sizeofT> {\n  using type = IndexSequence<I..., (sizeofT + I)...>;\n};\n\n// Backport of std::make_index_sequence.\n// It uses O(ln(N)) instantiation depth.\ntemplate <size_t N>\nstruct MakeIndexSequenceImpl\n    : DoubleSequence<N % 2 == 1, typename MakeIndexSequenceImpl<N / 2>::type,\n                     N / 2>::type {};\n\ntemplate <>\nstruct MakeIndexSequenceImpl<0> : IndexSequence<> {};\n\ntemplate <size_t N>\nusing MakeIndexSequence = typename MakeIndexSequenceImpl<N>::type;\n\ntemplate <typename... T>\nusing IndexSequenceFor = typename MakeIndexSequence<sizeof...(T)>::type;\n\ntemplate <size_t>\nstruct Ignore {\n  Ignore(...);  // NOLINT\n};\n\ntemplate <typename>\nstruct ElemFromListImpl;\ntemplate <size_t... I>\nstruct ElemFromListImpl<IndexSequence<I...>> {\n  // We make Ignore a template to solve a problem with MSVC.\n  // A non-template Ignore would work fine with `decltype(Ignore(I))...`, but\n  // MSVC doesn't understand how to deal with that pack expansion.\n  // Use `0 * I` to have a single instantiation of Ignore.\n  template <typename R>\n  static R Apply(Ignore<0 * I>..., R (*)(), ...);\n};\n\ntemplate <size_t N, typename... T>\nstruct ElemFromList {\n  using type =\n      decltype(ElemFromListImpl<typename MakeIndexSequence<N>::type>::Apply(\n          static_cast<T (*)()>(nullptr)...));\n};\n\nstruct FlatTupleConstructTag {};\n\ntemplate <typename... T>\nclass FlatTuple;\n\ntemplate <typename Derived, size_t I>\nstruct FlatTupleElemBase;\n\ntemplate <typename... T, size_t I>\nstruct FlatTupleElemBase<FlatTuple<T...>, I> {\n  using value_type = typename ElemFromList<I, T...>::type;\n  FlatTupleElemBase() = default;\n  template <typename Arg>\n  explicit FlatTupleElemBase(FlatTupleConstructTag, Arg&& t)\n      : value(std::forward<Arg>(t)) {}\n  value_type value;\n};\n\ntemplate <typename Derived, typename Idx>\nstruct FlatTupleBase;\n\ntemplate <size_t... Idx, typename... T>\nstruct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>\n    : FlatTupleElemBase<FlatTuple<T...>, Idx>... {\n  using Indices = IndexSequence<Idx...>;\n  FlatTupleBase() = default;\n  template <typename... Args>\n  explicit FlatTupleBase(FlatTupleConstructTag, Args&&... args)\n      : FlatTupleElemBase<FlatTuple<T...>, Idx>(FlatTupleConstructTag{},\n                                                std::forward<Args>(args))... {}\n\n  template <size_t I>\n  const typename ElemFromList<I, T...>::type& Get() const {\n    return FlatTupleElemBase<FlatTuple<T...>, I>::value;\n  }\n\n  template <size_t I>\n  typename ElemFromList<I, T...>::type& Get() {\n    return FlatTupleElemBase<FlatTuple<T...>, I>::value;\n  }\n\n  template <typename F>\n  auto Apply(F&& f) -> decltype(std::forward<F>(f)(this->Get<Idx>()...)) {\n    return std::forward<F>(f)(Get<Idx>()...);\n  }\n\n  template <typename F>\n  auto Apply(F&& f) const -> decltype(std::forward<F>(f)(this->Get<Idx>()...)) {\n    return std::forward<F>(f)(Get<Idx>()...);\n  }\n};\n\n// Analog to std::tuple but with different tradeoffs.\n// This class minimizes the template instantiation depth, thus allowing more\n// elements than std::tuple would. std::tuple has been seen to require an\n// instantiation depth of more than 10x the number of elements in some\n// implementations.\n// FlatTuple and ElemFromList are not recursive and have a fixed depth\n// regardless of T...\n// MakeIndexSequence, on the other hand, it is recursive but with an\n// instantiation depth of O(ln(N)).\ntemplate <typename... T>\nclass FlatTuple\n    : private FlatTupleBase<FlatTuple<T...>,\n                            typename MakeIndexSequence<sizeof...(T)>::type> {\n  using Indices = typename FlatTupleBase<\n      FlatTuple<T...>, typename MakeIndexSequence<sizeof...(T)>::type>::Indices;\n\n public:\n  FlatTuple() = default;\n  template <typename... Args>\n  explicit FlatTuple(FlatTupleConstructTag tag, Args&&... args)\n      : FlatTuple::FlatTupleBase(tag, std::forward<Args>(args)...) {}\n\n  using FlatTuple::FlatTupleBase::Apply;\n  using FlatTuple::FlatTupleBase::Get;\n};\n\n// Utility functions to be called with static_assert to induce deprecation\n// warnings.\nGTEST_INTERNAL_DEPRECATED(\n    \"INSTANTIATE_TEST_CASE_P is deprecated, please use \"\n    \"INSTANTIATE_TEST_SUITE_P\")\nconstexpr bool InstantiateTestCase_P_IsDeprecated() { return true; }\n\nGTEST_INTERNAL_DEPRECATED(\n    \"TYPED_TEST_CASE_P is deprecated, please use \"\n    \"TYPED_TEST_SUITE_P\")\nconstexpr bool TypedTestCase_P_IsDeprecated() { return true; }\n\nGTEST_INTERNAL_DEPRECATED(\n    \"TYPED_TEST_CASE is deprecated, please use \"\n    \"TYPED_TEST_SUITE\")\nconstexpr bool TypedTestCaseIsDeprecated() { return true; }\n\nGTEST_INTERNAL_DEPRECATED(\n    \"REGISTER_TYPED_TEST_CASE_P is deprecated, please use \"\n    \"REGISTER_TYPED_TEST_SUITE_P\")\nconstexpr bool RegisterTypedTestCase_P_IsDeprecated() { return true; }\n\nGTEST_INTERNAL_DEPRECATED(\n    \"INSTANTIATE_TYPED_TEST_CASE_P is deprecated, please use \"\n    \"INSTANTIATE_TYPED_TEST_SUITE_P\")\nconstexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; }\n\n}  // namespace internal\n}  // namespace testing\n\nnamespace std {\n// Some standard library implementations use `struct tuple_size` and some use\n// `class tuple_size`. Clang warns about the mismatch.\n// https://reviews.llvm.org/D55466\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wmismatched-tags\"\n#endif\ntemplate <typename... Ts>\nstruct tuple_size<testing::internal::FlatTuple<Ts...>>\n    : std::integral_constant<size_t, sizeof...(Ts)> {};\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n}  // namespace std\n\n#define GTEST_MESSAGE_AT_(file, line, message, result_type) \\\n  ::testing::internal::AssertHelper(result_type, file, line, message) \\\n    = ::testing::Message()\n\n#define GTEST_MESSAGE_(message, result_type) \\\n  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)\n\n#define GTEST_FATAL_FAILURE_(message) \\\n  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)\n\n#define GTEST_NONFATAL_FAILURE_(message) \\\n  GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)\n\n#define GTEST_SUCCESS_(message) \\\n  GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)\n\n#define GTEST_SKIP_(message) \\\n  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)\n\n// Suppress MSVC warning 4072 (unreachable code) for the code following\n// statement if it returns or throws (or doesn't return or throw in some\n// situations).\n// NOTE: The \"else\" is important to keep this expansion to prevent a top-level\n// \"else\" from attaching to our \"if\".\n#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \\\n  if (::testing::internal::AlwaysTrue()) {                        \\\n    statement;                                                    \\\n  } else                     /* NOLINT */                         \\\n    static_assert(true, \"\")  // User must have a semicolon after expansion.\n\n#if GTEST_HAS_EXCEPTIONS\n\nnamespace testing {\nnamespace internal {\n\nclass NeverThrown {\n public:\n  const char* what() const noexcept {\n    return \"this exception should never be thrown\";\n  }\n};\n\n}  // namespace internal\n}  // namespace testing\n\n#if GTEST_HAS_RTTI\n\n#define GTEST_EXCEPTION_TYPE_(e) ::testing::internal::GetTypeName(typeid(e))\n\n#else  // GTEST_HAS_RTTI\n\n#define GTEST_EXCEPTION_TYPE_(e) \\\n  std::string { \"an std::exception-derived error\" }\n\n#endif  // GTEST_HAS_RTTI\n\n#define GTEST_TEST_THROW_CATCH_STD_EXCEPTION_(statement, expected_exception)   \\\n  catch (typename std::conditional<                                            \\\n         std::is_same<typename std::remove_cv<typename std::remove_reference<  \\\n                          expected_exception>::type>::type,                    \\\n                      std::exception>::value,                                  \\\n         const ::testing::internal::NeverThrown&, const std::exception&>::type \\\n             e) {                                                              \\\n    gtest_msg.value = \"Expected: \" #statement                                  \\\n                      \" throws an exception of type \" #expected_exception      \\\n                      \".\\n  Actual: it throws \";                               \\\n    gtest_msg.value += GTEST_EXCEPTION_TYPE_(e);                               \\\n    gtest_msg.value += \" with description \\\"\";                                 \\\n    gtest_msg.value += e.what();                                               \\\n    gtest_msg.value += \"\\\".\";                                                  \\\n    goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);                \\\n  }\n\n#else  // GTEST_HAS_EXCEPTIONS\n\n#define GTEST_TEST_THROW_CATCH_STD_EXCEPTION_(statement, expected_exception)\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n#define GTEST_TEST_THROW_(statement, expected_exception, fail)              \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                             \\\n  if (::testing::internal::TrueWithString gtest_msg{}) {                    \\\n    bool gtest_caught_expected = false;                                     \\\n    try {                                                                   \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);            \\\n    } catch (expected_exception const&) {                                   \\\n      gtest_caught_expected = true;                                         \\\n    }                                                                       \\\n    GTEST_TEST_THROW_CATCH_STD_EXCEPTION_(statement, expected_exception)    \\\n    catch (...) {                                                           \\\n      gtest_msg.value = \"Expected: \" #statement                             \\\n                        \" throws an exception of type \" #expected_exception \\\n                        \".\\n  Actual: it throws a different type.\";         \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);           \\\n    }                                                                       \\\n    if (!gtest_caught_expected) {                                           \\\n      gtest_msg.value = \"Expected: \" #statement                             \\\n                        \" throws an exception of type \" #expected_exception \\\n                        \".\\n  Actual: it throws nothing.\";                  \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);           \\\n    }                                                                       \\\n  } else /*NOLINT*/                                                         \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__)                   \\\n        : fail(gtest_msg.value.c_str())\n\n#if GTEST_HAS_EXCEPTIONS\n\n#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_()                \\\n  catch (std::exception const& e) {                               \\\n    gtest_msg.value = \"it throws \";                               \\\n    gtest_msg.value += GTEST_EXCEPTION_TYPE_(e);                  \\\n    gtest_msg.value += \" with description \\\"\";                    \\\n    gtest_msg.value += e.what();                                  \\\n    gtest_msg.value += \"\\\".\";                                     \\\n    goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \\\n  }\n\n#else  // GTEST_HAS_EXCEPTIONS\n\n#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_()\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n#define GTEST_TEST_NO_THROW_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::TrueWithString gtest_msg{}) { \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \\\n    catch (...) { \\\n      gtest_msg.value = \"it throws.\"; \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \\\n      fail((\"Expected: \" #statement \" doesn't throw an exception.\\n\" \\\n            \"  Actual: \" + gtest_msg.value).c_str())\n\n#define GTEST_TEST_ANY_THROW_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    bool gtest_caught_any = false; \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (...) { \\\n      gtest_caught_any = true; \\\n    } \\\n    if (!gtest_caught_any) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \\\n      fail(\"Expected: \" #statement \" throws an exception.\\n\" \\\n           \"  Actual: it doesn't.\")\n\n\n// Implements Boolean test assertions such as EXPECT_TRUE. expression can be\n// either a boolean expression or an AssertionResult. text is a textual\n// representation of expression as it was passed into the EXPECT_TRUE.\n#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (const ::testing::AssertionResult gtest_ar_ = \\\n      ::testing::AssertionResult(expression)) \\\n    ; \\\n  else \\\n    fail(::testing::internal::GetBoolAssertionFailureMessage(\\\n        gtest_ar_, text, #actual, #expected).c_str())\n\n#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \\\n      fail(\"Expected: \" #statement \" doesn't generate new fatal \" \\\n           \"failures in the current thread.\\n\" \\\n           \"  Actual: it does.\")\n\n// Expands to the name of the class that implements the given test.\n#define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \\\n  test_suite_name##_##test_name##_Test\n\n// Helper macro for defining tests.\n#define GTEST_TEST_(test_suite_name, test_name, parent_class, parent_id)      \\\n  static_assert(sizeof(GTEST_STRINGIFY_(test_suite_name)) > 1,                \\\n                \"test_suite_name must not be empty\");                         \\\n  static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1,                      \\\n                \"test_name must not be empty\");                               \\\n  class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)                    \\\n      : public parent_class {                                                 \\\n   public:                                                                    \\\n    GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default;           \\\n    ~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \\\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name,   \\\n                                                           test_name));       \\\n    GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name,   \\\n                                                           test_name));       \\\n                                                                              \\\n   private:                                                                   \\\n    void TestBody() override;                                                 \\\n    static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;     \\\n  };                                                                          \\\n                                                                              \\\n  ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name,          \\\n                                                    test_name)::test_info_ =  \\\n      ::testing::internal::MakeAndRegisterTestInfo(                           \\\n          #test_suite_name, #test_name, nullptr, nullptr,                     \\\n          ::testing::internal::CodeLocation(__FILE__, __LINE__), (parent_id), \\\n          ::testing::internal::SuiteApiResolver<                              \\\n              parent_class>::GetSetUpCaseOrSuite(__FILE__, __LINE__),         \\\n          ::testing::internal::SuiteApiResolver<                              \\\n              parent_class>::GetTearDownCaseOrSuite(__FILE__, __LINE__),      \\\n          new ::testing::internal::TestFactoryImpl<GTEST_TEST_CLASS_NAME_(    \\\n              test_suite_name, test_name)>);                                  \\\n  void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file defines the public API for death tests.  It is\n// #included by gtest.h so a user doesn't need to include this\n// directly.\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n\n// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This header file defines internal utilities needed for implementing\n// death tests.  They are subject to change without notice.\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// The Google C++ Testing and Mocking Framework (Google Test)\n//\n// This file implements just enough of the matcher interface to allow\n// EXPECT_DEATH and friends to accept a matcher argument.\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_\n\n#include <atomic>\n#include <memory>\n#include <ostream>\n#include <string>\n#include <type_traits>\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Google Test - The Google C++ Testing and Mocking Framework\n//\n// This file implements a universal value printer that can print a\n// value of any type T:\n//\n//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);\n//\n// A user can teach this function how to print a class type T by\n// defining either operator<<() or PrintTo() in the namespace that\n// defines T.  More specifically, the FIRST defined function in the\n// following list will be used (assuming T is defined in namespace\n// foo):\n//\n//   1. foo::PrintTo(const T&, ostream*)\n//   2. operator<<(ostream&, const T&) defined in either foo or the\n//      global namespace.\n//\n// However if T is an STL-style container then it is printed element-wise\n// unless foo::PrintTo(const T&, ostream*) is defined. Note that\n// operator<<() is ignored for container types.\n//\n// If none of the above is defined, it will print the debug string of\n// the value if it is a protocol buffer, or print the raw bytes in the\n// value otherwise.\n//\n// To aid debugging: when T is a reference type, the address of the\n// value is also printed; when T is a (const) char pointer, both the\n// pointer value and the NUL-terminated string it points to are\n// printed.\n//\n// We also provide some convenient wrappers:\n//\n//   // Prints a value to a string.  For a (const or not) char\n//   // pointer, the NUL-terminated string (but not the pointer) is\n//   // printed.\n//   std::string ::testing::PrintToString(const T& value);\n//\n//   // Prints a value tersely: for a reference type, the referenced\n//   // value (but not the address) is printed; for a (const or not) char\n//   // pointer, the NUL-terminated string (but not the pointer) is\n//   // printed.\n//   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);\n//\n//   // Prints value using the type inferred by the compiler.  The difference\n//   // from UniversalTersePrint() is that this function prints both the\n//   // pointer and the NUL-terminated string for a (const or not) char pointer.\n//   void ::testing::internal::UniversalPrint(const T& value, ostream*);\n//\n//   // Prints the fields of a tuple tersely to a string vector, one\n//   // element for each field. Tuple support must be enabled in\n//   // gtest-port.h.\n//   std::vector<string> UniversalTersePrintTupleFieldsToStrings(\n//       const Tuple& value);\n//\n// Known limitation:\n//\n// The print primitives print the elements of an STL-style container\n// using the compiler-inferred type of *iter where iter is a\n// const_iterator of the container.  When const_iterator is an input\n// iterator but not a forward iterator, this inferred type may not\n// match value_type, and the print output may be incorrect.  In\n// practice, this is rarely a problem as for most containers\n// const_iterator is a forward iterator.  We'll fix this if there's an\n// actual need for it.  Note that this fix cannot rely on value_type\n// being defined as many user-defined container types don't have\n// value_type.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n\n#include <functional>\n#include <memory>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n#include <tuple>\n#include <type_traits>\n#include <utility>\n#include <vector>\n\n\n#if GTEST_HAS_RTTI\n#include <typeindex>\n#include <typeinfo>\n#endif  // GTEST_HAS_RTTI\n\nnamespace testing {\n\n// Definitions in the internal* namespaces are subject to change without notice.\n// DO NOT USE THEM IN USER CODE!\nnamespace internal {\n\ntemplate <typename T>\nvoid UniversalPrint(const T& value, ::std::ostream* os);\n\n// Used to print an STL-style container when the user doesn't define\n// a PrintTo() for it.\nstruct ContainerPrinter {\n  template <typename T,\n            typename = typename std::enable_if<\n                (sizeof(IsContainerTest<T>(0)) == sizeof(IsContainer)) &&\n                !IsRecursiveContainer<T>::value>::type>\n  static void PrintValue(const T& container, std::ostream* os) {\n    const size_t kMaxCount = 32;  // The maximum number of elements to print.\n    *os << '{';\n    size_t count = 0;\n    for (auto&& elem : container) {\n      if (count > 0) {\n        *os << ',';\n        if (count == kMaxCount) {  // Enough has been printed.\n          *os << \" ...\";\n          break;\n        }\n      }\n      *os << ' ';\n      // We cannot call PrintTo(elem, os) here as PrintTo() doesn't\n      // handle `elem` being a native array.\n      internal::UniversalPrint(elem, os);\n      ++count;\n    }\n\n    if (count > 0) {\n      *os << ' ';\n    }\n    *os << '}';\n  }\n};\n\n// Used to print a pointer that is neither a char pointer nor a member\n// pointer, when the user doesn't define PrintTo() for it.  (A member\n// variable pointer or member function pointer doesn't really point to\n// a location in the address space.  Their representation is\n// implementation-defined.  Therefore they will be printed as raw\n// bytes.)\nstruct FunctionPointerPrinter {\n  template <typename T, typename = typename std::enable_if<\n                            std::is_function<T>::value>::type>\n  static void PrintValue(T* p, ::std::ostream* os) {\n    if (p == nullptr) {\n      *os << \"NULL\";\n    } else {\n      // T is a function type, so '*os << p' doesn't do what we want\n      // (it just prints p as bool).  We want to print p as a const\n      // void*.\n      *os << reinterpret_cast<const void*>(p);\n    }\n  }\n};\n\nstruct PointerPrinter {\n  template <typename T>\n  static void PrintValue(T* p, ::std::ostream* os) {\n    if (p == nullptr) {\n      *os << \"NULL\";\n    } else {\n      // T is not a function type.  We just call << to print p,\n      // relying on ADL to pick up user-defined << for their pointer\n      // types, if any.\n      *os << p;\n    }\n  }\n};\n\nnamespace internal_stream_operator_without_lexical_name_lookup {\n\n// The presence of an operator<< here will terminate lexical scope lookup\n// straight away (even though it cannot be a match because of its argument\n// types). Thus, the two operator<< calls in StreamPrinter will find only ADL\n// candidates.\nstruct LookupBlocker {};\nvoid operator<<(LookupBlocker, LookupBlocker);\n\nstruct StreamPrinter {\n  template <typename T,\n            // Don't accept member pointers here. We'd print them via implicit\n            // conversion to bool, which isn't useful.\n            typename = typename std::enable_if<\n                !std::is_member_pointer<T>::value>::type,\n            // Only accept types for which we can find a streaming operator via\n            // ADL (possibly involving implicit conversions).\n            typename = decltype(std::declval<std::ostream&>()\n                                << std::declval<const T&>())>\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    // Call streaming operator found by ADL, possibly with implicit conversions\n    // of the arguments.\n    *os << value;\n  }\n};\n\n}  // namespace internal_stream_operator_without_lexical_name_lookup\n\nstruct ProtobufPrinter {\n  // We print a protobuf using its ShortDebugString() when the string\n  // doesn't exceed this many characters; otherwise we print it using\n  // DebugString() for better readability.\n  static const size_t kProtobufOneLinerMaxLength = 50;\n\n  template <typename T,\n            typename = typename std::enable_if<\n                internal::HasDebugStringAndShortDebugString<T>::value>::type>\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    std::string pretty_str = value.ShortDebugString();\n    if (pretty_str.length() > kProtobufOneLinerMaxLength) {\n      pretty_str = \"\\n\" + value.DebugString();\n    }\n    *os << (\"<\" + pretty_str + \">\");\n  }\n};\n\nstruct ConvertibleToIntegerPrinter {\n  // Since T has no << operator or PrintTo() but can be implicitly\n  // converted to BiggestInt, we print it as a BiggestInt.\n  //\n  // Most likely T is an enum type (either named or unnamed), in which\n  // case printing it as an integer is the desired behavior.  In case\n  // T is not an enum, printing it as an integer is the best we can do\n  // given that it has no user-defined printer.\n  static void PrintValue(internal::BiggestInt value, ::std::ostream* os) {\n    *os << value;\n  }\n};\n\nstruct ConvertibleToStringViewPrinter {\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n  static void PrintValue(internal::StringView value, ::std::ostream* os) {\n    internal::UniversalPrint(value, os);\n  }\n#endif\n};\n\n\n// Prints the given number of bytes in the given object to the given\n// ostream.\nGTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,\n                                     size_t count,\n                                     ::std::ostream* os);\nstruct RawBytesPrinter {\n  // SFINAE on `sizeof` to make sure we have a complete type.\n  template <typename T, size_t = sizeof(T)>\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    PrintBytesInObjectTo(\n        static_cast<const unsigned char*>(\n            // Load bearing cast to void* to support iOS\n            reinterpret_cast<const void*>(std::addressof(value))),\n        sizeof(value), os);\n  }\n};\n\nstruct FallbackPrinter {\n  template <typename T>\n  static void PrintValue(const T&, ::std::ostream* os) {\n    *os << \"(incomplete type)\";\n  }\n};\n\n// Try every printer in order and return the first one that works.\ntemplate <typename T, typename E, typename Printer, typename... Printers>\nstruct FindFirstPrinter : FindFirstPrinter<T, E, Printers...> {};\n\ntemplate <typename T, typename Printer, typename... Printers>\nstruct FindFirstPrinter<\n    T, decltype(Printer::PrintValue(std::declval<const T&>(), nullptr)),\n    Printer, Printers...> {\n  using type = Printer;\n};\n\n// Select the best printer in the following order:\n//  - Print containers (they have begin/end/etc).\n//  - Print function pointers.\n//  - Print object pointers.\n//  - Use the stream operator, if available.\n//  - Print protocol buffers.\n//  - Print types convertible to BiggestInt.\n//  - Print types convertible to StringView, if available.\n//  - Fallback to printing the raw bytes of the object.\ntemplate <typename T>\nvoid PrintWithFallback(const T& value, ::std::ostream* os) {\n  using Printer = typename FindFirstPrinter<\n      T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter,\n      internal_stream_operator_without_lexical_name_lookup::StreamPrinter,\n      ProtobufPrinter, ConvertibleToIntegerPrinter,\n      ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type;\n  Printer::PrintValue(value, os);\n}\n\n// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a\n// value of type ToPrint that is an operand of a comparison assertion\n// (e.g. ASSERT_EQ).  OtherOperand is the type of the other operand in\n// the comparison, and is used to help determine the best way to\n// format the value.  In particular, when the value is a C string\n// (char pointer) and the other operand is an STL string object, we\n// want to format the C string as a string, since we know it is\n// compared by value with the string object.  If the value is a char\n// pointer but the other operand is not an STL string object, we don't\n// know whether the pointer is supposed to point to a NUL-terminated\n// string, and thus want to print it as a pointer to be safe.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n// The default case.\ntemplate <typename ToPrint, typename OtherOperand>\nclass FormatForComparison {\n public:\n  static ::std::string Format(const ToPrint& value) {\n    return ::testing::PrintToString(value);\n  }\n};\n\n// Array.\ntemplate <typename ToPrint, size_t N, typename OtherOperand>\nclass FormatForComparison<ToPrint[N], OtherOperand> {\n public:\n  static ::std::string Format(const ToPrint* value) {\n    return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);\n  }\n};\n\n// By default, print C string as pointers to be safe, as we don't know\n// whether they actually point to a NUL-terminated string.\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)                \\\n  template <typename OtherOperand>                                      \\\n  class FormatForComparison<CharType*, OtherOperand> {                  \\\n   public:                                                              \\\n    static ::std::string Format(CharType* value) {                      \\\n      return ::testing::PrintToString(static_cast<const void*>(value)); \\\n    }                                                                   \\\n  }\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);\n#ifdef __cpp_char8_t\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char8_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char8_t);\n#endif\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char16_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char16_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char32_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char32_t);\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_\n\n// If a C string is compared with an STL string object, we know it's meant\n// to point to a NUL-terminated string, and thus can print it as a string.\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \\\n  template <>                                                           \\\n  class FormatForComparison<CharType*, OtherStringType> {               \\\n   public:                                                              \\\n    static ::std::string Format(CharType* value) {                      \\\n      return ::testing::PrintToString(value);                           \\\n    }                                                                   \\\n  }\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);\n#ifdef __cpp_char8_t\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char8_t, ::std::u8string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char8_t, ::std::u8string);\n#endif\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char16_t, ::std::u16string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char16_t, ::std::u16string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char32_t, ::std::u32string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char32_t, ::std::u32string);\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);\n#endif\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_\n\n// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)\n// operand to be used in a failure message.  The type (but not value)\n// of the other operand may affect the format.  This allows us to\n// print a char* as a raw pointer when it is compared against another\n// char* or void*, and print it as a C string when it is compared\n// against an std::string object, for example.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\ntemplate <typename T1, typename T2>\nstd::string FormatForComparisonFailureMessage(\n    const T1& value, const T2& /* other_operand */) {\n  return FormatForComparison<T1, T2>::Format(value);\n}\n\n// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given\n// value to the given ostream.  The caller must ensure that\n// 'ostream_ptr' is not NULL, or the behavior is undefined.\n//\n// We define UniversalPrinter as a class template (as opposed to a\n// function template), as we need to partially specialize it for\n// reference types, which cannot be done with function templates.\ntemplate <typename T>\nclass UniversalPrinter;\n\n// Prints the given value using the << operator if it has one;\n// otherwise prints the bytes in it.  This is what\n// UniversalPrinter<T>::Print() does when PrintTo() is not specialized\n// or overloaded for type T.\n//\n// A user can override this behavior for a class type Foo by defining\n// an overload of PrintTo() in the namespace where Foo is defined.  We\n// give the user this option as sometimes defining a << operator for\n// Foo is not desirable (e.g. the coding style may prevent doing it,\n// or there is already a << operator but it doesn't do what the user\n// wants).\ntemplate <typename T>\nvoid PrintTo(const T& value, ::std::ostream* os) {\n  internal::PrintWithFallback(value, os);\n}\n\n// The following list of PrintTo() overloads tells\n// UniversalPrinter<T>::Print() how to print standard types (built-in\n// types, strings, plain arrays, and pointers).\n\n// Overloads for various char types.\nGTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);\nGTEST_API_ void PrintTo(signed char c, ::std::ostream* os);\ninline void PrintTo(char c, ::std::ostream* os) {\n  // When printing a plain char, we always treat it as unsigned.  This\n  // way, the output won't be affected by whether the compiler thinks\n  // char is signed or not.\n  PrintTo(static_cast<unsigned char>(c), os);\n}\n\n// Overloads for other simple built-in types.\ninline void PrintTo(bool x, ::std::ostream* os) {\n  *os << (x ? \"true\" : \"false\");\n}\n\n// Overload for wchar_t type.\n// Prints a wchar_t as a symbol if it is printable or as its internal\n// code otherwise and also as its decimal code (except for L'\\0').\n// The L'\\0' char is printed as \"L'\\\\0'\". The decimal code is printed\n// as signed integer when wchar_t is implemented by the compiler\n// as a signed type and is printed as an unsigned integer when wchar_t\n// is implemented as an unsigned type.\nGTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);\n\nGTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);\ninline void PrintTo(char16_t c, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<char32_t>(c), os);\n}\n#ifdef __cpp_char8_t\ninline void PrintTo(char8_t c, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<char32_t>(c), os);\n}\n#endif\n\n// Overloads for C strings.\nGTEST_API_ void PrintTo(const char* s, ::std::ostream* os);\ninline void PrintTo(char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const char*>(s), os);\n}\n\n// signed/unsigned char is often used for representing binary data, so\n// we print pointers to it as void* to be safe.\ninline void PrintTo(const signed char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(signed char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(const unsigned char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(unsigned char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\n#ifdef __cpp_char8_t\n// Overloads for u8 strings.\nvoid PrintTo(const char8_t* s, ::std::ostream* os);\ninline void PrintTo(char8_t* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const char8_t*>(s), os);\n}\n#endif\n// Overloads for u16 strings.\nvoid PrintTo(const char16_t* s, ::std::ostream* os);\ninline void PrintTo(char16_t* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const char16_t*>(s), os);\n}\n// Overloads for u32 strings.\nvoid PrintTo(const char32_t* s, ::std::ostream* os);\ninline void PrintTo(char32_t* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const char32_t*>(s), os);\n}\n\n// MSVC can be configured to define wchar_t as a typedef of unsigned\n// short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native\n// type.  When wchar_t is a typedef, defining an overload for const\n// wchar_t* would cause unsigned short* be printed as a wide string,\n// possibly causing invalid memory accesses.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n// Overloads for wide C strings\nGTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);\ninline void PrintTo(wchar_t* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const wchar_t*>(s), os);\n}\n#endif\n\n// Overload for C arrays.  Multi-dimensional arrays are printed\n// properly.\n\n// Prints the given number of elements in an array, without printing\n// the curly braces.\ntemplate <typename T>\nvoid PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {\n  UniversalPrint(a[0], os);\n  for (size_t i = 1; i != count; i++) {\n    *os << \", \";\n    UniversalPrint(a[i], os);\n  }\n}\n\n// Overloads for ::std::string.\nGTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);\ninline void PrintTo(const ::std::string& s, ::std::ostream* os) {\n  PrintStringTo(s, os);\n}\n\n// Overloads for ::std::u8string\n#ifdef __cpp_char8_t\nGTEST_API_ void PrintU8StringTo(const ::std::u8string& s, ::std::ostream* os);\ninline void PrintTo(const ::std::u8string& s, ::std::ostream* os) {\n  PrintU8StringTo(s, os);\n}\n#endif\n\n// Overloads for ::std::u16string\nGTEST_API_ void PrintU16StringTo(const ::std::u16string& s, ::std::ostream* os);\ninline void PrintTo(const ::std::u16string& s, ::std::ostream* os) {\n  PrintU16StringTo(s, os);\n}\n\n// Overloads for ::std::u32string\nGTEST_API_ void PrintU32StringTo(const ::std::u32string& s, ::std::ostream* os);\ninline void PrintTo(const ::std::u32string& s, ::std::ostream* os) {\n  PrintU32StringTo(s, os);\n}\n\n// Overloads for ::std::wstring.\n#if GTEST_HAS_STD_WSTRING\nGTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);\ninline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {\n  PrintWideStringTo(s, os);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n// Overload for internal::StringView.\ninline void PrintTo(internal::StringView sp, ::std::ostream* os) {\n  PrintTo(::std::string(sp), os);\n}\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\ninline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << \"(nullptr)\"; }\n\ntemplate <typename T>\nvoid PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {\n  UniversalPrinter<T&>::Print(ref.get(), os);\n}\n\ninline const void* VoidifyPointer(const void* p) { return p; }\ninline const void* VoidifyPointer(volatile const void* p) {\n  return const_cast<const void*>(p);\n}\n\ntemplate <typename T, typename Ptr>\nvoid PrintSmartPointer(const Ptr& ptr, std::ostream* os, char) {\n  if (ptr == nullptr) {\n    *os << \"(nullptr)\";\n  } else {\n    // We can't print the value. Just print the pointer..\n    *os << \"(\" << (VoidifyPointer)(ptr.get()) << \")\";\n  }\n}\ntemplate <typename T, typename Ptr,\n          typename = typename std::enable_if<!std::is_void<T>::value &&\n                                             !std::is_array<T>::value>::type>\nvoid PrintSmartPointer(const Ptr& ptr, std::ostream* os, int) {\n  if (ptr == nullptr) {\n    *os << \"(nullptr)\";\n  } else {\n    *os << \"(ptr = \" << (VoidifyPointer)(ptr.get()) << \", value = \";\n    UniversalPrinter<T>::Print(*ptr, os);\n    *os << \")\";\n  }\n}\n\ntemplate <typename T, typename D>\nvoid PrintTo(const std::unique_ptr<T, D>& ptr, std::ostream* os) {\n  (PrintSmartPointer<T>)(ptr, os, 0);\n}\n\ntemplate <typename T>\nvoid PrintTo(const std::shared_ptr<T>& ptr, std::ostream* os) {\n  (PrintSmartPointer<T>)(ptr, os, 0);\n}\n\n// Helper function for printing a tuple.  T must be instantiated with\n// a tuple type.\ntemplate <typename T>\nvoid PrintTupleTo(const T&, std::integral_constant<size_t, 0>,\n                  ::std::ostream*) {}\n\ntemplate <typename T, size_t I>\nvoid PrintTupleTo(const T& t, std::integral_constant<size_t, I>,\n                  ::std::ostream* os) {\n  PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);\n  GTEST_INTENTIONAL_CONST_COND_PUSH_()\n  if (I > 1) {\n    GTEST_INTENTIONAL_CONST_COND_POP_()\n    *os << \", \";\n  }\n  UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(\n      std::get<I - 1>(t), os);\n}\n\ntemplate <typename... Types>\nvoid PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {\n  *os << \"(\";\n  PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);\n  *os << \")\";\n}\n\n// Overload for std::pair.\ntemplate <typename T1, typename T2>\nvoid PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {\n  *os << '(';\n  // We cannot use UniversalPrint(value.first, os) here, as T1 may be\n  // a reference type.  The same for printing value.second.\n  UniversalPrinter<T1>::Print(value.first, os);\n  *os << \", \";\n  UniversalPrinter<T2>::Print(value.second, os);\n  *os << ')';\n}\n\n#if GTEST_HAS_RTTI\ninline void PrintTo(const ::std::type_info& value, ::std::ostream* os) {\n  internal::PrintTo<::std::type_info>(value, os);\n  *os << \" (\\\"\" << value.name() << \"\\\")\";\n}\n\ninline void PrintTo(const ::std::type_index& value, ::std::ostream* os) {\n  internal::PrintTo<::std::type_index>(value, os);\n  *os << \" (\\\"\" << value.name() << \"\\\")\";\n}\n#endif  // GTEST_HAS_RTTI\n\n// Implements printing a non-reference type T by letting the compiler\n// pick the right overload of PrintTo() for T.\ntemplate <typename T>\nclass UniversalPrinter {\n public:\n  // MSVC warns about adding const to a function type, so we want to\n  // disable the warning.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)\n\n  // Note: we deliberately don't call this PrintTo(), as that name\n  // conflicts with ::testing::internal::PrintTo in the body of the\n  // function.\n  static void Print(const T& value, ::std::ostream* os) {\n    // By default, ::testing::internal::PrintTo() is used for printing\n    // the value.\n    //\n    // Thanks to Koenig look-up, if T is a class and has its own\n    // PrintTo() function defined in its namespace, that function will\n    // be visible here.  Since it is more specific than the generic ones\n    // in ::testing::internal, it will be picked by the compiler in the\n    // following statement - exactly what we want.\n    PrintTo(value, os);\n  }\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n};\n\n// Remove any const-qualifiers before passing a type to UniversalPrinter.\ntemplate <typename T>\nclass UniversalPrinter<const T> : public UniversalPrinter<T> {};\n\n#if GTEST_INTERNAL_HAS_ANY\n\n// Printer for std::any / absl::any\n\ntemplate <>\nclass UniversalPrinter<Any> {\n public:\n  static void Print(const Any& value, ::std::ostream* os) {\n    if (value.has_value()) {\n      *os << \"value of type \" << GetTypeName(value);\n    } else {\n      *os << \"no value\";\n    }\n  }\n\n private:\n  static std::string GetTypeName(const Any& value) {\n#if GTEST_HAS_RTTI\n    return internal::GetTypeName(value.type());\n#else\n    static_cast<void>(value);  // possibly unused\n    return \"<unknown_type>\";\n#endif  // GTEST_HAS_RTTI\n  }\n};\n\n#endif  // GTEST_INTERNAL_HAS_ANY\n\n#if GTEST_INTERNAL_HAS_OPTIONAL\n\n// Printer for std::optional / absl::optional\n\ntemplate <typename T>\nclass UniversalPrinter<Optional<T>> {\n public:\n  static void Print(const Optional<T>& value, ::std::ostream* os) {\n    *os << '(';\n    if (!value) {\n      *os << \"nullopt\";\n    } else {\n      UniversalPrint(*value, os);\n    }\n    *os << ')';\n  }\n};\n\n#endif  // GTEST_INTERNAL_HAS_OPTIONAL\n\n#if GTEST_INTERNAL_HAS_VARIANT\n\n// Printer for std::variant / absl::variant\n\ntemplate <typename... T>\nclass UniversalPrinter<Variant<T...>> {\n public:\n  static void Print(const Variant<T...>& value, ::std::ostream* os) {\n    *os << '(';\n#if GTEST_HAS_ABSL\n    absl::visit(Visitor{os, value.index()}, value);\n#else\n    std::visit(Visitor{os, value.index()}, value);\n#endif  // GTEST_HAS_ABSL\n    *os << ')';\n  }\n\n private:\n  struct Visitor {\n    template <typename U>\n    void operator()(const U& u) const {\n      *os << \"'\" << GetTypeName<U>() << \"(index = \" << index\n          << \")' with value \";\n      UniversalPrint(u, os);\n    }\n    ::std::ostream* os;\n    std::size_t index;\n  };\n};\n\n#endif  // GTEST_INTERNAL_HAS_VARIANT\n\n// UniversalPrintArray(begin, len, os) prints an array of 'len'\n// elements, starting at address 'begin'.\ntemplate <typename T>\nvoid UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {\n  if (len == 0) {\n    *os << \"{}\";\n  } else {\n    *os << \"{ \";\n    const size_t kThreshold = 18;\n    const size_t kChunkSize = 8;\n    // If the array has more than kThreshold elements, we'll have to\n    // omit some details by printing only the first and the last\n    // kChunkSize elements.\n    if (len <= kThreshold) {\n      PrintRawArrayTo(begin, len, os);\n    } else {\n      PrintRawArrayTo(begin, kChunkSize, os);\n      *os << \", ..., \";\n      PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);\n    }\n    *os << \" }\";\n  }\n}\n// This overload prints a (const) char array compactly.\nGTEST_API_ void UniversalPrintArray(\n    const char* begin, size_t len, ::std::ostream* os);\n\n#ifdef __cpp_char8_t\n// This overload prints a (const) char8_t array compactly.\nGTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,\n                                    ::std::ostream* os);\n#endif\n\n// This overload prints a (const) char16_t array compactly.\nGTEST_API_ void UniversalPrintArray(const char16_t* begin, size_t len,\n                                    ::std::ostream* os);\n\n// This overload prints a (const) char32_t array compactly.\nGTEST_API_ void UniversalPrintArray(const char32_t* begin, size_t len,\n                                    ::std::ostream* os);\n\n// This overload prints a (const) wchar_t array compactly.\nGTEST_API_ void UniversalPrintArray(\n    const wchar_t* begin, size_t len, ::std::ostream* os);\n\n// Implements printing an array type T[N].\ntemplate <typename T, size_t N>\nclass UniversalPrinter<T[N]> {\n public:\n  // Prints the given array, omitting some elements when there are too\n  // many.\n  static void Print(const T (&a)[N], ::std::ostream* os) {\n    UniversalPrintArray(a, N, os);\n  }\n};\n\n// Implements printing a reference type T&.\ntemplate <typename T>\nclass UniversalPrinter<T&> {\n public:\n  // MSVC warns about adding const to a function type, so we want to\n  // disable the warning.\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4180)\n\n  static void Print(const T& value, ::std::ostream* os) {\n    // Prints the address of the value.  We use reinterpret_cast here\n    // as static_cast doesn't compile when T is a function type.\n    *os << \"@\" << reinterpret_cast<const void*>(&value) << \" \";\n\n    // Then prints the value itself.\n    UniversalPrint(value, os);\n  }\n\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n};\n\n// Prints a value tersely: for a reference type, the referenced value\n// (but not the address) is printed; for a (const) char pointer, the\n// NUL-terminated string (but not the pointer) is printed.\n\ntemplate <typename T>\nclass UniversalTersePrinter {\n public:\n  static void Print(const T& value, ::std::ostream* os) {\n    UniversalPrint(value, os);\n  }\n};\ntemplate <typename T>\nclass UniversalTersePrinter<T&> {\n public:\n  static void Print(const T& value, ::std::ostream* os) {\n    UniversalPrint(value, os);\n  }\n};\ntemplate <typename T, size_t N>\nclass UniversalTersePrinter<T[N]> {\n public:\n  static void Print(const T (&value)[N], ::std::ostream* os) {\n    UniversalPrinter<T[N]>::Print(value, os);\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<const char*> {\n public:\n  static void Print(const char* str, ::std::ostream* os) {\n    if (str == nullptr) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(std::string(str), os);\n    }\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<char*> : public UniversalTersePrinter<const char*> {\n};\n\n#ifdef __cpp_char8_t\ntemplate <>\nclass UniversalTersePrinter<const char8_t*> {\n public:\n  static void Print(const char8_t* str, ::std::ostream* os) {\n    if (str == nullptr) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(::std::u8string(str), os);\n    }\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<char8_t*>\n    : public UniversalTersePrinter<const char8_t*> {};\n#endif\n\ntemplate <>\nclass UniversalTersePrinter<const char16_t*> {\n public:\n  static void Print(const char16_t* str, ::std::ostream* os) {\n    if (str == nullptr) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(::std::u16string(str), os);\n    }\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<char16_t*>\n    : public UniversalTersePrinter<const char16_t*> {};\n\ntemplate <>\nclass UniversalTersePrinter<const char32_t*> {\n public:\n  static void Print(const char32_t* str, ::std::ostream* os) {\n    if (str == nullptr) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(::std::u32string(str), os);\n    }\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<char32_t*>\n    : public UniversalTersePrinter<const char32_t*> {};\n\n#if GTEST_HAS_STD_WSTRING\ntemplate <>\nclass UniversalTersePrinter<const wchar_t*> {\n public:\n  static void Print(const wchar_t* str, ::std::ostream* os) {\n    if (str == nullptr) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(::std::wstring(str), os);\n    }\n  }\n};\n#endif\n\ntemplate <>\nclass UniversalTersePrinter<wchar_t*> {\n public:\n  static void Print(wchar_t* str, ::std::ostream* os) {\n    UniversalTersePrinter<const wchar_t*>::Print(str, os);\n  }\n};\n\ntemplate <typename T>\nvoid UniversalTersePrint(const T& value, ::std::ostream* os) {\n  UniversalTersePrinter<T>::Print(value, os);\n}\n\n// Prints a value using the type inferred by the compiler.  The\n// difference between this and UniversalTersePrint() is that for a\n// (const) char pointer, this prints both the pointer and the\n// NUL-terminated string.\ntemplate <typename T>\nvoid UniversalPrint(const T& value, ::std::ostream* os) {\n  // A workarond for the bug in VC++ 7.1 that prevents us from instantiating\n  // UniversalPrinter with T directly.\n  typedef T T1;\n  UniversalPrinter<T1>::Print(value, os);\n}\n\ntypedef ::std::vector< ::std::string> Strings;\n\n  // Tersely prints the first N fields of a tuple to a string vector,\n  // one element for each field.\ntemplate <typename Tuple>\nvoid TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,\n                               Strings*) {}\ntemplate <typename Tuple, size_t I>\nvoid TersePrintPrefixToStrings(const Tuple& t,\n                               std::integral_constant<size_t, I>,\n                               Strings* strings) {\n  TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),\n                            strings);\n  ::std::stringstream ss;\n  UniversalTersePrint(std::get<I - 1>(t), &ss);\n  strings->push_back(ss.str());\n}\n\n// Prints the fields of a tuple tersely to a string vector, one\n// element for each field.  See the comment before\n// UniversalTersePrint() for how we define \"tersely\".\ntemplate <typename Tuple>\nStrings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {\n  Strings result;\n  TersePrintPrefixToStrings(\n      value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),\n      &result);\n  return result;\n}\n\n}  // namespace internal\n\ntemplate <typename T>\n::std::string PrintToString(const T& value) {\n  ::std::stringstream ss;\n  internal::UniversalTersePrinter<T>::Print(value, &ss);\n  return ss.str();\n}\n\n}  // namespace testing\n\n// Include any custom printer added by the local installation.\n// We must include this header at the end to make sure it can use the\n// declarations from this file.\n// Copyright 2015, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// This file provides an injection point for custom printers in a local\n// installation of gTest.\n// It will be included from gtest-printers.h and the overrides in this file\n// will be visible to everyone.\n//\n// Injection point for custom user configurations. See README for details\n//\n// ** Custom implementation starts here **\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n\n// MSVC warning C5046 is new as of VS2017 version 15.8.\n#if defined(_MSC_VER) && _MSC_VER >= 1915\n#define GTEST_MAYBE_5046_ 5046\n#else\n#define GTEST_MAYBE_5046_\n#endif\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(\n    4251 GTEST_MAYBE_5046_ /* class A needs to have dll-interface to be used by\n                              clients of class B */\n    /* Symbol involving type with internal linkage not defined */)\n\nnamespace testing {\n\n// To implement a matcher Foo for type T, define:\n//   1. a class FooMatcherMatcher that implements the matcher interface:\n//     using is_gtest_matcher = void;\n//     bool MatchAndExplain(const T&, std::ostream*);\n//       (MatchResultListener* can also be used instead of std::ostream*)\n//     void DescribeTo(std::ostream*);\n//     void DescribeNegationTo(std::ostream*);\n//\n//   2. a factory function that creates a Matcher<T> object from a\n//      FooMatcherMatcher.\n\nclass MatchResultListener {\n public:\n  // Creates a listener object with the given underlying ostream.  The\n  // listener does not own the ostream, and does not dereference it\n  // in the constructor or destructor.\n  explicit MatchResultListener(::std::ostream* os) : stream_(os) {}\n  virtual ~MatchResultListener() = 0;  // Makes this class abstract.\n\n  // Streams x to the underlying ostream; does nothing if the ostream\n  // is NULL.\n  template <typename T>\n  MatchResultListener& operator<<(const T& x) {\n    if (stream_ != nullptr) *stream_ << x;\n    return *this;\n  }\n\n  // Returns the underlying ostream.\n  ::std::ostream* stream() { return stream_; }\n\n  // Returns true if and only if the listener is interested in an explanation\n  // of the match result.  A matcher's MatchAndExplain() method can use\n  // this information to avoid generating the explanation when no one\n  // intends to hear it.\n  bool IsInterested() const { return stream_ != nullptr; }\n\n private:\n  ::std::ostream* const stream_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);\n};\n\ninline MatchResultListener::~MatchResultListener() {\n}\n\n// An instance of a subclass of this knows how to describe itself as a\n// matcher.\nclass MatcherDescriberInterface {\n public:\n  virtual ~MatcherDescriberInterface() {}\n\n  // Describes this matcher to an ostream.  The function should print\n  // a verb phrase that describes the property a value matching this\n  // matcher should have.  The subject of the verb phrase is the value\n  // being matched.  For example, the DescribeTo() method of the Gt(7)\n  // matcher prints \"is greater than 7\".\n  virtual void DescribeTo(::std::ostream* os) const = 0;\n\n  // Describes the negation of this matcher to an ostream.  For\n  // example, if the description of this matcher is \"is greater than\n  // 7\", the negated description could be \"is not greater than 7\".\n  // You are not required to override this when implementing\n  // MatcherInterface, but it is highly advised so that your matcher\n  // can produce good error messages.\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"not (\";\n    DescribeTo(os);\n    *os << \")\";\n  }\n};\n\n// The implementation of a matcher.\ntemplate <typename T>\nclass MatcherInterface : public MatcherDescriberInterface {\n public:\n  // Returns true if and only if the matcher matches x; also explains the\n  // match result to 'listener' if necessary (see the next paragraph), in\n  // the form of a non-restrictive relative clause (\"which ...\",\n  // \"whose ...\", etc) that describes x.  For example, the\n  // MatchAndExplain() method of the Pointee(...) matcher should\n  // generate an explanation like \"which points to ...\".\n  //\n  // Implementations of MatchAndExplain() should add an explanation of\n  // the match result *if and only if* they can provide additional\n  // information that's not already present (or not obvious) in the\n  // print-out of x and the matcher's description.  Whether the match\n  // succeeds is not a factor in deciding whether an explanation is\n  // needed, as sometimes the caller needs to print a failure message\n  // when the match succeeds (e.g. when the matcher is used inside\n  // Not()).\n  //\n  // For example, a \"has at least 10 elements\" matcher should explain\n  // what the actual element count is, regardless of the match result,\n  // as it is useful information to the reader; on the other hand, an\n  // \"is empty\" matcher probably only needs to explain what the actual\n  // size is when the match fails, as it's redundant to say that the\n  // size is 0 when the value is already known to be empty.\n  //\n  // You should override this method when defining a new matcher.\n  //\n  // It's the responsibility of the caller (Google Test) to guarantee\n  // that 'listener' is not NULL.  This helps to simplify a matcher's\n  // implementation when it doesn't care about the performance, as it\n  // can talk to 'listener' without checking its validity first.\n  // However, in order to implement dummy listeners efficiently,\n  // listener->stream() may be NULL.\n  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;\n\n  // Inherits these methods from MatcherDescriberInterface:\n  //   virtual void DescribeTo(::std::ostream* os) const = 0;\n  //   virtual void DescribeNegationTo(::std::ostream* os) const;\n};\n\nnamespace internal {\n\nstruct AnyEq {\n  template <typename A, typename B>\n  bool operator()(const A& a, const B& b) const { return a == b; }\n};\nstruct AnyNe {\n  template <typename A, typename B>\n  bool operator()(const A& a, const B& b) const { return a != b; }\n};\nstruct AnyLt {\n  template <typename A, typename B>\n  bool operator()(const A& a, const B& b) const { return a < b; }\n};\nstruct AnyGt {\n  template <typename A, typename B>\n  bool operator()(const A& a, const B& b) const { return a > b; }\n};\nstruct AnyLe {\n  template <typename A, typename B>\n  bool operator()(const A& a, const B& b) const { return a <= b; }\n};\nstruct AnyGe {\n  template <typename A, typename B>\n  bool operator()(const A& a, const B& b) const { return a >= b; }\n};\n\n// A match result listener that ignores the explanation.\nclass DummyMatchResultListener : public MatchResultListener {\n public:\n  DummyMatchResultListener() : MatchResultListener(nullptr) {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);\n};\n\n// A match result listener that forwards the explanation to a given\n// ostream.  The difference between this and MatchResultListener is\n// that the former is concrete.\nclass StreamMatchResultListener : public MatchResultListener {\n public:\n  explicit StreamMatchResultListener(::std::ostream* os)\n      : MatchResultListener(os) {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);\n};\n\nstruct SharedPayloadBase {\n  std::atomic<int> ref{1};\n  void Ref() { ref.fetch_add(1, std::memory_order_relaxed); }\n  bool Unref() { return ref.fetch_sub(1, std::memory_order_acq_rel) == 1; }\n};\n\ntemplate <typename T>\nstruct SharedPayload : SharedPayloadBase {\n  explicit SharedPayload(const T& v) : value(v) {}\n  explicit SharedPayload(T&& v) : value(std::move(v)) {}\n\n  static void Destroy(SharedPayloadBase* shared) {\n    delete static_cast<SharedPayload*>(shared);\n  }\n\n  T value;\n};\n\ntemplate <typename T>\nusing is_trivially_copy_constructible =\n#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5\n    std::has_trivial_copy_constructor<T>;\n#else\n    std::is_trivially_copy_constructible<T>;\n#endif\n\n// An internal class for implementing Matcher<T>, which will derive\n// from it.  We put functionalities common to all Matcher<T>\n// specializations here to avoid code duplication.\ntemplate <typename T>\nclass MatcherBase : private MatcherDescriberInterface {\n public:\n  // Returns true if and only if the matcher matches x; also explains the\n  // match result to 'listener'.\n  bool MatchAndExplain(const T& x, MatchResultListener* listener) const {\n    GTEST_CHECK_(vtable_ != nullptr);\n    return vtable_->match_and_explain(*this, x, listener);\n  }\n\n  // Returns true if and only if this matcher matches x.\n  bool Matches(const T& x) const {\n    DummyMatchResultListener dummy;\n    return MatchAndExplain(x, &dummy);\n  }\n\n  // Describes this matcher to an ostream.\n  void DescribeTo(::std::ostream* os) const final {\n    GTEST_CHECK_(vtable_ != nullptr);\n    vtable_->describe(*this, os, false);\n  }\n\n  // Describes the negation of this matcher to an ostream.\n  void DescribeNegationTo(::std::ostream* os) const final {\n    GTEST_CHECK_(vtable_ != nullptr);\n    vtable_->describe(*this, os, true);\n  }\n\n  // Explains why x matches, or doesn't match, the matcher.\n  void ExplainMatchResultTo(const T& x, ::std::ostream* os) const {\n    StreamMatchResultListener listener(os);\n    MatchAndExplain(x, &listener);\n  }\n\n  // Returns the describer for this matcher object; retains ownership\n  // of the describer, which is only guaranteed to be alive when\n  // this matcher object is alive.\n  const MatcherDescriberInterface* GetDescriber() const {\n    if (vtable_ == nullptr) return nullptr;\n    return vtable_->get_describer(*this);\n  }\n\n protected:\n  MatcherBase() : vtable_(nullptr), buffer_() {}\n\n  // Constructs a matcher from its implementation.\n  template <typename U>\n  explicit MatcherBase(const MatcherInterface<U>* impl)\n      : vtable_(nullptr), buffer_() {\n    Init(impl);\n  }\n\n  template <typename M, typename = typename std::remove_reference<\n                            M>::type::is_gtest_matcher>\n  MatcherBase(M&& m) : vtable_(nullptr), buffer_() {  // NOLINT\n    Init(std::forward<M>(m));\n  }\n\n  MatcherBase(const MatcherBase& other)\n      : vtable_(other.vtable_), buffer_(other.buffer_) {\n    if (IsShared()) buffer_.shared->Ref();\n  }\n\n  MatcherBase& operator=(const MatcherBase& other) {\n    if (this == &other) return *this;\n    Destroy();\n    vtable_ = other.vtable_;\n    buffer_ = other.buffer_;\n    if (IsShared()) buffer_.shared->Ref();\n    return *this;\n  }\n\n  MatcherBase(MatcherBase&& other)\n      : vtable_(other.vtable_), buffer_(other.buffer_) {\n    other.vtable_ = nullptr;\n  }\n\n  MatcherBase& operator=(MatcherBase&& other) {\n    if (this == &other) return *this;\n    Destroy();\n    vtable_ = other.vtable_;\n    buffer_ = other.buffer_;\n    other.vtable_ = nullptr;\n    return *this;\n  }\n\n  ~MatcherBase() override { Destroy(); }\n\n private:\n  struct VTable {\n    bool (*match_and_explain)(const MatcherBase&, const T&,\n                              MatchResultListener*);\n    void (*describe)(const MatcherBase&, std::ostream*, bool negation);\n    // Returns the captured object if it implements the interface, otherwise\n    // returns the MatcherBase itself.\n    const MatcherDescriberInterface* (*get_describer)(const MatcherBase&);\n    // Called on shared instances when the reference count reaches 0.\n    void (*shared_destroy)(SharedPayloadBase*);\n  };\n\n  bool IsShared() const {\n    return vtable_ != nullptr && vtable_->shared_destroy != nullptr;\n  }\n\n  // If the implementation uses a listener, call that.\n  template <typename P>\n  static auto MatchAndExplainImpl(const MatcherBase& m, const T& value,\n                                  MatchResultListener* listener)\n      -> decltype(P::Get(m).MatchAndExplain(value, listener->stream())) {\n    return P::Get(m).MatchAndExplain(value, listener->stream());\n  }\n\n  template <typename P>\n  static auto MatchAndExplainImpl(const MatcherBase& m, const T& value,\n                                  MatchResultListener* listener)\n      -> decltype(P::Get(m).MatchAndExplain(value, listener)) {\n    return P::Get(m).MatchAndExplain(value, listener);\n  }\n\n  template <typename P>\n  static void DescribeImpl(const MatcherBase& m, std::ostream* os,\n                           bool negation) {\n    if (negation) {\n      P::Get(m).DescribeNegationTo(os);\n    } else {\n      P::Get(m).DescribeTo(os);\n    }\n  }\n\n  template <typename P>\n  static const MatcherDescriberInterface* GetDescriberImpl(\n      const MatcherBase& m) {\n    // If the impl is a MatcherDescriberInterface, then return it.\n    // Otherwise use MatcherBase itself.\n    // This allows us to implement the GetDescriber() function without support\n    // from the impl, but some users really want to get their impl back when\n    // they call GetDescriber().\n    // We use std::get on a tuple as a workaround of not having `if constexpr`.\n    return std::get<(\n        std::is_convertible<decltype(&P::Get(m)),\n                            const MatcherDescriberInterface*>::value\n            ? 1\n            : 0)>(std::make_tuple(&m, &P::Get(m)));\n  }\n\n  template <typename P>\n  const VTable* GetVTable() {\n    static constexpr VTable kVTable = {&MatchAndExplainImpl<P>,\n                                       &DescribeImpl<P>, &GetDescriberImpl<P>,\n                                       P::shared_destroy};\n    return &kVTable;\n  }\n\n  union Buffer {\n    // Add some types to give Buffer some common alignment/size use cases.\n    void* ptr;\n    double d;\n    int64_t i;\n    // And add one for the out-of-line cases.\n    SharedPayloadBase* shared;\n  };\n\n  void Destroy() {\n    if (IsShared() && buffer_.shared->Unref()) {\n      vtable_->shared_destroy(buffer_.shared);\n    }\n  }\n\n  template <typename M>\n  static constexpr bool IsInlined() {\n    return sizeof(M) <= sizeof(Buffer) && alignof(M) <= alignof(Buffer) &&\n           is_trivially_copy_constructible<M>::value &&\n           std::is_trivially_destructible<M>::value;\n  }\n\n  template <typename M, bool = MatcherBase::IsInlined<M>()>\n  struct ValuePolicy {\n    static const M& Get(const MatcherBase& m) {\n      // When inlined along with Init, need to be explicit to avoid violating\n      // strict aliasing rules.\n      const M *ptr = static_cast<const M*>(\n          static_cast<const void*>(&m.buffer_));\n      return *ptr;\n    }\n    static void Init(MatcherBase& m, M impl) {\n      ::new (static_cast<void*>(&m.buffer_)) M(impl);\n    }\n    static constexpr auto shared_destroy = nullptr;\n  };\n\n  template <typename M>\n  struct ValuePolicy<M, false> {\n    using Shared = SharedPayload<M>;\n    static const M& Get(const MatcherBase& m) {\n      return static_cast<Shared*>(m.buffer_.shared)->value;\n    }\n    template <typename Arg>\n    static void Init(MatcherBase& m, Arg&& arg) {\n      m.buffer_.shared = new Shared(std::forward<Arg>(arg));\n    }\n    static constexpr auto shared_destroy = &Shared::Destroy;\n  };\n\n  template <typename U, bool B>\n  struct ValuePolicy<const MatcherInterface<U>*, B> {\n    using M = const MatcherInterface<U>;\n    using Shared = SharedPayload<std::unique_ptr<M>>;\n    static const M& Get(const MatcherBase& m) {\n      return *static_cast<Shared*>(m.buffer_.shared)->value;\n    }\n    static void Init(MatcherBase& m, M* impl) {\n      m.buffer_.shared = new Shared(std::unique_ptr<M>(impl));\n    }\n\n    static constexpr auto shared_destroy = &Shared::Destroy;\n  };\n\n  template <typename M>\n  void Init(M&& m) {\n    using MM = typename std::decay<M>::type;\n    using Policy = ValuePolicy<MM>;\n    vtable_ = GetVTable<Policy>();\n    Policy::Init(*this, std::forward<M>(m));\n  }\n\n  const VTable* vtable_;\n  Buffer buffer_;\n};\n\n}  // namespace internal\n\n// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)\n// object that can check whether a value of type T matches.  The\n// implementation of Matcher<T> is just a std::shared_ptr to const\n// MatcherInterface<T>.  Don't inherit from Matcher!\ntemplate <typename T>\nclass Matcher : public internal::MatcherBase<T> {\n public:\n  // Constructs a null matcher.  Needed for storing Matcher objects in STL\n  // containers.  A default-constructed matcher is not yet initialized.  You\n  // cannot use it until a valid value has been assigned to it.\n  explicit Matcher() {}  // NOLINT\n\n  // Constructs a matcher from its implementation.\n  explicit Matcher(const MatcherInterface<const T&>* impl)\n      : internal::MatcherBase<T>(impl) {}\n\n  template <typename U>\n  explicit Matcher(\n      const MatcherInterface<U>* impl,\n      typename std::enable_if<!std::is_same<U, const U&>::value>::type* =\n          nullptr)\n      : internal::MatcherBase<T>(impl) {}\n\n  template <typename M, typename = typename std::remove_reference<\n                            M>::type::is_gtest_matcher>\n  Matcher(M&& m) : internal::MatcherBase<T>(std::forward<M>(m)) {}  // NOLINT\n\n  // Implicit constructor here allows people to write\n  // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes\n  Matcher(T value);  // NOLINT\n};\n\n// The following two specializations allow the user to write str\n// instead of Eq(str) and \"foo\" instead of Eq(\"foo\") when a std::string\n// matcher is expected.\ntemplate <>\nclass GTEST_API_ Matcher<const std::string&>\n    : public internal::MatcherBase<const std::string&> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<const std::string&>* impl)\n      : internal::MatcherBase<const std::string&>(impl) {}\n\n  template <typename M, typename = typename std::remove_reference<\n                            M>::type::is_gtest_matcher>\n  Matcher(M&& m)  // NOLINT\n      : internal::MatcherBase<const std::string&>(std::forward<M>(m)) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a std::string object.\n  Matcher(const std::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n};\n\ntemplate <>\nclass GTEST_API_ Matcher<std::string>\n    : public internal::MatcherBase<std::string> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<const std::string&>* impl)\n      : internal::MatcherBase<std::string>(impl) {}\n  explicit Matcher(const MatcherInterface<std::string>* impl)\n      : internal::MatcherBase<std::string>(impl) {}\n\n  template <typename M, typename = typename std::remove_reference<\n                            M>::type::is_gtest_matcher>\n  Matcher(M&& m)  // NOLINT\n      : internal::MatcherBase<std::string>(std::forward<M>(m)) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a string object.\n  Matcher(const std::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n};\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n// The following two specializations allow the user to write str\n// instead of Eq(str) and \"foo\" instead of Eq(\"foo\") when a absl::string_view\n// matcher is expected.\ntemplate <>\nclass GTEST_API_ Matcher<const internal::StringView&>\n    : public internal::MatcherBase<const internal::StringView&> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)\n      : internal::MatcherBase<const internal::StringView&>(impl) {}\n\n  template <typename M, typename = typename std::remove_reference<\n                            M>::type::is_gtest_matcher>\n  Matcher(M&& m)  // NOLINT\n      : internal::MatcherBase<const internal::StringView&>(std::forward<M>(m)) {\n  }\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a std::string object.\n  Matcher(const std::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n\n  // Allows the user to pass absl::string_views or std::string_views directly.\n  Matcher(internal::StringView s);  // NOLINT\n};\n\ntemplate <>\nclass GTEST_API_ Matcher<internal::StringView>\n    : public internal::MatcherBase<internal::StringView> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)\n      : internal::MatcherBase<internal::StringView>(impl) {}\n  explicit Matcher(const MatcherInterface<internal::StringView>* impl)\n      : internal::MatcherBase<internal::StringView>(impl) {}\n\n  template <typename M, typename = typename std::remove_reference<\n                            M>::type::is_gtest_matcher>\n  Matcher(M&& m)  // NOLINT\n      : internal::MatcherBase<internal::StringView>(std::forward<M>(m)) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a std::string object.\n  Matcher(const std::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n\n  // Allows the user to pass absl::string_views or std::string_views directly.\n  Matcher(internal::StringView s);  // NOLINT\n};\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n// Prints a matcher in a human-readable format.\ntemplate <typename T>\nstd::ostream& operator<<(std::ostream& os, const Matcher<T>& matcher) {\n  matcher.DescribeTo(&os);\n  return os;\n}\n\n// The PolymorphicMatcher class template makes it easy to implement a\n// polymorphic matcher (i.e. a matcher that can match values of more\n// than one type, e.g. Eq(n) and NotNull()).\n//\n// To define a polymorphic matcher, a user should provide an Impl\n// class that has a DescribeTo() method and a DescribeNegationTo()\n// method, and define a member function (or member function template)\n//\n//   bool MatchAndExplain(const Value& value,\n//                        MatchResultListener* listener) const;\n//\n// See the definition of NotNull() for a complete example.\ntemplate <class Impl>\nclass PolymorphicMatcher {\n public:\n  explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}\n\n  // Returns a mutable reference to the underlying matcher\n  // implementation object.\n  Impl& mutable_impl() { return impl_; }\n\n  // Returns an immutable reference to the underlying matcher\n  // implementation object.\n  const Impl& impl() const { return impl_; }\n\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new MonomorphicImpl<const T&>(impl_));\n  }\n\n private:\n  template <typename T>\n  class MonomorphicImpl : public MatcherInterface<T> {\n   public:\n    explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}\n\n    void DescribeTo(::std::ostream* os) const override { impl_.DescribeTo(os); }\n\n    void DescribeNegationTo(::std::ostream* os) const override {\n      impl_.DescribeNegationTo(os);\n    }\n\n    bool MatchAndExplain(T x, MatchResultListener* listener) const override {\n      return impl_.MatchAndExplain(x, listener);\n    }\n\n   private:\n    const Impl impl_;\n  };\n\n  Impl impl_;\n};\n\n// Creates a matcher from its implementation.\n// DEPRECATED: Especially in the generic code, prefer:\n//   Matcher<T>(new MyMatcherImpl<const T&>(...));\n//\n// MakeMatcher may create a Matcher that accepts its argument by value, which\n// leads to unnecessary copies & lack of support for non-copyable types.\ntemplate <typename T>\ninline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {\n  return Matcher<T>(impl);\n}\n\n// Creates a polymorphic matcher from its implementation.  This is\n// easier to use than the PolymorphicMatcher<Impl> constructor as it\n// doesn't require you to explicitly write the template argument, e.g.\n//\n//   MakePolymorphicMatcher(foo);\n// vs\n//   PolymorphicMatcher<TypeOfFoo>(foo);\ntemplate <class Impl>\ninline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {\n  return PolymorphicMatcher<Impl>(impl);\n}\n\nnamespace internal {\n// Implements a matcher that compares a given value with a\n// pre-supplied value using one of the ==, <=, <, etc, operators.  The\n// two values being compared don't have to have the same type.\n//\n// The matcher defined here is polymorphic (for example, Eq(5) can be\n// used to match an int, a short, a double, etc).  Therefore we use\n// a template type conversion operator in the implementation.\n//\n// The following template definition assumes that the Rhs parameter is\n// a \"bare\" type (i.e. neither 'const T' nor 'T&').\ntemplate <typename D, typename Rhs, typename Op>\nclass ComparisonBase {\n public:\n  explicit ComparisonBase(const Rhs& rhs) : rhs_(rhs) {}\n\n  using is_gtest_matcher = void;\n\n  template <typename Lhs>\n  bool MatchAndExplain(const Lhs& lhs, std::ostream*) const {\n    return Op()(lhs, Unwrap(rhs_));\n  }\n  void DescribeTo(std::ostream* os) const {\n    *os << D::Desc() << \" \";\n    UniversalPrint(Unwrap(rhs_), os);\n  }\n  void DescribeNegationTo(std::ostream* os) const {\n    *os << D::NegatedDesc() << \" \";\n    UniversalPrint(Unwrap(rhs_), os);\n  }\n\n private:\n  template <typename T>\n  static const T& Unwrap(const T& v) {\n    return v;\n  }\n  template <typename T>\n  static const T& Unwrap(std::reference_wrapper<T> v) {\n    return v;\n  }\n\n  Rhs rhs_;\n};\n\ntemplate <typename Rhs>\nclass EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {\n public:\n  explicit EqMatcher(const Rhs& rhs)\n      : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) { }\n  static const char* Desc() { return \"is equal to\"; }\n  static const char* NegatedDesc() { return \"isn't equal to\"; }\n};\ntemplate <typename Rhs>\nclass NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {\n public:\n  explicit NeMatcher(const Rhs& rhs)\n      : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) { }\n  static const char* Desc() { return \"isn't equal to\"; }\n  static const char* NegatedDesc() { return \"is equal to\"; }\n};\ntemplate <typename Rhs>\nclass LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {\n public:\n  explicit LtMatcher(const Rhs& rhs)\n      : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) { }\n  static const char* Desc() { return \"is <\"; }\n  static const char* NegatedDesc() { return \"isn't <\"; }\n};\ntemplate <typename Rhs>\nclass GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {\n public:\n  explicit GtMatcher(const Rhs& rhs)\n      : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) { }\n  static const char* Desc() { return \"is >\"; }\n  static const char* NegatedDesc() { return \"isn't >\"; }\n};\ntemplate <typename Rhs>\nclass LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {\n public:\n  explicit LeMatcher(const Rhs& rhs)\n      : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) { }\n  static const char* Desc() { return \"is <=\"; }\n  static const char* NegatedDesc() { return \"isn't <=\"; }\n};\ntemplate <typename Rhs>\nclass GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {\n public:\n  explicit GeMatcher(const Rhs& rhs)\n      : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) { }\n  static const char* Desc() { return \"is >=\"; }\n  static const char* NegatedDesc() { return \"isn't >=\"; }\n};\n\ntemplate <typename T, typename = typename std::enable_if<\n                          std::is_constructible<std::string, T>::value>::type>\nusing StringLike = T;\n\n// Implements polymorphic matchers MatchesRegex(regex) and\n// ContainsRegex(regex), which can be used as a Matcher<T> as long as\n// T can be converted to a string.\nclass MatchesRegexMatcher {\n public:\n  MatchesRegexMatcher(const RE* regex, bool full_match)\n      : regex_(regex), full_match_(full_match) {}\n\n#if GTEST_INTERNAL_HAS_STRING_VIEW\n  bool MatchAndExplain(const internal::StringView& s,\n                       MatchResultListener* listener) const {\n    return MatchAndExplain(std::string(s), listener);\n  }\n#endif  // GTEST_INTERNAL_HAS_STRING_VIEW\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != nullptr && MatchAndExplain(std::string(s), listener);\n  }\n\n  // Matches anything that can convert to std::string.\n  //\n  // This is a template, not just a plain function with const std::string&,\n  // because absl::string_view has some interfering non-explicit constructors.\n  template <class MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const std::string& s2(s);\n    return full_match_ ? RE::FullMatch(s2, *regex_)\n                       : RE::PartialMatch(s2, *regex_);\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << (full_match_ ? \"matches\" : \"contains\") << \" regular expression \";\n    UniversalPrinter<std::string>::Print(regex_->pattern(), os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't \" << (full_match_ ? \"match\" : \"contain\")\n        << \" regular expression \";\n    UniversalPrinter<std::string>::Print(regex_->pattern(), os);\n  }\n\n private:\n  const std::shared_ptr<const RE> regex_;\n  const bool full_match_;\n};\n}  // namespace internal\n\n// Matches a string that fully matches regular expression 'regex'.\n// The matcher takes ownership of 'regex'.\ninline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(\n    const internal::RE* regex) {\n  return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));\n}\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(\n    const internal::StringLike<T>& regex) {\n  return MatchesRegex(new internal::RE(std::string(regex)));\n}\n\n// Matches a string that contains regular expression 'regex'.\n// The matcher takes ownership of 'regex'.\ninline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(\n    const internal::RE* regex) {\n  return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));\n}\ntemplate <typename T = std::string>\nPolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(\n    const internal::StringLike<T>& regex) {\n  return ContainsRegex(new internal::RE(std::string(regex)));\n}\n\n// Creates a polymorphic matcher that matches anything equal to x.\n// Note: if the parameter of Eq() were declared as const T&, Eq(\"foo\")\n// wouldn't compile.\ntemplate <typename T>\ninline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }\n\n// Constructs a Matcher<T> from a 'value' of type T.  The constructed\n// matcher matches any value that's equal to 'value'.\ntemplate <typename T>\nMatcher<T>::Matcher(T value) { *this = Eq(value); }\n\n// Creates a monomorphic matcher that matches anything with type Lhs\n// and equal to rhs.  A user may need to use this instead of Eq(...)\n// in order to resolve an overloading ambiguity.\n//\n// TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))\n// or Matcher<T>(x), but more readable than the latter.\n//\n// We could define similar monomorphic matchers for other comparison\n// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do\n// it yet as those are used much less than Eq() in practice.  A user\n// can always write Matcher<T>(Lt(5)) to be explicit about the type,\n// for example.\ntemplate <typename Lhs, typename Rhs>\ninline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }\n\n// Creates a polymorphic matcher that matches anything >= x.\ntemplate <typename Rhs>\ninline internal::GeMatcher<Rhs> Ge(Rhs x) {\n  return internal::GeMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything > x.\ntemplate <typename Rhs>\ninline internal::GtMatcher<Rhs> Gt(Rhs x) {\n  return internal::GtMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything <= x.\ntemplate <typename Rhs>\ninline internal::LeMatcher<Rhs> Le(Rhs x) {\n  return internal::LeMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything < x.\ntemplate <typename Rhs>\ninline internal::LtMatcher<Rhs> Lt(Rhs x) {\n  return internal::LtMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything != x.\ntemplate <typename Rhs>\ninline internal::NeMatcher<Rhs> Ne(Rhs x) {\n  return internal::NeMatcher<Rhs>(x);\n}\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251 5046\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_\n\n#include <stdio.h>\n#include <memory>\n\nnamespace testing {\nnamespace internal {\n\nGTEST_DECLARE_string_(internal_run_death_test);\n\n// Names of the flags (needed for parsing Google Test flags).\nconst char kDeathTestStyleFlag[] = \"death_test_style\";\nconst char kDeathTestUseFork[] = \"death_test_use_fork\";\nconst char kInternalRunDeathTestFlag[] = \"internal_run_death_test\";\n\n#if GTEST_HAS_DEATH_TEST\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\n// DeathTest is a class that hides much of the complexity of the\n// GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method\n// returns a concrete class that depends on the prevailing death test\n// style, as defined by the --gtest_death_test_style and/or\n// --gtest_internal_run_death_test flags.\n\n// In describing the results of death tests, these terms are used with\n// the corresponding definitions:\n//\n// exit status:  The integer exit information in the format specified\n//               by wait(2)\n// exit code:    The integer code passed to exit(3), _exit(2), or\n//               returned from main()\nclass GTEST_API_ DeathTest {\n public:\n  // Create returns false if there was an error determining the\n  // appropriate action to take for the current death test; for example,\n  // if the gtest_death_test_style flag is set to an invalid value.\n  // The LastMessage method will return a more detailed message in that\n  // case.  Otherwise, the DeathTest pointer pointed to by the \"test\"\n  // argument is set.  If the death test should be skipped, the pointer\n  // is set to NULL; otherwise, it is set to the address of a new concrete\n  // DeathTest object that controls the execution of the current test.\n  static bool Create(const char* statement, Matcher<const std::string&> matcher,\n                     const char* file, int line, DeathTest** test);\n  DeathTest();\n  virtual ~DeathTest() { }\n\n  // A helper class that aborts a death test when it's deleted.\n  class ReturnSentinel {\n   public:\n    explicit ReturnSentinel(DeathTest* test) : test_(test) { }\n    ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }\n   private:\n    DeathTest* const test_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);\n  } GTEST_ATTRIBUTE_UNUSED_;\n\n  // An enumeration of possible roles that may be taken when a death\n  // test is encountered.  EXECUTE means that the death test logic should\n  // be executed immediately.  OVERSEE means that the program should prepare\n  // the appropriate environment for a child process to execute the death\n  // test, then wait for it to complete.\n  enum TestRole { OVERSEE_TEST, EXECUTE_TEST };\n\n  // An enumeration of the three reasons that a test might be aborted.\n  enum AbortReason {\n    TEST_ENCOUNTERED_RETURN_STATEMENT,\n    TEST_THREW_EXCEPTION,\n    TEST_DID_NOT_DIE\n  };\n\n  // Assumes one of the above roles.\n  virtual TestRole AssumeRole() = 0;\n\n  // Waits for the death test to finish and returns its status.\n  virtual int Wait() = 0;\n\n  // Returns true if the death test passed; that is, the test process\n  // exited during the test, its exit status matches a user-supplied\n  // predicate, and its stderr output matches a user-supplied regular\n  // expression.\n  // The user-supplied predicate may be a macro expression rather\n  // than a function pointer or functor, or else Wait and Passed could\n  // be combined.\n  virtual bool Passed(bool exit_status_ok) = 0;\n\n  // Signals that the death test did not die as expected.\n  virtual void Abort(AbortReason reason) = 0;\n\n  // Returns a human-readable outcome message regarding the outcome of\n  // the last death test.\n  static const char* LastMessage();\n\n  static void set_last_death_test_message(const std::string& message);\n\n private:\n  // A string containing a description of the outcome of the last death test.\n  static std::string last_death_test_message_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);\n};\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n// Factory interface for death tests.  May be mocked out for testing.\nclass DeathTestFactory {\n public:\n  virtual ~DeathTestFactory() { }\n  virtual bool Create(const char* statement,\n                      Matcher<const std::string&> matcher, const char* file,\n                      int line, DeathTest** test) = 0;\n};\n\n// A concrete DeathTestFactory implementation for normal use.\nclass DefaultDeathTestFactory : public DeathTestFactory {\n public:\n  bool Create(const char* statement, Matcher<const std::string&> matcher,\n              const char* file, int line, DeathTest** test) override;\n};\n\n// Returns true if exit_status describes a process that was terminated\n// by a signal, or exited normally with a nonzero exit code.\nGTEST_API_ bool ExitedUnsuccessfully(int exit_status);\n\n// A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads\n// and interpreted as a regex (rather than an Eq matcher) for legacy\n// compatibility.\ninline Matcher<const ::std::string&> MakeDeathTestMatcher(\n    ::testing::internal::RE regex) {\n  return ContainsRegex(regex.pattern());\n}\ninline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {\n  return ContainsRegex(regex);\n}\ninline Matcher<const ::std::string&> MakeDeathTestMatcher(\n    const ::std::string& regex) {\n  return ContainsRegex(regex);\n}\n\n// If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's\n// used directly.\ninline Matcher<const ::std::string&> MakeDeathTestMatcher(\n    Matcher<const ::std::string&> matcher) {\n  return matcher;\n}\n\n// Traps C++ exceptions escaping statement and reports them as test\n// failures. Note that trapping SEH exceptions is not implemented here.\n# if GTEST_HAS_EXCEPTIONS\n#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n  try { \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n  } catch (const ::std::exception& gtest_exception) { \\\n    fprintf(\\\n        stderr, \\\n        \"\\n%s: Caught std::exception-derived exception escaping the \" \\\n        \"death test statement. Exception message: %s\\n\", \\\n        ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \\\n        gtest_exception.what()); \\\n    fflush(stderr); \\\n    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \\\n  } catch (...) { \\\n    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \\\n  }\n\n# else\n#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n  GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n\n# endif\n\n// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,\n// ASSERT_EXIT*, and EXPECT_EXIT*.\n#define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail)        \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \\\n  if (::testing::internal::AlwaysTrue()) {                                     \\\n    ::testing::internal::DeathTest* gtest_dt;                                  \\\n    if (!::testing::internal::DeathTest::Create(                               \\\n            #statement,                                                        \\\n            ::testing::internal::MakeDeathTestMatcher(regex_or_matcher),       \\\n            __FILE__, __LINE__, &gtest_dt)) {                                  \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__);                        \\\n    }                                                                          \\\n    if (gtest_dt != nullptr) {                                                 \\\n      std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \\\n      switch (gtest_dt->AssumeRole()) {                                        \\\n        case ::testing::internal::DeathTest::OVERSEE_TEST:                     \\\n          if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) {                \\\n            goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__);                  \\\n          }                                                                    \\\n          break;                                                               \\\n        case ::testing::internal::DeathTest::EXECUTE_TEST: {                   \\\n          ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel(       \\\n              gtest_dt);                                                       \\\n          GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt);            \\\n          gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE);   \\\n          break;                                                               \\\n        }                                                                      \\\n        default:                                                               \\\n          break;                                                               \\\n      }                                                                        \\\n    }                                                                          \\\n  } else                                                                       \\\n    GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__)                                \\\n        : fail(::testing::internal::DeathTest::LastMessage())\n// The symbol \"fail\" here expands to something into which a message\n// can be streamed.\n\n// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in\n// NDEBUG mode. In this case we need the statements to be executed and the macro\n// must accept a streamed message even though the message is never printed.\n// The regex object is not evaluated, but it is used to prevent \"unused\"\n// warnings and to avoid an expression that doesn't compile in debug mode.\n#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher)    \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                  \\\n  if (::testing::internal::AlwaysTrue()) {                       \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);   \\\n  } else if (!::testing::internal::AlwaysTrue()) {               \\\n    ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \\\n  } else                                                         \\\n    ::testing::Message()\n\n// A class representing the parsed contents of the\n// --gtest_internal_run_death_test flag, as it existed when\n// RUN_ALL_TESTS was called.\nclass InternalRunDeathTestFlag {\n public:\n  InternalRunDeathTestFlag(const std::string& a_file,\n                           int a_line,\n                           int an_index,\n                           int a_write_fd)\n      : file_(a_file), line_(a_line), index_(an_index),\n        write_fd_(a_write_fd) {}\n\n  ~InternalRunDeathTestFlag() {\n    if (write_fd_ >= 0)\n      posix::Close(write_fd_);\n  }\n\n  const std::string& file() const { return file_; }\n  int line() const { return line_; }\n  int index() const { return index_; }\n  int write_fd() const { return write_fd_; }\n\n private:\n  std::string file_;\n  int line_;\n  int index_;\n  int write_fd_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);\n};\n\n// Returns a newly created InternalRunDeathTestFlag object with fields\n// initialized from the GTEST_FLAG(internal_run_death_test) flag if\n// the flag is specified; otherwise returns NULL.\nInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n\nnamespace testing {\n\n// This flag controls the style of death tests.  Valid values are \"threadsafe\",\n// meaning that the death test child process will re-execute the test binary\n// from the start, running only a single death test, or \"fast\",\n// meaning that the child process will execute the test logic immediately\n// after forking.\nGTEST_DECLARE_string_(death_test_style);\n\n#if GTEST_HAS_DEATH_TEST\n\nnamespace internal {\n\n// Returns a Boolean value indicating whether the caller is currently\n// executing in the context of the death test child process.  Tools such as\n// Valgrind heap checkers may need this to modify their behavior in death\n// tests.  IMPORTANT: This is an internal utility.  Using it may break the\n// implementation of death tests.  User code MUST NOT use it.\nGTEST_API_ bool InDeathTestChild();\n\n}  // namespace internal\n\n// The following macros are useful for writing death tests.\n\n// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is\n// executed:\n//\n//   1. It generates a warning if there is more than one active\n//   thread.  This is because it's safe to fork() or clone() only\n//   when there is a single thread.\n//\n//   2. The parent process clone()s a sub-process and runs the death\n//   test in it; the sub-process exits with code 0 at the end of the\n//   death test, if it hasn't exited already.\n//\n//   3. The parent process waits for the sub-process to terminate.\n//\n//   4. The parent process checks the exit code and error message of\n//   the sub-process.\n//\n// Examples:\n//\n//   ASSERT_DEATH(server.SendMessage(56, \"Hello\"), \"Invalid port number\");\n//   for (int i = 0; i < 5; i++) {\n//     EXPECT_DEATH(server.ProcessRequest(i),\n//                  \"Invalid request .* in ProcessRequest()\")\n//                  << \"Failed to die on request \" << i;\n//   }\n//\n//   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), \"Exiting\");\n//\n//   bool KilledBySIGHUP(int exit_code) {\n//     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;\n//   }\n//\n//   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, \"Hanging up!\");\n//\n// On the regular expressions used in death tests:\n//\n//   GOOGLETEST_CM0005 DO NOT DELETE\n//   On POSIX-compliant systems (*nix), we use the <regex.h> library,\n//   which uses the POSIX extended regex syntax.\n//\n//   On other platforms (e.g. Windows or Mac), we only support a simple regex\n//   syntax implemented as part of Google Test.  This limited\n//   implementation should be enough most of the time when writing\n//   death tests; though it lacks many features you can find in PCRE\n//   or POSIX extended regex syntax.  For example, we don't support\n//   union (\"x|y\"), grouping (\"(xy)\"), brackets (\"[xy]\"), and\n//   repetition count (\"x{5,7}\"), among others.\n//\n//   Below is the syntax that we do support.  We chose it to be a\n//   subset of both PCRE and POSIX extended regex, so it's easy to\n//   learn wherever you come from.  In the following: 'A' denotes a\n//   literal character, period (.), or a single \\\\ escape sequence;\n//   'x' and 'y' denote regular expressions; 'm' and 'n' are for\n//   natural numbers.\n//\n//     c     matches any literal character c\n//     \\\\d   matches any decimal digit\n//     \\\\D   matches any character that's not a decimal digit\n//     \\\\f   matches \\f\n//     \\\\n   matches \\n\n//     \\\\r   matches \\r\n//     \\\\s   matches any ASCII whitespace, including \\n\n//     \\\\S   matches any character that's not a whitespace\n//     \\\\t   matches \\t\n//     \\\\v   matches \\v\n//     \\\\w   matches any letter, _, or decimal digit\n//     \\\\W   matches any character that \\\\w doesn't match\n//     \\\\c   matches any literal character c, which must be a punctuation\n//     .     matches any single character except \\n\n//     A?    matches 0 or 1 occurrences of A\n//     A*    matches 0 or many occurrences of A\n//     A+    matches 1 or many occurrences of A\n//     ^     matches the beginning of a string (not that of each line)\n//     $     matches the end of a string (not that of each line)\n//     xy    matches x followed by y\n//\n//   If you accidentally use PCRE or POSIX extended regex features\n//   not implemented by us, you will get a run-time failure.  In that\n//   case, please try to rewrite your regular expression within the\n//   above syntax.\n//\n//   This implementation is *not* meant to be as highly tuned or robust\n//   as a compiled regex library, but should perform well enough for a\n//   death test, which already incurs significant overhead by launching\n//   a child process.\n//\n// Known caveats:\n//\n//   A \"threadsafe\" style death test obtains the path to the test\n//   program from argv[0] and re-executes it in the sub-process.  For\n//   simplicity, the current implementation doesn't search the PATH\n//   when launching the sub-process.  This means that the user must\n//   invoke the test program via a path that contains at least one\n//   path separator (e.g. path/to/foo_test and\n//   /absolute/path/to/bar_test are fine, but foo_test is not).  This\n//   is rarely a problem as people usually don't put the test binary\n//   directory in PATH.\n//\n\n// Asserts that a given statement causes the program to exit, with an\n// integer exit status that satisfies predicate, and emitting error output\n// that matches regex.\n# define ASSERT_EXIT(statement, predicate, regex) \\\n    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)\n\n// Like ASSERT_EXIT, but continues on to successive tests in the\n// test suite, if any:\n# define EXPECT_EXIT(statement, predicate, regex) \\\n    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)\n\n// Asserts that a given statement causes the program to exit, either by\n// explicitly exiting with a nonzero exit code or being killed by a\n// signal, and emitting error output that matches regex.\n# define ASSERT_DEATH(statement, regex) \\\n    ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)\n\n// Like ASSERT_DEATH, but continues on to successive tests in the\n// test suite, if any:\n# define EXPECT_DEATH(statement, regex) \\\n    EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)\n\n// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:\n\n// Tests that an exit code describes a normal exit with a given exit code.\nclass GTEST_API_ ExitedWithCode {\n public:\n  explicit ExitedWithCode(int exit_code);\n  ExitedWithCode(const ExitedWithCode&) = default;\n  void operator=(const ExitedWithCode& other) = delete;\n  bool operator()(int exit_status) const;\n private:\n  const int exit_code_;\n};\n\n# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA\n// Tests that an exit code describes an exit due to termination by a\n// given signal.\n// GOOGLETEST_CM0006 DO NOT DELETE\nclass GTEST_API_ KilledBySignal {\n public:\n  explicit KilledBySignal(int signum);\n  bool operator()(int exit_status) const;\n private:\n  const int signum_;\n};\n# endif  // !GTEST_OS_WINDOWS\n\n// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.\n// The death testing framework causes this to have interesting semantics,\n// since the sideeffects of the call are only visible in opt mode, and not\n// in debug mode.\n//\n// In practice, this can be used to test functions that utilize the\n// LOG(DFATAL) macro using the following style:\n//\n// int DieInDebugOr12(int* sideeffect) {\n//   if (sideeffect) {\n//     *sideeffect = 12;\n//   }\n//   LOG(DFATAL) << \"death\";\n//   return 12;\n// }\n//\n// TEST(TestSuite, TestDieOr12WorksInDgbAndOpt) {\n//   int sideeffect = 0;\n//   // Only asserts in dbg.\n//   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), \"death\");\n//\n// #ifdef NDEBUG\n//   // opt-mode has sideeffect visible.\n//   EXPECT_EQ(12, sideeffect);\n// #else\n//   // dbg-mode no visible sideeffect.\n//   EXPECT_EQ(0, sideeffect);\n// #endif\n// }\n//\n// This will assert that DieInDebugReturn12InOpt() crashes in debug\n// mode, usually due to a DCHECK or LOG(DFATAL), but returns the\n// appropriate fallback value (12 in this case) in opt mode. If you\n// need to test that a function has appropriate side-effects in opt\n// mode, include assertions against the side-effects.  A general\n// pattern for this is:\n//\n// EXPECT_DEBUG_DEATH({\n//   // Side-effects here will have an effect after this statement in\n//   // opt mode, but none in debug mode.\n//   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));\n// }, \"death\");\n//\n# ifdef NDEBUG\n\n#  define EXPECT_DEBUG_DEATH(statement, regex) \\\n  GTEST_EXECUTE_STATEMENT_(statement, regex)\n\n#  define ASSERT_DEBUG_DEATH(statement, regex) \\\n  GTEST_EXECUTE_STATEMENT_(statement, regex)\n\n# else\n\n#  define EXPECT_DEBUG_DEATH(statement, regex) \\\n  EXPECT_DEATH(statement, regex)\n\n#  define ASSERT_DEBUG_DEATH(statement, regex) \\\n  ASSERT_DEATH(statement, regex)\n\n# endif  // NDEBUG for EXPECT_DEBUG_DEATH\n#endif  // GTEST_HAS_DEATH_TEST\n\n// This macro is used for implementing macros such as\n// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where\n// death tests are not supported. Those macros must compile on such systems\n// if and only if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters\n// on systems that support death tests. This allows one to write such a macro on\n// a system that does not support death tests and be sure that it will compile\n// on a death-test supporting system. It is exposed publicly so that systems\n// that have death-tests with stricter requirements than GTEST_HAS_DEATH_TEST\n// can write their own equivalent of EXPECT_DEATH_IF_SUPPORTED and\n// ASSERT_DEATH_IF_SUPPORTED.\n//\n// Parameters:\n//   statement -  A statement that a macro such as EXPECT_DEATH would test\n//                for program termination. This macro has to make sure this\n//                statement is compiled but not executed, to ensure that\n//                EXPECT_DEATH_IF_SUPPORTED compiles with a certain\n//                parameter if and only if EXPECT_DEATH compiles with it.\n//   regex     -  A regex that a macro such as EXPECT_DEATH would use to test\n//                the output of statement.  This parameter has to be\n//                compiled but not evaluated by this macro, to ensure that\n//                this macro only accepts expressions that a macro such as\n//                EXPECT_DEATH would accept.\n//   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED\n//                and a return statement for ASSERT_DEATH_IF_SUPPORTED.\n//                This ensures that ASSERT_DEATH_IF_SUPPORTED will not\n//                compile inside functions where ASSERT_DEATH doesn't\n//                compile.\n//\n//  The branch that has an always false condition is used to ensure that\n//  statement and regex are compiled (and thus syntactically correct) but\n//  never executed. The unreachable code macro protects the terminator\n//  statement from generating an 'unreachable code' warning in case\n//  statement unconditionally returns or throws. The Message constructor at\n//  the end allows the syntax of streaming additional messages into the\n//  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.\n# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n    if (::testing::internal::AlwaysTrue()) { \\\n      GTEST_LOG_(WARNING) \\\n          << \"Death tests are not supported on this platform.\\n\" \\\n          << \"Statement '\" #statement \"' cannot be verified.\"; \\\n    } else if (::testing::internal::AlwaysFalse()) { \\\n      ::testing::internal::RE::PartialMatch(\".*\", (regex)); \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n      terminator; \\\n    } else \\\n      ::testing::Message()\n\n// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and\n// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if\n// death tests are supported; otherwise they just issue a warning.  This is\n// useful when you are combining death test assertions with normal test\n// assertions in one test.\n#if GTEST_HAS_DEATH_TEST\n# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \\\n    EXPECT_DEATH(statement, regex)\n# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \\\n    ASSERT_DEATH(statement, regex)\n#else\n# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \\\n    GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, )\n# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \\\n    GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return)\n#endif\n\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Macros and functions for implementing parameterized tests\n// in Google C++ Testing and Mocking Framework (Google Test)\n//\n// GOOGLETEST_CM0001 DO NOT DELETE\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n\n// Value-parameterized tests allow you to test your code with different\n// parameters without writing multiple copies of the same test.\n//\n// Here is how you use value-parameterized tests:\n\n#if 0\n\n// To write value-parameterized tests, first you should define a fixture\n// class. It is usually derived from testing::TestWithParam<T> (see below for\n// another inheritance scheme that's sometimes useful in more complicated\n// class hierarchies), where the type of your parameter values.\n// TestWithParam<T> is itself derived from testing::Test. T can be any\n// copyable type. If it's a raw pointer, you are responsible for managing the\n// lifespan of the pointed values.\n\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual class fixture members here.\n};\n\n// Then, use the TEST_P macro to define as many parameterized tests\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n// or \"pattern\", whichever you prefer to think.\n\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n\n// Finally, you can use INSTANTIATE_TEST_SUITE_P to instantiate the test\n// case with any set of parameters you want. Google Test defines a number\n// of functions for generating test parameters. They return what we call\n// (surprise!) parameter generators. Here is a summary of them, which\n// are all in the testing namespace:\n//\n//\n//  Range(begin, end [, step]) - Yields values {begin, begin+step,\n//                               begin+step+step, ...}. The values do not\n//                               include end. step defaults to 1.\n//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.\n//  ValuesIn(container)        - Yields values from a C-style array, an STL\n//  ValuesIn(begin,end)          container, or an iterator range [begin, end).\n//  Bool()                     - Yields sequence {false, true}.\n//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product\n//                               for the math savvy) of the values generated\n//                               by the N generators.\n//\n// For more details, see comments at the definitions of these functions below\n// in this file.\n//\n// The following statement will instantiate tests from the FooTest test suite\n// each with parameter values \"meeny\", \"miny\", and \"moe\".\n\nINSTANTIATE_TEST_SUITE_P(InstantiationName,\n                         FooTest,\n                         Values(\"meeny\", \"miny\", \"moe\"));\n\n// To distinguish different instances of the pattern, (yes, you\n// can instantiate it more than once) the first argument to the\n// INSTANTIATE_TEST_SUITE_P macro is a prefix that will be added to the\n// actual test suite name. Remember to pick unique prefixes for different\n// instantiations. The tests from the instantiation above will have\n// these names:\n//\n//    * InstantiationName/FooTest.DoesBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.DoesBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.DoesBlah/2 for \"moe\"\n//    * InstantiationName/FooTest.HasBlahBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.HasBlahBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.HasBlahBlah/2 for \"moe\"\n//\n// You can use these names in --gtest_filter.\n//\n// This statement will instantiate all tests from FooTest again, each\n// with parameter values \"cat\" and \"dog\":\n\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));\n\n// The tests from the instantiation above will have these names:\n//\n//    * AnotherInstantiationName/FooTest.DoesBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.DoesBlah/1 for \"dog\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for \"dog\"\n//\n// Please note that INSTANTIATE_TEST_SUITE_P will instantiate all tests\n// in the given test suite, whether their definitions come before or\n// AFTER the INSTANTIATE_TEST_SUITE_P statement.\n//\n// Please also note that generator expressions (including parameters to the\n// generators) are evaluated in InitGoogleTest(), after main() has started.\n// This allows the user on one hand, to adjust generator parameters in order\n// to dynamically determine a set of tests to run and on the other hand,\n// give the user a chance to inspect the generated tests with Google Test\n// reflection API before RUN_ALL_TESTS() is executed.\n//\n// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc\n// for more examples.\n//\n// In the future, we plan to publish the API for defining new parameter\n// generators. But for now this interface remains part of the internal\n// implementation and is subject to change.\n//\n//\n// A parameterized test fixture must be derived from testing::Test and from\n// testing::WithParamInterface<T>, where T is the type of the parameter\n// values. Inheriting from TestWithParam<T> satisfies that requirement because\n// TestWithParam<T> inherits from both Test and WithParamInterface. In more\n// complicated hierarchies, however, it is occasionally useful to inherit\n// separately from Test and WithParamInterface. For example:\n\nclass BaseTest : public ::testing::Test {\n  // You can inherit all the usual members for a non-parameterized test\n  // fixture here.\n};\n\nclass DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n  // The usual test fixture members go here too.\n};\n\nTEST_F(BaseTest, HasFoo) {\n  // This is an ordinary non-parameterized test.\n}\n\nTEST_P(DerivedTest, DoesBlah) {\n  // GetParam works just the same here as if you inherit from TestWithParam.\n  EXPECT_TRUE(foo.Blah(GetParam()));\n}\n\n#endif  // 0\n\n#include <iterator>\n#include <utility>\n\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// Type and function utilities for implementing parameterized tests.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n\n#include <ctype.h>\n\n#include <cassert>\n#include <iterator>\n#include <memory>\n#include <set>\n#include <tuple>\n#include <type_traits>\n#include <utility>\n#include <vector>\n\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n\n#include <iosfwd>\n#include <vector>\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// A copyable object representing the result of a test part (i.e. an\n// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).\n//\n// Don't inherit from TestPartResult as its destructor is not virtual.\nclass GTEST_API_ TestPartResult {\n public:\n  // The possible outcomes of a test part (i.e. an assertion or an\n  // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).\n  enum Type {\n    kSuccess,          // Succeeded.\n    kNonFatalFailure,  // Failed but the test can continue.\n    kFatalFailure,     // Failed and the test should be terminated.\n    kSkip              // Skipped.\n  };\n\n  // C'tor.  TestPartResult does NOT have a default constructor.\n  // Always use this constructor (with parameters) to create a\n  // TestPartResult object.\n  TestPartResult(Type a_type, const char* a_file_name, int a_line_number,\n                 const char* a_message)\n      : type_(a_type),\n        file_name_(a_file_name == nullptr ? \"\" : a_file_name),\n        line_number_(a_line_number),\n        summary_(ExtractSummary(a_message)),\n        message_(a_message) {}\n\n  // Gets the outcome of the test part.\n  Type type() const { return type_; }\n\n  // Gets the name of the source file where the test part took place, or\n  // NULL if it's unknown.\n  const char* file_name() const {\n    return file_name_.empty() ? nullptr : file_name_.c_str();\n  }\n\n  // Gets the line in the source file where the test part took place,\n  // or -1 if it's unknown.\n  int line_number() const { return line_number_; }\n\n  // Gets the summary of the failure message.\n  const char* summary() const { return summary_.c_str(); }\n\n  // Gets the message associated with the test part.\n  const char* message() const { return message_.c_str(); }\n\n  // Returns true if and only if the test part was skipped.\n  bool skipped() const { return type_ == kSkip; }\n\n  // Returns true if and only if the test part passed.\n  bool passed() const { return type_ == kSuccess; }\n\n  // Returns true if and only if the test part non-fatally failed.\n  bool nonfatally_failed() const { return type_ == kNonFatalFailure; }\n\n  // Returns true if and only if the test part fatally failed.\n  bool fatally_failed() const { return type_ == kFatalFailure; }\n\n  // Returns true if and only if the test part failed.\n  bool failed() const { return fatally_failed() || nonfatally_failed(); }\n\n private:\n  Type type_;\n\n  // Gets the summary of the failure message by omitting the stack\n  // trace in it.\n  static std::string ExtractSummary(const char* message);\n\n  // The name of the source file where the test part took place, or\n  // \"\" if the source file is unknown.\n  std::string file_name_;\n  // The line in the source file where the test part took place, or -1\n  // if the line number is unknown.\n  int line_number_;\n  std::string summary_;  // The test failure summary.\n  std::string message_;  // The test failure message.\n};\n\n// Prints a TestPartResult object.\nstd::ostream& operator<<(std::ostream& os, const TestPartResult& result);\n\n// An array of TestPartResult objects.\n//\n// Don't inherit from TestPartResultArray as its destructor is not\n// virtual.\nclass GTEST_API_ TestPartResultArray {\n public:\n  TestPartResultArray() {}\n\n  // Appends the given TestPartResult to the array.\n  void Append(const TestPartResult& result);\n\n  // Returns the TestPartResult at the given index (0-based).\n  const TestPartResult& GetTestPartResult(int index) const;\n\n  // Returns the number of TestPartResult objects in the array.\n  int size() const;\n\n private:\n  std::vector<TestPartResult> array_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);\n};\n\n// This interface knows how to report a test part result.\nclass GTEST_API_ TestPartResultReporterInterface {\n public:\n  virtual ~TestPartResultReporterInterface() {}\n\n  virtual void ReportTestPartResult(const TestPartResult& result) = 0;\n};\n\nnamespace internal {\n\n// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a\n// statement generates new fatal failures. To do so it registers itself as the\n// current test part result reporter. Besides checking if fatal failures were\n// reported, it only delegates the reporting to the former result reporter.\n// The original result reporter is restored in the destructor.\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nclass GTEST_API_ HasNewFatalFailureHelper\n    : public TestPartResultReporterInterface {\n public:\n  HasNewFatalFailureHelper();\n  ~HasNewFatalFailureHelper() override;\n  void ReportTestPartResult(const TestPartResult& result) override;\n  bool has_new_fatal_failure() const { return has_new_fatal_failure_; }\n private:\n  bool has_new_fatal_failure_;\n  TestPartResultReporterInterface* original_reporter_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n\nnamespace testing {\n// Input to a parameterized test name generator, describing a test parameter.\n// Consists of the parameter value and the integer parameter index.\ntemplate <class ParamType>\nstruct TestParamInfo {\n  TestParamInfo(const ParamType& a_param, size_t an_index) :\n    param(a_param),\n    index(an_index) {}\n  ParamType param;\n  size_t index;\n};\n\n// A builtin parameterized test name generator which returns the result of\n// testing::PrintToString.\nstruct PrintToStringParamName {\n  template <class ParamType>\n  std::string operator()(const TestParamInfo<ParamType>& info) const {\n    return PrintToString(info.param);\n  }\n};\n\nnamespace internal {\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n// Utility Functions\n\n// Outputs a message explaining invalid registration of different\n// fixture class for the same test suite. This may happen when\n// TEST_P macro is used to define two tests with the same name\n// but in different namespaces.\nGTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,\n                                           CodeLocation code_location);\n\ntemplate <typename> class ParamGeneratorInterface;\ntemplate <typename> class ParamGenerator;\n\n// Interface for iterating over elements provided by an implementation\n// of ParamGeneratorInterface<T>.\ntemplate <typename T>\nclass ParamIteratorInterface {\n public:\n  virtual ~ParamIteratorInterface() {}\n  // A pointer to the base generator instance.\n  // Used only for the purposes of iterator comparison\n  // to make sure that two iterators belong to the same generator.\n  virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;\n  // Advances iterator to point to the next element\n  // provided by the generator. The caller is responsible\n  // for not calling Advance() on an iterator equal to\n  // BaseGenerator()->End().\n  virtual void Advance() = 0;\n  // Clones the iterator object. Used for implementing copy semantics\n  // of ParamIterator<T>.\n  virtual ParamIteratorInterface* Clone() const = 0;\n  // Dereferences the current iterator and provides (read-only) access\n  // to the pointed value. It is the caller's responsibility not to call\n  // Current() on an iterator equal to BaseGenerator()->End().\n  // Used for implementing ParamGenerator<T>::operator*().\n  virtual const T* Current() const = 0;\n  // Determines whether the given iterator and other point to the same\n  // element in the sequence generated by the generator.\n  // Used for implementing ParamGenerator<T>::operator==().\n  virtual bool Equals(const ParamIteratorInterface& other) const = 0;\n};\n\n// Class iterating over elements provided by an implementation of\n// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>\n// and implements the const forward iterator concept.\ntemplate <typename T>\nclass ParamIterator {\n public:\n  typedef T value_type;\n  typedef const T& reference;\n  typedef ptrdiff_t difference_type;\n\n  // ParamIterator assumes ownership of the impl_ pointer.\n  ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}\n  ParamIterator& operator=(const ParamIterator& other) {\n    if (this != &other)\n      impl_.reset(other.impl_->Clone());\n    return *this;\n  }\n\n  const T& operator*() const { return *impl_->Current(); }\n  const T* operator->() const { return impl_->Current(); }\n  // Prefix version of operator++.\n  ParamIterator& operator++() {\n    impl_->Advance();\n    return *this;\n  }\n  // Postfix version of operator++.\n  ParamIterator operator++(int /*unused*/) {\n    ParamIteratorInterface<T>* clone = impl_->Clone();\n    impl_->Advance();\n    return ParamIterator(clone);\n  }\n  bool operator==(const ParamIterator& other) const {\n    return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);\n  }\n  bool operator!=(const ParamIterator& other) const {\n    return !(*this == other);\n  }\n\n private:\n  friend class ParamGenerator<T>;\n  explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}\n  std::unique_ptr<ParamIteratorInterface<T> > impl_;\n};\n\n// ParamGeneratorInterface<T> is the binary interface to access generators\n// defined in other translation units.\ntemplate <typename T>\nclass ParamGeneratorInterface {\n public:\n  typedef T ParamType;\n\n  virtual ~ParamGeneratorInterface() {}\n\n  // Generator interface definition\n  virtual ParamIteratorInterface<T>* Begin() const = 0;\n  virtual ParamIteratorInterface<T>* End() const = 0;\n};\n\n// Wraps ParamGeneratorInterface<T> and provides general generator syntax\n// compatible with the STL Container concept.\n// This class implements copy initialization semantics and the contained\n// ParamGeneratorInterface<T> instance is shared among all copies\n// of the original object. This is possible because that instance is immutable.\ntemplate<typename T>\nclass ParamGenerator {\n public:\n  typedef ParamIterator<T> iterator;\n\n  explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}\n  ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}\n\n  ParamGenerator& operator=(const ParamGenerator& other) {\n    impl_ = other.impl_;\n    return *this;\n  }\n\n  iterator begin() const { return iterator(impl_->Begin()); }\n  iterator end() const { return iterator(impl_->End()); }\n\n private:\n  std::shared_ptr<const ParamGeneratorInterface<T> > impl_;\n};\n\n// Generates values from a range of two comparable values. Can be used to\n// generate sequences of user-defined types that implement operator+() and\n// operator<().\n// This class is used in the Range() function.\ntemplate <typename T, typename IncrementT>\nclass RangeGenerator : public ParamGeneratorInterface<T> {\n public:\n  RangeGenerator(T begin, T end, IncrementT step)\n      : begin_(begin), end_(end),\n        step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}\n  ~RangeGenerator() override {}\n\n  ParamIteratorInterface<T>* Begin() const override {\n    return new Iterator(this, begin_, 0, step_);\n  }\n  ParamIteratorInterface<T>* End() const override {\n    return new Iterator(this, end_, end_index_, step_);\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<T> {\n   public:\n    Iterator(const ParamGeneratorInterface<T>* base, T value, int index,\n             IncrementT step)\n        : base_(base), value_(value), index_(index), step_(step) {}\n    ~Iterator() override {}\n\n    const ParamGeneratorInterface<T>* BaseGenerator() const override {\n      return base_;\n    }\n    void Advance() override {\n      value_ = static_cast<T>(value_ + step_);\n      index_++;\n    }\n    ParamIteratorInterface<T>* Clone() const override {\n      return new Iterator(*this);\n    }\n    const T* Current() const override { return &value_; }\n    bool Equals(const ParamIteratorInterface<T>& other) const override {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const int other_index =\n          CheckedDowncastToActualType<const Iterator>(&other)->index_;\n      return index_ == other_index;\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : ParamIteratorInterface<T>(),\n          base_(other.base_), value_(other.value_), index_(other.index_),\n          step_(other.step_) {}\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<T>* const base_;\n    T value_;\n    int index_;\n    const IncrementT step_;\n  };  // class RangeGenerator::Iterator\n\n  static int CalculateEndIndex(const T& begin,\n                               const T& end,\n                               const IncrementT& step) {\n    int end_index = 0;\n    for (T i = begin; i < end; i = static_cast<T>(i + step))\n      end_index++;\n    return end_index;\n  }\n\n  // No implementation - assignment is unsupported.\n  void operator=(const RangeGenerator& other);\n\n  const T begin_;\n  const T end_;\n  const IncrementT step_;\n  // The index for the end() iterator. All the elements in the generated\n  // sequence are indexed (0-based) to aid iterator comparison.\n  const int end_index_;\n};  // class RangeGenerator\n\n\n// Generates values from a pair of STL-style iterators. Used in the\n// ValuesIn() function. The elements are copied from the source range\n// since the source can be located on the stack, and the generator\n// is likely to persist beyond that stack frame.\ntemplate <typename T>\nclass ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {\n public:\n  template <typename ForwardIterator>\n  ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)\n      : container_(begin, end) {}\n  ~ValuesInIteratorRangeGenerator() override {}\n\n  ParamIteratorInterface<T>* Begin() const override {\n    return new Iterator(this, container_.begin());\n  }\n  ParamIteratorInterface<T>* End() const override {\n    return new Iterator(this, container_.end());\n  }\n\n private:\n  typedef typename ::std::vector<T> ContainerType;\n\n  class Iterator : public ParamIteratorInterface<T> {\n   public:\n    Iterator(const ParamGeneratorInterface<T>* base,\n             typename ContainerType::const_iterator iterator)\n        : base_(base), iterator_(iterator) {}\n    ~Iterator() override {}\n\n    const ParamGeneratorInterface<T>* BaseGenerator() const override {\n      return base_;\n    }\n    void Advance() override {\n      ++iterator_;\n      value_.reset();\n    }\n    ParamIteratorInterface<T>* Clone() const override {\n      return new Iterator(*this);\n    }\n    // We need to use cached value referenced by iterator_ because *iterator_\n    // can return a temporary object (and of type other then T), so just\n    // having \"return &*iterator_;\" doesn't work.\n    // value_ is updated here and not in Advance() because Advance()\n    // can advance iterator_ beyond the end of the range, and we cannot\n    // detect that fact. The client code, on the other hand, is\n    // responsible for not calling Current() on an out-of-range iterator.\n    const T* Current() const override {\n      if (value_.get() == nullptr) value_.reset(new T(*iterator_));\n      return value_.get();\n    }\n    bool Equals(const ParamIteratorInterface<T>& other) const override {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      return iterator_ ==\n          CheckedDowncastToActualType<const Iterator>(&other)->iterator_;\n    }\n\n   private:\n    Iterator(const Iterator& other)\n          // The explicit constructor call suppresses a false warning\n          // emitted by gcc when supplied with the -Wextra option.\n        : ParamIteratorInterface<T>(),\n          base_(other.base_),\n          iterator_(other.iterator_) {}\n\n    const ParamGeneratorInterface<T>* const base_;\n    typename ContainerType::const_iterator iterator_;\n    // A cached value of *iterator_. We keep it here to allow access by\n    // pointer in the wrapping iterator's operator->().\n    // value_ needs to be mutable to be accessed in Current().\n    // Use of std::unique_ptr helps manage cached value's lifetime,\n    // which is bound by the lifespan of the iterator itself.\n    mutable std::unique_ptr<const T> value_;\n  };  // class ValuesInIteratorRangeGenerator::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const ValuesInIteratorRangeGenerator& other);\n\n  const ContainerType container_;\n};  // class ValuesInIteratorRangeGenerator\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Default parameterized test name generator, returns a string containing the\n// integer test parameter index.\ntemplate <class ParamType>\nstd::string DefaultParamName(const TestParamInfo<ParamType>& info) {\n  Message name_stream;\n  name_stream << info.index;\n  return name_stream.GetString();\n}\n\ntemplate <typename T = int>\nvoid TestNotEmpty() {\n  static_assert(sizeof(T) == 0, \"Empty arguments are not allowed.\");\n}\ntemplate <typename T = int>\nvoid TestNotEmpty(const T&) {}\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Stores a parameter value and later creates tests parameterized with that\n// value.\ntemplate <class TestClass>\nclass ParameterizedTestFactory : public TestFactoryBase {\n public:\n  typedef typename TestClass::ParamType ParamType;\n  explicit ParameterizedTestFactory(ParamType parameter) :\n      parameter_(parameter) {}\n  Test* CreateTest() override {\n    TestClass::SetParam(&parameter_);\n    return new TestClass();\n  }\n\n private:\n  const ParamType parameter_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// TestMetaFactoryBase is a base class for meta-factories that create\n// test factories for passing into MakeAndRegisterTestInfo function.\ntemplate <class ParamType>\nclass TestMetaFactoryBase {\n public:\n  virtual ~TestMetaFactoryBase() {}\n\n  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// TestMetaFactory creates test factories for passing into\n// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives\n// ownership of test factory pointer, same factory object cannot be passed\n// into that method twice. But ParameterizedTestSuiteInfo is going to call\n// it for each Test/Parameter value combination. Thus it needs meta factory\n// creator class.\ntemplate <class TestSuite>\nclass TestMetaFactory\n    : public TestMetaFactoryBase<typename TestSuite::ParamType> {\n public:\n  using ParamType = typename TestSuite::ParamType;\n\n  TestMetaFactory() {}\n\n  TestFactoryBase* CreateTestFactory(ParamType parameter) override {\n    return new ParameterizedTestFactory<TestSuite>(parameter);\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestSuiteInfoBase is a generic interface\n// to ParameterizedTestSuiteInfo classes. ParameterizedTestSuiteInfoBase\n// accumulates test information provided by TEST_P macro invocations\n// and generators provided by INSTANTIATE_TEST_SUITE_P macro invocations\n// and uses that information to register all resulting test instances\n// in RegisterTests method. The ParameterizeTestSuiteRegistry class holds\n// a collection of pointers to the ParameterizedTestSuiteInfo objects\n// and calls RegisterTests() on each of them when asked.\nclass ParameterizedTestSuiteInfoBase {\n public:\n  virtual ~ParameterizedTestSuiteInfoBase() {}\n\n  // Base part of test suite name for display purposes.\n  virtual const std::string& GetTestSuiteName() const = 0;\n  // Test suite id to verify identity.\n  virtual TypeId GetTestSuiteTypeId() const = 0;\n  // UnitTest class invokes this method to register tests in this\n  // test suite right before running them in RUN_ALL_TESTS macro.\n  // This method should not be called more than once on any single\n  // instance of a ParameterizedTestSuiteInfoBase derived class.\n  virtual void RegisterTests() = 0;\n\n protected:\n  ParameterizedTestSuiteInfoBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfoBase);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Report a the name of a test_suit as safe to ignore\n// as the side effect of construction of this type.\nstruct MarkAsIgnored {\n  explicit MarkAsIgnored(const char* test_suite);\n};\n\nGTEST_API_ void InsertSyntheticTestCase(const std::string& name,\n                                        CodeLocation location, bool has_test_p);\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestSuiteInfo accumulates tests obtained from TEST_P\n// macro invocations for a particular test suite and generators\n// obtained from INSTANTIATE_TEST_SUITE_P macro invocations for that\n// test suite. It registers tests with all values generated by all\n// generators when asked.\ntemplate <class TestSuite>\nclass ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {\n public:\n  // ParamType and GeneratorCreationFunc are private types but are required\n  // for declarations of public methods AddTestPattern() and\n  // AddTestSuiteInstantiation().\n  using ParamType = typename TestSuite::ParamType;\n  // A function that returns an instance of appropriate generator type.\n  typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();\n  using ParamNameGeneratorFunc = std::string(const TestParamInfo<ParamType>&);\n\n  explicit ParameterizedTestSuiteInfo(const char* name,\n                                      CodeLocation code_location)\n      : test_suite_name_(name), code_location_(code_location) {}\n\n  // Test suite base name for display purposes.\n  const std::string& GetTestSuiteName() const override {\n    return test_suite_name_;\n  }\n  // Test suite id to verify identity.\n  TypeId GetTestSuiteTypeId() const override { return GetTypeId<TestSuite>(); }\n  // TEST_P macro uses AddTestPattern() to record information\n  // about a single test in a LocalTestInfo structure.\n  // test_suite_name is the base name of the test suite (without invocation\n  // prefix). test_base_name is the name of an individual test without\n  // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is\n  // test suite base name and DoBar is test base name.\n  void AddTestPattern(const char* test_suite_name, const char* test_base_name,\n                      TestMetaFactoryBase<ParamType>* meta_factory,\n                      CodeLocation code_location) {\n    tests_.push_back(std::shared_ptr<TestInfo>(new TestInfo(\n        test_suite_name, test_base_name, meta_factory, code_location)));\n  }\n  // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information\n  // about a generator.\n  int AddTestSuiteInstantiation(const std::string& instantiation_name,\n                                GeneratorCreationFunc* func,\n                                ParamNameGeneratorFunc* name_func,\n                                const char* file, int line) {\n    instantiations_.push_back(\n        InstantiationInfo(instantiation_name, func, name_func, file, line));\n    return 0;  // Return value used only to run this method in namespace scope.\n  }\n  // UnitTest class invokes this method to register tests in this test suite\n  // right before running tests in RUN_ALL_TESTS macro.\n  // This method should not be called more than once on any single\n  // instance of a ParameterizedTestSuiteInfoBase derived class.\n  // UnitTest has a guard to prevent from calling this method more than once.\n  void RegisterTests() override {\n    bool generated_instantiations = false;\n\n    for (typename TestInfoContainer::iterator test_it = tests_.begin();\n         test_it != tests_.end(); ++test_it) {\n      std::shared_ptr<TestInfo> test_info = *test_it;\n      for (typename InstantiationContainer::iterator gen_it =\n               instantiations_.begin(); gen_it != instantiations_.end();\n               ++gen_it) {\n        const std::string& instantiation_name = gen_it->name;\n        ParamGenerator<ParamType> generator((*gen_it->generator)());\n        ParamNameGeneratorFunc* name_func = gen_it->name_func;\n        const char* file = gen_it->file;\n        int line = gen_it->line;\n\n        std::string test_suite_name;\n        if ( !instantiation_name.empty() )\n          test_suite_name = instantiation_name + \"/\";\n        test_suite_name += test_info->test_suite_base_name;\n\n        size_t i = 0;\n        std::set<std::string> test_param_names;\n        for (typename ParamGenerator<ParamType>::iterator param_it =\n                 generator.begin();\n             param_it != generator.end(); ++param_it, ++i) {\n          generated_instantiations = true;\n\n          Message test_name_stream;\n\n          std::string param_name = name_func(\n              TestParamInfo<ParamType>(*param_it, i));\n\n          GTEST_CHECK_(IsValidParamName(param_name))\n              << \"Parameterized test name '\" << param_name\n              << \"' is invalid, in \" << file\n              << \" line \" << line << std::endl;\n\n          GTEST_CHECK_(test_param_names.count(param_name) == 0)\n              << \"Duplicate parameterized test name '\" << param_name\n              << \"', in \" << file << \" line \" << line << std::endl;\n\n          test_param_names.insert(param_name);\n\n          if (!test_info->test_base_name.empty()) {\n            test_name_stream << test_info->test_base_name << \"/\";\n          }\n          test_name_stream << param_name;\n          MakeAndRegisterTestInfo(\n              test_suite_name.c_str(), test_name_stream.GetString().c_str(),\n              nullptr,  // No type parameter.\n              PrintToString(*param_it).c_str(), test_info->code_location,\n              GetTestSuiteTypeId(),\n              SuiteApiResolver<TestSuite>::GetSetUpCaseOrSuite(file, line),\n              SuiteApiResolver<TestSuite>::GetTearDownCaseOrSuite(file, line),\n              test_info->test_meta_factory->CreateTestFactory(*param_it));\n        }  // for param_it\n      }  // for gen_it\n    }  // for test_it\n\n    if (!generated_instantiations) {\n      // There are no generaotrs, or they all generate nothing ...\n      InsertSyntheticTestCase(GetTestSuiteName(), code_location_,\n                              !tests_.empty());\n    }\n  }    // RegisterTests\n\n private:\n  // LocalTestInfo structure keeps information about a single test registered\n  // with TEST_P macro.\n  struct TestInfo {\n    TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,\n             TestMetaFactoryBase<ParamType>* a_test_meta_factory,\n             CodeLocation a_code_location)\n        : test_suite_base_name(a_test_suite_base_name),\n          test_base_name(a_test_base_name),\n          test_meta_factory(a_test_meta_factory),\n          code_location(a_code_location) {}\n\n    const std::string test_suite_base_name;\n    const std::string test_base_name;\n    const std::unique_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;\n    const CodeLocation code_location;\n  };\n  using TestInfoContainer = ::std::vector<std::shared_ptr<TestInfo> >;\n  // Records data received from INSTANTIATE_TEST_SUITE_P macros:\n  //  <Instantiation name, Sequence generator creation function,\n  //     Name generator function, Source file, Source line>\n  struct InstantiationInfo {\n      InstantiationInfo(const std::string &name_in,\n                        GeneratorCreationFunc* generator_in,\n                        ParamNameGeneratorFunc* name_func_in,\n                        const char* file_in,\n                        int line_in)\n          : name(name_in),\n            generator(generator_in),\n            name_func(name_func_in),\n            file(file_in),\n            line(line_in) {}\n\n      std::string name;\n      GeneratorCreationFunc* generator;\n      ParamNameGeneratorFunc* name_func;\n      const char* file;\n      int line;\n  };\n  typedef ::std::vector<InstantiationInfo> InstantiationContainer;\n\n  static bool IsValidParamName(const std::string& name) {\n    // Check for empty string\n    if (name.empty())\n      return false;\n\n    // Check for invalid characters\n    for (std::string::size_type index = 0; index < name.size(); ++index) {\n      if (!isalnum(name[index]) && name[index] != '_')\n        return false;\n    }\n\n    return true;\n  }\n\n  const std::string test_suite_name_;\n  CodeLocation code_location_;\n  TestInfoContainer tests_;\n  InstantiationContainer instantiations_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteInfo);\n};  // class ParameterizedTestSuiteInfo\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\ntemplate <class TestCase>\nusing ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestSuiteRegistry contains a map of\n// ParameterizedTestSuiteInfoBase classes accessed by test suite names. TEST_P\n// and INSTANTIATE_TEST_SUITE_P macros use it to locate their corresponding\n// ParameterizedTestSuiteInfo descriptors.\nclass ParameterizedTestSuiteRegistry {\n public:\n  ParameterizedTestSuiteRegistry() {}\n  ~ParameterizedTestSuiteRegistry() {\n    for (auto& test_suite_info : test_suite_infos_) {\n      delete test_suite_info;\n    }\n  }\n\n  // Looks up or creates and returns a structure containing information about\n  // tests and instantiations of a particular test suite.\n  template <class TestSuite>\n  ParameterizedTestSuiteInfo<TestSuite>* GetTestSuitePatternHolder(\n      const char* test_suite_name, CodeLocation code_location) {\n    ParameterizedTestSuiteInfo<TestSuite>* typed_test_info = nullptr;\n    for (auto& test_suite_info : test_suite_infos_) {\n      if (test_suite_info->GetTestSuiteName() == test_suite_name) {\n        if (test_suite_info->GetTestSuiteTypeId() != GetTypeId<TestSuite>()) {\n          // Complain about incorrect usage of Google Test facilities\n          // and terminate the program since we cannot guaranty correct\n          // test suite setup and tear-down in this case.\n          ReportInvalidTestSuiteType(test_suite_name, code_location);\n          posix::Abort();\n        } else {\n          // At this point we are sure that the object we found is of the same\n          // type we are looking for, so we downcast it to that type\n          // without further checks.\n          typed_test_info = CheckedDowncastToActualType<\n              ParameterizedTestSuiteInfo<TestSuite> >(test_suite_info);\n        }\n        break;\n      }\n    }\n    if (typed_test_info == nullptr) {\n      typed_test_info = new ParameterizedTestSuiteInfo<TestSuite>(\n          test_suite_name, code_location);\n      test_suite_infos_.push_back(typed_test_info);\n    }\n    return typed_test_info;\n  }\n  void RegisterTests() {\n    for (auto& test_suite_info : test_suite_infos_) {\n      test_suite_info->RegisterTests();\n    }\n  }\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  template <class TestCase>\n  ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(\n      const char* test_case_name, CodeLocation code_location) {\n    return GetTestSuitePatternHolder<TestCase>(test_case_name, code_location);\n  }\n\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n private:\n  using TestSuiteInfoContainer = ::std::vector<ParameterizedTestSuiteInfoBase*>;\n\n  TestSuiteInfoContainer test_suite_infos_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestSuiteRegistry);\n};\n\n// Keep track of what type-parameterized test suite are defined and\n// where as well as which are intatiated. This allows susequently\n// identifying suits that are defined but never used.\nclass TypeParameterizedTestSuiteRegistry {\n public:\n  // Add a suite definition\n  void RegisterTestSuite(const char* test_suite_name,\n                         CodeLocation code_location);\n\n  // Add an instantiation of a suit.\n  void RegisterInstantiation(const char* test_suite_name);\n\n  // For each suit repored as defined but not reported as instantiation,\n  // emit a test that reports that fact (configurably, as an error).\n  void CheckForInstantiations();\n\n private:\n  struct TypeParameterizedTestSuiteInfo {\n    explicit TypeParameterizedTestSuiteInfo(CodeLocation c)\n        : code_location(c), instantiated(false) {}\n\n    CodeLocation code_location;\n    bool instantiated;\n  };\n\n  std::map<std::string, TypeParameterizedTestSuiteInfo> suites_;\n};\n\n}  // namespace internal\n\n// Forward declarations of ValuesIn(), which is implemented in\n// include/gtest/gtest-param-test.h.\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container);\n\nnamespace internal {\n// Used in the Values() function to provide polymorphic capabilities.\n\n#ifdef _MSC_VER\n#pragma warning(push)\n#pragma warning(disable : 4100)\n#endif\n\ntemplate <typename... Ts>\nclass ValueArray {\n public:\n  explicit ValueArray(Ts... v) : v_(FlatTupleConstructTag{}, std::move(v)...) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {  // NOLINT\n    return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));\n  }\n\n private:\n  template <typename T, size_t... I>\n  std::vector<T> MakeVector(IndexSequence<I...>) const {\n    return std::vector<T>{static_cast<T>(v_.template Get<I>())...};\n  }\n\n  FlatTuple<Ts...> v_;\n};\n\n#ifdef _MSC_VER\n#pragma warning(pop)\n#endif\n\ntemplate <typename... T>\nclass CartesianProductGenerator\n    : public ParamGeneratorInterface<::std::tuple<T...>> {\n public:\n  typedef ::std::tuple<T...> ParamType;\n\n  CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)\n      : generators_(g) {}\n  ~CartesianProductGenerator() override {}\n\n  ParamIteratorInterface<ParamType>* Begin() const override {\n    return new Iterator(this, generators_, false);\n  }\n  ParamIteratorInterface<ParamType>* End() const override {\n    return new Iterator(this, generators_, true);\n  }\n\n private:\n  template <class I>\n  class IteratorImpl;\n  template <size_t... I>\n  class IteratorImpl<IndexSequence<I...>>\n      : public ParamIteratorInterface<ParamType> {\n   public:\n    IteratorImpl(const ParamGeneratorInterface<ParamType>* base,\n             const std::tuple<ParamGenerator<T>...>& generators, bool is_end)\n        : base_(base),\n          begin_(std::get<I>(generators).begin()...),\n          end_(std::get<I>(generators).end()...),\n          current_(is_end ? end_ : begin_) {\n      ComputeCurrentValue();\n    }\n    ~IteratorImpl() override {}\n\n    const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    void Advance() override {\n      assert(!AtEnd());\n      // Advance the last iterator.\n      ++std::get<sizeof...(T) - 1>(current_);\n      // if that reaches end, propagate that up.\n      AdvanceIfEnd<sizeof...(T) - 1>();\n      ComputeCurrentValue();\n    }\n    ParamIteratorInterface<ParamType>* Clone() const override {\n      return new IteratorImpl(*this);\n    }\n\n    const ParamType* Current() const override { return current_value_.get(); }\n\n    bool Equals(const ParamIteratorInterface<ParamType>& other) const override {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const IteratorImpl* typed_other =\n          CheckedDowncastToActualType<const IteratorImpl>(&other);\n\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      if (AtEnd() && typed_other->AtEnd()) return true;\n\n      bool same = true;\n      bool dummy[] = {\n          (same = same && std::get<I>(current_) ==\n                              std::get<I>(typed_other->current_))...};\n      (void)dummy;\n      return same;\n    }\n\n   private:\n    template <size_t ThisI>\n    void AdvanceIfEnd() {\n      if (std::get<ThisI>(current_) != std::get<ThisI>(end_)) return;\n\n      bool last = ThisI == 0;\n      if (last) {\n        // We are done. Nothing else to propagate.\n        return;\n      }\n\n      constexpr size_t NextI = ThisI - (ThisI != 0);\n      std::get<ThisI>(current_) = std::get<ThisI>(begin_);\n      ++std::get<NextI>(current_);\n      AdvanceIfEnd<NextI>();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = std::make_shared<ParamType>(*std::get<I>(current_)...);\n    }\n    bool AtEnd() const {\n      bool at_end = false;\n      bool dummy[] = {\n          (at_end = at_end || std::get<I>(current_) == std::get<I>(end_))...};\n      (void)dummy;\n      return at_end;\n    }\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    std::tuple<typename ParamGenerator<T>::iterator...> begin_;\n    std::tuple<typename ParamGenerator<T>::iterator...> end_;\n    std::tuple<typename ParamGenerator<T>::iterator...> current_;\n    std::shared_ptr<ParamType> current_value_;\n  };\n\n  using Iterator = IteratorImpl<typename MakeIndexSequence<sizeof...(T)>::type>;\n\n  std::tuple<ParamGenerator<T>...> generators_;\n};\n\ntemplate <class... Gen>\nclass CartesianProductHolder {\n public:\n  CartesianProductHolder(const Gen&... g) : generators_(g...) {}\n  template <typename... T>\n  operator ParamGenerator<::std::tuple<T...>>() const {\n    return ParamGenerator<::std::tuple<T...>>(\n        new CartesianProductGenerator<T...>(generators_));\n  }\n\n private:\n  std::tuple<Gen...> generators_;\n};\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n\nnamespace testing {\n\n// Functions producing parameter generators.\n//\n// Google Test uses these generators to produce parameters for value-\n// parameterized tests. When a parameterized test suite is instantiated\n// with a particular generator, Google Test creates and runs tests\n// for each element in the sequence produced by the generator.\n//\n// In the following sample, tests from test suite FooTest are instantiated\n// each three times with parameter values 3, 5, and 8:\n//\n// class FooTest : public TestWithParam<int> { ... };\n//\n// TEST_P(FooTest, TestThis) {\n// }\n// TEST_P(FooTest, TestThat) {\n// }\n// INSTANTIATE_TEST_SUITE_P(TestSequence, FooTest, Values(3, 5, 8));\n//\n\n// Range() returns generators providing sequences of values in a range.\n//\n// Synopsis:\n// Range(start, end)\n//   - returns a generator producing a sequence of values {start, start+1,\n//     start+2, ..., }.\n// Range(start, end, step)\n//   - returns a generator producing a sequence of values {start, start+step,\n//     start+step+step, ..., }.\n// Notes:\n//   * The generated sequences never include end. For example, Range(1, 5)\n//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)\n//     returns a generator producing {1, 3, 5, 7}.\n//   * start and end must have the same type. That type may be any integral or\n//     floating-point type or a user defined type satisfying these conditions:\n//     * It must be assignable (have operator=() defined).\n//     * It must have operator+() (operator+(int-compatible type) for\n//       two-operand version).\n//     * It must have operator<() defined.\n//     Elements in the resulting sequences will also have that type.\n//   * Condition start < end must be satisfied in order for resulting sequences\n//     to contain any elements.\n//\ntemplate <typename T, typename IncrementT>\ninternal::ParamGenerator<T> Range(T start, T end, IncrementT step) {\n  return internal::ParamGenerator<T>(\n      new internal::RangeGenerator<T, IncrementT>(start, end, step));\n}\n\ntemplate <typename T>\ninternal::ParamGenerator<T> Range(T start, T end) {\n  return Range(start, end, 1);\n}\n\n// ValuesIn() function allows generation of tests with parameters coming from\n// a container.\n//\n// Synopsis:\n// ValuesIn(const T (&array)[N])\n//   - returns a generator producing sequences with elements from\n//     a C-style array.\n// ValuesIn(const Container& container)\n//   - returns a generator producing sequences with elements from\n//     an STL-style container.\n// ValuesIn(Iterator begin, Iterator end)\n//   - returns a generator producing sequences with elements from\n//     a range [begin, end) defined by a pair of STL-style iterators. These\n//     iterators can also be plain C pointers.\n//\n// Please note that ValuesIn copies the values from the containers\n// passed in and keeps them to generate tests in RUN_ALL_TESTS().\n//\n// Examples:\n//\n// This instantiates tests from test suite StringTest\n// each with C-string values of \"foo\", \"bar\", and \"baz\":\n//\n// const char* strings[] = {\"foo\", \"bar\", \"baz\"};\n// INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings));\n//\n// This instantiates tests from test suite StlStringTest\n// each with STL strings with values \"a\" and \"b\":\n//\n// ::std::vector< ::std::string> GetParameterStrings() {\n//   ::std::vector< ::std::string> v;\n//   v.push_back(\"a\");\n//   v.push_back(\"b\");\n//   return v;\n// }\n//\n// INSTANTIATE_TEST_SUITE_P(CharSequence,\n//                          StlStringTest,\n//                          ValuesIn(GetParameterStrings()));\n//\n//\n// This will also instantiate tests from CharTest\n// each with parameter values 'a' and 'b':\n//\n// ::std::list<char> GetParameterChars() {\n//   ::std::list<char> list;\n//   list.push_back('a');\n//   list.push_back('b');\n//   return list;\n// }\n// ::std::list<char> l = GetParameterChars();\n// INSTANTIATE_TEST_SUITE_P(CharSequence2,\n//                          CharTest,\n//                          ValuesIn(l.begin(), l.end()));\n//\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n    typename std::iterator_traits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end) {\n  typedef typename std::iterator_traits<ForwardIterator>::value_type ParamType;\n  return internal::ParamGenerator<ParamType>(\n      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));\n}\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {\n  return ValuesIn(array, array + N);\n}\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container) {\n  return ValuesIn(container.begin(), container.end());\n}\n\n// Values() allows generating tests from explicitly specified list of\n// parameters.\n//\n// Synopsis:\n// Values(T v1, T v2, ..., T vN)\n//   - returns a generator producing sequences with elements v1, v2, ..., vN.\n//\n// For example, this instantiates tests from test suite BarTest each\n// with values \"one\", \"two\", and \"three\":\n//\n// INSTANTIATE_TEST_SUITE_P(NumSequence,\n//                          BarTest,\n//                          Values(\"one\", \"two\", \"three\"));\n//\n// This instantiates tests from test suite BazTest each with values 1, 2, 3.5.\n// The exact type of values will depend on the type of parameter in BazTest.\n//\n// INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));\n//\n//\ntemplate <typename... T>\ninternal::ValueArray<T...> Values(T... v) {\n  return internal::ValueArray<T...>(std::move(v)...);\n}\n\n// Bool() allows generating tests with parameters in a set of (false, true).\n//\n// Synopsis:\n// Bool()\n//   - returns a generator producing sequences with elements {false, true}.\n//\n// It is useful when testing code that depends on Boolean flags. Combinations\n// of multiple flags can be tested when several Bool()'s are combined using\n// Combine() function.\n//\n// In the following example all tests in the test suite FlagDependentTest\n// will be instantiated twice with parameters false and true.\n//\n// class FlagDependentTest : public testing::TestWithParam<bool> {\n//   virtual void SetUp() {\n//     external_flag = GetParam();\n//   }\n// }\n// INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());\n//\ninline internal::ParamGenerator<bool> Bool() {\n  return Values(false, true);\n}\n\n// Combine() allows the user to combine two or more sequences to produce\n// values of a Cartesian product of those sequences' elements.\n//\n// Synopsis:\n// Combine(gen1, gen2, ..., genN)\n//   - returns a generator producing sequences with elements coming from\n//     the Cartesian product of elements from the sequences generated by\n//     gen1, gen2, ..., genN. The sequence elements will have a type of\n//     std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types\n//     of elements from sequences produces by gen1, gen2, ..., genN.\n//\n// Example:\n//\n// This will instantiate tests in test suite AnimalTest each one with\n// the parameter values tuple(\"cat\", BLACK), tuple(\"cat\", WHITE),\n// tuple(\"dog\", BLACK), and tuple(\"dog\", WHITE):\n//\n// enum Color { BLACK, GRAY, WHITE };\n// class AnimalTest\n//     : public testing::TestWithParam<std::tuple<const char*, Color> > {...};\n//\n// TEST_P(AnimalTest, AnimalLooksNice) {...}\n//\n// INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,\n//                          Combine(Values(\"cat\", \"dog\"),\n//                                  Values(BLACK, WHITE)));\n//\n// This will instantiate tests in FlagDependentTest with all variations of two\n// Boolean flags:\n//\n// class FlagDependentTest\n//     : public testing::TestWithParam<std::tuple<bool, bool> > {\n//   virtual void SetUp() {\n//     // Assigns external_flag_1 and external_flag_2 values from the tuple.\n//     std::tie(external_flag_1, external_flag_2) = GetParam();\n//   }\n// };\n//\n// TEST_P(FlagDependentTest, TestFeature1) {\n//   // Test your code using external_flag_1 and external_flag_2 here.\n// }\n// INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest,\n//                          Combine(Bool(), Bool()));\n//\ntemplate <typename... Generator>\ninternal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {\n  return internal::CartesianProductHolder<Generator...>(g...);\n}\n\n#define TEST_P(test_suite_name, test_name)                                     \\\n  class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)                     \\\n      : public test_suite_name {                                               \\\n   public:                                                                     \\\n    GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {}                    \\\n    void TestBody() override;                                                  \\\n                                                                               \\\n   private:                                                                    \\\n    static int AddToRegistry() {                                               \\\n      ::testing::UnitTest::GetInstance()                                       \\\n          ->parameterized_test_registry()                                      \\\n          .GetTestSuitePatternHolder<test_suite_name>(                         \\\n              GTEST_STRINGIFY_(test_suite_name),                               \\\n              ::testing::internal::CodeLocation(__FILE__, __LINE__))           \\\n          ->AddTestPattern(                                                    \\\n              GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name),  \\\n              new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \\\n                  test_suite_name, test_name)>(),                              \\\n              ::testing::internal::CodeLocation(__FILE__, __LINE__));          \\\n      return 0;                                                                \\\n    }                                                                          \\\n    static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_;               \\\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name,    \\\n                                                           test_name));        \\\n  };                                                                           \\\n  int GTEST_TEST_CLASS_NAME_(test_suite_name,                                  \\\n                             test_name)::gtest_registering_dummy_ =            \\\n      GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry();     \\\n  void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()\n\n// The last argument to INSTANTIATE_TEST_SUITE_P allows the user to specify\n// generator and an optional function or functor that generates custom test name\n// suffixes based on the test parameters. Such a function or functor should\n// accept one argument of type testing::TestParamInfo<class ParamType>, and\n// return std::string.\n//\n// testing::PrintToStringParamName is a builtin test suffix generator that\n// returns the value of testing::PrintToString(GetParam()).\n//\n// Note: test names must be non-empty, unique, and may only contain ASCII\n// alphanumeric characters or underscore. Because PrintToString adds quotes\n// to std::string and C strings, it won't work for these types.\n\n#define GTEST_EXPAND_(arg) arg\n#define GTEST_GET_FIRST_(first, ...) first\n#define GTEST_GET_SECOND_(first, second, ...) second\n\n#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...)                \\\n  static ::testing::internal::ParamGenerator<test_suite_name::ParamType>      \\\n      gtest_##prefix##test_suite_name##_EvalGenerator_() {                    \\\n    return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_));        \\\n  }                                                                           \\\n  static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_(   \\\n      const ::testing::TestParamInfo<test_suite_name::ParamType>& info) {     \\\n    if (::testing::internal::AlwaysFalse()) {                                 \\\n      ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_(      \\\n          __VA_ARGS__,                                                        \\\n          ::testing::internal::DefaultParamName<test_suite_name::ParamType>,  \\\n          DUMMY_PARAM_)));                                                    \\\n      auto t = std::make_tuple(__VA_ARGS__);                                  \\\n      static_assert(std::tuple_size<decltype(t)>::value <= 2,                 \\\n                    \"Too Many Args!\");                                        \\\n    }                                                                         \\\n    return ((GTEST_EXPAND_(GTEST_GET_SECOND_(                                 \\\n        __VA_ARGS__,                                                          \\\n        ::testing::internal::DefaultParamName<test_suite_name::ParamType>,    \\\n        DUMMY_PARAM_))))(info);                                               \\\n  }                                                                           \\\n  static int gtest_##prefix##test_suite_name##_dummy_                         \\\n      GTEST_ATTRIBUTE_UNUSED_ =                                               \\\n          ::testing::UnitTest::GetInstance()                                  \\\n              ->parameterized_test_registry()                                 \\\n              .GetTestSuitePatternHolder<test_suite_name>(                    \\\n                  GTEST_STRINGIFY_(test_suite_name),                          \\\n                  ::testing::internal::CodeLocation(__FILE__, __LINE__))      \\\n              ->AddTestSuiteInstantiation(                                    \\\n                  GTEST_STRINGIFY_(prefix),                                   \\\n                  &gtest_##prefix##test_suite_name##_EvalGenerator_,          \\\n                  &gtest_##prefix##test_suite_name##_EvalGenerateName_,       \\\n                  __FILE__, __LINE__)\n\n\n// Allow Marking a Parameterized test class as not needing to be instantiated.\n#define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T)                   \\\n  namespace gtest_do_not_use_outside_namespace_scope {}                   \\\n  static const ::testing::internal::MarkAsIgnored gtest_allow_ignore_##T( \\\n      GTEST_STRINGIFY_(T))\n\n// Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n#define INSTANTIATE_TEST_CASE_P                                            \\\n  static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \\\n                \"\");                                                       \\\n  INSTANTIATE_TEST_SUITE_P\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//\n// Google C++ Testing and Mocking Framework definitions useful in production code.\n// GOOGLETEST_CM0003 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_\n\n// When you need to test the private or protected members of a class,\n// use the FRIEND_TEST macro to declare your tests as friends of the\n// class.  For example:\n//\n// class MyClass {\n//  private:\n//   void PrivateMethod();\n//   FRIEND_TEST(MyClassTest, PrivateMethodWorks);\n// };\n//\n// class MyClassTest : public testing::Test {\n//   // ...\n// };\n//\n// TEST_F(MyClassTest, PrivateMethodWorks) {\n//   // Can call MyClass::PrivateMethod() here.\n// }\n//\n// Note: The test class must be in the same namespace as the class being tested.\n// For example, putting MyClassTest in an anonymous namespace will not work.\n\n#define FRIEND_TEST(test_case_name, test_name)\\\nfriend class test_case_name##_##test_name##_Test\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n\n// This header implements typed tests and type-parameterized tests.\n\n// Typed (aka type-driven) tests repeat the same test for types in a\n// list.  You must know which types you want to test with when writing\n// typed tests. Here's how you do it:\n\n#if 0\n\n// First, define a fixture class template.  It should be parameterized\n// by a type.  Remember to derive it from testing::Test.\ntemplate <typename T>\nclass FooTest : public testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n\n// Next, associate a list of types with the test suite, which will be\n// repeated for each type in the list.  The typedef is necessary for\n// the macro to parse correctly.\ntypedef testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_SUITE(FooTest, MyTypes);\n\n// If the type list contains only one type, you can write that type\n// directly without Types<...>:\n//   TYPED_TEST_SUITE(FooTest, int);\n\n// Then, use TYPED_TEST() instead of TEST_F() to define as many typed\n// tests for this test suite as you want.\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to the special name TypeParam to get the type\n  // parameter.  Since we are inside a derived class template, C++ requires\n  // us to visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the TestFixture::\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the \"typename\n  // TestFixture::\" prefix.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n\n// TYPED_TEST_SUITE takes an optional third argument which allows to specify a\n// class that generates custom test name suffixes based on the type. This should\n// be a class which has a static template function GetName(int index) returning\n// a string for each type. The provided integer index equals the index of the\n// type in the provided type list. In many cases the index can be ignored.\n//\n// For example:\n//   class MyTypeNames {\n//    public:\n//     template <typename T>\n//     static std::string GetName(int) {\n//       if (std::is_same<T, char>()) return \"char\";\n//       if (std::is_same<T, int>()) return \"int\";\n//       if (std::is_same<T, unsigned int>()) return \"unsignedInt\";\n//     }\n//   };\n//   TYPED_TEST_SUITE(FooTest, MyTypes, MyTypeNames);\n\n#endif  // 0\n\n// Type-parameterized tests are abstract test patterns parameterized\n// by a type.  Compared with typed tests, type-parameterized tests\n// allow you to define the test pattern without knowing what the type\n// parameters are.  The defined pattern can be instantiated with\n// different types any number of times, in any number of translation\n// units.\n//\n// If you are designing an interface or concept, you can define a\n// suite of type-parameterized tests to verify properties that any\n// valid implementation of the interface/concept should have.  Then,\n// each implementation can easily instantiate the test suite to verify\n// that it conforms to the requirements, without having to write\n// similar tests repeatedly.  Here's an example:\n\n#if 0\n\n// First, define a fixture class template.  It should be parameterized\n// by a type.  Remember to derive it from testing::Test.\ntemplate <typename T>\nclass FooTest : public testing::Test {\n  ...\n};\n\n// Next, declare that you will define a type-parameterized test suite\n// (the _P suffix is for \"parameterized\" or \"pattern\", whichever you\n// prefer):\nTYPED_TEST_SUITE_P(FooTest);\n\n// Then, use TYPED_TEST_P() to define as many type-parameterized tests\n// for this type-parameterized test suite as you want.\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n\n// Now the tricky part: you need to register all test patterns before\n// you can instantiate them.  The first argument of the macro is the\n// test suite name; the rest are the names of the tests in this test\n// case.\nREGISTER_TYPED_TEST_SUITE_P(FooTest,\n                            DoesBlah, HasPropertyA);\n\n// Finally, you are free to instantiate the pattern with the types you\n// want.  If you put the above code in a header file, you can #include\n// it in multiple C++ source files and instantiate it multiple times.\n//\n// To distinguish different instances of the pattern, the first\n// argument to the INSTANTIATE_* macro is a prefix that will be added\n// to the actual test suite name.  Remember to pick unique prefixes for\n// different instances.\ntypedef testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);\n\n// If the type list contains only one type, you can write that type\n// directly without Types<...>:\n//   INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, int);\n//\n// Similar to the optional argument of TYPED_TEST_SUITE above,\n// INSTANTIATE_TEST_SUITE_P takes an optional fourth argument which allows to\n// generate custom names.\n//   INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes, MyTypeNames);\n\n#endif  // 0\n\n\n// Implements typed tests.\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the name of the typedef for the type parameters of the\n// given test suite.\n#define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_\n\n// Expands to the name of the typedef for the NameGenerator, responsible for\n// creating the suffixes of the name.\n#define GTEST_NAME_GENERATOR_(TestSuiteName) \\\n  gtest_type_params_##TestSuiteName##_NameGenerator\n\n#define TYPED_TEST_SUITE(CaseName, Types, ...)                          \\\n  typedef ::testing::internal::GenerateTypeList<Types>::type            \\\n      GTEST_TYPE_PARAMS_(CaseName);                                     \\\n  typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \\\n      GTEST_NAME_GENERATOR_(CaseName)\n\n#define TYPED_TEST(CaseName, TestName)                                        \\\n  static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1,                       \\\n                \"test-name must not be empty\");                               \\\n  template <typename gtest_TypeParam_>                                        \\\n  class GTEST_TEST_CLASS_NAME_(CaseName, TestName)                            \\\n      : public CaseName<gtest_TypeParam_> {                                   \\\n   private:                                                                   \\\n    typedef CaseName<gtest_TypeParam_> TestFixture;                           \\\n    typedef gtest_TypeParam_ TypeParam;                                       \\\n    void TestBody() override;                                                 \\\n  };                                                                          \\\n  static bool gtest_##CaseName##_##TestName##_registered_                     \\\n      GTEST_ATTRIBUTE_UNUSED_ = ::testing::internal::TypeParameterizedTest<   \\\n          CaseName,                                                           \\\n          ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName,   \\\n                                                                  TestName)>, \\\n          GTEST_TYPE_PARAMS_(                                                 \\\n              CaseName)>::Register(\"\",                                        \\\n                                   ::testing::internal::CodeLocation(         \\\n                                       __FILE__, __LINE__),                   \\\n                                   GTEST_STRINGIFY_(CaseName),                \\\n                                   GTEST_STRINGIFY_(TestName), 0,             \\\n                                   ::testing::internal::GenerateNames<        \\\n                                       GTEST_NAME_GENERATOR_(CaseName),       \\\n                                       GTEST_TYPE_PARAMS_(CaseName)>());      \\\n  template <typename gtest_TypeParam_>                                        \\\n  void GTEST_TEST_CLASS_NAME_(CaseName,                                       \\\n                              TestName)<gtest_TypeParam_>::TestBody()\n\n// Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n#define TYPED_TEST_CASE                                                \\\n  static_assert(::testing::internal::TypedTestCaseIsDeprecated(), \"\"); \\\n  TYPED_TEST_SUITE\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n// Implements type-parameterized tests.\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the namespace name that the type-parameterized tests for\n// the given type-parameterized test suite are defined in.  The exact\n// name of the namespace is subject to change without notice.\n#define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the name of the variable used to remember the names of\n// the defined tests in the given test suite.\n#define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \\\n  gtest_typed_test_suite_p_state_##TestSuiteName##_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.\n//\n// Expands to the name of the variable used to remember the names of\n// the registered tests in the given test suite.\n#define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \\\n  gtest_registered_test_names_##TestSuiteName##_\n\n// The variables defined in the type-parameterized test macros are\n// static as typically these macros are used in a .h file that can be\n// #included in multiple translation units linked together.\n#define TYPED_TEST_SUITE_P(SuiteName)              \\\n  static ::testing::internal::TypedTestSuitePState \\\n      GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)\n\n// Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n#define TYPED_TEST_CASE_P                                                 \\\n  static_assert(::testing::internal::TypedTestCase_P_IsDeprecated(), \"\"); \\\n  TYPED_TEST_SUITE_P\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n#define TYPED_TEST_P(SuiteName, TestName)                             \\\n  namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                       \\\n    template <typename gtest_TypeParam_>                              \\\n    class TestName : public SuiteName<gtest_TypeParam_> {             \\\n     private:                                                         \\\n      typedef SuiteName<gtest_TypeParam_> TestFixture;                \\\n      typedef gtest_TypeParam_ TypeParam;                             \\\n      void TestBody() override;                                       \\\n    };                                                                \\\n    static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n        GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName(       \\\n            __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName),          \\\n            GTEST_STRINGIFY_(TestName));                              \\\n  }                                                                   \\\n  template <typename gtest_TypeParam_>                                \\\n  void GTEST_SUITE_NAMESPACE_(                                        \\\n      SuiteName)::TestName<gtest_TypeParam_>::TestBody()\n\n// Note: this won't work correctly if the trailing arguments are macros.\n#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...)                         \\\n  namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                             \\\n    typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_;    \\\n  }                                                                         \\\n  static const char* const GTEST_REGISTERED_TEST_NAMES_(                    \\\n      SuiteName) GTEST_ATTRIBUTE_UNUSED_ =                                  \\\n      GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \\\n          GTEST_STRINGIFY_(SuiteName), __FILE__, __LINE__, #__VA_ARGS__)\n\n// Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n#define REGISTER_TYPED_TEST_CASE_P                                           \\\n  static_assert(::testing::internal::RegisterTypedTestCase_P_IsDeprecated(), \\\n                \"\");                                                         \\\n  REGISTER_TYPED_TEST_SUITE_P\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...)       \\\n  static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1,                       \\\n                \"test-suit-prefix must not be empty\");                      \\\n  static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ =        \\\n      ::testing::internal::TypeParameterizedTestSuite<                      \\\n          SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_,    \\\n          ::testing::internal::GenerateTypeList<Types>::type>::             \\\n          Register(GTEST_STRINGIFY_(Prefix),                                \\\n                   ::testing::internal::CodeLocation(__FILE__, __LINE__),   \\\n                   &GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName),             \\\n                   GTEST_STRINGIFY_(SuiteName),                             \\\n                   GTEST_REGISTERED_TEST_NAMES_(SuiteName),                 \\\n                   ::testing::internal::GenerateNames<                      \\\n                       ::testing::internal::NameGeneratorSelector<          \\\n                           __VA_ARGS__>::type,                              \\\n                       ::testing::internal::GenerateTypeList<Types>::type>())\n\n// Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n#define INSTANTIATE_TYPED_TEST_CASE_P                                      \\\n  static_assert(                                                           \\\n      ::testing::internal::InstantiateTypedTestCase_P_IsDeprecated(), \"\"); \\\n  INSTANTIATE_TYPED_TEST_SUITE_P\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n\nGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \\\n/* class A needs to have dll-interface to be used by clients of class B */)\n\nnamespace testing {\n\n// Silence C4100 (unreferenced formal parameter) and 4805\n// unsafe mix of type 'const int' and type 'const bool'\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4805)\n# pragma warning(disable:4100)\n#endif\n\n\n// Declares the flags.\n\n// This flag temporary enables the disabled tests.\nGTEST_DECLARE_bool_(also_run_disabled_tests);\n\n// This flag brings the debugger on an assertion failure.\nGTEST_DECLARE_bool_(break_on_failure);\n\n// This flag controls whether Google Test catches all test-thrown exceptions\n// and logs them as failures.\nGTEST_DECLARE_bool_(catch_exceptions);\n\n// This flag enables using colors in terminal output. Available values are\n// \"yes\" to enable colors, \"no\" (disable colors), or \"auto\" (the default)\n// to let Google Test decide.\nGTEST_DECLARE_string_(color);\n\n// This flag controls whether the test runner should continue execution past\n// first failure.\nGTEST_DECLARE_bool_(fail_fast);\n\n// This flag sets up the filter to select by name using a glob pattern\n// the tests to run. If the filter is not given all tests are executed.\nGTEST_DECLARE_string_(filter);\n\n// This flag controls whether Google Test installs a signal handler that dumps\n// debugging information when fatal signals are raised.\nGTEST_DECLARE_bool_(install_failure_signal_handler);\n\n// This flag causes the Google Test to list tests. None of the tests listed\n// are actually run if the flag is provided.\nGTEST_DECLARE_bool_(list_tests);\n\n// This flag controls whether Google Test emits a detailed XML report to a file\n// in addition to its normal textual output.\nGTEST_DECLARE_string_(output);\n\n// This flags control whether Google Test prints only test failures.\nGTEST_DECLARE_bool_(brief);\n\n// This flags control whether Google Test prints the elapsed time for each\n// test.\nGTEST_DECLARE_bool_(print_time);\n\n// This flags control whether Google Test prints UTF8 characters as text.\nGTEST_DECLARE_bool_(print_utf8);\n\n// This flag specifies the random number seed.\nGTEST_DECLARE_int32_(random_seed);\n\n// This flag sets how many times the tests are repeated. The default value\n// is 1. If the value is -1 the tests are repeating forever.\nGTEST_DECLARE_int32_(repeat);\n\n// This flag controls whether Google Test includes Google Test internal\n// stack frames in failure stack traces.\nGTEST_DECLARE_bool_(show_internal_stack_frames);\n\n// When this flag is specified, tests' order is randomized on every iteration.\nGTEST_DECLARE_bool_(shuffle);\n\n// This flag specifies the maximum number of stack frames to be\n// printed in a failure message.\nGTEST_DECLARE_int32_(stack_trace_depth);\n\n// When this flag is specified, a failed assertion will throw an\n// exception if exceptions are enabled, or exit the program with a\n// non-zero code otherwise. For use with an external test framework.\nGTEST_DECLARE_bool_(throw_on_failure);\n\n// When this flag is set with a \"host:port\" string, on supported\n// platforms test results are streamed to the specified port on\n// the specified host machine.\nGTEST_DECLARE_string_(stream_result_to);\n\n#if GTEST_USE_OWN_FLAGFILE_FLAG_\nGTEST_DECLARE_string_(flagfile);\n#endif  // GTEST_USE_OWN_FLAGFILE_FLAG_\n\n// The upper limit for valid stack trace depths.\nconst int kMaxStackTraceDepth = 100;\n\nnamespace internal {\n\nclass AssertHelper;\nclass DefaultGlobalTestPartResultReporter;\nclass ExecDeathTest;\nclass NoExecDeathTest;\nclass FinalSuccessChecker;\nclass GTestFlagSaver;\nclass StreamingListenerTest;\nclass TestResultAccessor;\nclass TestEventListenersAccessor;\nclass TestEventRepeater;\nclass UnitTestRecordPropertyTestHelper;\nclass WindowsDeathTest;\nclass FuchsiaDeathTest;\nclass UnitTestImpl* GetUnitTestImpl();\nvoid ReportFailureInUnknownLocation(TestPartResult::Type result_type,\n                                    const std::string& message);\nstd::set<std::string>* GetIgnoredParameterizedTestSuites();\n\n}  // namespace internal\n\n// The friend relationship of some of these classes is cyclic.\n// If we don't forward declare them the compiler might confuse the classes\n// in friendship clauses with same named classes on the scope.\nclass Test;\nclass TestSuite;\n\n// Old API is still available but deprecated\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\nusing TestCase = TestSuite;\n#endif\nclass TestInfo;\nclass UnitTest;\n\n// A class for indicating whether an assertion was successful.  When\n// the assertion wasn't successful, the AssertionResult object\n// remembers a non-empty message that describes how it failed.\n//\n// To create an instance of this class, use one of the factory functions\n// (AssertionSuccess() and AssertionFailure()).\n//\n// This class is useful for two purposes:\n//   1. Defining predicate functions to be used with Boolean test assertions\n//      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts\n//   2. Defining predicate-format functions to be\n//      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).\n//\n// For example, if you define IsEven predicate:\n//\n//   testing::AssertionResult IsEven(int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess();\n//     else\n//       return testing::AssertionFailure() << n << \" is odd\";\n//   }\n//\n// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))\n// will print the message\n//\n//   Value of: IsEven(Fib(5))\n//     Actual: false (5 is odd)\n//   Expected: true\n//\n// instead of a more opaque\n//\n//   Value of: IsEven(Fib(5))\n//     Actual: false\n//   Expected: true\n//\n// in case IsEven is a simple Boolean predicate.\n//\n// If you expect your predicate to be reused and want to support informative\n// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up\n// about half as often as positive ones in our tests), supply messages for\n// both success and failure cases:\n//\n//   testing::AssertionResult IsEven(int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess() << n << \" is even\";\n//     else\n//       return testing::AssertionFailure() << n << \" is odd\";\n//   }\n//\n// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print\n//\n//   Value of: IsEven(Fib(6))\n//     Actual: true (8 is even)\n//   Expected: false\n//\n// NB: Predicates that support negative Boolean assertions have reduced\n// performance in positive ones so be careful not to use them in tests\n// that have lots (tens of thousands) of positive Boolean assertions.\n//\n// To use this class with EXPECT_PRED_FORMAT assertions such as:\n//\n//   // Verifies that Foo() returns an even number.\n//   EXPECT_PRED_FORMAT1(IsEven, Foo());\n//\n// you need to define:\n//\n//   testing::AssertionResult IsEven(const char* expr, int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess();\n//     else\n//       return testing::AssertionFailure()\n//         << \"Expected: \" << expr << \" is even\\n  Actual: it's \" << n;\n//   }\n//\n// If Foo() returns 5, you will see the following message:\n//\n//   Expected: Foo() is even\n//     Actual: it's 5\n//\nclass GTEST_API_ AssertionResult {\n public:\n  // Copy constructor.\n  // Used in EXPECT_TRUE/FALSE(assertion_result).\n  AssertionResult(const AssertionResult& other);\n\n// C4800 is a level 3 warning in Visual Studio 2015 and earlier.\n// This warning is not emitted in Visual Studio 2017.\n// This warning is off by default starting in Visual Studio 2019 but can be\n// enabled with command-line options.\n#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)\n  GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)\n#endif\n\n  // Used in the EXPECT_TRUE/FALSE(bool_expression).\n  //\n  // T must be contextually convertible to bool.\n  //\n  // The second parameter prevents this overload from being considered if\n  // the argument is implicitly convertible to AssertionResult. In that case\n  // we want AssertionResult's copy constructor to be used.\n  template <typename T>\n  explicit AssertionResult(\n      const T& success,\n      typename std::enable_if<\n          !std::is_convertible<T, AssertionResult>::value>::type*\n      /*enabler*/\n      = nullptr)\n      : success_(success) {}\n\n#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)\n  GTEST_DISABLE_MSC_WARNINGS_POP_()\n#endif\n\n  // Assignment operator.\n  AssertionResult& operator=(AssertionResult other) {\n    swap(other);\n    return *this;\n  }\n\n  // Returns true if and only if the assertion succeeded.\n  operator bool() const { return success_; }  // NOLINT\n\n  // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.\n  AssertionResult operator!() const;\n\n  // Returns the text streamed into this AssertionResult. Test assertions\n  // use it when they fail (i.e., the predicate's outcome doesn't match the\n  // assertion's expectation). When nothing has been streamed into the\n  // object, returns an empty string.\n  const char* message() const {\n    return message_.get() != nullptr ? message_->c_str() : \"\";\n  }\n  // Deprecated; please use message() instead.\n  const char* failure_message() const { return message(); }\n\n  // Streams a custom failure message into this object.\n  template <typename T> AssertionResult& operator<<(const T& value) {\n    AppendMessage(Message() << value);\n    return *this;\n  }\n\n  // Allows streaming basic output manipulators such as endl or flush into\n  // this object.\n  AssertionResult& operator<<(\n      ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {\n    AppendMessage(Message() << basic_manipulator);\n    return *this;\n  }\n\n private:\n  // Appends the contents of message to message_.\n  void AppendMessage(const Message& a_message) {\n    if (message_.get() == nullptr) message_.reset(new ::std::string);\n    message_->append(a_message.GetString().c_str());\n  }\n\n  // Swap the contents of this AssertionResult with other.\n  void swap(AssertionResult& other);\n\n  // Stores result of the assertion predicate.\n  bool success_;\n  // Stores the message describing the condition in case the expectation\n  // construct is not satisfied with the predicate's outcome.\n  // Referenced via a pointer to avoid taking too much stack frame space\n  // with test assertions.\n  std::unique_ptr< ::std::string> message_;\n};\n\n// Makes a successful assertion result.\nGTEST_API_ AssertionResult AssertionSuccess();\n\n// Makes a failed assertion result.\nGTEST_API_ AssertionResult AssertionFailure();\n\n// Makes a failed assertion result with the given failure message.\n// Deprecated; use AssertionFailure() << msg.\nGTEST_API_ AssertionResult AssertionFailure(const Message& msg);\n\n}  // namespace testing\n\n// Includes the auto-generated header that implements a family of generic\n// predicate assertion macros. This include comes late because it relies on\n// APIs declared above.\n// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on 01/02/2019 by command\n// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!\n//\n// Implements a family of generic predicate assertion macros.\n// GOOGLETEST_CM0001 DO NOT DELETE\n\n#ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n#define GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\n\nnamespace testing {\n\n// This header implements a family of generic predicate assertion\n// macros:\n//\n//   ASSERT_PRED_FORMAT1(pred_format, v1)\n//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)\n//   ...\n//\n// where pred_format is a function or functor that takes n (in the\n// case of ASSERT_PRED_FORMATn) values and their source expression\n// text, and returns a testing::AssertionResult.  See the definition\n// of ASSERT_EQ in gtest.h for an example.\n//\n// If you don't care about formatting, you can use the more\n// restrictive version:\n//\n//   ASSERT_PRED1(pred, v1)\n//   ASSERT_PRED2(pred, v1, v2)\n//   ...\n//\n// where pred is an n-ary function or functor that returns bool,\n// and the values v1, v2, ..., must support the << operator for\n// streaming to std::ostream.\n//\n// We also define the EXPECT_* variations.\n//\n// For now we only support predicates whose arity is at most 5.\n// Please email googletestframework@googlegroups.com if you need\n// support for higher arities.\n\n// GTEST_ASSERT_ is the basic statement to which all of the assertions\n// in this file reduce.  Don't use this in your code.\n\n#define GTEST_ASSERT_(expression, on_failure) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (const ::testing::AssertionResult gtest_ar = (expression)) \\\n    ; \\\n  else \\\n    on_failure(gtest_ar.failure_message())\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1>\nAssertionResult AssertPred1Helper(const char* pred_text,\n                                  const char* e1,\n                                  Pred pred,\n                                  const T1& v1) {\n  if (pred(v1)) return AssertionSuccess();\n\n  return AssertionFailure()\n         << pred_text << \"(\" << e1 << \") evaluates to false, where\"\n         << \"\\n\"\n         << e1 << \" evaluates to \" << ::testing::PrintToString(v1);\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, v1), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use\n// this in your code.\n#define GTEST_PRED1_(pred, v1, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \\\n                                             #v1, \\\n                                             pred, \\\n                                             v1), on_failure)\n\n// Unary predicate assertion macros.\n#define EXPECT_PRED_FORMAT1(pred_format, v1) \\\n  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED1(pred, v1) \\\n  GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT1(pred_format, v1) \\\n  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED1(pred, v1) \\\n  GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2>\nAssertionResult AssertPred2Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2) {\n  if (pred(v1, v2)) return AssertionSuccess();\n\n  return AssertionFailure()\n         << pred_text << \"(\" << e1 << \", \" << e2\n         << \") evaluates to false, where\"\n         << \"\\n\"\n         << e1 << \" evaluates to \" << ::testing::PrintToString(v1) << \"\\n\"\n         << e2 << \" evaluates to \" << ::testing::PrintToString(v2);\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use\n// this in your code.\n#define GTEST_PRED2_(pred, v1, v2, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2), on_failure)\n\n// Binary predicate assertion macros.\n#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \\\n  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED2(pred, v1, v2) \\\n  GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \\\n  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED2(pred, v1, v2) \\\n  GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3>\nAssertionResult AssertPred3Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3) {\n  if (pred(v1, v2, v3)) return AssertionSuccess();\n\n  return AssertionFailure()\n         << pred_text << \"(\" << e1 << \", \" << e2 << \", \" << e3\n         << \") evaluates to false, where\"\n         << \"\\n\"\n         << e1 << \" evaluates to \" << ::testing::PrintToString(v1) << \"\\n\"\n         << e2 << \" evaluates to \" << ::testing::PrintToString(v2) << \"\\n\"\n         << e3 << \" evaluates to \" << ::testing::PrintToString(v3);\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use\n// this in your code.\n#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3), on_failure)\n\n// Ternary predicate assertion macros.\n#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \\\n  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED3(pred, v1, v2, v3) \\\n  GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \\\n  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED3(pred, v1, v2, v3) \\\n  GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3,\n          typename T4>\nAssertionResult AssertPred4Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  const char* e4,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3,\n                                  const T4& v4) {\n  if (pred(v1, v2, v3, v4)) return AssertionSuccess();\n\n  return AssertionFailure()\n         << pred_text << \"(\" << e1 << \", \" << e2 << \", \" << e3 << \", \" << e4\n         << \") evaluates to false, where\"\n         << \"\\n\"\n         << e1 << \" evaluates to \" << ::testing::PrintToString(v1) << \"\\n\"\n         << e2 << \" evaluates to \" << ::testing::PrintToString(v2) << \"\\n\"\n         << e3 << \" evaluates to \" << ::testing::PrintToString(v3) << \"\\n\"\n         << e4 << \" evaluates to \" << ::testing::PrintToString(v4);\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use\n// this in your code.\n#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             #v4, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3, \\\n                                             v4), on_failure)\n\n// 4-ary predicate assertion macros.\n#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \\\n  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED4(pred, v1, v2, v3, v4) \\\n  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \\\n  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED4(pred, v1, v2, v3, v4) \\\n  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3,\n          typename T4,\n          typename T5>\nAssertionResult AssertPred5Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  const char* e4,\n                                  const char* e5,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3,\n                                  const T4& v4,\n                                  const T5& v5) {\n  if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();\n\n  return AssertionFailure()\n         << pred_text << \"(\" << e1 << \", \" << e2 << \", \" << e3 << \", \" << e4\n         << \", \" << e5 << \") evaluates to false, where\"\n         << \"\\n\"\n         << e1 << \" evaluates to \" << ::testing::PrintToString(v1) << \"\\n\"\n         << e2 << \" evaluates to \" << ::testing::PrintToString(v2) << \"\\n\"\n         << e3 << \" evaluates to \" << ::testing::PrintToString(v3) << \"\\n\"\n         << e4 << \" evaluates to \" << ::testing::PrintToString(v4) << \"\\n\"\n         << e5 << \" evaluates to \" << ::testing::PrintToString(v5);\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use\n// this in your code.\n#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             #v4, \\\n                                             #v5, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3, \\\n                                             v4, \\\n                                             v5), on_failure)\n\n// 5-ary predicate assertion macros.\n#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \\\n  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \\\n  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \\\n  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \\\n  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)\n\n\n\n}  // namespace testing\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\nnamespace testing {\n\n// The abstract class that all tests inherit from.\n//\n// In Google Test, a unit test program contains one or many TestSuites, and\n// each TestSuite contains one or many Tests.\n//\n// When you define a test using the TEST macro, you don't need to\n// explicitly derive from Test - the TEST macro automatically does\n// this for you.\n//\n// The only time you derive from Test is when defining a test fixture\n// to be used in a TEST_F.  For example:\n//\n//   class FooTest : public testing::Test {\n//    protected:\n//     void SetUp() override { ... }\n//     void TearDown() override { ... }\n//     ...\n//   };\n//\n//   TEST_F(FooTest, Bar) { ... }\n//   TEST_F(FooTest, Baz) { ... }\n//\n// Test is not copyable.\nclass GTEST_API_ Test {\n public:\n  friend class TestInfo;\n\n  // The d'tor is virtual as we intend to inherit from Test.\n  virtual ~Test();\n\n  // Sets up the stuff shared by all tests in this test suite.\n  //\n  // Google Test will call Foo::SetUpTestSuite() before running the first\n  // test in test suite Foo.  Hence a sub-class can define its own\n  // SetUpTestSuite() method to shadow the one defined in the super\n  // class.\n  static void SetUpTestSuite() {}\n\n  // Tears down the stuff shared by all tests in this test suite.\n  //\n  // Google Test will call Foo::TearDownTestSuite() after running the last\n  // test in test suite Foo.  Hence a sub-class can define its own\n  // TearDownTestSuite() method to shadow the one defined in the super\n  // class.\n  static void TearDownTestSuite() {}\n\n  // Legacy API is deprecated but still available. Use SetUpTestSuite and\n  // TearDownTestSuite instead.\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  static void TearDownTestCase() {}\n  static void SetUpTestCase() {}\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Returns true if and only if the current test has a fatal failure.\n  static bool HasFatalFailure();\n\n  // Returns true if and only if the current test has a non-fatal failure.\n  static bool HasNonfatalFailure();\n\n  // Returns true if and only if the current test was skipped.\n  static bool IsSkipped();\n\n  // Returns true if and only if the current test has a (either fatal or\n  // non-fatal) failure.\n  static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }\n\n  // Logs a property for the current test, test suite, or for the entire\n  // invocation of the test program when used outside of the context of a\n  // test suite.  Only the last value for a given key is remembered.  These\n  // are public static so they can be called from utility functions that are\n  // not members of the test fixture.  Calls to RecordProperty made during\n  // lifespan of the test (from the moment its constructor starts to the\n  // moment its destructor finishes) will be output in XML as attributes of\n  // the <testcase> element.  Properties recorded from fixture's\n  // SetUpTestSuite or TearDownTestSuite are logged as attributes of the\n  // corresponding <testsuite> element.  Calls to RecordProperty made in the\n  // global context (before or after invocation of RUN_ALL_TESTS and from\n  // SetUp/TearDown method of Environment objects registered with Google\n  // Test) will be output as attributes of the <testsuites> element.\n  static void RecordProperty(const std::string& key, const std::string& value);\n  static void RecordProperty(const std::string& key, int value);\n\n protected:\n  // Creates a Test object.\n  Test();\n\n  // Sets up the test fixture.\n  virtual void SetUp();\n\n  // Tears down the test fixture.\n  virtual void TearDown();\n\n private:\n  // Returns true if and only if the current test has the same fixture class\n  // as the first test in the current test suite.\n  static bool HasSameFixtureClass();\n\n  // Runs the test after the test fixture has been set up.\n  //\n  // A sub-class must implement this to define the test logic.\n  //\n  // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.\n  // Instead, use the TEST or TEST_F macro.\n  virtual void TestBody() = 0;\n\n  // Sets up, executes, and tears down the test.\n  void Run();\n\n  // Deletes self.  We deliberately pick an unusual name for this\n  // internal method to avoid clashing with names used in user TESTs.\n  void DeleteSelf_() { delete this; }\n\n  const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;\n\n  // Often a user misspells SetUp() as Setup() and spends a long time\n  // wondering why it is never called by Google Test.  The declaration of\n  // the following method is solely for catching such an error at\n  // compile time:\n  //\n  //   - The return type is deliberately chosen to be not void, so it\n  //   will be a conflict if void Setup() is declared in the user's\n  //   test fixture.\n  //\n  //   - This method is private, so it will be another compiler error\n  //   if the method is called from the user's test fixture.\n  //\n  // DO NOT OVERRIDE THIS FUNCTION.\n  //\n  // If you see an error about overriding the following function or\n  // about it being private, you have mis-spelled SetUp() as Setup().\n  struct Setup_should_be_spelled_SetUp {};\n  virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }\n\n  // We disallow copying Tests.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);\n};\n\ntypedef internal::TimeInMillis TimeInMillis;\n\n// A copyable object representing a user specified test property which can be\n// output as a key/value string pair.\n//\n// Don't inherit from TestProperty as its destructor is not virtual.\nclass TestProperty {\n public:\n  // C'tor.  TestProperty does NOT have a default constructor.\n  // Always use this constructor (with parameters) to create a\n  // TestProperty object.\n  TestProperty(const std::string& a_key, const std::string& a_value) :\n    key_(a_key), value_(a_value) {\n  }\n\n  // Gets the user supplied key.\n  const char* key() const {\n    return key_.c_str();\n  }\n\n  // Gets the user supplied value.\n  const char* value() const {\n    return value_.c_str();\n  }\n\n  // Sets a new value, overriding the one supplied in the constructor.\n  void SetValue(const std::string& new_value) {\n    value_ = new_value;\n  }\n\n private:\n  // The key supplied by the user.\n  std::string key_;\n  // The value supplied by the user.\n  std::string value_;\n};\n\n// The result of a single Test.  This includes a list of\n// TestPartResults, a list of TestProperties, a count of how many\n// death tests there are in the Test, and how much time it took to run\n// the Test.\n//\n// TestResult is not copyable.\nclass GTEST_API_ TestResult {\n public:\n  // Creates an empty TestResult.\n  TestResult();\n\n  // D'tor.  Do not inherit from TestResult.\n  ~TestResult();\n\n  // Gets the number of all test parts.  This is the sum of the number\n  // of successful test parts and the number of failed test parts.\n  int total_part_count() const;\n\n  // Returns the number of the test properties.\n  int test_property_count() const;\n\n  // Returns true if and only if the test passed (i.e. no test part failed).\n  bool Passed() const { return !Skipped() && !Failed(); }\n\n  // Returns true if and only if the test was skipped.\n  bool Skipped() const;\n\n  // Returns true if and only if the test failed.\n  bool Failed() const;\n\n  // Returns true if and only if the test fatally failed.\n  bool HasFatalFailure() const;\n\n  // Returns true if and only if the test has a non-fatal failure.\n  bool HasNonfatalFailure() const;\n\n  // Returns the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Gets the time of the test case start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const { return start_timestamp_; }\n\n  // Returns the i-th test part result among all the results. i can range from 0\n  // to total_part_count() - 1. If i is not in that range, aborts the program.\n  const TestPartResult& GetTestPartResult(int i) const;\n\n  // Returns the i-th test property. i can range from 0 to\n  // test_property_count() - 1. If i is not in that range, aborts the\n  // program.\n  const TestProperty& GetTestProperty(int i) const;\n\n private:\n  friend class TestInfo;\n  friend class TestSuite;\n  friend class UnitTest;\n  friend class internal::DefaultGlobalTestPartResultReporter;\n  friend class internal::ExecDeathTest;\n  friend class internal::TestResultAccessor;\n  friend class internal::UnitTestImpl;\n  friend class internal::WindowsDeathTest;\n  friend class internal::FuchsiaDeathTest;\n\n  // Gets the vector of TestPartResults.\n  const std::vector<TestPartResult>& test_part_results() const {\n    return test_part_results_;\n  }\n\n  // Gets the vector of TestProperties.\n  const std::vector<TestProperty>& test_properties() const {\n    return test_properties_;\n  }\n\n  // Sets the start time.\n  void set_start_timestamp(TimeInMillis start) { start_timestamp_ = start; }\n\n  // Sets the elapsed time.\n  void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }\n\n  // Adds a test property to the list. The property is validated and may add\n  // a non-fatal failure if invalid (e.g., if it conflicts with reserved\n  // key names). If a property is already recorded for the same key, the\n  // value will be updated, rather than storing multiple values for the same\n  // key.  xml_element specifies the element for which the property is being\n  // recorded and is used for validation.\n  void RecordProperty(const std::string& xml_element,\n                      const TestProperty& test_property);\n\n  // Adds a failure if the key is a reserved attribute of Google Test\n  // testsuite tags.  Returns true if the property is valid.\n  // FIXME: Validate attribute names are legal and human readable.\n  static bool ValidateTestProperty(const std::string& xml_element,\n                                   const TestProperty& test_property);\n\n  // Adds a test part result to the list.\n  void AddTestPartResult(const TestPartResult& test_part_result);\n\n  // Returns the death test count.\n  int death_test_count() const { return death_test_count_; }\n\n  // Increments the death test count, returning the new count.\n  int increment_death_test_count() { return ++death_test_count_; }\n\n  // Clears the test part results.\n  void ClearTestPartResults();\n\n  // Clears the object.\n  void Clear();\n\n  // Protects mutable state of the property vector and of owned\n  // properties, whose values may be updated.\n  internal::Mutex test_properties_mutex_;\n\n  // The vector of TestPartResults\n  std::vector<TestPartResult> test_part_results_;\n  // The vector of TestProperties\n  std::vector<TestProperty> test_properties_;\n  // Running count of death tests.\n  int death_test_count_;\n  // The start time, in milliseconds since UNIX Epoch.\n  TimeInMillis start_timestamp_;\n  // The elapsed time, in milliseconds.\n  TimeInMillis elapsed_time_;\n\n  // We disallow copying TestResult.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);\n};  // class TestResult\n\n// A TestInfo object stores the following information about a test:\n//\n//   Test suite name\n//   Test name\n//   Whether the test should be run\n//   A function pointer that creates the test object when invoked\n//   Test result\n//\n// The constructor of TestInfo registers itself with the UnitTest\n// singleton such that the RUN_ALL_TESTS() macro knows which tests to\n// run.\nclass GTEST_API_ TestInfo {\n public:\n  // Destructs a TestInfo object.  This function is not virtual, so\n  // don't inherit from TestInfo.\n  ~TestInfo();\n\n  // Returns the test suite name.\n  const char* test_suite_name() const { return test_suite_name_.c_str(); }\n\n// Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  const char* test_case_name() const { return test_suite_name(); }\n#endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Returns the test name.\n  const char* name() const { return name_.c_str(); }\n\n  // Returns the name of the parameter type, or NULL if this is not a typed\n  // or a type-parameterized test.\n  const char* type_param() const {\n    if (type_param_.get() != nullptr) return type_param_->c_str();\n    return nullptr;\n  }\n\n  // Returns the text representation of the value parameter, or NULL if this\n  // is not a value-parameterized test.\n  const char* value_param() const {\n    if (value_param_.get() != nullptr) return value_param_->c_str();\n    return nullptr;\n  }\n\n  // Returns the file name where this test is defined.\n  const char* file() const { return location_.file.c_str(); }\n\n  // Returns the line where this test is defined.\n  int line() const { return location_.line; }\n\n  // Return true if this test should not be run because it's in another shard.\n  bool is_in_another_shard() const { return is_in_another_shard_; }\n\n  // Returns true if this test should run, that is if the test is not\n  // disabled (or it is disabled but the also_run_disabled_tests flag has\n  // been specified) and its full name matches the user-specified filter.\n  //\n  // Google Test allows the user to filter the tests by their full names.\n  // The full name of a test Bar in test suite Foo is defined as\n  // \"Foo.Bar\".  Only the tests that match the filter will run.\n  //\n  // A filter is a colon-separated list of glob (not regex) patterns,\n  // optionally followed by a '-' and a colon-separated list of\n  // negative patterns (tests to exclude).  A test is run if it\n  // matches one of the positive patterns and does not match any of\n  // the negative patterns.\n  //\n  // For example, *A*:Foo.* is a filter that matches any string that\n  // contains the character 'A' or starts with \"Foo.\".\n  bool should_run() const { return should_run_; }\n\n  // Returns true if and only if this test will appear in the XML report.\n  bool is_reportable() const {\n    // The XML report includes tests matching the filter, excluding those\n    // run in other shards.\n    return matches_filter_ && !is_in_another_shard_;\n  }\n\n  // Returns the result of the test.\n  const TestResult* result() const { return &result_; }\n\n private:\n#if GTEST_HAS_DEATH_TEST\n  friend class internal::DefaultDeathTestFactory;\n#endif  // GTEST_HAS_DEATH_TEST\n  friend class Test;\n  friend class TestSuite;\n  friend class internal::UnitTestImpl;\n  friend class internal::StreamingListenerTest;\n  friend TestInfo* internal::MakeAndRegisterTestInfo(\n      const char* test_suite_name, const char* name, const char* type_param,\n      const char* value_param, internal::CodeLocation code_location,\n      internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,\n      internal::TearDownTestSuiteFunc tear_down_tc,\n      internal::TestFactoryBase* factory);\n\n  // Constructs a TestInfo object. The newly constructed instance assumes\n  // ownership of the factory object.\n  TestInfo(const std::string& test_suite_name, const std::string& name,\n           const char* a_type_param,   // NULL if not a type-parameterized test\n           const char* a_value_param,  // NULL if not a value-parameterized test\n           internal::CodeLocation a_code_location,\n           internal::TypeId fixture_class_id,\n           internal::TestFactoryBase* factory);\n\n  // Increments the number of death tests encountered in this test so\n  // far.\n  int increment_death_test_count() {\n    return result_.increment_death_test_count();\n  }\n\n  // Creates the test object, runs it, records its result, and then\n  // deletes it.\n  void Run();\n\n  // Skip and records the test result for this object.\n  void Skip();\n\n  static void ClearTestResult(TestInfo* test_info) {\n    test_info->result_.Clear();\n  }\n\n  // These fields are immutable properties of the test.\n  const std::string test_suite_name_;    // test suite name\n  const std::string name_;               // Test name\n  // Name of the parameter type, or NULL if this is not a typed or a\n  // type-parameterized test.\n  const std::unique_ptr<const ::std::string> type_param_;\n  // Text representation of the value parameter, or NULL if this is not a\n  // value-parameterized test.\n  const std::unique_ptr<const ::std::string> value_param_;\n  internal::CodeLocation location_;\n  const internal::TypeId fixture_class_id_;  // ID of the test fixture class\n  bool should_run_;           // True if and only if this test should run\n  bool is_disabled_;          // True if and only if this test is disabled\n  bool matches_filter_;       // True if this test matches the\n                              // user-specified filter.\n  bool is_in_another_shard_;  // Will be run in another shard.\n  internal::TestFactoryBase* const factory_;  // The factory that creates\n                                              // the test object\n\n  // This field is mutable and needs to be reset before running the\n  // test for the second time.\n  TestResult result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);\n};\n\n// A test suite, which consists of a vector of TestInfos.\n//\n// TestSuite is not copyable.\nclass GTEST_API_ TestSuite {\n public:\n  // Creates a TestSuite with the given name.\n  //\n  // TestSuite does NOT have a default constructor.  Always use this\n  // constructor to create a TestSuite object.\n  //\n  // Arguments:\n  //\n  //   name:         name of the test suite\n  //   a_type_param: the name of the test's type parameter, or NULL if\n  //                 this is not a type-parameterized test.\n  //   set_up_tc:    pointer to the function that sets up the test suite\n  //   tear_down_tc: pointer to the function that tears down the test suite\n  TestSuite(const char* name, const char* a_type_param,\n            internal::SetUpTestSuiteFunc set_up_tc,\n            internal::TearDownTestSuiteFunc tear_down_tc);\n\n  // Destructor of TestSuite.\n  virtual ~TestSuite();\n\n  // Gets the name of the TestSuite.\n  const char* name() const { return name_.c_str(); }\n\n  // Returns the name of the parameter type, or NULL if this is not a\n  // type-parameterized test suite.\n  const char* type_param() const {\n    if (type_param_.get() != nullptr) return type_param_->c_str();\n    return nullptr;\n  }\n\n  // Returns true if any test in this test suite should run.\n  bool should_run() const { return should_run_; }\n\n  // Gets the number of successful tests in this test suite.\n  int successful_test_count() const;\n\n  // Gets the number of skipped tests in this test suite.\n  int skipped_test_count() const;\n\n  // Gets the number of failed tests in this test suite.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests in this test suite.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Get the number of tests in this test suite that should run.\n  int test_to_run_count() const;\n\n  // Gets the number of all tests in this test suite.\n  int total_test_count() const;\n\n  // Returns true if and only if the test suite passed.\n  bool Passed() const { return !Failed(); }\n\n  // Returns true if and only if the test suite failed.\n  bool Failed() const {\n    return failed_test_count() > 0 || ad_hoc_test_result().Failed();\n  }\n\n  // Returns the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Gets the time of the test suite start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const { return start_timestamp_; }\n\n  // Returns the i-th test among all the tests. i can range from 0 to\n  // total_test_count() - 1. If i is not in that range, returns NULL.\n  const TestInfo* GetTestInfo(int i) const;\n\n  // Returns the TestResult that holds test properties recorded during\n  // execution of SetUpTestSuite and TearDownTestSuite.\n  const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }\n\n private:\n  friend class Test;\n  friend class internal::UnitTestImpl;\n\n  // Gets the (mutable) vector of TestInfos in this TestSuite.\n  std::vector<TestInfo*>& test_info_list() { return test_info_list_; }\n\n  // Gets the (immutable) vector of TestInfos in this TestSuite.\n  const std::vector<TestInfo*>& test_info_list() const {\n    return test_info_list_;\n  }\n\n  // Returns the i-th test among all the tests. i can range from 0 to\n  // total_test_count() - 1. If i is not in that range, returns NULL.\n  TestInfo* GetMutableTestInfo(int i);\n\n  // Sets the should_run member.\n  void set_should_run(bool should) { should_run_ = should; }\n\n  // Adds a TestInfo to this test suite.  Will delete the TestInfo upon\n  // destruction of the TestSuite object.\n  void AddTestInfo(TestInfo * test_info);\n\n  // Clears the results of all tests in this test suite.\n  void ClearResult();\n\n  // Clears the results of all tests in the given test suite.\n  static void ClearTestSuiteResult(TestSuite* test_suite) {\n    test_suite->ClearResult();\n  }\n\n  // Runs every test in this TestSuite.\n  void Run();\n\n  // Skips the execution of tests under this TestSuite\n  void Skip();\n\n  // Runs SetUpTestSuite() for this TestSuite.  This wrapper is needed\n  // for catching exceptions thrown from SetUpTestSuite().\n  void RunSetUpTestSuite() {\n    if (set_up_tc_ != nullptr) {\n      (*set_up_tc_)();\n    }\n  }\n\n  // Runs TearDownTestSuite() for this TestSuite.  This wrapper is\n  // needed for catching exceptions thrown from TearDownTestSuite().\n  void RunTearDownTestSuite() {\n    if (tear_down_tc_ != nullptr) {\n      (*tear_down_tc_)();\n    }\n  }\n\n  // Returns true if and only if test passed.\n  static bool TestPassed(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Passed();\n  }\n\n  // Returns true if and only if test skipped.\n  static bool TestSkipped(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Skipped();\n  }\n\n  // Returns true if and only if test failed.\n  static bool TestFailed(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Failed();\n  }\n\n  // Returns true if and only if the test is disabled and will be reported in\n  // the XML report.\n  static bool TestReportableDisabled(const TestInfo* test_info) {\n    return test_info->is_reportable() && test_info->is_disabled_;\n  }\n\n  // Returns true if and only if test is disabled.\n  static bool TestDisabled(const TestInfo* test_info) {\n    return test_info->is_disabled_;\n  }\n\n  // Returns true if and only if this test will appear in the XML report.\n  static bool TestReportable(const TestInfo* test_info) {\n    return test_info->is_reportable();\n  }\n\n  // Returns true if the given test should run.\n  static bool ShouldRunTest(const TestInfo* test_info) {\n    return test_info->should_run();\n  }\n\n  // Shuffles the tests in this test suite.\n  void ShuffleTests(internal::Random* random);\n\n  // Restores the test order to before the first shuffle.\n  void UnshuffleTests();\n\n  // Name of the test suite.\n  std::string name_;\n  // Name of the parameter type, or NULL if this is not a typed or a\n  // type-parameterized test.\n  const std::unique_ptr<const ::std::string> type_param_;\n  // The vector of TestInfos in their original order.  It owns the\n  // elements in the vector.\n  std::vector<TestInfo*> test_info_list_;\n  // Provides a level of indirection for the test list to allow easy\n  // shuffling and restoring the test order.  The i-th element in this\n  // vector is the index of the i-th test in the shuffled test list.\n  std::vector<int> test_indices_;\n  // Pointer to the function that sets up the test suite.\n  internal::SetUpTestSuiteFunc set_up_tc_;\n  // Pointer to the function that tears down the test suite.\n  internal::TearDownTestSuiteFunc tear_down_tc_;\n  // True if and only if any test in this test suite should run.\n  bool should_run_;\n  // The start time, in milliseconds since UNIX Epoch.\n  TimeInMillis start_timestamp_;\n  // Elapsed time, in milliseconds.\n  TimeInMillis elapsed_time_;\n  // Holds test properties recorded during execution of SetUpTestSuite and\n  // TearDownTestSuite.\n  TestResult ad_hoc_test_result_;\n\n  // We disallow copying TestSuites.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);\n};\n\n// An Environment object is capable of setting up and tearing down an\n// environment.  You should subclass this to define your own\n// environment(s).\n//\n// An Environment object does the set-up and tear-down in virtual\n// methods SetUp() and TearDown() instead of the constructor and the\n// destructor, as:\n//\n//   1. You cannot safely throw from a destructor.  This is a problem\n//      as in some cases Google Test is used where exceptions are enabled, and\n//      we may want to implement ASSERT_* using exceptions where they are\n//      available.\n//   2. You cannot use ASSERT_* directly in a constructor or\n//      destructor.\nclass Environment {\n public:\n  // The d'tor is virtual as we need to subclass Environment.\n  virtual ~Environment() {}\n\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n private:\n  // If you see an error about overriding the following function or\n  // about it being private, you have mis-spelled SetUp() as Setup().\n  struct Setup_should_be_spelled_SetUp {};\n  virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }\n};\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Exception which can be thrown from TestEventListener::OnTestPartResult.\nclass GTEST_API_ AssertionException\n    : public internal::GoogleTestFailureException {\n public:\n  explicit AssertionException(const TestPartResult& result)\n      : GoogleTestFailureException(result) {}\n};\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// The interface for tracing execution of tests. The methods are organized in\n// the order the corresponding events are fired.\nclass TestEventListener {\n public:\n  virtual ~TestEventListener() {}\n\n  // Fired before any test activity starts.\n  virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;\n\n  // Fired before each iteration of tests starts.  There may be more than\n  // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration\n  // index, starting from 0.\n  virtual void OnTestIterationStart(const UnitTest& unit_test,\n                                    int iteration) = 0;\n\n  // Fired before environment set-up for each iteration of tests starts.\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;\n\n  // Fired after environment set-up for each iteration of tests ends.\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;\n\n  // Fired before the test suite starts.\n  virtual void OnTestSuiteStart(const TestSuite& /*test_suite*/) {}\n\n  //  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Fired before the test starts.\n  virtual void OnTestStart(const TestInfo& test_info) = 0;\n\n  // Fired after a failed assertion or a SUCCEED() invocation.\n  // If you want to throw an exception from this function to skip to the next\n  // TEST, it must be AssertionException defined above, or inherited from it.\n  virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;\n\n  // Fired after the test ends.\n  virtual void OnTestEnd(const TestInfo& test_info) = 0;\n\n  // Fired after the test suite ends.\n  virtual void OnTestSuiteEnd(const TestSuite& /*test_suite*/) {}\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Fired before environment tear-down for each iteration of tests starts.\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;\n\n  // Fired after environment tear-down for each iteration of tests ends.\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;\n\n  // Fired after each iteration of tests finishes.\n  virtual void OnTestIterationEnd(const UnitTest& unit_test,\n                                  int iteration) = 0;\n\n  // Fired after all test activities have ended.\n  virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;\n};\n\n// The convenience class for users who need to override just one or two\n// methods and are not concerned that a possible change to a signature of\n// the methods they override will not be caught during the build.  For\n// comments about each method please see the definition of TestEventListener\n// above.\nclass EmptyTestEventListener : public TestEventListener {\n public:\n  void OnTestProgramStart(const UnitTest& /*unit_test*/) override {}\n  void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                            int /*iteration*/) override {}\n  void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {}\n  void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {}\n  void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {}\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseStart(const TestCase& /*test_case*/) override {}\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  void OnTestStart(const TestInfo& /*test_info*/) override {}\n  void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {}\n  void OnTestEnd(const TestInfo& /*test_info*/) override {}\n  void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {}\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  void OnTestCaseEnd(const TestCase& /*test_case*/) override {}\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {}\n  void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {}\n  void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                          int /*iteration*/) override {}\n  void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {}\n};\n\n// TestEventListeners lets users add listeners to track events in Google Test.\nclass GTEST_API_ TestEventListeners {\n public:\n  TestEventListeners();\n  ~TestEventListeners();\n\n  // Appends an event listener to the end of the list. Google Test assumes\n  // the ownership of the listener (i.e. it will delete the listener when\n  // the test program finishes).\n  void Append(TestEventListener* listener);\n\n  // Removes the given event listener from the list and returns it.  It then\n  // becomes the caller's responsibility to delete the listener. Returns\n  // NULL if the listener is not found in the list.\n  TestEventListener* Release(TestEventListener* listener);\n\n  // Returns the standard listener responsible for the default console\n  // output.  Can be removed from the listeners list to shut down default\n  // console output.  Note that removing this object from the listener list\n  // with Release transfers its ownership to the caller and makes this\n  // function return NULL the next time.\n  TestEventListener* default_result_printer() const {\n    return default_result_printer_;\n  }\n\n  // Returns the standard listener responsible for the default XML output\n  // controlled by the --gtest_output=xml flag.  Can be removed from the\n  // listeners list by users who want to shut down the default XML output\n  // controlled by this flag and substitute it with custom one.  Note that\n  // removing this object from the listener list with Release transfers its\n  // ownership to the caller and makes this function return NULL the next\n  // time.\n  TestEventListener* default_xml_generator() const {\n    return default_xml_generator_;\n  }\n\n private:\n  friend class TestSuite;\n  friend class TestInfo;\n  friend class internal::DefaultGlobalTestPartResultReporter;\n  friend class internal::NoExecDeathTest;\n  friend class internal::TestEventListenersAccessor;\n  friend class internal::UnitTestImpl;\n\n  // Returns repeater that broadcasts the TestEventListener events to all\n  // subscribers.\n  TestEventListener* repeater();\n\n  // Sets the default_result_printer attribute to the provided listener.\n  // The listener is also added to the listener list and previous\n  // default_result_printer is removed from it and deleted. The listener can\n  // also be NULL in which case it will not be added to the list. Does\n  // nothing if the previous and the current listener objects are the same.\n  void SetDefaultResultPrinter(TestEventListener* listener);\n\n  // Sets the default_xml_generator attribute to the provided listener.  The\n  // listener is also added to the listener list and previous\n  // default_xml_generator is removed from it and deleted. The listener can\n  // also be NULL in which case it will not be added to the list. Does\n  // nothing if the previous and the current listener objects are the same.\n  void SetDefaultXmlGenerator(TestEventListener* listener);\n\n  // Controls whether events will be forwarded by the repeater to the\n  // listeners in the list.\n  bool EventForwardingEnabled() const;\n  void SuppressEventForwarding();\n\n  // The actual list of listeners.\n  internal::TestEventRepeater* repeater_;\n  // Listener responsible for the standard result output.\n  TestEventListener* default_result_printer_;\n  // Listener responsible for the creation of the XML output file.\n  TestEventListener* default_xml_generator_;\n\n  // We disallow copying TestEventListeners.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);\n};\n\n// A UnitTest consists of a vector of TestSuites.\n//\n// This is a singleton class.  The only instance of UnitTest is\n// created when UnitTest::GetInstance() is first called.  This\n// instance is never deleted.\n//\n// UnitTest is not copyable.\n//\n// This class is thread-safe as long as the methods are called\n// according to their specification.\nclass GTEST_API_ UnitTest {\n public:\n  // Gets the singleton UnitTest object.  The first time this method\n  // is called, a UnitTest object is constructed and returned.\n  // Consecutive calls will return the same object.\n  static UnitTest* GetInstance();\n\n  // Runs all tests in this UnitTest object and prints the result.\n  // Returns 0 if successful, or 1 otherwise.\n  //\n  // This method can only be called from the main thread.\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  int Run() GTEST_MUST_USE_RESULT_;\n\n  // Returns the working directory when the first TEST() or TEST_F()\n  // was executed.  The UnitTest object owns the string.\n  const char* original_working_dir() const;\n\n  // Returns the TestSuite object for the test that's currently running,\n  // or NULL if no test is running.\n  const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);\n\n// Legacy API is still available but deprecated\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_);\n#endif\n\n  // Returns the TestInfo object for the test that's currently running,\n  // or NULL if no test is running.\n  const TestInfo* current_test_info() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Returns the random seed used at the start of the current test run.\n  int random_seed() const;\n\n  // Returns the ParameterizedTestSuiteRegistry object used to keep track of\n  // value-parameterized tests and instantiate and register them.\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Gets the number of successful test suites.\n  int successful_test_suite_count() const;\n\n  // Gets the number of failed test suites.\n  int failed_test_suite_count() const;\n\n  // Gets the number of all test suites.\n  int total_test_suite_count() const;\n\n  // Gets the number of all test suites that contain at least one test\n  // that should run.\n  int test_suite_to_run_count() const;\n\n  //  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  int successful_test_case_count() const;\n  int failed_test_case_count() const;\n  int total_test_case_count() const;\n  int test_case_to_run_count() const;\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Gets the number of successful tests.\n  int successful_test_count() const;\n\n  // Gets the number of skipped tests.\n  int skipped_test_count() const;\n\n  // Gets the number of failed tests.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Gets the number of all tests.\n  int total_test_count() const;\n\n  // Gets the number of tests that should run.\n  int test_to_run_count() const;\n\n  // Gets the time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const;\n\n  // Gets the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const;\n\n  // Returns true if and only if the unit test passed (i.e. all test suites\n  // passed).\n  bool Passed() const;\n\n  // Returns true if and only if the unit test failed (i.e. some test suite\n  // failed or something outside of all tests failed).\n  bool Failed() const;\n\n  // Gets the i-th test suite among all the test suites. i can range from 0 to\n  // total_test_suite_count() - 1. If i is not in that range, returns NULL.\n  const TestSuite* GetTestSuite(int i) const;\n\n//  Legacy API is deprecated but still available\n#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n  const TestCase* GetTestCase(int i) const;\n#endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_\n\n  // Returns the TestResult containing information on test failures and\n  // properties logged outside of individual test suites.\n  const TestResult& ad_hoc_test_result() const;\n\n  // Returns the list of event listeners that can be used to track events\n  // inside Google Test.\n  TestEventListeners& listeners();\n\n private:\n  // Registers and returns a global test environment.  When a test\n  // program is run, all global test environments will be set-up in\n  // the order they were registered.  After all tests in the program\n  // have finished, all global test environments will be torn-down in\n  // the *reverse* order they were registered.\n  //\n  // The UnitTest object takes ownership of the given environment.\n  //\n  // This method can only be called from the main thread.\n  Environment* AddEnvironment(Environment* env);\n\n  // Adds a TestPartResult to the current TestResult object.  All\n  // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)\n  // eventually call this to report their results.  The user code\n  // should use the assertion macros instead of calling this directly.\n  void AddTestPartResult(TestPartResult::Type result_type,\n                         const char* file_name,\n                         int line_number,\n                         const std::string& message,\n                         const std::string& os_stack_trace)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Adds a TestProperty to the current TestResult object when invoked from\n  // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked\n  // from SetUpTestSuite or TearDownTestSuite, or to the global property set\n  // when invoked elsewhere.  If the result already contains a property with\n  // the same key, the value will be updated.\n  void RecordProperty(const std::string& key, const std::string& value);\n\n  // Gets the i-th test suite among all the test suites. i can range from 0 to\n  // total_test_suite_count() - 1. If i is not in that range, returns NULL.\n  TestSuite* GetMutableTestSuite(int i);\n\n  // Accessors for the implementation object.\n  internal::UnitTestImpl* impl() { return impl_; }\n  const internal::UnitTestImpl* impl() const { return impl_; }\n\n  // These classes and functions are friends as they need to access private\n  // members of UnitTest.\n  friend class ScopedTrace;\n  friend class Test;\n  friend class internal::AssertHelper;\n  friend class internal::StreamingListenerTest;\n  friend class internal::UnitTestRecordPropertyTestHelper;\n  friend Environment* AddGlobalTestEnvironment(Environment* env);\n  friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites();\n  friend internal::UnitTestImpl* internal::GetUnitTestImpl();\n  friend void internal::ReportFailureInUnknownLocation(\n      TestPartResult::Type result_type,\n      const std::string& message);\n\n  // Creates an empty UnitTest.\n  UnitTest();\n\n  // D'tor\n  virtual ~UnitTest();\n\n  // Pushes a trace defined by SCOPED_TRACE() on to the per-thread\n  // Google Test trace stack.\n  void PushGTestTrace(const internal::TraceInfo& trace)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Pops a trace from the per-thread Google Test trace stack.\n  void PopGTestTrace()\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Protects mutable state in *impl_.  This is mutable as some const\n  // methods need to lock it too.\n  mutable internal::Mutex mutex_;\n\n  // Opaque implementation object.  This field is never changed once\n  // the object is constructed.  We don't mark it as const here, as\n  // doing so will cause a warning in the constructor of UnitTest.\n  // Mutable state in *impl_ is protected by mutex_.\n  internal::UnitTestImpl* impl_;\n\n  // We disallow copying UnitTest.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);\n};\n\n// A convenient wrapper for adding an environment for the test\n// program.\n//\n// You should call this before RUN_ALL_TESTS() is called, probably in\n// main().  If you use gtest_main, you need to call this before main()\n// starts for it to take effect.  For example, you can define a global\n// variable like this:\n//\n//   testing::Environment* const foo_env =\n//       testing::AddGlobalTestEnvironment(new FooEnvironment);\n//\n// However, we strongly recommend you to write your own main() and\n// call AddGlobalTestEnvironment() there, as relying on initialization\n// of global variables makes the code harder to read and may cause\n// problems when you register multiple environments from different\n// translation units and the environments have dependencies among them\n// (remember that the compiler doesn't guarantee the order in which\n// global variables from different translation units are initialized).\ninline Environment* AddGlobalTestEnvironment(Environment* env) {\n  return UnitTest::GetInstance()->AddEnvironment(env);\n}\n\n// Initializes Google Test.  This must be called before calling\n// RUN_ALL_TESTS().  In particular, it parses a command line for the\n// flags that Google Test recognizes.  Whenever a Google Test flag is\n// seen, it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Test flag variables are\n// updated.\n//\n// Calling the function for the second time has no user-visible effect.\nGTEST_API_ void InitGoogleTest(int* argc, char** argv);\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);\n\n// This overloaded version can be used on Arduino/embedded platforms where\n// there is no argc/argv.\nGTEST_API_ void InitGoogleTest();\n\nnamespace internal {\n\n// Separate the error generating code from the code path to reduce the stack\n// frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers\n// when calling EXPECT_* in a tight loop.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperEQFailure(const char* lhs_expression,\n                                   const char* rhs_expression,\n                                   const T1& lhs, const T2& rhs) {\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   FormatForComparisonFailureMessage(lhs, rhs),\n                   FormatForComparisonFailureMessage(rhs, lhs),\n                   false);\n}\n\n// This block of code defines operator==/!=\n// to block lexical scope lookup.\n// It prevents using invalid operator==/!= defined at namespace scope.\nstruct faketype {};\ninline bool operator==(faketype, faketype) { return true; }\ninline bool operator!=(faketype, faketype) { return false; }\n\n// The helper function for {ASSERT|EXPECT}_EQ.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperEQ(const char* lhs_expression,\n                            const char* rhs_expression,\n                            const T1& lhs,\n                            const T2& rhs) {\n  if (lhs == rhs) {\n    return AssertionSuccess();\n  }\n\n  return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);\n}\n\nclass EqHelper {\n public:\n  // This templatized version is for the general case.\n  template <\n      typename T1, typename T2,\n      // Disable this overload for cases where one argument is a pointer\n      // and the other is the null pointer constant.\n      typename std::enable_if<!std::is_integral<T1>::value ||\n                              !std::is_pointer<T2>::value>::type* = nullptr>\n  static AssertionResult Compare(const char* lhs_expression,\n                                 const char* rhs_expression, const T1& lhs,\n                                 const T2& rhs) {\n    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);\n  }\n\n  // With this overloaded version, we allow anonymous enums to be used\n  // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous\n  // enums can be implicitly cast to BiggestInt.\n  //\n  // Even though its body looks the same as the above version, we\n  // cannot merge the two, as it will make anonymous enums unhappy.\n  static AssertionResult Compare(const char* lhs_expression,\n                                 const char* rhs_expression,\n                                 BiggestInt lhs,\n                                 BiggestInt rhs) {\n    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);\n  }\n\n  template <typename T>\n  static AssertionResult Compare(\n      const char* lhs_expression, const char* rhs_expression,\n      // Handle cases where '0' is used as a null pointer literal.\n      std::nullptr_t /* lhs */, T* rhs) {\n    // We already know that 'lhs' is a null pointer.\n    return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),\n                       rhs);\n  }\n};\n\n// Separate the error generating code from the code path to reduce the stack\n// frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers\n// when calling EXPECT_OP in a tight loop.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,\n                                   const T1& val1, const T2& val2,\n                                   const char* op) {\n  return AssertionFailure()\n         << \"Expected: (\" << expr1 << \") \" << op << \" (\" << expr2\n         << \"), actual: \" << FormatForComparisonFailureMessage(val1, val2)\n         << \" vs \" << FormatForComparisonFailureMessage(val2, val1);\n}\n\n// A macro for implementing the helper functions needed to implement\n// ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste\n// of similar code.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n#define GTEST_IMPL_CMP_HELPER_(op_name, op)\\\ntemplate <typename T1, typename T2>\\\nAssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \\\n                                   const T1& val1, const T2& val2) {\\\n  if (val1 op val2) {\\\n    return AssertionSuccess();\\\n  } else {\\\n    return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\\\n  }\\\n}\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n// Implements the helper function for {ASSERT|EXPECT}_NE\nGTEST_IMPL_CMP_HELPER_(NE, !=)\n// Implements the helper function for {ASSERT|EXPECT}_LE\nGTEST_IMPL_CMP_HELPER_(LE, <=)\n// Implements the helper function for {ASSERT|EXPECT}_LT\nGTEST_IMPL_CMP_HELPER_(LT, <)\n// Implements the helper function for {ASSERT|EXPECT}_GE\nGTEST_IMPL_CMP_HELPER_(GE, >=)\n// Implements the helper function for {ASSERT|EXPECT}_GT\nGTEST_IMPL_CMP_HELPER_(GT, >)\n\n#undef GTEST_IMPL_CMP_HELPER_\n\n// The helper function for {ASSERT|EXPECT}_STREQ.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const char* s1,\n                                          const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRCASEEQ.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression,\n                                              const char* s2_expression,\n                                              const char* s1,\n                                              const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRNE.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const char* s1,\n                                          const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRCASENE.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,\n                                              const char* s2_expression,\n                                              const char* s1,\n                                              const char* s2);\n\n\n// Helper function for *_STREQ on wide strings.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const wchar_t* s1,\n                                          const wchar_t* s2);\n\n// Helper function for *_STRNE on wide strings.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const wchar_t* s1,\n                                          const wchar_t* s2);\n\n}  // namespace internal\n\n// IsSubstring() and IsNotSubstring() are intended to be used as the\n// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by\n// themselves.  They check whether needle is a substring of haystack\n// (NULL is considered a substring of itself only), and return an\n// appropriate error message when they fail.\n//\n// The {needle,haystack}_expr arguments are the stringified\n// expressions that generated the two real arguments.\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack);\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack);\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack);\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack);\n#endif  // GTEST_HAS_STD_WSTRING\n\nnamespace internal {\n\n// Helper template function for comparing floating-points.\n//\n// Template parameter:\n//\n//   RawType: the raw floating-point type (either float or double)\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\ntemplate <typename RawType>\nAssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,\n                                         const char* rhs_expression,\n                                         RawType lhs_value,\n                                         RawType rhs_value) {\n  const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);\n\n  if (lhs.AlmostEquals(rhs)) {\n    return AssertionSuccess();\n  }\n\n  ::std::stringstream lhs_ss;\n  lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n         << lhs_value;\n\n  ::std::stringstream rhs_ss;\n  rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n         << rhs_value;\n\n  return EqFailure(lhs_expression,\n                   rhs_expression,\n                   StringStreamToString(&lhs_ss),\n                   StringStreamToString(&rhs_ss),\n                   false);\n}\n\n// Helper function for implementing ASSERT_NEAR.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,\n                                                const char* expr2,\n                                                const char* abs_error_expr,\n                                                double val1,\n                                                double val2,\n                                                double abs_error);\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n// A class that enables one to stream messages to assertion macros\nclass GTEST_API_ AssertHelper {\n public:\n  // Constructor.\n  AssertHelper(TestPartResult::Type type,\n               const char* file,\n               int line,\n               const char* message);\n  ~AssertHelper();\n\n  // Message assignment is a semantic trick to enable assertion\n  // streaming; see the GTEST_MESSAGE_ macro below.\n  void operator=(const Message& message) const;\n\n private:\n  // We put our data in a struct so that the size of the AssertHelper class can\n  // be as small as possible.  This is important because gcc is incapable of\n  // re-using stack space even for temporary variables, so every EXPECT_EQ\n  // reserves stack space for another AssertHelper.\n  struct AssertHelperData {\n    AssertHelperData(TestPartResult::Type t,\n                     const char* srcfile,\n                     int line_num,\n                     const char* msg)\n        : type(t), file(srcfile), line(line_num), message(msg) { }\n\n    TestPartResult::Type const type;\n    const char* const file;\n    int const line;\n    std::string const message;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);\n  };\n\n  AssertHelperData* const data_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);\n};\n\n}  // namespace internal\n\n// The pure interface class that all value-parameterized tests inherit from.\n// A value-parameterized class must inherit from both ::testing::Test and\n// ::testing::WithParamInterface. In most cases that just means inheriting\n// from ::testing::TestWithParam, but more complicated test hierarchies\n// may need to inherit from Test and WithParamInterface at different levels.\n//\n// This interface has support for accessing the test parameter value via\n// the GetParam() method.\n//\n// Use it with one of the parameter generator defining functions, like Range(),\n// Values(), ValuesIn(), Bool(), and Combine().\n//\n// class FooTest : public ::testing::TestWithParam<int> {\n//  protected:\n//   FooTest() {\n//     // Can use GetParam() here.\n//   }\n//   ~FooTest() override {\n//     // Can use GetParam() here.\n//   }\n//   void SetUp() override {\n//     // Can use GetParam() here.\n//   }\n//   void TearDown override {\n//     // Can use GetParam() here.\n//   }\n// };\n// TEST_P(FooTest, DoesBar) {\n//   // Can use GetParam() method here.\n//   Foo foo;\n//   ASSERT_TRUE(foo.DoesBar(GetParam()));\n// }\n// INSTANTIATE_TEST_SUITE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));\n\ntemplate <typename T>\nclass WithParamInterface {\n public:\n  typedef T ParamType;\n  virtual ~WithParamInterface() {}\n\n  // The current parameter value. Is also available in the test fixture's\n  // constructor.\n  static const ParamType& GetParam() {\n    GTEST_CHECK_(parameter_ != nullptr)\n        << \"GetParam() can only be called inside a value-parameterized test \"\n        << \"-- did you intend to write TEST_P instead of TEST_F?\";\n    return *parameter_;\n  }\n\n private:\n  // Sets parameter value. The caller is responsible for making sure the value\n  // remains alive and unchanged throughout the current test.\n  static void SetParam(const ParamType* parameter) {\n    parameter_ = parameter;\n  }\n\n  // Static value used for accessing parameter during a test lifetime.\n  static const ParamType* parameter_;\n\n  // TestClass must be a subclass of WithParamInterface<T> and Test.\n  template <class TestClass> friend class internal::ParameterizedTestFactory;\n};\n\ntemplate <typename T>\nconst T* WithParamInterface<T>::parameter_ = nullptr;\n\n// Most value-parameterized classes can ignore the existence of\n// WithParamInterface, and can just inherit from ::testing::TestWithParam.\n\ntemplate <typename T>\nclass TestWithParam : public Test, public WithParamInterface<T> {\n};\n\n// Macros for indicating success/failure in test code.\n\n// Skips test in runtime.\n// Skipping test aborts current function.\n// Skipped tests are neither successful nor failed.\n#define GTEST_SKIP() GTEST_SKIP_(\"\")\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n// SUCCEED generates a success - it doesn't automatically make the\n// current test successful, as a test is only successful when it has\n// no failure.\n//\n// EXPECT_* verifies that a certain condition is satisfied.  If not,\n// it behaves like ADD_FAILURE.  In particular:\n//\n//   EXPECT_TRUE  verifies that a Boolean condition is true.\n//   EXPECT_FALSE verifies that a Boolean condition is false.\n//\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n// that they will also abort the current function on failure.  People\n// usually want the fail-fast behavior of FAIL and ASSERT_*, but those\n// writing data-driven tests often find themselves using ADD_FAILURE\n// and EXPECT_* more.\n\n// Generates a nonfatal failure with a generic message.\n#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_(\"Failed\")\n\n// Generates a nonfatal failure at the given source file location with\n// a generic message.\n#define ADD_FAILURE_AT(file, line) \\\n  GTEST_MESSAGE_AT_(file, line, \"Failed\", \\\n                    ::testing::TestPartResult::kNonFatalFailure)\n\n// Generates a fatal failure with a generic message.\n#define GTEST_FAIL() GTEST_FATAL_FAILURE_(\"Failed\")\n\n// Like GTEST_FAIL(), but at the given source file location.\n#define GTEST_FAIL_AT(file, line)         \\\n  GTEST_MESSAGE_AT_(file, line, \"Failed\", \\\n                    ::testing::TestPartResult::kFatalFailure)\n\n// Define this macro to 1 to omit the definition of FAIL(), which is a\n// generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_FAIL\n# define FAIL() GTEST_FAIL()\n#endif\n\n// Generates a success with a generic message.\n#define GTEST_SUCCEED() GTEST_SUCCESS_(\"Succeeded\")\n\n// Define this macro to 1 to omit the definition of SUCCEED(), which\n// is a generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_SUCCEED\n# define SUCCEED() GTEST_SUCCEED()\n#endif\n\n// Macros for testing exceptions.\n//\n//    * {ASSERT|EXPECT}_THROW(statement, expected_exception):\n//         Tests that the statement throws the expected exception.\n//    * {ASSERT|EXPECT}_NO_THROW(statement):\n//         Tests that the statement doesn't throw any exception.\n//    * {ASSERT|EXPECT}_ANY_THROW(statement):\n//         Tests that the statement throws an exception.\n\n#define EXPECT_THROW(statement, expected_exception) \\\n  GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_NO_THROW(statement) \\\n  GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_ANY_THROW(statement) \\\n  GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_THROW(statement, expected_exception) \\\n  GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)\n#define ASSERT_NO_THROW(statement) \\\n  GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)\n#define ASSERT_ANY_THROW(statement) \\\n  GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)\n\n// Boolean assertions. Condition can be either a Boolean expression or an\n// AssertionResult. For more information on how to use AssertionResult with\n// these macros see comments on that class.\n#define GTEST_EXPECT_TRUE(condition) \\\n  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \\\n                      GTEST_NONFATAL_FAILURE_)\n#define GTEST_EXPECT_FALSE(condition) \\\n  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \\\n                      GTEST_NONFATAL_FAILURE_)\n#define GTEST_ASSERT_TRUE(condition) \\\n  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \\\n                      GTEST_FATAL_FAILURE_)\n#define GTEST_ASSERT_FALSE(condition) \\\n  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \\\n                      GTEST_FATAL_FAILURE_)\n\n// Define these macros to 1 to omit the definition of the corresponding\n// EXPECT or ASSERT, which clashes with some users' own code.\n\n#if !GTEST_DONT_DEFINE_EXPECT_TRUE\n#define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)\n#endif\n\n#if !GTEST_DONT_DEFINE_EXPECT_FALSE\n#define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_TRUE\n#define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_FALSE\n#define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)\n#endif\n\n// Macros for testing equalities and inequalities.\n//\n//    * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2\n//    * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2\n//    * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2\n//    * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2\n//    * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2\n//    * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2\n//\n// When they are not, Google Test prints both the tested expressions and\n// their actual values.  The values must be compatible built-in types,\n// or you will get a compiler error.  By \"compatible\" we mean that the\n// values can be compared by the respective operator.\n//\n// Note:\n//\n//   1. It is possible to make a user-defined type work with\n//   {ASSERT|EXPECT}_??(), but that requires overloading the\n//   comparison operators and is thus discouraged by the Google C++\n//   Usage Guide.  Therefore, you are advised to use the\n//   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are\n//   equal.\n//\n//   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on\n//   pointers (in particular, C strings).  Therefore, if you use it\n//   with two C strings, you are testing how their locations in memory\n//   are related, not how their content is related.  To compare two C\n//   strings by content, use {ASSERT|EXPECT}_STR*().\n//\n//   3. {ASSERT|EXPECT}_EQ(v1, v2) is preferred to\n//   {ASSERT|EXPECT}_TRUE(v1 == v2), as the former tells you\n//   what the actual value is when it fails, and similarly for the\n//   other comparisons.\n//\n//   4. Do not depend on the order in which {ASSERT|EXPECT}_??()\n//   evaluate their arguments, which is undefined.\n//\n//   5. These macros evaluate their arguments exactly once.\n//\n// Examples:\n//\n//   EXPECT_NE(Foo(), 5);\n//   EXPECT_EQ(a_pointer, NULL);\n//   ASSERT_LT(i, array_size);\n//   ASSERT_GT(records.size(), 0) << \"There is no record left.\";\n\n#define EXPECT_EQ(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)\n#define EXPECT_NE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)\n#define EXPECT_LE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)\n#define EXPECT_LT(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)\n#define EXPECT_GE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)\n#define EXPECT_GT(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)\n\n#define GTEST_ASSERT_EQ(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)\n#define GTEST_ASSERT_NE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)\n#define GTEST_ASSERT_LE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)\n#define GTEST_ASSERT_LT(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)\n#define GTEST_ASSERT_GE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)\n#define GTEST_ASSERT_GT(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)\n\n// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of\n// ASSERT_XY(), which clashes with some users' own code.\n\n#if !GTEST_DONT_DEFINE_ASSERT_EQ\n# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_NE\n# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_LE\n# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_LT\n# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_GE\n# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_GT\n# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)\n#endif\n\n// C-string Comparisons.  All tests treat NULL and any non-NULL string\n// as different.  Two NULLs are equal.\n//\n//    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2\n//    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2\n//    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case\n//    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case\n//\n// For wide or narrow string objects, you can use the\n// {ASSERT|EXPECT}_??() macros.\n//\n// Don't depend on the order in which the arguments are evaluated,\n// which is undefined.\n//\n// These macros evaluate their arguments exactly once.\n\n#define EXPECT_STREQ(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)\n#define EXPECT_STRNE(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)\n#define EXPECT_STRCASEEQ(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)\n#define EXPECT_STRCASENE(s1, s2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)\n\n#define ASSERT_STREQ(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)\n#define ASSERT_STRNE(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)\n#define ASSERT_STRCASEEQ(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)\n#define ASSERT_STRCASENE(s1, s2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)\n\n// Macros for comparing floating-point numbers.\n//\n//    * {ASSERT|EXPECT}_FLOAT_EQ(val1, val2):\n//         Tests that two float values are almost equal.\n//    * {ASSERT|EXPECT}_DOUBLE_EQ(val1, val2):\n//         Tests that two double values are almost equal.\n//    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):\n//         Tests that v1 and v2 are within the given distance to each other.\n//\n// Google Test uses ULP-based comparison to automatically pick a default\n// error bound that is appropriate for the operands.  See the\n// FloatingPoint template class in gtest-internal.h if you are\n// interested in the implementation details.\n\n#define EXPECT_FLOAT_EQ(val1, val2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \\\n                      val1, val2)\n\n#define EXPECT_DOUBLE_EQ(val1, val2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \\\n                      val1, val2)\n\n#define ASSERT_FLOAT_EQ(val1, val2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \\\n                      val1, val2)\n\n#define ASSERT_DOUBLE_EQ(val1, val2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \\\n                      val1, val2)\n\n#define EXPECT_NEAR(val1, val2, abs_error)\\\n  EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \\\n                      val1, val2, abs_error)\n\n#define ASSERT_NEAR(val1, val2, abs_error)\\\n  ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \\\n                      val1, val2, abs_error)\n\n// These predicate format functions work on floating-point values, and\n// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.\n//\n//   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nGTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,\n                                   float val1, float val2);\nGTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,\n                                    double val1, double val2);\n\n\n#if GTEST_OS_WINDOWS\n\n// Macros that test for HRESULT failure and success, these are only useful\n// on Windows, and rely on Windows SDK macros and APIs to compile.\n//\n//    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)\n//\n// When expr unexpectedly fails or succeeds, Google Test prints the\n// expected result and the actual result with both a human-readable\n// string representation of the error, if available, as well as the\n// hex result code.\n# define EXPECT_HRESULT_SUCCEEDED(expr) \\\n    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))\n\n# define ASSERT_HRESULT_SUCCEEDED(expr) \\\n    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))\n\n# define EXPECT_HRESULT_FAILED(expr) \\\n    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))\n\n# define ASSERT_HRESULT_FAILED(expr) \\\n    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))\n\n#endif  // GTEST_OS_WINDOWS\n\n// Macros that execute statement and check that it doesn't generate new fatal\n// failures in the current thread.\n//\n//   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);\n//\n// Examples:\n//\n//   EXPECT_NO_FATAL_FAILURE(Process());\n//   ASSERT_NO_FATAL_FAILURE(Process()) << \"Process() failed\";\n//\n#define ASSERT_NO_FATAL_FAILURE(statement) \\\n    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)\n#define EXPECT_NO_FATAL_FAILURE(statement) \\\n    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)\n\n// Causes a trace (including the given source file path and line number,\n// and the given message) to be included in every test failure message generated\n// by code in the scope of the lifetime of an instance of this class. The effect\n// is undone with the destruction of the instance.\n//\n// The message argument can be anything streamable to std::ostream.\n//\n// Example:\n//   testing::ScopedTrace trace(\"file.cc\", 123, \"message\");\n//\nclass GTEST_API_ ScopedTrace {\n public:\n  // The c'tor pushes the given source file location and message onto\n  // a trace stack maintained by Google Test.\n\n  // Template version. Uses Message() to convert the values into strings.\n  // Slow, but flexible.\n  template <typename T>\n  ScopedTrace(const char* file, int line, const T& message) {\n    PushTrace(file, line, (Message() << message).GetString());\n  }\n\n  // Optimize for some known types.\n  ScopedTrace(const char* file, int line, const char* message) {\n    PushTrace(file, line, message ? message : \"(null)\");\n  }\n\n  ScopedTrace(const char* file, int line, const std::string& message) {\n    PushTrace(file, line, message);\n  }\n\n  // The d'tor pops the info pushed by the c'tor.\n  //\n  // Note that the d'tor is not virtual in order to be efficient.\n  // Don't inherit from ScopedTrace!\n  ~ScopedTrace();\n\n private:\n  void PushTrace(const char* file, int line, std::string message);\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);\n} GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its\n                            // c'tor and d'tor.  Therefore it doesn't\n                            // need to be used otherwise.\n\n// Causes a trace (including the source file path, the current line\n// number, and the given message) to be included in every test failure\n// message generated by code in the current scope.  The effect is\n// undone when the control leaves the current scope.\n//\n// The message argument can be anything streamable to std::ostream.\n//\n// In the implementation, we include the current line number as part\n// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s\n// to appear in the same block - as long as they are on different\n// lines.\n//\n// Assuming that each thread maintains its own stack of traces.\n// Therefore, a SCOPED_TRACE() would (correctly) only affect the\n// assertions in its own thread.\n#define SCOPED_TRACE(message) \\\n  ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\\\n    __FILE__, __LINE__, (message))\n\n// Compile-time assertion for type equality.\n// StaticAssertTypeEq<type1, type2>() compiles if and only if type1 and type2\n// are the same type.  The value it returns is not interesting.\n//\n// Instead of making StaticAssertTypeEq a class template, we make it a\n// function template that invokes a helper class template.  This\n// prevents a user from misusing StaticAssertTypeEq<T1, T2> by\n// defining objects of that type.\n//\n// CAVEAT:\n//\n// When used inside a method of a class template,\n// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is\n// instantiated.  For example, given:\n//\n//   template <typename T> class Foo {\n//    public:\n//     void Bar() { testing::StaticAssertTypeEq<int, T>(); }\n//   };\n//\n// the code:\n//\n//   void Test1() { Foo<bool> foo; }\n//\n// will NOT generate a compiler error, as Foo<bool>::Bar() is never\n// actually instantiated.  Instead, you need:\n//\n//   void Test2() { Foo<bool> foo; foo.Bar(); }\n//\n// to cause a compiler error.\ntemplate <typename T1, typename T2>\nconstexpr bool StaticAssertTypeEq() noexcept {\n  static_assert(std::is_same<T1, T2>::value, \"T1 and T2 are not the same type\");\n  return true;\n}\n\n// Defines a test.\n//\n// The first parameter is the name of the test suite, and the second\n// parameter is the name of the test within the test suite.\n//\n// The convention is to end the test suite name with \"Test\".  For\n// example, a test suite for the Foo class can be named FooTest.\n//\n// Test code should appear between braces after an invocation of\n// this macro.  Example:\n//\n//   TEST(FooTest, InitializesCorrectly) {\n//     Foo foo;\n//     EXPECT_TRUE(foo.StatusIsOK());\n//   }\n\n// Note that we call GetTestTypeId() instead of GetTypeId<\n// ::testing::Test>() here to get the type ID of testing::Test.  This\n// is to work around a suspected linker bug when using Google Test as\n// a framework on Mac OS X.  The bug causes GetTypeId<\n// ::testing::Test>() to return different values depending on whether\n// the call is from the Google Test framework itself or from user test\n// code.  GetTestTypeId() is guaranteed to always return the same\n// value, as it always calls GetTypeId<>() from the Google Test\n// framework.\n#define GTEST_TEST(test_suite_name, test_name)             \\\n  GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \\\n              ::testing::internal::GetTestTypeId())\n\n// Define this macro to 1 to omit the definition of TEST(), which\n// is a generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_TEST\n#define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)\n#endif\n\n// Defines a test that uses a test fixture.\n//\n// The first parameter is the name of the test fixture class, which\n// also doubles as the test suite name.  The second parameter is the\n// name of the test within the test suite.\n//\n// A test fixture class must be declared earlier.  The user should put\n// the test code between braces after using this macro.  Example:\n//\n//   class FooTest : public testing::Test {\n//    protected:\n//     void SetUp() override { b_.AddElement(3); }\n//\n//     Foo a_;\n//     Foo b_;\n//   };\n//\n//   TEST_F(FooTest, InitializesCorrectly) {\n//     EXPECT_TRUE(a_.StatusIsOK());\n//   }\n//\n//   TEST_F(FooTest, ReturnsElementCountCorrectly) {\n//     EXPECT_EQ(a_.size(), 0);\n//     EXPECT_EQ(b_.size(), 1);\n//   }\n//\n// GOOGLETEST_CM0011 DO NOT DELETE\n#if !GTEST_DONT_DEFINE_TEST\n#define TEST_F(test_fixture, test_name)\\\n  GTEST_TEST_(test_fixture, test_name, test_fixture, \\\n              ::testing::internal::GetTypeId<test_fixture>())\n#endif  // !GTEST_DONT_DEFINE_TEST\n\n// Returns a path to temporary directory.\n// Tries to determine an appropriate directory for the platform.\nGTEST_API_ std::string TempDir();\n\n#ifdef _MSC_VER\n#  pragma warning(pop)\n#endif\n\n// Dynamically registers a test with the framework.\n//\n// This is an advanced API only to be used when the `TEST` macros are\n// insufficient. The macros should be preferred when possible, as they avoid\n// most of the complexity of calling this function.\n//\n// The `factory` argument is a factory callable (move-constructible) object or\n// function pointer that creates a new instance of the Test object. It\n// handles ownership to the caller. The signature of the callable is\n// `Fixture*()`, where `Fixture` is the test fixture class for the test. All\n// tests registered with the same `test_suite_name` must return the same\n// fixture type. This is checked at runtime.\n//\n// The framework will infer the fixture class from the factory and will call\n// the `SetUpTestSuite` and `TearDownTestSuite` for it.\n//\n// Must be called before `RUN_ALL_TESTS()` is invoked, otherwise behavior is\n// undefined.\n//\n// Use case example:\n//\n// class MyFixture : public ::testing::Test {\n//  public:\n//   // All of these optional, just like in regular macro usage.\n//   static void SetUpTestSuite() { ... }\n//   static void TearDownTestSuite() { ... }\n//   void SetUp() override { ... }\n//   void TearDown() override { ... }\n// };\n//\n// class MyTest : public MyFixture {\n//  public:\n//   explicit MyTest(int data) : data_(data) {}\n//   void TestBody() override { ... }\n//\n//  private:\n//   int data_;\n// };\n//\n// void RegisterMyTests(const std::vector<int>& values) {\n//   for (int v : values) {\n//     ::testing::RegisterTest(\n//         \"MyFixture\", (\"Test\" + std::to_string(v)).c_str(), nullptr,\n//         std::to_string(v).c_str(),\n//         __FILE__, __LINE__,\n//         // Important to use the fixture type as the return type here.\n//         [=]() -> MyFixture* { return new MyTest(v); });\n//   }\n// }\n// ...\n// int main(int argc, char** argv) {\n//   std::vector<int> values_to_test = LoadValuesFromConfig();\n//   RegisterMyTests(values_to_test);\n//   ...\n//   return RUN_ALL_TESTS();\n// }\n//\ntemplate <int&... ExplicitParameterBarrier, typename Factory>\nTestInfo* RegisterTest(const char* test_suite_name, const char* test_name,\n                       const char* type_param, const char* value_param,\n                       const char* file, int line, Factory factory) {\n  using TestT = typename std::remove_pointer<decltype(factory())>::type;\n\n  class FactoryImpl : public internal::TestFactoryBase {\n   public:\n    explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}\n    Test* CreateTest() override { return factory_(); }\n\n   private:\n    Factory factory_;\n  };\n\n  return internal::MakeAndRegisterTestInfo(\n      test_suite_name, test_name, type_param, value_param,\n      internal::CodeLocation(file, line), internal::GetTypeId<TestT>(),\n      internal::SuiteApiResolver<TestT>::GetSetUpCaseOrSuite(file, line),\n      internal::SuiteApiResolver<TestT>::GetTearDownCaseOrSuite(file, line),\n      new FactoryImpl{std::move(factory)});\n}\n\n}  // namespace testing\n\n// Use this function in main() to run all tests.  It returns 0 if all\n// tests are successful, or 1 otherwise.\n//\n// RUN_ALL_TESTS() should be invoked after the command line has been\n// parsed by InitGoogleTest().\n//\n// This function was formerly a macro; thus, it is in the global\n// namespace and has an all-caps name.\nint RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;\n\ninline int RUN_ALL_TESTS() {\n  return ::testing::UnitTest::GetInstance()->Run();\n}\n\nGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251\n\n#endif  // GOOGLETEST_INCLUDE_GTEST_GTEST_H_\n"
  },
  {
    "path": "test/gtest-extra-test.cc",
    "content": "// Formatting library for C++ - tests of custom Google Test assertions\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"gtest-extra.h\"\n\n#include <gtest/gtest-spi.h>\n\n#include <cstring>\n#include <memory>\n#include <stdexcept>\n\n#include \"fmt/os.h\"\n#include \"util.h\"\n\n// Tests that assertion macros evaluate their arguments exactly once.\nnamespace {\nclass single_evaluation_test : public ::testing::Test {\n protected:\n  single_evaluation_test() {\n    p_ = s_;\n    a_ = 0;\n    b_ = 0;\n  }\n\n  static const char* const s_;\n  static const char* p_;\n\n  static int a_;\n  static int b_;\n};\n}  // namespace\n\nconst char* const single_evaluation_test::s_ = \"01234\";\nconst char* single_evaluation_test::p_;\nint single_evaluation_test::a_;\nint single_evaluation_test::b_;\n\nvoid do_nothing() {}\n\nFMT_NORETURN void throw_exception() { throw std::runtime_error(\"test\"); }\n\nFMT_NORETURN void throw_system_error() {\n  throw fmt::system_error(EDOM, \"test\");\n}\n\n// Tests that when EXPECT_THROW_MSG fails, it evaluates its message argument\n// exactly once.\nTEST_F(single_evaluation_test, failed_expect_throw_msg) {\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(throw_exception(), std::exception, p_++), \"01234\");\n  EXPECT_EQ(s_ + 1, p_);\n}\n\n// Tests that when EXPECT_SYSTEM_ERROR fails, it evaluates its message argument\n// exactly once.\nTEST_F(single_evaluation_test, failed_expect_system_error) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, p_++),\n                          \"01234\");\n  EXPECT_EQ(s_ + 1, p_);\n}\n\n// Tests that assertion arguments are evaluated exactly once.\nTEST_F(single_evaluation_test, exception_tests) {\n  // successful EXPECT_THROW_MSG\n  EXPECT_THROW_MSG(\n      {  // NOLINT\n        a_++;\n        throw_exception();\n      },\n      std::exception, (b_++, \"test\"));\n  EXPECT_EQ(1, a_);\n  EXPECT_EQ(1, b_);\n\n  // failed EXPECT_THROW_MSG, throws different type\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW_MSG(\n                              {  // NOLINT\n                                a_++;\n                                throw_exception();\n                              },\n                              std::logic_error, (b_++, \"test\")),\n                          \"throws a different type\");\n  EXPECT_EQ(2, a_);\n  EXPECT_EQ(2, b_);\n\n  // failed EXPECT_THROW_MSG, throws an exception with different message\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW_MSG(\n                              {  // NOLINT\n                                a_++;\n                                throw_exception();\n                              },\n                              std::exception, (b_++, \"other\")),\n                          \"throws an exception with a different message\");\n  EXPECT_EQ(3, a_);\n  EXPECT_EQ(3, b_);\n\n  // failed EXPECT_THROW_MSG, throws nothing\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(a_++, std::exception, (b_++, \"test\")), \"throws nothing\");\n  EXPECT_EQ(4, a_);\n  EXPECT_EQ(4, b_);\n}\n\nTEST_F(single_evaluation_test, system_error_tests) {\n  // successful EXPECT_SYSTEM_ERROR\n  EXPECT_SYSTEM_ERROR(\n      {  // NOLINT\n        a_++;\n        throw_system_error();\n      },\n      EDOM, (b_++, \"test\"));\n  EXPECT_EQ(1, a_);\n  EXPECT_EQ(1, b_);\n\n  // failed EXPECT_SYSTEM_ERROR, throws different type\n  EXPECT_NONFATAL_FAILURE(EXPECT_SYSTEM_ERROR(\n                              {  // NOLINT\n                                a_++;\n                                throw_exception();\n                              },\n                              EDOM, (b_++, \"test\")),\n                          \"throws a different type\");\n  EXPECT_EQ(2, a_);\n  EXPECT_EQ(2, b_);\n\n  // failed EXPECT_SYSTEM_ERROR, throws an exception with different message\n  EXPECT_NONFATAL_FAILURE(EXPECT_SYSTEM_ERROR(\n                              {  // NOLINT\n                                a_++;\n                                throw_system_error();\n                              },\n                              EDOM, (b_++, \"other\")),\n                          \"throws an exception with a different message\");\n  EXPECT_EQ(3, a_);\n  EXPECT_EQ(3, b_);\n\n  // failed EXPECT_SYSTEM_ERROR, throws nothing\n  EXPECT_NONFATAL_FAILURE(EXPECT_SYSTEM_ERROR(a_++, EDOM, (b_++, \"test\")),\n                          \"throws nothing\");\n  EXPECT_EQ(4, a_);\n  EXPECT_EQ(4, b_);\n}\n\n#if FMT_USE_FCNTL\n// Tests that when EXPECT_WRITE fails, it evaluates its message argument\n// exactly once.\nTEST_F(single_evaluation_test, failed_expect_write) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_WRITE(stdout, std::printf(\"test\"), p_++),\n                          \"01234\");\n  EXPECT_EQ(s_ + 1, p_);\n}\n\n// Tests that assertion arguments are evaluated exactly once.\nTEST_F(single_evaluation_test, write_tests) {\n  // successful EXPECT_WRITE\n  EXPECT_WRITE(\n      stdout,\n      {  // NOLINT\n        a_++;\n        std::printf(\"test\");\n      },\n      (b_++, \"test\"));\n  EXPECT_EQ(1, a_);\n  EXPECT_EQ(1, b_);\n\n  // failed EXPECT_WRITE\n  EXPECT_NONFATAL_FAILURE(EXPECT_WRITE(\n                              stdout,\n                              {  // NOLINT\n                                a_++;\n                                std::printf(\"test\");\n                              },\n                              (b_++, \"other\")),\n                          \"Actual: test\");\n  EXPECT_EQ(2, a_);\n  EXPECT_EQ(2, b_);\n}\n\n// Tests EXPECT_WRITE.\nTEST(gtest_extra_test, expect_write) {\n  EXPECT_WRITE(stdout, do_nothing(), \"\");\n  EXPECT_WRITE(stdout, std::printf(\"test\"), \"test\");\n  EXPECT_WRITE(stderr, std::fprintf(stderr, \"test\"), \"test\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_WRITE(stdout, std::printf(\"that\"), \"this\"),\n                          \"Expected: this\\n\"\n                          \"  Actual: that\");\n}\n\nTEST(gtest_extra_test, expect_write_streaming) {\n  EXPECT_WRITE(stdout, std::printf(\"test\"), \"test\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_WRITE(stdout, std::printf(\"test\"), \"other\")\n                              << \"expected failure\",\n                          \"expected failure\");\n}\n#endif  // FMT_USE_FCNTL\n\n// Tests that the compiler will not complain about unreachable code in the\n// EXPECT_THROW_MSG macro.\nTEST(gtest_extra_test, expect_throw_no_unreachable_code_warning) {\n  int n = 0;\n  (void)n;\n  using std::runtime_error;\n  EXPECT_THROW_MSG(throw runtime_error(\"\"), runtime_error, \"\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW_MSG(n++, runtime_error, \"\"), \"\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW_MSG(throw 1, runtime_error, \"\"), \"\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(throw runtime_error(\"a\"), runtime_error, \"b\"), \"\");\n}\n\n// Tests that the compiler will not complain about unreachable code in the\n// EXPECT_SYSTEM_ERROR macro.\nTEST(gtest_extra_test, expect_system_error_no_unreachable_code_warning) {\n  int n = 0;\n  (void)n;\n  EXPECT_SYSTEM_ERROR(throw fmt::system_error(EDOM, \"test\"), EDOM, \"test\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_SYSTEM_ERROR(n++, EDOM, \"\"), \"\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_SYSTEM_ERROR(throw 1, EDOM, \"\"), \"\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_SYSTEM_ERROR(throw fmt::system_error(EDOM, \"aaa\"), EDOM, \"bbb\"),\n      \"\");\n}\n\nTEST(gtest_extra_test, expect_throw_behaves_like_single_statement) {\n  if (::testing::internal::AlwaysFalse())\n    EXPECT_THROW_MSG(do_nothing(), std::exception, \"\");\n\n  if (::testing::internal::AlwaysTrue())\n    EXPECT_THROW_MSG(throw_exception(), std::exception, \"test\");\n  else\n    do_nothing();\n}\n\nTEST(gtest_extra_test, expect_system_error_behaves_like_single_statement) {\n  if (::testing::internal::AlwaysFalse())\n    EXPECT_SYSTEM_ERROR(do_nothing(), EDOM, \"\");\n\n  if (::testing::internal::AlwaysTrue())\n    EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, \"test\");\n  else\n    do_nothing();\n}\n\nTEST(gtest_extra_test, expect_write_behaves_like_single_statement) {\n  if (::testing::internal::AlwaysFalse())\n    EXPECT_WRITE(stdout, std::printf(\"x\"), \"x\");\n\n  if (::testing::internal::AlwaysTrue())\n    EXPECT_WRITE(stdout, std::printf(\"x\"), \"x\");\n  else\n    do_nothing();\n}\n\n// Tests EXPECT_THROW_MSG.\nTEST(gtest_extra_test, expect_throw_msg) {\n  EXPECT_THROW_MSG(throw_exception(), std::exception, \"test\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(throw_exception(), std::logic_error, \"test\"),\n      \"Expected: throw_exception() throws an exception of \"\n      \"type std::logic_error.\\n  Actual: it throws a different type.\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(do_nothing(), std::exception, \"test\"),\n      \"Expected: do_nothing() throws an exception of type std::exception.\\n\"\n      \"  Actual: it throws nothing.\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(throw_exception(), std::exception, \"other\"),\n      \"throw_exception() throws an exception with a different message.\\n\"\n      \"Expected: other\\n\"\n      \"  Actual: test\");\n}\n\n// Tests EXPECT_SYSTEM_ERROR.\nTEST(gtest_extra_test, expect_system_error) {\n  EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, \"test\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_SYSTEM_ERROR(throw_exception(), EDOM, \"test\"),\n      \"Expected: throw_exception() throws an exception of \"\n      \"type std::system_error.\\n  Actual: it throws a different type.\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_SYSTEM_ERROR(do_nothing(), EDOM, \"test\"),\n      \"Expected: do_nothing() throws an exception of type std::system_error.\\n\"\n      \"  Actual: it throws nothing.\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, \"other\"),\n      fmt::format(\n          \"throw_system_error() throws an exception with a different message.\\n\"\n          \"Expected: {}\\n\"\n          \"  Actual: {}\",\n          system_error_message(EDOM, \"other\"),\n          system_error_message(EDOM, \"test\")));\n}\n\nTEST(gtest_extra_test, expect_throw_msg_streaming) {\n  EXPECT_THROW_MSG(throw_exception(), std::exception, \"test\")\n      << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW_MSG(throw_exception(), std::exception, \"other\")\n          << \"expected failure\",\n      \"expected failure\");\n}\n\nTEST(gtest_extra_test, expect_system_error_streaming) {\n  EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, \"test\")\n      << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_SYSTEM_ERROR(throw_system_error(), EDOM, \"other\")\n          << \"expected failure\",\n      \"expected failure\");\n}\n\n#if FMT_USE_FCNTL\n\nusing fmt::buffered_file;\nusing fmt::file;\n\nTEST(output_redirect_test, scoped_redirect) {\n  auto pipe = fmt::pipe();\n  {\n    buffered_file file(pipe.write_end.fdopen(\"w\"));\n    std::fprintf(file.get(), \"[[[\");\n    {\n      output_redirect redir(file.get());\n      std::fprintf(file.get(), \"censored\");\n    }\n    std::fprintf(file.get(), \"]]]\");\n  }\n  EXPECT_READ(pipe.read_end, \"[[[]]]\");\n}\n\n// Test that output_redirect handles errors in flush correctly.\nTEST(output_redirect_test, flush_error_in_ctor) {\n  auto pipe = fmt::pipe();\n  int write_fd = pipe.write_end.descriptor();\n  file write_copy = pipe.write_end.dup(write_fd);\n  buffered_file f = pipe.write_end.fdopen(\"w\");\n  // Put a character in a file buffer.\n  EXPECT_EQ('x', fputc('x', f.get()));\n  FMT_POSIX(close(write_fd));\n  std::unique_ptr<output_redirect> redir{nullptr};\n  EXPECT_SYSTEM_ERROR_NOASSERT(redir.reset(new output_redirect(f.get())), EBADF,\n                               \"cannot flush stream\");\n  redir.reset(nullptr);\n  write_copy.dup2(write_fd);  // \"undo\" close or dtor will fail\n}\n\nTEST(output_redirect_test, dup_error_in_ctor) {\n  buffered_file f = open_buffered_file();\n  int fd = (f.descriptor)();\n  file copy = file::dup(fd);\n  FMT_POSIX(close(fd));\n  std::unique_ptr<output_redirect> redir{nullptr};\n  EXPECT_SYSTEM_ERROR_NOASSERT(\n      redir.reset(new output_redirect(f.get(), false)), EBADF,\n      fmt::format(\"cannot duplicate file descriptor {}\", fd));\n  copy.dup2(fd);  // \"undo\" close or dtor will fail\n}\n\nTEST(output_redirect_test, restore_and_read) {\n  auto pipe = fmt::pipe();\n  buffered_file file(pipe.write_end.fdopen(\"w\"));\n  std::fprintf(file.get(), \"[[[\");\n  output_redirect redir(file.get());\n  std::fprintf(file.get(), \"censored\");\n  EXPECT_EQ(\"censored\", redir.restore_and_read());\n  EXPECT_EQ(\"\", redir.restore_and_read());\n  std::fprintf(file.get(), \"]]]\");\n  file = buffered_file();\n  EXPECT_READ(pipe.read_end, \"[[[]]]\");\n}\n\n// Test that OutputRedirect handles errors in flush correctly.\nTEST(output_redirect_test, flush_error_in_restore_and_read) {\n  auto pipe = fmt::pipe();\n  int write_fd = pipe.write_end.descriptor();\n  file write_copy = pipe.write_end.dup(write_fd);\n  buffered_file f = pipe.write_end.fdopen(\"w\");\n  output_redirect redir(f.get());\n  // Put a character in a file buffer.\n  EXPECT_EQ('x', fputc('x', f.get()));\n  FMT_POSIX(close(write_fd));\n  EXPECT_SYSTEM_ERROR_NOASSERT(redir.restore_and_read(), EBADF,\n                               \"cannot flush stream\");\n  write_copy.dup2(write_fd);  // \"undo\" close or dtor will fail\n}\n\nTEST(output_redirect_test, error_in_dtor) {\n  auto pipe = fmt::pipe();\n  int write_fd = pipe.write_end.descriptor();\n  file write_copy = pipe.write_end.dup(write_fd);\n  buffered_file f = pipe.write_end.fdopen(\"w\");\n  std::unique_ptr<output_redirect> redir(new output_redirect(f.get()));\n  // Put a character in a file buffer.\n  EXPECT_EQ('x', fputc('x', f.get()));\n  EXPECT_WRITE(\n      stderr,\n      {\n        // The close function must be called inside EXPECT_WRITE,\n        // otherwise the system may recycle closed file descriptor when\n        // redirecting the output in EXPECT_STDERR and the second close\n        // will break output redirection.\n        FMT_POSIX(close(write_fd));\n        SUPPRESS_ASSERT(redir.reset(nullptr));\n      },\n      system_error_message(EBADF, \"cannot flush stream\"));\n  write_copy.dup2(write_fd);  // \"undo\" close or dtor of buffered_file will fail\n}\n\n#endif  // FMT_USE_FCNTL\n"
  },
  {
    "path": "test/gtest-extra.cc",
    "content": "// Formatting library for C++ - custom Google Test assertions\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"gtest-extra.h\"\n\n#if FMT_USE_FCNTL\n\nusing fmt::file;\n\noutput_redirect::output_redirect(FILE* f, bool flush) : file_(f) {\n  if (flush) this->flush();\n  int fd = FMT_POSIX(fileno(f));\n  // Create a file object referring to the original file.\n  original_ = file::dup(fd);\n  // Create a pipe.\n  auto pipe = fmt::pipe();\n  read_end_ = std::move(pipe.read_end);\n  // Connect the passed FILE object to the write end of the pipe.\n  pipe.write_end.dup2(fd);\n}\n\noutput_redirect::~output_redirect() noexcept {\n  try {\n    restore();\n  } catch (const std::exception& e) {\n    std::fputs(e.what(), stderr);\n  }\n}\n\nvoid output_redirect::flush() {\n  int result = 0;\n  do {\n    result = fflush(file_);\n  } while (result == EOF && errno == EINTR);\n  if (result != 0) throw fmt::system_error(errno, \"cannot flush stream\");\n}\n\nvoid output_redirect::restore() {\n  if (original_.descriptor() == -1) return;  // Already restored.\n  flush();\n  // Restore the original file.\n  original_.dup2(FMT_POSIX(fileno(file_)));\n  original_.close();\n}\n\nstd::string output_redirect::restore_and_read() {\n  // Restore output.\n  restore();\n\n  // Read everything from the pipe.\n  std::string content;\n  if (read_end_.descriptor() == -1) return content;  // Already read.\n  enum { BUFFER_SIZE = 4096 };\n  char buffer[BUFFER_SIZE];\n  size_t count = 0;\n  do {\n    count = read_end_.read(buffer, BUFFER_SIZE);\n    content.append(buffer, count);\n  } while (count != 0);\n  read_end_.close();\n  return content;\n}\n\nstd::string read(file& f, size_t count) {\n  std::string buffer(count, '\\0');\n  size_t n = 0, offset = 0;\n  do {\n    n = f.read(&buffer[offset], count - offset);\n    // We can't read more than size_t bytes since count has type size_t.\n    offset += n;\n  } while (offset < count && n != 0);\n  buffer.resize(offset);\n  return buffer;\n}\n\n#endif  // FMT_USE_FCNTL\n"
  },
  {
    "path": "test/gtest-extra.h",
    "content": "// Formatting library for C++ - custom Google Test assertions\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_GTEST_EXTRA_H_\n#define FMT_GTEST_EXTRA_H_\n\n#include <stdlib.h>  // _invalid_parameter_handler\n\n#include <string>\n\n#include \"fmt/os.h\"\n#include \"gmock/gmock.h\"\n\n#ifdef _MSC_VER\n#  include <crtdbg.h>\n#endif\n\n#define FMT_TEST_THROW_(statement, expected_exception, expected_message, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \\\n  if (::testing::AssertionResult gtest_ar = ::testing::AssertionSuccess()) {   \\\n    std::string gtest_expected_message = expected_message;                     \\\n    bool gtest_caught_expected = false;                                        \\\n    try {                                                                      \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);               \\\n    } catch (expected_exception const& e) {                                    \\\n      if (gtest_expected_message != e.what()) {                                \\\n        gtest_ar << #statement                                                 \\\n            \" throws an exception with a different message.\\n\"                 \\\n                 << \"Expected: \" << gtest_expected_message << \"\\n\"             \\\n                 << \"  Actual: \" << e.what();                                  \\\n        goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);            \\\n      }                                                                        \\\n      gtest_caught_expected = true;                                            \\\n    } catch (...) {                                                            \\\n      gtest_ar << \"Expected: \" #statement                                      \\\n                  \" throws an exception of type \" #expected_exception          \\\n                  \".\\n  Actual: it throws a different type.\";                  \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);              \\\n    }                                                                          \\\n    if (!gtest_caught_expected) {                                              \\\n      gtest_ar << \"Expected: \" #statement                                      \\\n                  \" throws an exception of type \" #expected_exception          \\\n                  \".\\n  Actual: it throws nothing.\";                           \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);              \\\n    }                                                                          \\\n  } else                                                                       \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__)                      \\\n        : fail(gtest_ar.failure_message())\n\n// Tests that the statement throws the expected exception and the exception's\n// what() method returns expected message.\n#define EXPECT_THROW_MSG(statement, expected_exception, expected_message) \\\n  FMT_TEST_THROW_(statement, expected_exception, expected_message,        \\\n                  GTEST_NONFATAL_FAILURE_)\n\ninline std::string system_error_message(int error_code,\n                                        const std::string& message) {\n  auto ec = std::error_code(error_code, std::generic_category());\n  return std::system_error(ec, message).what();\n}\n\n#define EXPECT_SYSTEM_ERROR(statement, error_code, message) \\\n  EXPECT_THROW_MSG(statement, std::system_error,            \\\n                   system_error_message(error_code, message))\n\n#if FMT_USE_FCNTL\n\n// Captures file output by redirecting it to a pipe.\n// The output it can handle is limited by the pipe capacity.\nclass output_redirect {\n private:\n  FILE* file_;\n  fmt::file original_;  // Original file passed to redirector.\n  fmt::file read_end_;  // Read end of the pipe where the output is redirected.\n\n  void flush();\n  void restore();\n\n public:\n  explicit output_redirect(FILE* file, bool flush = true);\n  ~output_redirect() noexcept;\n\n  output_redirect(const output_redirect&) = delete;\n  void operator=(const output_redirect&) = delete;\n\n  // Restores the original file, reads output from the pipe into a string\n  // and returns it.\n  std::string restore_and_read();\n};\n\n#  define FMT_TEST_WRITE_(statement, expected_output, file, fail)              \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_                                              \\\n    if (::testing::AssertionResult gtest_ar = ::testing::AssertionSuccess()) { \\\n      std::string gtest_expected_output = expected_output;                     \\\n      output_redirect gtest_redir(file);                                       \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);               \\\n      std::string gtest_output = gtest_redir.restore_and_read();               \\\n      if (gtest_output != gtest_expected_output) {                             \\\n        gtest_ar << #statement \" produces different output.\\n\"                 \\\n                 << \"Expected: \" << gtest_expected_output << \"\\n\"              \\\n                 << \"  Actual: \" << gtest_output;                              \\\n        goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__);            \\\n      }                                                                        \\\n    } else                                                                     \\\n      GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__)                    \\\n          : fail(gtest_ar.failure_message())\n\n// Tests that the statement writes the expected output to file.\n#  define EXPECT_WRITE(file, statement, expected_output) \\\n    FMT_TEST_WRITE_(statement, expected_output, file, GTEST_NONFATAL_FAILURE_)\n\n#  ifdef _MSC_VER\n\n// Suppresses Windows assertions on invalid file descriptors, making\n// POSIX functions return proper error codes instead of crashing on Windows.\nclass suppress_assert {\n private:\n  _invalid_parameter_handler original_handler_;\n  int original_report_mode_;\n\n  static void handle_invalid_parameter(const wchar_t*, const wchar_t*,\n                                       const wchar_t*, unsigned, uintptr_t) {}\n\n public:\n  suppress_assert()\n      : original_handler_(\n            _set_invalid_parameter_handler(handle_invalid_parameter)),\n        original_report_mode_(_CrtSetReportMode(_CRT_ASSERT, 0)) {}\n  ~suppress_assert() {\n    _set_invalid_parameter_handler(original_handler_);\n    _CrtSetReportMode(_CRT_ASSERT, original_report_mode_);\n    (void)original_report_mode_;\n  }\n};\n\n#    define SUPPRESS_ASSERT(statement) \\\n      {                                \\\n        suppress_assert sa;            \\\n        statement;                     \\\n      }\n#  else\n#    define SUPPRESS_ASSERT(statement) statement\n#  endif  // _MSC_VER\n\n#  define EXPECT_SYSTEM_ERROR_NOASSERT(statement, error_code, message) \\\n    EXPECT_SYSTEM_ERROR(SUPPRESS_ASSERT(statement), error_code, message)\n\n// Attempts to read count characters from a file.\nstd::string read(fmt::file& f, size_t count);\n\n#  define EXPECT_READ(file, expected_content) \\\n    EXPECT_EQ(expected_content,               \\\n              read(file, fmt::string_view(expected_content).size()))\n\n#else\n#  define EXPECT_WRITE(file, statement, expected_output) \\\n    do {                                                 \\\n      (void)(file);                                      \\\n      (void)(statement);                                 \\\n      (void)(expected_output);                           \\\n      SUCCEED();                                         \\\n    } while (false)\n#endif  // FMT_USE_FCNTL\n\n#endif  // FMT_GTEST_EXTRA_H_\n"
  },
  {
    "path": "test/header-only-test.cc",
    "content": "// Header-only configuration test\n\n#include \"fmt/base.h\"\n#include \"fmt/ostream.h\"\n#include \"gtest/gtest.h\"\n\n#ifndef FMT_HEADER_ONLY\n#  error \"Not in the header-only mode.\"\n#endif\n\nTEST(header_only_test, format) { EXPECT_EQ(fmt::format(\"foo\"), \"foo\"); }\n"
  },
  {
    "path": "test/mock-allocator.h",
    "content": "// Formatting library for C++ - mock allocator\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_MOCK_ALLOCATOR_H_\n#define FMT_MOCK_ALLOCATOR_H_\n\n#include <assert.h>  // assert\n#include <stddef.h>  // size_t\n\n#include <memory>  // std::allocator_traits\n\n#include \"gmock/gmock.h\"\n\ntemplate <typename T> class mock_allocator {\n public:\n  using value_type = T;\n  using size_type = size_t;\n\n  using pointer = T*;\n  using const_pointer = const T*;\n  using reference = T&;\n  using const_reference = const T&;\n  using difference_type = ptrdiff_t;\n\n  template <typename U> struct rebind {\n    using other = mock_allocator<U>;\n  };\n\n  mock_allocator() {}\n  mock_allocator(const mock_allocator&) {}\n\n  MOCK_METHOD(T*, allocate, (size_t));\n  MOCK_METHOD(void, deallocate, (T*, size_t));\n};\n\ntemplate <typename Allocator, bool PropagateOnMove = true> class allocator_ref {\n private:\n  Allocator* alloc_;\n\n  void move(allocator_ref& other) {\n    alloc_ = other.alloc_;\n    other.alloc_ = nullptr;\n  }\n\n public:\n  using value_type = typename Allocator::value_type;\n  using propagate_on_container_move_assignment =\n      fmt::bool_constant<PropagateOnMove>;\n\n  explicit allocator_ref(Allocator* alloc = nullptr) : alloc_(alloc) {}\n\n  allocator_ref(const allocator_ref& other) : alloc_(other.alloc_) {}\n  allocator_ref(allocator_ref&& other) { move(other); }\n\n  allocator_ref& operator=(allocator_ref&& other) {\n    assert(this != &other);\n    move(other);\n    return *this;\n  }\n\n  allocator_ref& operator=(const allocator_ref& other) {\n    alloc_ = other.alloc_;\n    return *this;\n  }\n\n public:\n  auto get() const -> Allocator* { return alloc_; }\n\n  auto allocate(size_t n) -> value_type* {\n    return std::allocator_traits<Allocator>::allocate(*alloc_, n);\n  }\n  void deallocate(value_type* p, size_t n) { alloc_->deallocate(p, n); }\n\n  friend auto operator==(allocator_ref a, allocator_ref b) noexcept -> bool {\n    if (a.alloc_ == b.alloc_) return true;\n    return a.alloc_ && b.alloc_ && *a.alloc_ == *b.alloc_;\n  }\n\n  friend auto operator!=(allocator_ref a, allocator_ref b) noexcept -> bool {\n    return !(a == b);\n  }\n};\n\n#endif  // FMT_MOCK_ALLOCATOR_H_\n"
  },
  {
    "path": "test/module-test.cc",
    "content": "// Formatting library for C++ - module tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n//\n// Copyright (c) 2021 - present, Daniela Engert\n// All Rights Reserved\n// {fmt} module.\n\n#ifdef _MSC_FULL_VER\n// hide some implementation bugs in msvc\n// that are not essential to users of the module.\n#  define FMT_HIDE_MODULE_BUGS\n#endif\n\n#include <bit>\n#include <chrono>\n#include <exception>\n#include <iterator>\n#include <locale>\n#include <memory>\n#include <ostream>\n#include <string>\n#include <string_view>\n#include <system_error>\n\n#if (__has_include(<fcntl.h>) || defined(__APPLE__) || \\\n     defined(__linux__)) &&                              \\\n    (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))\n#  include <fcntl.h>\n#  define FMT_USE_FCNTL 1\n#else\n#  define FMT_USE_FCNTL 0\n#endif\n#if defined(_WIN32) && !defined(__MINGW32__)\n#  define FMT_POSIX(call) _##call\n#else\n#  define FMT_POSIX(call) call\n#endif\n\nimport fmt;\n\n// check for macros leaking from BMI\nstatic bool macro_leaked =\n#if defined(FMT_CORE_H_) || defined(FMT_FORMAT_H_)\n    true;\n#else\n    false;\n#endif\n\n#define FMT_OS_H_  // don't pull in os.h, neither directly nor indirectly\n#include \"gtest-extra.h\"\n\n// an implicitly exported namespace must be visible [module.interface]/2.2\nTEST(module_test, namespace) {\n  using namespace fmt;\n  using namespace fmt::literals;\n  ASSERT_TRUE(true);\n}\n\nnamespace detail {\nbool oops_detail_namespace_is_visible;\n}\n\nnamespace fmt {\nbool namespace_detail_invisible() {\n#if defined(FMT_HIDE_MODULE_BUGS) && defined(_MSC_FULL_VER) && \\\n    _MSC_FULL_VER <= 193700000\n  // bug in msvc up to at least 17.7:\n\n  // the namespace is visible even when it is neither\n  // implicitly nor explicitly exported\n  return true;\n#else\n  using namespace detail;\n  // this fails to compile if fmt::detail is visible\n  return !oops_detail_namespace_is_visible;\n#endif\n}\n}  // namespace fmt\n\n// the non-exported namespace 'detail' must be invisible [module.interface]/2\nTEST(module_test, detail_namespace) {\n  EXPECT_TRUE(fmt::namespace_detail_invisible());\n}\n\n// macros must not be imported from a *named* module  [cpp.import]/5.1\nTEST(module_test, macros) {\n#if defined(FMT_HIDE_MODULE_BUGS) && defined(_MSC_FULL_VER) && \\\n    _MSC_FULL_VER <= 192930130\n  // bug in msvc up to 16.11-pre2:\n  // include-guard macros leak from BMI\n  // and even worse: they cannot be #undef-ined\n  macro_leaked = false;\n#endif\n  EXPECT_FALSE(macro_leaked);\n}\n\n// The following is less about functional testing (that's done elsewhere)\n// but rather visibility of all client-facing overloads, reachability of\n// non-exported entities, name lookup and overload resolution within\n// template instantitions.\n// Exercise all exported entities of the API at least once.\n// Instantiate as many code paths as possible.\n\nTEST(module_test, to_string) {\n  EXPECT_EQ(\"42\", fmt::to_string(42));\n  EXPECT_EQ(\"42\", fmt::to_string(42.0));\n\n  EXPECT_EQ(L\"42\", fmt::to_wstring(42));\n  EXPECT_EQ(L\"42\", fmt::to_wstring(42.0));\n}\n\nTEST(module_test, format) {\n  EXPECT_EQ(\"42\", fmt::format(\"{:}\", 42));\n  EXPECT_EQ(\"-42\", fmt::format(\"{0}\", -42.0));\n\n  EXPECT_EQ(L\"42\", fmt::format(L\"{:}\", 42));\n  EXPECT_EQ(L\"-42\", fmt::format(L\"{0}\", -42.0));\n}\n\nTEST(module_test, format_to) {\n  std::string s;\n  fmt::format_to(std::back_inserter(s), \"{}\", 42);\n  EXPECT_EQ(\"42\", s);\n\n  char buffer[4] = {0};\n  fmt::format_to(buffer, \"{}\", 42);\n  EXPECT_EQ(\"42\", std::string_view(buffer));\n\n  fmt::memory_buffer mb;\n  fmt::format_to(std::back_inserter(mb), \"{}\", 42);\n  EXPECT_EQ(\"42\", std::string_view(buffer));\n\n  std::wstring w;\n  fmt::format_to(std::back_inserter(w), L\"{}\", 42);\n  EXPECT_EQ(L\"42\", w);\n\n  wchar_t wbuffer[4] = {0};\n  fmt::format_to(wbuffer, L\"{}\", 42);\n  EXPECT_EQ(L\"42\", std::wstring_view(wbuffer));\n\n  fmt::wmemory_buffer wb;\n  fmt::format_to(std::back_inserter(wb), L\"{}\", 42);\n  EXPECT_EQ(L\"42\", std::wstring_view(wbuffer));\n}\n\nTEST(module_test, formatted_size) {\n  EXPECT_EQ(2u, fmt::formatted_size(\"{}\", 42));\n  EXPECT_EQ(2u, fmt::formatted_size(L\"{}\", 42));\n}\n\nTEST(module_test, format_to_n) {\n  std::string s;\n  auto result = fmt::format_to_n(std::back_inserter(s), 1, \"{}\", 42);\n  EXPECT_EQ(2u, result.size);\n  char buffer[4] = {0};\n  fmt::format_to_n(buffer, 3, \"{}\", 12345);\n\n  std::wstring w;\n  auto wresult = fmt::format_to_n(std::back_inserter(w), 1, L\"{}\", 42);\n  EXPECT_EQ(2u, wresult.size);\n  wchar_t wbuffer[4] = {0};\n  fmt::format_to_n(wbuffer, 3, L\"{}\", 12345);\n}\n\nTEST(module_test, format_args) {\n  auto no_args = fmt::format_args();\n  EXPECT_FALSE(no_args.get(1));\n\n  fmt::basic_format_args args = fmt::make_format_args(42);\n  EXPECT_TRUE(args.max_size() > 0);\n  auto arg0 = args.get(0);\n  EXPECT_TRUE(arg0);\n  decltype(arg0) arg_none;\n  EXPECT_FALSE(arg_none);\n  EXPECT_TRUE(arg0.type() != arg_none.type());\n}\n\nTEST(module_test, wformat_args) {\n  auto no_args = fmt::wformat_args();\n  EXPECT_FALSE(no_args.get(1));\n  fmt::basic_format_args args = fmt::make_wformat_args(42);\n  EXPECT_TRUE(args.get(0));\n}\n\nTEST(module_test, dynamic_format_args) {\n  fmt::dynamic_format_arg_store<fmt::format_context> dyn_store;\n  dyn_store.push_back(fmt::arg(\"a42\", 42));\n  fmt::basic_format_args args = dyn_store;\n  EXPECT_FALSE(args.get(3));\n  EXPECT_TRUE(args.get(fmt::string_view(\"a42\")));\n\n  fmt::dynamic_format_arg_store<fmt::wformat_context> wdyn_store;\n  wdyn_store.push_back(fmt::arg(L\"a42\", 42));\n  fmt::basic_format_args wargs = wdyn_store;\n  EXPECT_FALSE(wargs.get(3));\n  EXPECT_TRUE(wargs.get(fmt::wstring_view(L\"a42\")));\n}\n\nTEST(module_test, vformat) {\n  EXPECT_EQ(\"42\", fmt::vformat(\"{}\", fmt::make_format_args(42)));\n  EXPECT_EQ(L\"42\",\n            fmt::vformat(fmt::wstring_view(L\"{}\"), fmt::make_wformat_args(42)));\n}\n\nTEST(module_test, vformat_to) {\n  auto store = fmt::make_format_args(42);\n  std::string s;\n  fmt::vformat_to(std::back_inserter(s), \"{}\", store);\n  EXPECT_EQ(\"42\", s);\n\n  char buffer[4] = {0};\n  fmt::vformat_to(buffer, \"{:}\", store);\n  EXPECT_EQ(\"42\", std::string_view(buffer));\n\n  auto wstore = fmt::make_wformat_args(42);\n  std::wstring w;\n  fmt::vformat_to(std::back_inserter(w), L\"{}\", wstore);\n  EXPECT_EQ(L\"42\", w);\n\n  wchar_t wbuffer[4] = {0};\n  fmt::vformat_to(wbuffer, L\"{:}\", wstore);\n  EXPECT_EQ(L\"42\", std::wstring_view(wbuffer));\n}\n\nTEST(module_test, vformat_to_n) {\n  auto store = fmt::make_format_args(12345);\n  std::string s;\n  auto result = fmt::vformat_to_n(std::back_inserter(s), 1, \"{}\", store);\n  char buffer[4] = {0};\n  fmt::vformat_to_n(buffer, 3, \"{:}\", store);\n\n  auto wstore = fmt::make_wformat_args(12345);\n  std::wstring w;\n  auto wresult = fmt::vformat_to_n(std::back_inserter(w), 1,\n                                   fmt::wstring_view(L\"{}\"), wstore);\n  wchar_t wbuffer[4] = {0};\n  fmt::vformat_to_n(wbuffer, 3, fmt::wstring_view(L\"{:}\"), wstore);\n}\n\nstd::string as_string(std::wstring_view text) {\n  return {reinterpret_cast<const char*>(text.data()),\n          text.size() * sizeof(text[0])};\n}\n\nTEST(module_test, print) {\n  EXPECT_WRITE(stdout, fmt::print(\"{}µ\", 42), \"42µ\");\n  EXPECT_WRITE(stderr, fmt::print(stderr, \"{}µ\", 4.2), \"4.2µ\");\n  EXPECT_WRITE(stdout, fmt::print(L\"{}µ\", 42), as_string(L\"42µ\"));\n  EXPECT_WRITE(stderr, fmt::print(stderr, L\"{}µ\", 4.2), as_string(L\"4.2µ\"));\n}\n\nTEST(module_test, vprint) {\n  EXPECT_WRITE(stdout, fmt::vprint(\"{:}µ\", fmt::make_format_args(42)), \"42µ\");\n  EXPECT_WRITE(stderr, fmt::vprint(stderr, \"{}\", fmt::make_format_args(4.2)),\n               \"4.2\");\n  EXPECT_WRITE(stdout, fmt::vprint(L\"{:}µ\", fmt::make_wformat_args(42)),\n               as_string(L\"42µ\"));\n  EXPECT_WRITE(stderr, fmt::vprint(stderr, L\"{}\", fmt::make_wformat_args(42)),\n               as_string(L\"42\"));\n}\n\nTEST(module_test, named_args) {\n  EXPECT_EQ(\"42\", fmt::format(\"{answer}\", fmt::arg(\"answer\", 42)));\n  EXPECT_EQ(L\"42\", fmt::format(L\"{answer}\", fmt::arg(L\"answer\", 42)));\n}\n\nTEST(module_test, literals) {\n  using namespace fmt::literals;\n  EXPECT_EQ(\"42\", fmt::format(\"{answer}\", \"answer\"_a = 42));\n  EXPECT_EQ(L\"42\", fmt::format(L\"{answer}\", L\"answer\"_a = 42));\n}\n\nTEST(module_test, locale) {\n  auto store = fmt::make_format_args(4.2);\n  const auto classic = std::locale::classic();\n  EXPECT_EQ(\"4.2\", fmt::format(classic, \"{:L}\", 4.2));\n  EXPECT_EQ(\"4.2\", fmt::vformat(classic, \"{:L}\", store));\n  std::string s;\n  fmt::vformat_to(std::back_inserter(s), classic, \"{:L}\", store);\n  EXPECT_EQ(\"4.2\", s);\n  EXPECT_EQ(\"4.2\", fmt::format(\"{:L}\", 4.2));\n\n  auto wstore = fmt::make_wformat_args(4.2);\n  EXPECT_EQ(L\"4.2\", fmt::format(classic, L\"{:L}\", 4.2));\n  EXPECT_EQ(L\"4.2\", fmt::vformat(classic, L\"{:L}\", wstore));\n  std::wstring w;\n  fmt::vformat_to(std::back_inserter(w), classic, L\"{:L}\", wstore);\n  EXPECT_EQ(L\"4.2\", w);\n  EXPECT_EQ(L\"4.2\", fmt::format(L\"{:L}\", 4.2));\n}\n\nTEST(module_test, string_view) {\n  fmt::string_view nsv(\"fmt\");\n  EXPECT_EQ(\"fmt\", nsv);\n  EXPECT_TRUE(fmt::string_view(\"fmt\") == nsv);\n\n  fmt::wstring_view wsv(L\"fmt\");\n  EXPECT_EQ(L\"fmt\", wsv);\n  EXPECT_TRUE(fmt::wstring_view(L\"fmt\") == wsv);\n}\n\nTEST(module_test, memory_buffer) {\n  fmt::basic_memory_buffer<char, fmt::inline_buffer_size> buffer;\n  fmt::format_to(std::back_inserter(buffer), \"{}\", \"42\");\n  EXPECT_EQ(\"42\", to_string(buffer));\n  fmt::memory_buffer nbuffer(std::move(buffer));\n  EXPECT_EQ(\"42\", to_string(nbuffer));\n  buffer = std::move(nbuffer);\n  EXPECT_EQ(\"42\", to_string(buffer));\n  nbuffer.clear();\n  EXPECT_EQ(0u, to_string(nbuffer).size());\n\n  fmt::wmemory_buffer wbuffer;\n  EXPECT_EQ(0u, to_string(wbuffer).size());\n}\n\nTEST(module_test, is_char) {\n  EXPECT_TRUE(fmt::is_char<char>());\n  EXPECT_TRUE(fmt::is_char<wchar_t>());\n  EXPECT_TRUE(fmt::is_char<char8_t>());\n  EXPECT_TRUE(fmt::is_char<char16_t>());\n  EXPECT_TRUE(fmt::is_char<char32_t>());\n  EXPECT_FALSE(fmt::is_char<signed char>());\n}\n\nTEST(module_test, ptr) {\n  uintptr_t answer = 42;\n  auto p = std::bit_cast<int*>(answer);\n  EXPECT_EQ(\"0x2a\", fmt::to_string(fmt::ptr(p)));\n  std::unique_ptr<int> up(p);\n  EXPECT_EQ(\"0x2a\", fmt::to_string(fmt::ptr(up)));\n  up.release();\n  auto sp = std::make_shared<int>(0);\n  p = sp.get();\n  EXPECT_EQ(fmt::to_string(fmt::ptr(p)), fmt::to_string(fmt::ptr(sp)));\n}\n\nTEST(module_test, errors) {\n  auto store = fmt::make_format_args(42);\n  EXPECT_THROW(throw fmt::format_error(\"oops\"), std::exception);\n  EXPECT_THROW(throw fmt::vsystem_error(0, \"{}\", store), std::system_error);\n  EXPECT_THROW(throw fmt::system_error(0, \"{}\", 42), std::system_error);\n\n  fmt::memory_buffer buffer;\n  fmt::format_system_error(buffer, 0, \"oops\");\n  auto oops = to_string(buffer);\n  EXPECT_TRUE(oops.size() > 0);\n  EXPECT_WRITE(stderr, fmt::report_system_error(0, \"oops\"), oops + '\\n');\n\n#ifdef _WIN32\n  EXPECT_THROW(throw fmt::vwindows_error(0, \"{}\", store), std::system_error);\n  EXPECT_THROW(throw fmt::windows_error(0, \"{}\", 42), std::system_error);\n  output_redirect redirect(stderr);\n  fmt::report_windows_error(0, \"oops\");\n  EXPECT_TRUE(redirect.restore_and_read().size() > 0);\n#endif\n}\n\nTEST(module_test, error_code) {\n  EXPECT_EQ(\"generic:42\",\n            fmt::format(\"{0}\", std::error_code(42, std::generic_category())));\n  EXPECT_EQ(\"system:42\",\n            fmt::format(\"{0}\", std::error_code(42, fmt::system_category())));\n  EXPECT_EQ(L\"generic:42\",\n            fmt::format(L\"{0}\", std::error_code(42, std::generic_category())));\n}\n\nTEST(module_test, format_int) {\n  fmt::format_int sanswer(42);\n  EXPECT_EQ(\"42\", fmt::string_view(sanswer.data(), sanswer.size()));\n  fmt::format_int uanswer(42u);\n  EXPECT_EQ(\"42\", fmt::string_view(uanswer.data(), uanswer.size()));\n}\n\nstruct test_formatter : fmt::formatter<char> {\n  bool check() { return true; }\n};\n\nTEST(module_test, formatter) { EXPECT_TRUE(test_formatter{}.check()); }\n\nTEST(module_test, join) {\n  int arr[3] = {1, 2, 3};\n  std::vector<double> vec{1.0, 2.0, 3.0};\n  std::initializer_list<int> il{1, 2, 3};\n  auto sep = fmt::string_view(\", \");\n  EXPECT_EQ(\"1, 2, 3\", to_string(fmt::join(arr + 0, arr + 3, sep)));\n  EXPECT_EQ(\"1, 2, 3\", to_string(fmt::join(arr, sep)));\n  EXPECT_EQ(\"1, 2, 3\", to_string(fmt::join(vec.begin(), vec.end(), sep)));\n  EXPECT_EQ(\"1, 2, 3\", to_string(fmt::join(vec, sep)));\n  EXPECT_EQ(\"1, 2, 3\", to_string(fmt::join(il, sep)));\n\n  auto wsep = fmt::wstring_view(L\", \");\n  EXPECT_EQ(L\"1, 2, 3\", fmt::format(L\"{}\", fmt::join(arr + 0, arr + 3, wsep)));\n  EXPECT_EQ(L\"1, 2, 3\", fmt::format(L\"{}\", fmt::join(arr, wsep)));\n  EXPECT_EQ(L\"1, 2, 3\", fmt::format(L\"{}\", fmt::join(il, wsep)));\n}\n\nTEST(module_test, time) {\n  auto time_now = std::time(nullptr);\n  EXPECT_TRUE(fmt::localtime(time_now).tm_year > 120);\n  EXPECT_TRUE(fmt::gmtime(time_now).tm_year > 120);\n  auto chrono_now = std::chrono::system_clock::now();\n  EXPECT_TRUE(fmt::gmtime(chrono_now).tm_year > 120);\n}\n\nTEST(module_test, time_point) {\n  auto now = std::chrono::system_clock::now();\n  std::string_view past(\"2021-05-20 10:30:15\");\n  EXPECT_TRUE(past < fmt::format(\"{:%Y-%m-%d %H:%M:%S}\", now));\n  std::wstring_view wpast(L\"2021-05-20 10:30:15\");\n  EXPECT_TRUE(wpast < fmt::format(L\"{:%Y-%m-%d %H:%M:%S}\", now));\n}\n\nTEST(module_test, time_duration) {\n  using us = std::chrono::duration<double, std::micro>;\n  EXPECT_EQ(\"42s\", fmt::format(\"{}\", std::chrono::seconds{42}));\n  EXPECT_EQ(\"4.2µs\", fmt::format(\"{:3.1}\", us{4.234}));\n  EXPECT_EQ(\"4.2µs\", fmt::format(std::locale::classic(), \"{:L}\", us{4.2}));\n\n  EXPECT_EQ(L\"42s\", fmt::format(L\"{}\", std::chrono::seconds{42}));\n  EXPECT_EQ(L\"4.2µs\", fmt::format(L\"{:3.1}\", us{4.234}));\n  EXPECT_EQ(L\"4.2µs\", fmt::format(std::locale::classic(), L\"{:L}\", us{4.2}));\n}\n\nTEST(module_test, weekday) {\n  EXPECT_EQ(\"Mon\", fmt::format(std::locale::classic(), \"{}\", fmt::weekday(1)));\n}\n\nTEST(module_test, printf) {\n  EXPECT_WRITE(stdout, fmt::printf(\"%f\", 42.123456), \"42.123456\");\n  EXPECT_WRITE(stdout, fmt::printf(\"%d\", 42), \"42\");\n  EXPECT_WRITE(stdout, fmt::printf(L\"%f\", 42.123456), as_string(L\"42.123456\"));\n  EXPECT_WRITE(stdout, fmt::printf(L\"%d\", 42), as_string(L\"42\"));\n}\n\nTEST(module_test, fprintf) {\n  EXPECT_WRITE(stderr, fmt::fprintf(stderr, \"%d\", 42), \"42\");\n  EXPECT_WRITE(stderr, fmt::fprintf(stderr, L\"%d\", 42), as_string(L\"42\"));\n}\n\nTEST(module_test, sprintf) {\n  EXPECT_EQ(\"42\", fmt::sprintf(\"%d\", 42));\n  EXPECT_EQ(L\"42\", fmt::sprintf(L\"%d\", 42));\n}\n\nTEST(module_test, vprintf) {\n  EXPECT_WRITE(stdout, fmt::vprintf(\"%d\", fmt::make_printf_args(42)), \"42\");\n  EXPECT_WRITE(stdout, fmt::vprintf(L\"%d\", fmt::make_wprintf_args(42)),\n               as_string(L\"42\"));\n}\n\nTEST(module_test, vfprintf) {\n  auto args = fmt::make_printf_args(42);\n  EXPECT_WRITE(stderr, fmt::vfprintf(stderr, \"%d\", args), \"42\");\n  auto wargs = fmt::make_wprintf_args(42);\n  EXPECT_WRITE(stderr, fmt::vfprintf(stderr, L\"%d\", wargs), as_string(L\"42\"));\n}\n\nTEST(module_test, vsprintf) {\n  EXPECT_EQ(\"42\", fmt::vsprintf(\"%d\", fmt::make_printf_args(42)));\n  EXPECT_EQ(L\"42\", fmt::vsprintf(L\"%d\", fmt::make_wprintf_args(42)));\n}\n\nTEST(module_test, color) {\n  auto fg_check = fg(fmt::rgb(255, 200, 30));\n  auto bg_check = bg(fmt::color::dark_slate_gray) | fmt::emphasis::italic;\n  auto emphasis_check = fmt::emphasis::underline | fmt::emphasis::bold;\n  EXPECT_EQ(\"\\x1B[30m42\\x1B[0m\",\n            fmt::format(fg(fmt::terminal_color::black), \"{}\", 42));\n  EXPECT_EQ(L\"\\x1B[30m42\\x1B[0m\",\n            fmt::format(fg(fmt::terminal_color::black), L\"{}\", 42));\n}\n\nTEST(module_test, cstring_view) {\n  auto s = \"fmt\";\n  EXPECT_EQ(s, fmt::cstring_view(s).c_str());\n  auto w = L\"fmt\";\n  EXPECT_EQ(w, fmt::wcstring_view(w).c_str());\n}\n\nTEST(module_test, buffered_file) {\n  EXPECT_TRUE(fmt::buffered_file{}.get() == nullptr);\n}\n\nTEST(module_test, output_file) {\n#ifdef __clang__\n  fmt::println(\"\\033[0;33m[=disabled=] {}\\033[0;0m\",\n               \"Clang 16.0 emits multiple copies of vtables\");\n#else\n  fmt::ostream out = fmt::output_file(\"module-test\", fmt::buffer_size = 1);\n  out.close();\n#endif\n}\n\nstruct custom_context {\n  using char_type = char;\n  using parse_context_type = fmt::format_parse_context;\n};\n\nTEST(module_test, custom_context) {\n  fmt::basic_format_arg<custom_context> custom_arg;\n  EXPECT_TRUE(!custom_arg);\n}\n\nTEST(module_test, compile_format_string) {\n  using namespace fmt::literals;\n#ifdef __clang__\n  fmt::println(\"\\033[0;33m[=disabled=] {}\\033[0;0m\",\n               \"Clang 16.0 fails to import user-defined literals\");\n#else\n  EXPECT_EQ(\"42\", fmt::format(\"{0:x}\"_cf, 0x42));\n  EXPECT_EQ(L\"42\", fmt::format(L\"{:}\"_cf, 42));\n  EXPECT_EQ(\"4.2\", fmt::format(\"{arg:3.1f}\"_cf, \"arg\"_a = 4.2));\n  EXPECT_EQ(L\" 42\", fmt::format(L\"{arg:>3}\"_cf, L\"arg\"_a = L\"42\"));\n#endif\n}\n"
  },
  {
    "path": "test/no-builtin-types-test.cc",
    "content": "// Formatting library for C++ - formatting library tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"gtest/gtest.h\"\n\n#if !defined(__GNUC__) || (__GNUC__ >= 5 || defined(__clang__))\n\n#  define FMT_BUILTIN_TYPES 0\n#  include \"fmt/compile.h\"\n\nTEST(no_builtin_types_test, format) {\n  EXPECT_EQ(fmt::format(\"{}\", 42), \"42\");\n  EXPECT_EQ(fmt::format(\"{}\", 42L), \"42\");\n}\n\nTEST(no_builtin_types_test, double_is_custom_type) {\n  double d = 42;\n  auto args = fmt::make_format_args(d);\n  EXPECT_EQ(fmt::format_args(args).get(0).type(),\n            fmt::detail::type::custom_type);\n}\n\nTEST(no_builtin_types_test, format_pointer_compiled) {\n  const void* p = nullptr;\n  fmt::format(FMT_COMPILE(\"{:} {}\"), 42, p);\n}\n#endif\n"
  },
  {
    "path": "test/noexception-test.cc",
    "content": "// Formatting library for C++ - Noexception tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/args.h\"\n#include \"fmt/base.h\"\n#include \"fmt/chrono.h\"\n#include \"fmt/color.h\"\n#include \"fmt/compile.h\"\n#include \"fmt/format.h\"\n#include \"fmt/os.h\"\n#include \"fmt/ostream.h\"\n#include \"fmt/printf.h\"\n#include \"fmt/ranges.h\"\n#include \"fmt/xchar.h\"\n"
  },
  {
    "path": "test/os-test.cc",
    "content": "// Formatting library for C++ - tests of the OS-specific functionality\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/os.h\"\n\n#include <cstdlib>  // std::exit\n#include <cstring>\n#include <memory>\n#include <thread>\n\n#include \"gtest-extra.h\"\n#include \"util.h\"\n\nusing fmt::buffered_file;\nusing testing::HasSubstr;\nusing wstring_view = fmt::basic_string_view<wchar_t>;\n\nstatic auto uniq_file_name(unsigned line_number) -> std::string {\n  return \"test-file\" + std::to_string(line_number);\n}\n\nauto safe_fopen(const char* filename, const char* mode) -> FILE* {\n#if defined(_WIN32) && !defined(__MINGW32__)\n  // Fix MSVC warning about \"unsafe\" fopen.\n  FILE* f = nullptr;\n  errno = fopen_s(&f, filename, mode);\n  return f;\n#else\n  return std::fopen(filename, mode);\n#endif\n}\n\n#ifdef _WIN32\n\n#  include <windows.h>\n\nTEST(os_test, format_windows_error) {\n  LPWSTR message = nullptr;\n  auto result = FormatMessageW(\n      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |\n          FORMAT_MESSAGE_IGNORE_INSERTS,\n      nullptr, ERROR_FILE_EXISTS, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n      reinterpret_cast<LPWSTR>(&message), 0, nullptr);\n  auto utf8_message =\n      fmt::detail::to_utf8<wchar_t>(wstring_view(message, result - 2));\n  LocalFree(message);\n  fmt::memory_buffer actual_message;\n  fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, \"test\");\n  EXPECT_EQ(fmt::format(\"test: {}\", utf8_message.str()),\n            fmt::to_string(actual_message));\n  actual_message.resize(0);\n}\n\nTEST(os_test, format_long_windows_error) {\n  LPWSTR message = nullptr;\n  // this error code is not available on all Windows platforms and\n  // Windows SDKs, so do not fail the test if the error string cannot\n  // be retrieved.\n  int provisioning_not_allowed = 0x80284013L;  // TBS_E_PROVISIONING_NOT_ALLOWED\n  auto result = FormatMessageW(\n      FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |\n          FORMAT_MESSAGE_IGNORE_INSERTS,\n      nullptr, static_cast<DWORD>(provisioning_not_allowed),\n      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n      reinterpret_cast<LPWSTR>(&message), 0, nullptr);\n  if (result == 0) {\n    LocalFree(message);\n    return;\n  }\n  auto utf8_message =\n      fmt::detail::to_utf8<wchar_t>(wstring_view(message, result - 2));\n  LocalFree(message);\n  fmt::memory_buffer actual_message;\n  fmt::detail::format_windows_error(actual_message, provisioning_not_allowed,\n                                    \"test\");\n  EXPECT_EQ(fmt::format(\"test: {}\", utf8_message.str()),\n            fmt::to_string(actual_message));\n}\n\nTEST(os_test, windows_error) {\n  auto error = std::system_error(std::error_code());\n  try {\n    throw fmt::windows_error(ERROR_FILE_EXISTS, \"test {}\", \"error\");\n  } catch (const std::system_error& e) {\n    error = e;\n  }\n  fmt::memory_buffer message;\n  fmt::detail::format_windows_error(message, ERROR_FILE_EXISTS, \"test error\");\n  EXPECT_THAT(error.what(), HasSubstr(to_string(message)));\n  EXPECT_EQ(ERROR_FILE_EXISTS, error.code().value());\n}\n\nTEST(os_test, report_windows_error) {\n  fmt::memory_buffer out;\n  fmt::detail::format_windows_error(out, ERROR_FILE_EXISTS, \"test error\");\n  out.push_back('\\n');\n  EXPECT_WRITE(stderr,\n               fmt::report_windows_error(ERROR_FILE_EXISTS, \"test error\"),\n               fmt::to_string(out));\n}\n\n#  if FMT_USE_FCNTL && !defined(__MINGW32__)\nTEST(file_test, open_windows_file) {\n  using fmt::file;\n  file out = file::open_windows_file(L\"test-file\",\n                                     file::WRONLY | file::CREATE | file::TRUNC);\n  out.write(\"x\", 1);\n  file in = file::open_windows_file(L\"test-file\", file::RDONLY);\n  EXPECT_READ(in, \"x\");\n}\n#  endif  // FMT_USE_FCNTL && !defined(__MINGW32__)\n\n#endif  // _WIN32\n\n#if FMT_USE_FCNTL\n\nusing fmt::file;\n\nauto isclosed(int fd) -> bool {\n  char buffer;\n  auto result = std::streamsize();\n  SUPPRESS_ASSERT(result = FMT_POSIX(read(fd, &buffer, 1)));\n  return result == -1 && errno == EBADF;\n}\n\n// Opens a file for reading.\nauto open_file() -> file {\n  auto pipe = fmt::pipe();\n  pipe.write_end.write(file_content, std::strlen(file_content));\n  pipe.write_end.close();\n  return std::move(pipe.read_end);\n}\n\n// Attempts to write a string to a file.\nvoid write(file& f, fmt::string_view s) {\n  size_t num_chars_left = s.size();\n  const char* ptr = s.data();\n  do {\n    size_t count = f.write(ptr, num_chars_left);\n    ptr += count;\n    // We can't write more than size_t bytes since num_chars_left\n    // has type size_t.\n    num_chars_left -= count;\n  } while (num_chars_left != 0);\n}\n\nTEST(buffered_file_test, default_ctor) {\n  auto f = buffered_file();\n  EXPECT_TRUE(f.get() == nullptr);\n}\n\nTEST(buffered_file_test, move_ctor) {\n  buffered_file bf = open_buffered_file();\n  FILE* fp = bf.get();\n  EXPECT_TRUE(fp != nullptr);\n  buffered_file bf2(std::move(bf));\n  EXPECT_EQ(fp, bf2.get());\n  EXPECT_TRUE(bf.get() == nullptr);\n}\n\nTEST(buffered_file_test, move_assignment) {\n  buffered_file bf = open_buffered_file();\n  FILE* fp = bf.get();\n  EXPECT_TRUE(fp != nullptr);\n  buffered_file bf2;\n  bf2 = std::move(bf);\n  EXPECT_EQ(fp, bf2.get());\n  EXPECT_TRUE(bf.get() == nullptr);\n}\n\nTEST(buffered_file_test, move_assignment_closes_file) {\n  buffered_file bf = open_buffered_file();\n  buffered_file bf2 = open_buffered_file();\n  int old_fd = bf2.descriptor();\n  bf2 = std::move(bf);\n  EXPECT_TRUE(isclosed(old_fd));\n}\n\nTEST(buffered_file_test, move_from_temporary_in_ctor) {\n  FILE* fp = nullptr;\n  buffered_file f = open_buffered_file(&fp);\n  EXPECT_EQ(fp, f.get());\n}\n\nTEST(buffered_file_test, move_from_temporary_in_assignment) {\n  FILE* fp = nullptr;\n  auto f = buffered_file();\n  f = open_buffered_file(&fp);\n  EXPECT_EQ(fp, f.get());\n}\n\nTEST(buffered_file_test, move_from_temporary_in_assignment_closes_file) {\n  buffered_file f = open_buffered_file();\n  int old_fd = f.descriptor();\n  f = open_buffered_file();\n  EXPECT_TRUE(isclosed(old_fd));\n}\n\nTEST(buffered_file_test, close_file_in_dtor) {\n  int fd = 0;\n  {\n    buffered_file f = open_buffered_file();\n    fd = f.descriptor();\n  }\n  EXPECT_TRUE(isclosed(fd));\n}\n\nTEST(buffered_file_test, close_error_in_dtor) {\n  auto f =\n      std::unique_ptr<buffered_file>(new buffered_file(open_buffered_file()));\n  EXPECT_WRITE(\n      stderr,\n      {\n        // The close function must be called inside EXPECT_WRITE,\n        // otherwise the system may recycle closed file descriptor when\n        // redirecting the output in EXPECT_STDERR and the second close\n        // will break output redirection.\n        FMT_POSIX(close(f->descriptor()));\n        SUPPRESS_ASSERT(f.reset(nullptr));\n      },\n      system_error_message(EBADF, \"cannot close file\") + \"\\n\");\n}\n\nTEST(buffered_file_test, close) {\n  buffered_file f = open_buffered_file();\n  int fd = f.descriptor();\n  f.close();\n  EXPECT_TRUE(f.get() == nullptr);\n  EXPECT_TRUE(isclosed(fd));\n}\n\nTEST(buffered_file_test, close_error) {\n  buffered_file f = open_buffered_file();\n  FMT_POSIX(close(f.descriptor()));\n  EXPECT_SYSTEM_ERROR_NOASSERT(f.close(), EBADF, \"cannot close file\");\n  EXPECT_TRUE(f.get() == nullptr);\n}\n\nTEST(buffered_file_test, descriptor) {\n  auto f = open_buffered_file();\n  EXPECT_TRUE(f.descriptor() != -1);\n  file copy = file::dup(f.descriptor());\n  EXPECT_READ(copy, file_content);\n}\n\nTEST(ostream_test, move) {\n  fmt::ostream out = fmt::output_file(uniq_file_name(__LINE__));\n  fmt::ostream moved(std::move(out));\n  moved.print(\"hello\");\n}\n\nTEST(ostream_test, move_while_holding_data) {\n  auto test_file = uniq_file_name(__LINE__);\n  {\n    fmt::ostream out = fmt::output_file(test_file);\n    out.print(\"Hello, \");\n    fmt::ostream moved(std::move(out));\n    moved.print(\"world!\\n\");\n  }\n  {\n    file in(test_file, file::RDONLY);\n    EXPECT_READ(in, \"Hello, world!\\n\");\n  }\n}\n\nTEST(ostream_test, print) {\n  auto test_file = uniq_file_name(__LINE__);\n  fmt::ostream out = fmt::output_file(test_file);\n  out.print(\"The answer is {}.\\n\", 42);\n  out.close();\n  file in(test_file, file::RDONLY);\n  EXPECT_READ(in, \"The answer is 42.\\n\");\n}\n\nTEST(ostream_test, buffer_boundary) {\n  auto str = std::string(4096, 'x');\n  auto test_file = uniq_file_name(__LINE__);\n  fmt::ostream out = fmt::output_file(test_file);\n  out.print(\"{}\", str);\n  out.print(\"{}\", str);\n  out.close();\n  file in(test_file, file::RDONLY);\n  EXPECT_READ(in, str + str);\n}\n\nTEST(ostream_test, buffer_size) {\n  auto test_file = uniq_file_name(__LINE__);\n  fmt::ostream out = fmt::output_file(test_file, fmt::buffer_size = 1);\n  out.print(\"{}\", \"foo\");\n  out.close();\n  file in(test_file, file::RDONLY);\n  EXPECT_READ(in, \"foo\");\n}\n\nTEST(ostream_test, truncate) {\n  auto test_file = uniq_file_name(__LINE__);\n  {\n    fmt::ostream out = fmt::output_file(test_file);\n    out.print(\"0123456789\");\n  }\n  {\n    fmt::ostream out = fmt::output_file(test_file);\n    out.print(\"foo\");\n  }\n  file in(test_file, file::RDONLY);\n  EXPECT_EQ(\"foo\", read(in, 4));\n}\n\nTEST(ostream_test, flush) {\n  auto test_file = uniq_file_name(__LINE__);\n  auto out = fmt::output_file(test_file);\n  out.print(\"x\");\n  out.flush();\n  auto in = fmt::file(test_file, file::RDONLY);\n  EXPECT_READ(in, \"x\");\n}\n\nTEST(file_test, default_ctor) {\n  file f;\n  EXPECT_EQ(-1, f.descriptor());\n}\n\nTEST(file_test, open_buffered_file_in_ctor) {\n  auto test_file = uniq_file_name(__LINE__);\n  FILE* fp = safe_fopen(test_file.c_str(), \"w\");\n  std::fputs(file_content, fp);\n  std::fclose(fp);\n  file f(test_file.c_str(), file::RDONLY);\n  // Check if the file is open by reading one character from it.\n  char buffer;\n  bool isopen = FMT_POSIX(read(f.descriptor(), &buffer, 1)) == 1;\n  ASSERT_TRUE(isopen);\n}\n\nTEST(file_test, open_buffered_file_error) {\n  EXPECT_SYSTEM_ERROR(file(\"nonexistent\", file::RDONLY), ENOENT,\n                      \"cannot open file nonexistent\");\n}\n\nTEST(file_test, move_ctor) {\n  file f = open_file();\n  int fd = f.descriptor();\n  EXPECT_NE(-1, fd);\n  file f2(std::move(f));\n  EXPECT_EQ(fd, f2.descriptor());\n  EXPECT_EQ(-1, f.descriptor());\n}\n\nTEST(file_test, move_assignment) {\n  file f = open_file();\n  int fd = f.descriptor();\n  EXPECT_NE(-1, fd);\n  file f2;\n  f2 = std::move(f);\n  EXPECT_EQ(fd, f2.descriptor());\n  EXPECT_EQ(-1, f.descriptor());\n}\n\nTEST(file_test, move_assignment_closes_file) {\n  file f = open_file();\n  file f2 = open_file();\n  int old_fd = f2.descriptor();\n  f2 = std::move(f);\n  EXPECT_TRUE(isclosed(old_fd));\n}\n\nfile open_buffered_file(int& fd) {\n  file f = open_file();\n  fd = f.descriptor();\n  return f;\n}\n\nTEST(file_test, move_from_temporary_in_ctor) {\n  int fd = 0xdead;\n  file f(open_buffered_file(fd));\n  EXPECT_EQ(fd, f.descriptor());\n}\n\nTEST(file_test, move_from_temporary_in_assignment) {\n  int fd = 0xdead;\n  file f;\n  f = open_buffered_file(fd);\n  EXPECT_EQ(fd, f.descriptor());\n}\n\nTEST(file_test, move_from_temporary_in_assignment_closes_file) {\n  int fd = 0xdead;\n  file f = open_file();\n  int old_fd = f.descriptor();\n  f = open_buffered_file(fd);\n  EXPECT_TRUE(isclosed(old_fd));\n}\n\nTEST(file_test, close_file_in_dtor) {\n  int fd = 0;\n  {\n    file f = open_file();\n    fd = f.descriptor();\n  }\n  EXPECT_TRUE(isclosed(fd));\n}\n\nTEST(file_test, close_error_in_dtor) {\n  std::unique_ptr<file> f(new file(open_file()));\n  EXPECT_WRITE(\n      stderr,\n      {\n        // The close function must be called inside EXPECT_WRITE,\n        // otherwise the system may recycle closed file descriptor when\n        // redirecting the output in EXPECT_STDERR and the second close\n        // will break output redirection.\n        FMT_POSIX(close(f->descriptor()));\n        SUPPRESS_ASSERT(f.reset(nullptr));\n      },\n      system_error_message(EBADF, \"cannot close file\") + \"\\n\");\n}\n\nTEST(file_test, close) {\n  file f = open_file();\n  int fd = f.descriptor();\n  f.close();\n  EXPECT_EQ(-1, f.descriptor());\n  EXPECT_TRUE(isclosed(fd));\n}\n\nTEST(file_test, close_error) {\n  file f = open_file();\n  FMT_POSIX(close(f.descriptor()));\n  EXPECT_SYSTEM_ERROR_NOASSERT(f.close(), EBADF, \"cannot close file\");\n  EXPECT_EQ(-1, f.descriptor());\n}\n\nTEST(file_test, read) {\n  file f = open_file();\n  EXPECT_READ(f, file_content);\n}\n\nTEST(file_test, read_error) {\n  file f(uniq_file_name(__LINE__), file::WRONLY | file::CREATE);\n  char buf;\n  // We intentionally read from a file opened in the write-only mode to\n  // cause error.\n  EXPECT_SYSTEM_ERROR(f.read(&buf, 1), EBADF, \"cannot read from file\");\n}\n\nTEST(file_test, write) {\n  auto pipe = fmt::pipe();\n  write(pipe.write_end, \"test\");\n  pipe.write_end.close();\n  EXPECT_READ(pipe.read_end, \"test\");\n}\n\nTEST(file_test, write_error) {\n  file f(uniq_file_name(__LINE__), file::RDONLY | file::CREATE);\n  // We intentionally write to a file opened in the read-only mode to\n  // cause error.\n  EXPECT_SYSTEM_ERROR(f.write(\" \", 1), EBADF, \"cannot write to file\");\n}\n\nTEST(file_test, dup) {\n  file f = open_file();\n  file copy = file::dup(f.descriptor());\n  EXPECT_NE(f.descriptor(), copy.descriptor());\n  EXPECT_EQ(file_content, read(copy, std::strlen(file_content)));\n}\n\n#  ifndef __COVERITY__\nTEST(file_test, dup_error) {\n  int value = -1;\n  EXPECT_SYSTEM_ERROR_NOASSERT(file::dup(value), EBADF,\n                               \"cannot duplicate file descriptor -1\");\n}\n#  endif\n\nTEST(file_test, dup2) {\n  file f = open_file();\n  file copy = open_file();\n  f.dup2(copy.descriptor());\n  EXPECT_NE(f.descriptor(), copy.descriptor());\n  EXPECT_READ(copy, file_content);\n}\n\nTEST(file_test, dup2_error) {\n  file f = open_file();\n  EXPECT_SYSTEM_ERROR_NOASSERT(\n      f.dup2(-1), EBADF,\n      fmt::format(\"cannot duplicate file descriptor {} to -1\", f.descriptor()));\n}\n\nTEST(file_test, dup2_noexcept) {\n  file f = open_file();\n  file copy = open_file();\n  std::error_code ec;\n  f.dup2(copy.descriptor(), ec);\n  EXPECT_EQ(ec.value(), 0);\n  EXPECT_NE(f.descriptor(), copy.descriptor());\n  EXPECT_READ(copy, file_content);\n}\n\nTEST(file_test, dup2_noexcept_error) {\n  file f = open_file();\n  std::error_code ec;\n  SUPPRESS_ASSERT(f.dup2(-1, ec));\n  EXPECT_EQ(EBADF, ec.value());\n}\n\nTEST(file_test, pipe) {\n  auto pipe = fmt::pipe();\n  EXPECT_NE(-1, pipe.read_end.descriptor());\n  EXPECT_NE(-1, pipe.write_end.descriptor());\n  write(pipe.write_end, \"test\");\n  EXPECT_READ(pipe.read_end, \"test\");\n}\n\nTEST(file_test, fdopen) {\n  auto pipe = fmt::pipe();\n  int read_fd = pipe.read_end.descriptor();\n  EXPECT_EQ(read_fd, FMT_POSIX(fileno(pipe.read_end.fdopen(\"r\").get())));\n}\n\n// Windows CRT implements _IOLBF incorrectly (full buffering).\n#  ifndef _WIN32\nTEST(file_test, line_buffering) {\n  auto pipe = fmt::pipe();\n\n  int write_fd = pipe.write_end.descriptor();\n  auto write_end = pipe.write_end.fdopen(\"w\");\n  setvbuf(write_end.get(), nullptr, _IOLBF, 4096);\n  write_end.print(\"42\\n\");\n  close(write_fd);\n  try {\n    write_end.close();\n  } catch (const std::system_error&) {\n  }\n\n  auto read_end = pipe.read_end.fdopen(\"r\");\n  std::thread reader([&]() {\n    int n = 0;\n    int result = fscanf(read_end.get(), \"%d\", &n);\n    (void)result;\n    EXPECT_EQ(n, 42);\n  });\n\n  reader.join();\n}\n#  endif  // _WIN32\n\nTEST(file_test, buffer_boundary) {\n  auto pipe = fmt::pipe();\n\n  auto write_end = pipe.write_end.fdopen(\"w\");\n  setvbuf(write_end.get(), nullptr, _IOFBF, 4096);\n  for (int i = 3; i < 4094; i++)\n    write_end.print(\"{}\", (i % 73) != 0 ? 'x' : '\\n');\n  write_end.print(\"{} {}\", 1234, 567);\n  write_end.close();\n\n  auto read_end = pipe.read_end.fdopen(\"r\");\n  char buf[4091] = {};\n  size_t n = fread(buf, 1, sizeof(buf), read_end.get());\n  EXPECT_EQ(n, sizeof(buf));\n  EXPECT_STREQ(fgets(buf, sizeof(buf), read_end.get()), \"1234 567\");\n}\n\nTEST(file_test, io_putting) {\n  auto pipe = fmt::pipe();\n  auto read_end = pipe.read_end.fdopen(\"r\");\n  auto write_end = pipe.write_end.fdopen(\"w\");\n\n  size_t read_size = 0;\n  auto reader = std::thread([&]() {\n    size_t n = 0;\n    do {\n      char buf[4096] = {};\n      n = fread(buf, 1, sizeof(buf), read_end.get());\n      read_size += n;\n    } while (n != 0);\n  });\n\n  // This initialize buffers but doesn't set _IO_CURRENTLY_PUTTING.\n  fseek(write_end.get(), 0, SEEK_SET);\n\n  size_t write_size = 0;\n  for (int i = 0; i <= 20000; ++i) {\n    auto s = fmt::format(\"{}\\n\", i);\n    fmt::print(write_end.get(), \"{}\", s);\n    write_size += s.size();\n  }\n\n  write_end.close();\n  reader.join();\n  EXPECT_EQ(read_size, write_size);\n}\n\n#endif  // FMT_USE_FCNTL\n"
  },
  {
    "path": "test/ostream-test.cc",
    "content": "// Formatting library for C++ - std::ostream support tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <fstream>\n\n#include \"fmt/format.h\"\n\nusing fmt::runtime;\n\nstruct test {};\n\n// Test that there is no issues with specializations when fmt/ostream.h is\n// included after fmt/format.h.\nnamespace fmt {\ntemplate <> struct formatter<test> : formatter<int> {\n  auto format(const test&, format_context& ctx) const -> decltype(ctx.out()) {\n    return formatter<int>::format(42, ctx);\n  }\n};\n}  // namespace fmt\n\n#include <sstream>\n\n#include \"fmt/compile.h\"\n#include \"fmt/ostream.h\"\n#include \"fmt/ranges.h\"\n#include \"gmock/gmock.h\"\n#include \"gtest-extra.h\"\n#include \"util.h\"\n\nauto operator<<(std::ostream& os, const date& d) -> std::ostream& {\n  os << d.year() << '-' << d.month() << '-' << d.day();\n  return os;\n}\n\nauto operator<<(std::wostream& os, const date& d) -> std::wostream& {\n  os << d.year() << L'-' << d.month() << L'-' << d.day();\n  return os;\n}\n\n// Make sure that overloaded comma operators do no harm to is_streamable.\nstruct type_with_comma_op {};\ntemplate <typename T> void operator,(type_with_comma_op, const T&);\ntemplate <typename T> type_with_comma_op operator<<(T&, const date&);\n\nenum streamable_enum {};\n\nauto operator<<(std::ostream& os, streamable_enum) -> std::ostream& {\n  return os << \"streamable_enum\";\n}\n\nenum unstreamable_enum {};\nauto format_as(unstreamable_enum e) -> int { return e; }\n\nstruct empty_test {};\nauto operator<<(std::ostream& os, empty_test) -> std::ostream& {\n  return os << \"\";\n}\n\nnamespace fmt {\ntemplate <> struct formatter<test_string> : ostream_formatter {};\ntemplate <> struct formatter<date> : ostream_formatter {};\ntemplate <> struct formatter<streamable_enum> : ostream_formatter {};\ntemplate <> struct formatter<empty_test> : ostream_formatter {};\n}  // namespace fmt\n\nTEST(ostream_test, enum) {\n  EXPECT_EQ(\"streamable_enum\", fmt::format(\"{}\", streamable_enum()));\n  EXPECT_EQ(\"0\", fmt::format(\"{}\", unstreamable_enum()));\n}\n\nTEST(ostream_test, format) {\n  EXPECT_EQ(\"a string\", fmt::format(\"{0}\", test_string(\"a string\")));\n  EXPECT_EQ(\"The date is 2012-12-9\",\n            fmt::format(\"The date is {0}\", date(2012, 12, 9)));\n}\n\nTEST(ostream_test, format_specs) {\n  using fmt::format_error;\n  EXPECT_EQ(\"def  \", fmt::format(\"{0:<5}\", test_string(\"def\")));\n  EXPECT_EQ(\"  def\", fmt::format(\"{0:>5}\", test_string(\"def\")));\n  EXPECT_EQ(\" def \", fmt::format(\"{0:^5}\", test_string(\"def\")));\n  EXPECT_EQ(\"def**\", fmt::format(\"{0:*<5}\", test_string(\"def\")));\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:+}\"), test_string()),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:-}\"), test_string()),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0: }\"), test_string()),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:#}\"), test_string()),\n                   format_error, \"invalid format specifier\");\n  EXPECT_THROW_MSG((void)fmt::format(runtime(\"{0:05}\"), test_string()),\n                   format_error, \"format specifier requires numeric argument\");\n  EXPECT_EQ(\"test         \", fmt::format(\"{0:13}\", test_string(\"test\")));\n  EXPECT_EQ(\"test         \", fmt::format(\"{0:{1}}\", test_string(\"test\"), 13));\n  EXPECT_EQ(\"te\", fmt::format(\"{0:.2}\", test_string(\"test\")));\n  EXPECT_EQ(\"te\", fmt::format(\"{0:.{1}}\", test_string(\"test\"), 2));\n}\n\nTEST(ostream_test, empty_custom_output) {\n  EXPECT_EQ(\"\", fmt::format(\"{}\", empty_test()));\n}\n\nTEST(ostream_test, print) {\n  {\n    std::ostringstream os;\n    fmt::print(os, \"Don't {}!\", \"panic\");\n    EXPECT_EQ(\"Don't panic!\", os.str());\n  }\n\n  {\n    std::ostringstream os;\n    fmt::println(os, \"Don't {}!\", \"panic\");\n    EXPECT_EQ(\"Don't panic!\\n\", os.str());\n  }\n}\n\nTEST(ostream_test, write_to_ostream) {\n  std::ostringstream os;\n  fmt::memory_buffer buffer;\n  const char* foo = \"foo\";\n  buffer.append(foo, foo + std::strlen(foo));\n  fmt::detail::write_buffer(os, buffer);\n  EXPECT_EQ(\"foo\", os.str());\n}\n\nTEST(ostream_test, write_to_ostream_max_size) {\n  auto max_size = fmt::detail::max_value<size_t>();\n  auto max_streamsize = fmt::detail::max_value<std::streamsize>();\n  if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;\n\n  struct test_buffer final : fmt::detail::buffer<char> {\n    explicit test_buffer(size_t size)\n        : fmt::detail::buffer<char>([](buffer<char>&, size_t) {}, nullptr, size,\n                                    size) {}\n  } buffer(max_size);\n\n  struct mock_streambuf : std::streambuf {\n    MOCK_METHOD(std::streamsize, xsputn, (const void*, std::streamsize));\n    auto xsputn(const char* s, std::streamsize n) -> std::streamsize override {\n      const void* v = s;\n      return xsputn(v, n);\n    }\n  } streambuf;\n\n  struct test_ostream : std::ostream {\n    explicit test_ostream(mock_streambuf& output_buffer)\n        : std::ostream(&output_buffer) {}\n  } os(streambuf);\n\n  testing::InSequence sequence;\n  const char* data = nullptr;\n  using ustreamsize = std::make_unsigned<std::streamsize>::type;\n  ustreamsize size = max_size;\n  do {\n    auto n = std::min(size, fmt::detail::to_unsigned(max_streamsize));\n    EXPECT_CALL(streambuf, xsputn(data, static_cast<std::streamsize>(n)))\n        .WillOnce(testing::Return(max_streamsize));\n    data += n;\n    size -= n;\n  } while (size != 0);\n  fmt::detail::write_buffer(os, buffer);\n}\n\nTEST(ostream_test, join) {\n  int v[3] = {1, 2, 3};\n  EXPECT_EQ(\"1, 2, 3\", fmt::format(\"{}\", fmt::join(v, v + 3, \", \")));\n}\n\nTEST(ostream_test, join_fallback_formatter) {\n  auto strs = std::vector<test_string>{test_string(\"foo\"), test_string(\"bar\")};\n  EXPECT_EQ(\"foo, bar\", fmt::format(\"{}\", fmt::join(strs, \", \")));\n}\n\n#if FMT_USE_CONSTEXPR\nTEST(ostream_test, constexpr_string) {\n  EXPECT_EQ(\"42\", fmt::format(FMT_STRING(\"{}\"), std::string(\"42\")));\n  EXPECT_EQ(\"a string\",\n            fmt::format(FMT_STRING(\"{0}\"), test_string(\"a string\")));\n}\n#endif\n\nnamespace fmt_test {\nstruct abc {};\n\ntemplate <typename Output> auto operator<<(Output& out, abc) -> Output& {\n  return out << \"abc\";\n}\n}  // namespace fmt_test\n\ntemplate <typename T> struct test_template {};\n\ntemplate <typename T>\nauto operator<<(std::ostream& os, test_template<T>) -> std::ostream& {\n  return os << 1;\n}\n\nnamespace fmt {\ntemplate <typename T> struct formatter<test_template<T>> : formatter<int> {\n  auto format(test_template<T>, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    return formatter<int>::format(2, ctx);\n  }\n};\n\ntemplate <> struct formatter<fmt_test::abc> : ostream_formatter {};\n}  // namespace fmt\n\nTEST(ostream_test, template) {\n  EXPECT_EQ(\"2\", fmt::format(\"{}\", test_template<int>()));\n}\n\nTEST(ostream_test, format_to_n) {\n  char buffer[4];\n  buffer[3] = 'x';\n  auto result = fmt::format_to_n(buffer, 3, \"{}\", fmt_test::abc());\n  EXPECT_EQ(3u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(\"abcx\", fmt::string_view(buffer, 4));\n  result = fmt::format_to_n(buffer, 3, \"x{}y\", fmt_test::abc());\n  EXPECT_EQ(5u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(\"xabx\", fmt::string_view(buffer, 4));\n}\n\nstruct copyfmt_test {};\n\nstd::ostream& operator<<(std::ostream& os, copyfmt_test) {\n  std::ios ios(nullptr);\n  ios.copyfmt(os);\n  return os << \"foo\";\n}\n\nnamespace fmt {\ntemplate <> struct formatter<copyfmt_test> : ostream_formatter {};\n}  // namespace fmt\n\nTEST(ostream_test, copyfmt) {\n  EXPECT_EQ(\"foo\", fmt::format(\"{}\", copyfmt_test()));\n}\n\nTEST(ostream_test, to_string) {\n  EXPECT_EQ(\"abc\", fmt::to_string(fmt_test::abc()));\n}\n\nTEST(ostream_test, range) {\n  auto strs = std::vector<test_string>{test_string(\"foo\"), test_string(\"bar\")};\n  EXPECT_EQ(\"[foo, bar]\", fmt::format(\"{}\", strs));\n}\n\nstruct abstract {\n  virtual ~abstract() = default;\n  virtual void f() = 0;\n  friend auto operator<<(std::ostream& os, const abstract&) -> std::ostream& {\n    return os;\n  }\n};\n\nnamespace fmt {\ntemplate <> struct formatter<abstract> : ostream_formatter {};\n}  // namespace fmt\n\nvoid format_abstract_compiles(const abstract& a) {\n  (void)fmt::format(FMT_COMPILE(\"{}\"), a);\n}\n\nTEST(ostream_test, is_formattable) {\n  EXPECT_TRUE(fmt::is_formattable<std::string>());\n  EXPECT_TRUE(fmt::is_formattable<fmt::detail::std_string_view<char>>());\n}\n\nstruct streamable_and_unformattable {};\n\nauto operator<<(std::ostream& os, streamable_and_unformattable)\n    -> std::ostream& {\n  return os << \"foo\";\n}\n\nTEST(ostream_test, streamed) {\n  EXPECT_FALSE(fmt::is_formattable<streamable_and_unformattable>());\n  EXPECT_EQ(fmt::format(\"{}\", fmt::streamed(streamable_and_unformattable())),\n            \"foo\");\n}\n\nTEST(ostream_test, closed_ofstream) {\n  std::ofstream ofs;\n  fmt::print(ofs, \"discard\");\n}\n\nstruct unlocalized {};\n\nauto operator<<(std::ostream& os, unlocalized) -> std::ostream& {\n  return os << 12345;\n}\n\nnamespace fmt {\ntemplate <> struct formatter<unlocalized> : ostream_formatter {};\n}  // namespace fmt\n\nTEST(ostream_test, unlocalized) {\n  auto loc = get_locale(\"en_US.UTF-8\");\n  std::locale::global(loc);\n  EXPECT_EQ(fmt::format(loc, \"{}\", unlocalized()), \"12345\");\n}\n"
  },
  {
    "path": "test/perf-sanity.cc",
    "content": "// A quick and dirty performance test.\n// For actual benchmarks see https://github.com/fmtlib/format-benchmark.\n\n#include <atomic>\n#include <chrono>\n#include <iterator>\n\n#include \"fmt/format.h\"\n\nint main() {\n  const int n = 10000000;\n\n  auto start = std::chrono::steady_clock::now();\n  for (int iteration = 0; iteration < n; ++iteration) {\n    auto buf = fmt::memory_buffer();\n    fmt::format_to(std::back_inserter(buf),\n                   \"Hello, {}. The answer is {} and {}.\", 1, 2345, 6789);\n  }\n  std::atomic_signal_fence(std::memory_order_acq_rel);  // Clobber memory.\n  auto end = std::chrono::steady_clock::now();\n\n  // Print time in milliseconds.\n  std::chrono::duration<double> duration = end - start;\n  fmt::print(\"{:.1f}\\n\", duration.count() * 1000);\n}\n"
  },
  {
    "path": "test/posix-mock-test.cc",
    "content": "// Tests of the C++ interface to POSIX functions that require mocks\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n// Disable bogus MSVC warnings.\n#if !defined(_CRT_SECURE_NO_WARNINGS) && defined(_MSC_VER)\n#  define _CRT_SECURE_NO_WARNINGS\n#endif\n\n#include \"posix-mock.h\"\n\n#include <errno.h>\n#include <fcntl.h>\n\n#include <climits>\n#include <memory>\n\n#include \"../src/os.cc\"\n\n#ifdef _WIN32\n#  include <io.h>\n#  undef max\n#endif\n\n#include \"gmock/gmock.h\"\n#include \"gtest-extra.h\"\n#include \"util.h\"\n\nusing fmt::buffered_file;\n\nusing testing::_;\nusing testing::Return;\nusing testing::StrEq;\n\ntemplate <typename Mock> struct scoped_mock : testing::StrictMock<Mock> {\n  scoped_mock() { Mock::instance = this; }\n  ~scoped_mock() { Mock::instance = nullptr; }\n};\n\nnamespace {\nint open_count;\nint close_count;\nint dup_count;\nint dup2_count;\nint fdopen_count;\nint read_count;\nint write_count;\nint pipe_count;\nint fopen_count;\nint fclose_count;\nint fileno_count;\nsize_t read_nbyte;\nsize_t write_nbyte;\nbool sysconf_error;\n\nenum { none, max_size, error } fstat_sim;\n}  // namespace\n\n#define EMULATE_EINTR(func, error_result) \\\n  if (func##_count != 0) {                \\\n    if (func##_count++ != 3) {            \\\n      errno = EINTR;                      \\\n      return error_result;                \\\n    }                                     \\\n  }\n\n#ifndef _MSC_VER\nint test::open(const char* path, int oflag, int mode) {\n  EMULATE_EINTR(open, -1);\n  return ::open(path, oflag, mode);\n}\n#endif\n\n#ifndef _WIN32\n\nlong test::sysconf(int name) {\n  long result = ::sysconf(name);\n  if (!sysconf_error) return result;\n  // Simulate an error.\n  errno = EINVAL;\n  return -1;\n}\n\nstatic off_t max_file_size() { return std::numeric_limits<off_t>::max(); }\n\nint test::fstat(int fd, struct stat* buf) {\n  int result = ::fstat(fd, buf);\n  if (fstat_sim == max_size) buf->st_size = max_file_size();\n  return result;\n}\n\n#else\n\nstatic LONGLONG max_file_size() { return std::numeric_limits<LONGLONG>::max(); }\n\nDWORD test::GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) {\n  if (fstat_sim == error) {\n    SetLastError(ERROR_ACCESS_DENIED);\n    return INVALID_FILE_SIZE;\n  }\n  if (fstat_sim == max_size) {\n    DWORD max = std::numeric_limits<DWORD>::max();\n    *lpFileSizeHigh = max >> 1;\n    return max;\n  }\n  return ::GetFileSize(hFile, lpFileSizeHigh);\n}\n\n#endif\n\nint test::close(int fildes) {\n  // Close the file first because close shouldn't be retried.\n  int result = ::FMT_POSIX(close(fildes));\n  EMULATE_EINTR(close, -1);\n  return result;\n}\n\nint test::dup(int fildes) {\n  EMULATE_EINTR(dup, -1);\n  return ::FMT_POSIX(dup(fildes));\n}\n\nint test::dup2(int fildes, int fildes2) {\n  EMULATE_EINTR(dup2, -1);\n  return ::FMT_POSIX(dup2(fildes, fildes2));\n}\n\nFILE* test::fdopen(int fildes, const char* mode) {\n  EMULATE_EINTR(fdopen, nullptr);\n  return ::FMT_POSIX(fdopen(fildes, mode));\n}\n\ntest::ssize_t test::read(int fildes, void* buf, test::size_t nbyte) {\n  read_nbyte = nbyte;\n  EMULATE_EINTR(read, -1);\n  return ::FMT_POSIX(read(fildes, buf, nbyte));\n}\n\ntest::ssize_t test::write(int fildes, const void* buf, test::size_t nbyte) {\n  write_nbyte = nbyte;\n  EMULATE_EINTR(write, -1);\n  return ::FMT_POSIX(write(fildes, buf, nbyte));\n}\n\n#ifndef _WIN32\nint test::pipe(int fildes[2]) {\n  EMULATE_EINTR(pipe, -1);\n  return ::pipe(fildes);\n}\n#else\nint test::pipe(int* pfds, unsigned psize, int textmode) {\n  EMULATE_EINTR(pipe, -1);\n  return _pipe(pfds, psize, textmode);\n}\n#endif\n\nFILE* test::fopen(const char* filename, const char* mode) {\n  EMULATE_EINTR(fopen, nullptr);\n  return ::fopen(filename, mode);\n}\n\nint test::fclose(FILE* stream) {\n  EMULATE_EINTR(fclose, EOF);\n  return ::fclose(stream);\n}\n\nint(test::fileno)(FILE* stream) {\n  EMULATE_EINTR(fileno, -1);\n#ifdef fileno\n  return FMT_POSIX(fileno(stream));\n#else\n  return ::FMT_POSIX(fileno(stream));\n#endif\n}\n\n#ifndef _WIN32\n#  define EXPECT_RETRY(statement, func, message) \\\n    func##_count = 1;                            \\\n    statement;                                   \\\n    EXPECT_EQ(4, func##_count);                  \\\n    func##_count = 0;\n#  define EXPECT_EQ_POSIX(expected, actual) EXPECT_EQ(expected, actual)\n#else\n#  define EXPECT_RETRY(statement, func, message)    \\\n    func##_count = 1;                               \\\n    EXPECT_SYSTEM_ERROR(statement, EINTR, message); \\\n    func##_count = 0;\n#  define EXPECT_EQ_POSIX(expected, actual)\n#endif\n\n#if FMT_USE_FCNTL\nvoid write_file(fmt::cstring_view filename, fmt::string_view content) {\n  fmt::buffered_file f(filename, \"w\");\n  f.print(\"{}\", content);\n}\n\nusing fmt::file;\n\nTEST(os_test, getpagesize) {\n#  ifdef _WIN32\n  SYSTEM_INFO si = {};\n  GetSystemInfo(&si);\n  EXPECT_EQ(si.dwPageSize, fmt::getpagesize());\n#  else\n  EXPECT_EQ(sysconf(_SC_PAGESIZE), fmt::getpagesize());\n  sysconf_error = true;\n  EXPECT_SYSTEM_ERROR(fmt::getpagesize(), EINVAL,\n                      \"cannot get memory page size\");\n  sysconf_error = false;\n#  endif\n}\n\nTEST(file_test, open_retry) {\n#  ifndef _WIN32\n  write_file(\"temp\", \"there must be something here\");\n  std::unique_ptr<file> f{nullptr};\n  EXPECT_RETRY(f.reset(new file(\"temp\", file::RDONLY)), open,\n               \"cannot open file temp\");\n  char c = 0;\n  f->read(&c, 1);\n#  endif\n}\n\nTEST(file_test, close_no_retry_in_dtor) {\n  auto pipe = fmt::pipe();\n  std::unique_ptr<file> f(new file(std::move(pipe.read_end)));\n  int saved_close_count = 0;\n  EXPECT_WRITE(\n      stderr,\n      {\n        close_count = 1;\n        f.reset(nullptr);\n        saved_close_count = close_count;\n        close_count = 0;\n      },\n      system_error_message(EINTR, \"cannot close file\") + \"\\n\");\n  EXPECT_EQ(2, saved_close_count);\n}\n\nTEST(file_test, close_no_retry) {\n  auto pipe = fmt::pipe();\n  close_count = 1;\n  EXPECT_SYSTEM_ERROR(pipe.read_end.close(), EINTR, \"cannot close file\");\n  EXPECT_EQ(2, close_count);\n  close_count = 0;\n}\n\nTEST(file_test, size) {\n  std::string content = \"top secret, destroy before reading\";\n  write_file(\"temp\", content);\n  file f(\"temp\", file::RDONLY);\n  EXPECT_GE(f.size(), 0);\n  EXPECT_EQ(content.size(), static_cast<unsigned long long>(f.size()));\n#  ifdef _WIN32\n  auto error_code = std::error_code();\n  fstat_sim = error;\n  try {\n    f.size();\n  } catch (const std::system_error& e) {\n    error_code = e.code();\n  }\n  fstat_sim = none;\n  EXPECT_EQ(error_code,\n            std::error_code(ERROR_ACCESS_DENIED, fmt::system_category()));\n#  else\n  f.close();\n  EXPECT_SYSTEM_ERROR(f.size(), EBADF, \"cannot get file attributes\");\n#  endif\n}\n\nTEST(file_test, max_size) {\n  write_file(\"temp\", \"\");\n  file f(\"temp\", file::RDONLY);\n  fstat_sim = max_size;\n  EXPECT_GE(f.size(), 0);\n  EXPECT_EQ(max_file_size(), f.size());\n  fstat_sim = none;\n}\n\nTEST(file_test, read_retry) {\n  auto pipe = fmt::pipe();\n  enum { SIZE = 4 };\n  pipe.write_end.write(\"test\", SIZE);\n  pipe.write_end.close();\n  char buffer[SIZE];\n  size_t count = 0;\n  EXPECT_RETRY(count = pipe.read_end.read(buffer, SIZE), read,\n               \"cannot read from file\");\n  EXPECT_EQ_POSIX(static_cast<std::streamsize>(SIZE), count);\n}\n\nTEST(file_test, write_retry) {\n  auto pipe = fmt::pipe();\n  enum { SIZE = 4 };\n  size_t count = 0;\n  EXPECT_RETRY(count = pipe.write_end.write(\"test\", SIZE), write,\n               \"cannot write to file\");\n  pipe.write_end.close();\n#  ifndef _WIN32\n  EXPECT_EQ(static_cast<std::streamsize>(SIZE), count);\n  char buffer[SIZE + 1];\n  pipe.read_end.read(buffer, SIZE);\n  buffer[SIZE] = '\\0';\n  EXPECT_STREQ(\"test\", buffer);\n#  endif\n}\n\n#  ifdef _WIN32\nTEST(file_test, convert_read_count) {\n  auto pipe = fmt::pipe();\n  char c;\n  size_t size = UINT_MAX;\n  if (sizeof(unsigned) != sizeof(size_t)) ++size;\n  read_count = 1;\n  read_nbyte = 0;\n  EXPECT_THROW(pipe.read_end.read(&c, size), std::system_error);\n  read_count = 0;\n  EXPECT_EQ(UINT_MAX, read_nbyte);\n}\n\nTEST(file_test, convert_write_count) {\n  auto pipe = fmt::pipe();\n  char c;\n  size_t size = UINT_MAX;\n  if (sizeof(unsigned) != sizeof(size_t)) ++size;\n  write_count = 1;\n  write_nbyte = 0;\n  EXPECT_THROW(pipe.write_end.write(&c, size), std::system_error);\n  write_count = 0;\n  EXPECT_EQ(UINT_MAX, write_nbyte);\n}\n#  endif\n\nTEST(file_test, dup_no_retry) {\n  int stdout_fd = FMT_POSIX(fileno(stdout));\n  dup_count = 1;\n  EXPECT_SYSTEM_ERROR(\n      file::dup(stdout_fd), EINTR,\n      fmt::format(\"cannot duplicate file descriptor {}\", stdout_fd));\n  dup_count = 0;\n}\n\nTEST(file_test, dup2_retry) {\n  int stdout_fd = FMT_POSIX(fileno(stdout));\n  file f1 = file::dup(stdout_fd), f2 = file::dup(stdout_fd);\n  EXPECT_RETRY(f1.dup2(f2.descriptor()), dup2,\n               fmt::format(\"cannot duplicate file descriptor {} to {}\",\n                           f1.descriptor(), f2.descriptor()));\n}\n\nTEST(file_test, dup2_no_except_retry) {\n  int stdout_fd = FMT_POSIX(fileno(stdout));\n  file f1 = file::dup(stdout_fd), f2 = file::dup(stdout_fd);\n  std::error_code ec;\n  dup2_count = 1;\n  f1.dup2(f2.descriptor(), ec);\n#  ifndef _WIN32\n  EXPECT_EQ(4, dup2_count);\n#  else\n  EXPECT_EQ(EINTR, ec.value());\n#  endif\n  dup2_count = 0;\n}\n\nTEST(file_test, pipe_no_retry) {\n  pipe_count = 1;\n  EXPECT_SYSTEM_ERROR(fmt::pipe(), EINTR, \"cannot create pipe\");\n  pipe_count = 0;\n}\n\nTEST(file_test, fdopen_no_retry) {\n  auto pipe = fmt::pipe();\n  fdopen_count = 1;\n  EXPECT_SYSTEM_ERROR(pipe.read_end.fdopen(\"r\"), EINTR,\n                      \"cannot associate stream with file descriptor\");\n  fdopen_count = 0;\n}\n\nTEST(buffered_file_test, open_retry) {\n  write_file(\"temp\", \"there must be something here\");\n  std::unique_ptr<buffered_file> f{nullptr};\n  EXPECT_RETRY(f.reset(new buffered_file(\"temp\", \"r\")), fopen,\n               \"cannot open file temp\");\n#  ifndef _WIN32\n  char c = 0;\n  if (fread(&c, 1, 1, f->get()) < 1)\n    throw fmt::system_error(errno, \"fread failed\");\n#  endif\n}\n\nTEST(buffered_file_test, close_no_retry_in_dtor) {\n  auto pipe = fmt::pipe();\n  std::unique_ptr<buffered_file> f(\n      new buffered_file(pipe.read_end.fdopen(\"r\")));\n  int saved_fclose_count = 0;\n  EXPECT_WRITE(\n      stderr,\n      {\n        fclose_count = 1;\n        f.reset(nullptr);\n        saved_fclose_count = fclose_count;\n        fclose_count = 0;\n      },\n      system_error_message(EINTR, \"cannot close file\") + \"\\n\");\n  EXPECT_EQ(2, saved_fclose_count);\n}\n\nTEST(buffered_file_test, close_no_retry) {\n  auto pipe = fmt::pipe();\n  buffered_file f = pipe.read_end.fdopen(\"r\");\n  fclose_count = 1;\n  EXPECT_SYSTEM_ERROR(f.close(), EINTR, \"cannot close file\");\n  EXPECT_EQ(2, fclose_count);\n  fclose_count = 0;\n}\n\nTEST(buffered_file_test, fileno_no_retry) {\n  auto pipe = fmt::pipe();\n  buffered_file f = pipe.read_end.fdopen(\"r\");\n  fileno_count = 1;\n  EXPECT_SYSTEM_ERROR((f.descriptor)(), EINTR, \"cannot get file descriptor\");\n  EXPECT_EQ(2, fileno_count);\n  fileno_count = 0;\n}\n#endif  // FMT_USE_FCNTL\n\nstruct test_mock {\n  static test_mock* instance;\n}* test_mock::instance;\n\nTEST(scoped_mock, scope) {\n  {\n    scoped_mock<test_mock> mock;\n    EXPECT_EQ(&mock, test_mock::instance);\n    test_mock& copy = mock;\n    static_cast<void>(copy);\n  }\n  EXPECT_EQ(nullptr, test_mock::instance);\n}\n"
  },
  {
    "path": "test/posix-mock.h",
    "content": "// Formatting library for C++ - mocks of POSIX functions\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_POSIX_TEST_H\n#define FMT_POSIX_TEST_H\n\n#include <errno.h>\n#include <locale.h>\n#include <stdio.h>\n#ifdef __APPLE__\n#  include <xlocale.h>\n#endif\n\n#ifdef _WIN32\n#  include <windows.h>\n#else\n#  include <sys/param.h>  // for FreeBSD version\n#  include <sys/types.h>  // for ssize_t\n#endif\n\n#ifndef _MSC_VER\nstruct stat;\n#endif\n\nnamespace test {\n\n#ifndef _MSC_VER\n// Size type for read and write.\nusing size_t = size_t;\nusing ssize_t = ssize_t;\nint open(const char* path, int oflag, int mode);\nint fstat(int fd, struct stat* buf);\n#else\nusing size_t = unsigned;\nusing ssize_t = int;\n#endif\n\n#ifndef _WIN32\nlong sysconf(int name);\n#else\nDWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);\n#endif\n\nint close(int fildes);\n\nint dup(int fildes);\nint dup2(int fildes, int fildes2);\n\nFILE* fdopen(int fildes, const char* mode);\n\nssize_t read(int fildes, void* buf, size_t nbyte);\nssize_t write(int fildes, const void* buf, size_t nbyte);\n\n#ifndef _WIN32\nint pipe(int fildes[2]);\n#else\nint pipe(int* pfds, unsigned psize, int textmode);\n#endif\n\nFILE* fopen(const char* filename, const char* mode);\nint fclose(FILE* stream);\nint(fileno)(FILE* stream);\n\n#if defined(FMT_LOCALE) && !defined(_WIN32)\nlocale_t newlocale(int category_mask, const char* locale, locale_t base);\n#endif\n}  // namespace test\n\n#define FMT_SYSTEM(call) test::call\n\n#endif  // FMT_POSIX_TEST_H\n"
  },
  {
    "path": "test/printf-test.cc",
    "content": "// Formatting library for C++ - printf tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/printf.h\"\n\n#include <cctype>\n#include <climits>\n#include <cstring>\n\n#include \"fmt/xchar.h\"  // DEPRECATED!\n#include \"gtest-extra.h\"\n#include \"util.h\"\n\nusing fmt::format;\nusing fmt::format_error;\nusing fmt::detail::max_value;\n\nconst unsigned big_num = INT_MAX + 1u;\n\n// Makes format string argument positional.\nstatic auto make_positional(fmt::string_view format) -> std::string {\n  std::string s(format.data(), format.size());\n  s.replace(s.find('%'), 1, \"%1$\");\n  return s;\n}\n\n// A wrapper around fmt::sprintf to workaround bogus warnings about invalid\n// format strings in MSVC.\ntemplate <typename... Args>\nauto test_sprintf(fmt::string_view format, const Args&... args) -> std::string {\n  return fmt::sprintf(format, args...);\n}\ntemplate <typename... Args>\nauto test_sprintf(fmt::basic_string_view<wchar_t> format, const Args&... args)\n    -> std::wstring {\n  return fmt::sprintf(format, args...);\n}\n\n#define EXPECT_PRINTF(expected_output, format, arg)     \\\n  EXPECT_EQ(expected_output, test_sprintf(format, arg)) \\\n      << \"format: \" << format;                          \\\n  EXPECT_EQ(expected_output, fmt::sprintf(make_positional(format), arg))\n\nTEST(printf_test, no_args) { EXPECT_EQ(\"test\", test_sprintf(\"test\")); }\n\nTEST(printf_test, escape) {\n  EXPECT_EQ(\"%\", test_sprintf(\"%%\"));\n  EXPECT_EQ(\"before %\", test_sprintf(\"before %%\"));\n  EXPECT_EQ(\"% after\", test_sprintf(\"%% after\"));\n  EXPECT_EQ(\"before % after\", test_sprintf(\"before %% after\"));\n  EXPECT_EQ(\"%s\", test_sprintf(\"%%s\"));\n}\n\nTEST(printf_test, positional_args) {\n  EXPECT_EQ(\"42\", test_sprintf(\"%1$d\", 42));\n  EXPECT_EQ(\"before 42\", test_sprintf(\"before %1$d\", 42));\n  EXPECT_EQ(\"42 after\", test_sprintf(\"%1$d after\", 42));\n  EXPECT_EQ(\"before 42 after\", test_sprintf(\"before %1$d after\", 42));\n  EXPECT_EQ(\"answer = 42\", test_sprintf(\"%1$s = %2$d\", \"answer\", 42));\n  EXPECT_EQ(\"42 is the answer\", test_sprintf(\"%2$d is the %1$s\", \"answer\", 42));\n  EXPECT_EQ(\"abracadabra\", test_sprintf(\"%1$s%2$s%1$s\", \"abra\", \"cad\"));\n}\n\nTEST(printf_test, automatic_arg_indexing) {\n  EXPECT_EQ(\"abc\", test_sprintf(\"%c%c%c\", 'a', 'b', 'c'));\n}\n\nTEST(printf_test, number_is_too_big_in_arg_index) {\n  EXPECT_THROW_MSG(test_sprintf(format(\"%{}$\", big_num)), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%{}$d\", big_num)), format_error,\n                   \"argument not found\");\n}\n\nTEST(printf_test, switch_arg_indexing) {\n  EXPECT_THROW_MSG(test_sprintf(\"%1$d%\", 1, 2), format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%1$d%{}d\", big_num), 1, 2),\n                   format_error, \"number is too big\");\n  EXPECT_THROW_MSG(test_sprintf(\"%1$d%d\", 1, 2), format_error,\n                   \"cannot switch from manual to automatic argument indexing\");\n\n  EXPECT_THROW_MSG(test_sprintf(\"%d%1$\", 1, 2), format_error,\n                   \"cannot switch from automatic to manual argument indexing\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%d%{}$d\", big_num), 1, 2), format_error,\n                   \"cannot switch from automatic to manual argument indexing\");\n  EXPECT_THROW_MSG(test_sprintf(\"%d%1$d\", 1, 2), format_error,\n                   \"cannot switch from automatic to manual argument indexing\");\n\n  // Indexing errors override width errors.\n  EXPECT_THROW_MSG(test_sprintf(format(\"%d%1${}d\", big_num), 1, 2),\n                   format_error, \"number is too big\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%1$d%{}d\", big_num), 1, 2),\n                   format_error, \"number is too big\");\n}\n\nTEST(printf_test, invalid_arg_index) {\n  EXPECT_THROW_MSG(test_sprintf(\"%0$d\", 42), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(\"%2$d\", 42), format_error,\n                   \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%{}$d\", INT_MAX), 42), format_error,\n                   \"argument not found\");\n\n  EXPECT_THROW_MSG(test_sprintf(\"%2$\", 42), format_error, \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%{}$d\", big_num), 42), format_error,\n                   \"argument not found\");\n}\n\nTEST(printf_test, default_align_right) {\n  EXPECT_PRINTF(\"   42\", \"%5d\", 42);\n  EXPECT_PRINTF(\"  abc\", \"%5s\", \"abc\");\n}\n\nTEST(printf_test, zero_flag) {\n  EXPECT_PRINTF(\"00042\", \"%05d\", 42);\n  EXPECT_PRINTF(\"-0042\", \"%05d\", -42);\n\n  EXPECT_PRINTF(\"00042\", \"%05d\", 42);\n  EXPECT_PRINTF(\"-0042\", \"%05d\", -42);\n  EXPECT_PRINTF(\"-004.2\", \"%06g\", -4.2);\n\n  EXPECT_PRINTF(\"+00042\", \"%00+6d\", 42);\n\n  EXPECT_PRINTF(\"   42\", \"%05.d\", 42);\n  EXPECT_PRINTF(\" 0042\", \"%05.4d\", 42);\n\n  // '0' flag is ignored for non-numeric types.\n  EXPECT_PRINTF(\"    x\", \"%05c\", 'x');\n}\n\nTEST(printf_test, plus_flag) {\n  EXPECT_PRINTF(\"+42\", \"%+d\", 42);\n  EXPECT_PRINTF(\"-42\", \"%+d\", -42);\n  EXPECT_PRINTF(\"+0042\", \"%+05d\", 42);\n  EXPECT_PRINTF(\"+0042\", \"%0++5d\", 42);\n\n  // '+' flag is ignored for non-numeric types.\n  EXPECT_PRINTF(\"x\", \"%+c\", 'x');\n\n  // '+' flag wins over space flag\n  EXPECT_PRINTF(\"+42\", \"%+ d\", 42);\n  EXPECT_PRINTF(\"-42\", \"%+ d\", -42);\n  EXPECT_PRINTF(\"+42\", \"% +d\", 42);\n  EXPECT_PRINTF(\"-42\", \"% +d\", -42);\n  EXPECT_PRINTF(\"+0042\", \"% +05d\", 42);\n  EXPECT_PRINTF(\"+0042\", \"%0+ 5d\", 42);\n\n  // '+' flag and space flag are both ignored for non-numeric types.\n  EXPECT_PRINTF(\"x\", \"%+ c\", 'x');\n  EXPECT_PRINTF(\"x\", \"% +c\", 'x');\n}\n\nTEST(printf_test, minus_flag) {\n  EXPECT_PRINTF(\"abc  \", \"%-5s\", \"abc\");\n  EXPECT_PRINTF(\"abc  \", \"%0--5s\", \"abc\");\n\n  EXPECT_PRINTF(\"7    \", \"%-5d\", 7);\n  EXPECT_PRINTF(\"97   \", \"%-5hhi\", 'a');\n  EXPECT_PRINTF(\"a    \", \"%-5c\", 'a');\n\n  // '0' flag is ignored if '-' flag is given\n  EXPECT_PRINTF(\"7    \", \"%-05d\", 7);\n  EXPECT_PRINTF(\"7    \", \"%0-5d\", 7);\n  EXPECT_PRINTF(\"a    \", \"%-05c\", 'a');\n  EXPECT_PRINTF(\"a    \", \"%0-5c\", 'a');\n  EXPECT_PRINTF(\"97   \", \"%-05hhi\", 'a');\n  EXPECT_PRINTF(\"97   \", \"%0-5hhi\", 'a');\n\n  // '-' and space flag don't interfere\n  EXPECT_PRINTF(\" 42\", \"%- d\", 42);\n}\n\nTEST(printf_test, space_flag) {\n  EXPECT_PRINTF(\" 42\", \"% d\", 42);\n  EXPECT_PRINTF(\"-42\", \"% d\", -42);\n  EXPECT_PRINTF(\" 0042\", \"% 05d\", 42);\n  EXPECT_PRINTF(\" 0042\", \"%0  5d\", 42);\n\n  // ' ' flag is ignored for non-numeric types.\n  EXPECT_PRINTF(\"x\", \"% c\", 'x');\n}\n\nTEST(printf_test, hash_flag) {\n  EXPECT_PRINTF(\"042\", \"%#o\", 042);\n  EXPECT_PRINTF(fmt::format(\"0{:o}\", static_cast<unsigned>(-042)), \"%#o\", -042);\n  EXPECT_PRINTF(\"0\", \"%#o\", 0);\n\n  EXPECT_PRINTF(\"0x42\", \"%#x\", 0x42);\n  EXPECT_PRINTF(\"0X42\", \"%#X\", 0x42);\n  EXPECT_PRINTF(fmt::format(\"0x{:x}\", static_cast<unsigned>(-0x42)), \"%#x\",\n                -0x42);\n  EXPECT_PRINTF(\"0\", \"%#x\", 0);\n\n  EXPECT_PRINTF(\"0x0042\", \"%#06x\", 0x42);\n  EXPECT_PRINTF(\"0x0042\", \"%0##6x\", 0x42);\n\n  EXPECT_PRINTF(\"-42.000000\", \"%#f\", -42.0);\n  EXPECT_PRINTF(\"-42.000000\", \"%#F\", -42.0);\n\n  char buffer[256];\n  safe_sprintf(buffer, \"%#e\", -42.0);\n  EXPECT_PRINTF(buffer, \"%#e\", -42.0);\n  safe_sprintf(buffer, \"%#E\", -42.0);\n  EXPECT_PRINTF(buffer, \"%#E\", -42.0);\n\n  EXPECT_PRINTF(\"-42.0000\", \"%#g\", -42.0);\n  EXPECT_PRINTF(\"-42.0000\", \"%#G\", -42.0);\n\n  EXPECT_PRINTF(\"0x1.p+4\", \"%#a\", 16.0);\n  EXPECT_PRINTF(\"0X1.P+4\", \"%#A\", 16.0);\n\n  // '#' flag is ignored for non-numeric types.\n  EXPECT_PRINTF(\"x\", \"%#c\", 'x');\n}\n\nTEST(printf_test, width) {\n  EXPECT_PRINTF(\"  abc\", \"%5s\", \"abc\");\n\n  // Width cannot be specified twice.\n  EXPECT_THROW_MSG(test_sprintf(\"%5-5d\", 42), format_error,\n                   \"invalid format specifier\");\n\n  EXPECT_THROW_MSG(test_sprintf(format(\"%{}d\", big_num), 42), format_error,\n                   \"number is too big\");\n  EXPECT_THROW_MSG(test_sprintf(format(\"%1${}d\", big_num), 42), format_error,\n                   \"number is too big\");\n}\n\nTEST(printf_test, dynamic_width) {\n  EXPECT_EQ(\"   42\", test_sprintf(\"%*d\", 5, 42));\n  EXPECT_EQ(\"42   \", test_sprintf(\"%*d\", -5, 42));\n  EXPECT_THROW_MSG(test_sprintf(\"%*d\", 5.0, 42), format_error,\n                   \"width is not integer\");\n  EXPECT_THROW_MSG(test_sprintf(\"%*d\"), format_error, \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(\"%*d\", big_num, 42), format_error,\n                   \"number is too big\");\n}\n\nTEST(printf_test, int_precision) {\n  EXPECT_PRINTF(\"00042\", \"%.5d\", 42);\n  EXPECT_PRINTF(\"-00042\", \"%.5d\", -42);\n  EXPECT_PRINTF(\"00042\", \"%.5x\", 0x42);\n  EXPECT_PRINTF(\"0x00042\", \"%#.5x\", 0x42);\n  EXPECT_PRINTF(\"00042\", \"%.5o\", 042);\n  EXPECT_PRINTF(\"00042\", \"%#.5o\", 042);\n\n  EXPECT_PRINTF(\"  00042\", \"%7.5d\", 42);\n  EXPECT_PRINTF(\"  00042\", \"%7.5x\", 0x42);\n  EXPECT_PRINTF(\"   0x00042\", \"%#10.5x\", 0x42);\n  EXPECT_PRINTF(\"  00042\", \"%7.5o\", 042);\n  EXPECT_PRINTF(\"     00042\", \"%#10.5o\", 042);\n\n  EXPECT_PRINTF(\"00042  \", \"%-7.5d\", 42);\n  EXPECT_PRINTF(\"00042  \", \"%-7.5x\", 0x42);\n  EXPECT_PRINTF(\"0x00042   \", \"%-#10.5x\", 0x42);\n  EXPECT_PRINTF(\"00042  \", \"%-7.5o\", 042);\n  EXPECT_PRINTF(\"00042     \", \"%-#10.5o\", 042);\n}\n\nTEST(printf_test, float_precision) {\n  char buffer[256];\n  safe_sprintf(buffer, \"%.3e\", 1234.5678);\n  EXPECT_PRINTF(buffer, \"%.3e\", 1234.5678);\n  EXPECT_PRINTF(\"1234.568\", \"%.3f\", 1234.5678);\n  EXPECT_PRINTF(\"1.23e+03\", \"%.3g\", 1234.5678);\n  safe_sprintf(buffer, \"%.3a\", 1234.5678);\n  EXPECT_PRINTF(buffer, \"%.3a\", 1234.5678);\n}\n\nTEST(printf_test, string_precision) {\n  char test[] = {'H', 'e', 'l', 'l', 'o'};\n  EXPECT_EQ(fmt::sprintf(\"%.4s\", test), \"Hell\");\n}\n\nTEST(printf_test, ignore_precision_for_non_numeric_arg) {\n  EXPECT_PRINTF(\"abc\", \"%.5s\", \"abc\");\n}\n\nTEST(printf_test, dynamic_precision) {\n  EXPECT_EQ(\"00042\", test_sprintf(\"%.*d\", 5, 42));\n  EXPECT_EQ(\"42\", test_sprintf(\"%.*d\", -5, 42));\n  EXPECT_THROW_MSG(test_sprintf(\"%.*d\", 5.0, 42), format_error,\n                   \"precision is not integer\");\n  EXPECT_THROW_MSG(test_sprintf(\"%.*d\"), format_error, \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(\"%.*d\", big_num, 42), format_error,\n                   \"number is too big\");\n  if (sizeof(long long) != sizeof(int)) {\n    long long prec = static_cast<long long>(INT_MIN) - 1;\n    EXPECT_THROW_MSG(test_sprintf(\"%.*d\", prec, 42), format_error,\n                     \"number is too big\");\n  }\n}\n\nTEST(printf_test, positional_width) {\n  EXPECT_EQ(\"   42\", test_sprintf(\"%2$*1$d\", 5, 42));\n  EXPECT_EQ(\"42   \", test_sprintf(\"%2$*1$d\", -5, 42));\n  EXPECT_EQ(\"  abc\", test_sprintf(\"%2$*1$s\", 5, \"abc\"));\n  EXPECT_THROW_MSG(test_sprintf(\"%2$*1$d\", 5.0, 42), format_error,\n                   \"width is not integer\");\n  EXPECT_THROW_MSG(test_sprintf(\"%2$*1$d\"), format_error, \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(\"%2$*1$d\", big_num, 42), format_error,\n                   \"number is too big\");\n}\n\nTEST(printf_test, positional_precision) {\n  EXPECT_EQ(\"00042\", test_sprintf(\"%2$.*1$d\", 5, 42));\n  EXPECT_EQ(\"42\", test_sprintf(\"%2$.*1$d\", -5, 42));\n  EXPECT_EQ(\"Hell\", test_sprintf(\"%2$.*1$s\", 4, \"Hello\"));\n  EXPECT_THROW_MSG(test_sprintf(\"%2$.*1$d\", 5.0, 42), format_error,\n                   \"precision is not integer\");\n  EXPECT_THROW_MSG(test_sprintf(\"%2$.*1$d\"), format_error, \"argument not found\");\n  EXPECT_THROW_MSG(test_sprintf(\"%2$.*1$d\", big_num, 42), format_error,\n                   \"number is too big\");\n}\n\nTEST(printf_test, positional_width_and_precision) {\n  EXPECT_EQ(\"  00042\", test_sprintf(\"%3$*1$.*2$d\", 7, 5, 42));\n  EXPECT_EQ(\"     ab\", test_sprintf(\"%3$*1$.*2$s\", 7, 2, \"abcdef\"));\n  EXPECT_EQ(\"  00042\", test_sprintf(\"%3$*1$.*2$x\", 7, 5, 0x42));\n  EXPECT_EQ(\"100.4400000\", test_sprintf(\"%6$-*5$.*4$f%3$s%2$s%1$s\", \"\", \"\", \"\", 7, 4, 100.44));\n}\n\ntemplate <typename T> struct make_signed {\n  using type = T;\n};\n\n#define SPECIALIZE_MAKE_SIGNED(T, S)  \\\n  template <> struct make_signed<T> { \\\n    using type = S;                   \\\n  }\n\nSPECIALIZE_MAKE_SIGNED(char, signed char);\nSPECIALIZE_MAKE_SIGNED(unsigned char, signed char);\nSPECIALIZE_MAKE_SIGNED(unsigned short, short);\nSPECIALIZE_MAKE_SIGNED(unsigned, int);\nSPECIALIZE_MAKE_SIGNED(unsigned long, long);\nSPECIALIZE_MAKE_SIGNED(unsigned long long, long long);\n\n// Test length format specifier ``length_spec``.\ntemplate <typename T, typename U>\nvoid test_length(const char* length_spec, U value) {\n  long long signed_value = 0;\n  unsigned long long unsigned_value = 0;\n  // Apply integer promotion to the argument.\n  unsigned long long max = max_value<U>();\n  if (max <= static_cast<unsigned>(max_value<int>())) {\n    signed_value = static_cast<int>(value);\n    unsigned_value = static_cast<unsigned long long>(value);\n  } else if (max <= max_value<unsigned>()) {\n    signed_value = static_cast<unsigned>(value);\n    unsigned_value = static_cast<unsigned long long>(value);\n  }\n  if (sizeof(U) <= sizeof(int) && sizeof(int) < sizeof(T)) {\n    signed_value = static_cast<long long>(value);\n    unsigned_value = static_cast<unsigned long long>(\n        static_cast<typename std::make_unsigned<unsigned>::type>(value));\n  } else {\n    signed_value = static_cast<typename make_signed<T>::type>(value);\n    unsigned_value = static_cast<typename std::make_unsigned<T>::type>(value);\n  }\n  std::ostringstream os;\n  os << signed_value;\n  EXPECT_PRINTF(os.str(), fmt::format(\"%{}d\", length_spec), value);\n  EXPECT_PRINTF(os.str(), fmt::format(\"%{}i\", length_spec), value);\n  os.str(\"\");\n  os << unsigned_value;\n  EXPECT_PRINTF(os.str(), fmt::format(\"%{}u\", length_spec), value);\n  os.str(\"\");\n  os << std::oct << unsigned_value;\n  EXPECT_PRINTF(os.str(), fmt::format(\"%{}o\", length_spec), value);\n  os.str(\"\");\n  os << std::hex << unsigned_value;\n  EXPECT_PRINTF(os.str(), fmt::format(\"%{}x\", length_spec), value);\n  os.str(\"\");\n  os << std::hex << std::uppercase << unsigned_value;\n  EXPECT_PRINTF(os.str(), fmt::format(\"%{}X\", length_spec), value);\n}\n\ntemplate <typename T> void test_length(const char* length_spec) {\n  T min = std::numeric_limits<T>::min(), max = max_value<T>();\n  test_length<T>(length_spec, 42);\n  test_length<T>(length_spec, -42);\n  test_length<T>(length_spec, min);\n  test_length<T>(length_spec, max);\n  long long long_long_min = std::numeric_limits<long long>::min();\n  if (static_cast<long long>(min) > long_long_min)\n    test_length<T>(length_spec, static_cast<long long>(min) - 1);\n  unsigned long long long_long_max = max_value<long long>();\n  if (static_cast<unsigned long long>(max) < long_long_max)\n    test_length<T>(length_spec, static_cast<long long>(max) + 1);\n  test_length<T>(length_spec, std::numeric_limits<short>::min());\n  test_length<T>(length_spec, max_value<unsigned short>());\n  test_length<T>(length_spec, std::numeric_limits<int>::min());\n  test_length<T>(length_spec, max_value<int>());\n  test_length<T>(length_spec, std::numeric_limits<unsigned>::min());\n  test_length<T>(length_spec, max_value<unsigned>());\n  test_length<T>(length_spec, std::numeric_limits<long long>::min());\n  test_length<T>(length_spec, max_value<long long>());\n  test_length<T>(length_spec, std::numeric_limits<unsigned long long>::min());\n  test_length<T>(length_spec, max_value<unsigned long long>());\n}\n\nTEST(printf_test, length) {\n  test_length<char>(\"hh\");\n  test_length<signed char>(\"hh\");\n  test_length<unsigned char>(\"hh\");\n  test_length<short>(\"h\");\n  test_length<unsigned short>(\"h\");\n  test_length<long>(\"l\");\n  test_length<unsigned long>(\"l\");\n  test_length<long long>(\"ll\");\n  test_length<unsigned long long>(\"ll\");\n  test_length<intmax_t>(\"j\");\n  test_length<size_t>(\"z\");\n  test_length<std::ptrdiff_t>(\"t\");\n  long double max = max_value<long double>();\n  EXPECT_PRINTF(fmt::format(\"{:.6}\", max), \"%g\", max);\n  EXPECT_PRINTF(fmt::format(\"{:.6}\", max), \"%Lg\", max);\n}\n\nTEST(printf_test, bool) { EXPECT_PRINTF(\"1\", \"%d\", true); }\n\nTEST(printf_test, int) {\n  EXPECT_PRINTF(\"-42\", \"%d\", -42);\n  EXPECT_PRINTF(\"-42\", \"%i\", -42);\n  unsigned u = 0 - 42u;\n  EXPECT_PRINTF(fmt::format(\"{}\", u), \"%u\", -42);\n  EXPECT_PRINTF(fmt::format(\"{:o}\", u), \"%o\", -42);\n  EXPECT_PRINTF(fmt::format(\"{:x}\", u), \"%x\", -42);\n  EXPECT_PRINTF(fmt::format(\"{:X}\", u), \"%X\", -42);\n}\n\nTEST(printf_test, long_long) {\n  // fmt::printf allows passing long long arguments to %d without length\n  // specifiers.\n  long long max = max_value<long long>();\n  EXPECT_PRINTF(fmt::format(\"{}\", max), \"%d\", max);\n}\n\nTEST(printf_test, float) {\n  EXPECT_PRINTF(\"392.650000\", \"%f\", 392.65);\n  EXPECT_PRINTF(\"392.65\", \"%.2f\", 392.65);\n  EXPECT_PRINTF(\"392.6\", \"%.1f\", 392.65);\n  EXPECT_PRINTF(\"393\", \"%.f\", 392.65);\n  EXPECT_PRINTF(\"392.650000\", \"%F\", 392.65);\n  char buffer[256];\n  safe_sprintf(buffer, \"%e\", 392.65);\n  EXPECT_PRINTF(buffer, \"%e\", 392.65);\n  safe_sprintf(buffer, \"%E\", 392.65);\n  EXPECT_PRINTF(buffer, \"%E\", 392.65);\n  EXPECT_PRINTF(\"392.65\", \"%g\", 392.65);\n  EXPECT_PRINTF(\"392.65\", \"%G\", 392.65);\n  EXPECT_PRINTF(\"392\", \"%g\", 392.0);\n  EXPECT_PRINTF(\"392\", \"%G\", 392.0);\n  EXPECT_PRINTF(\"4.56e-07\", \"%g\", 0.000000456);\n  safe_sprintf(buffer, \"%a\", -392.65);\n  EXPECT_EQ(buffer, format(\"{:a}\", -392.65));\n  safe_sprintf(buffer, \"%A\", -392.65);\n  EXPECT_EQ(buffer, format(\"{:A}\", -392.65));\n}\n\nTEST(printf_test, inf) {\n  double inf = std::numeric_limits<double>::infinity();\n  for (const char* type = \"fega\"; *type; ++type) {\n    EXPECT_PRINTF(\"inf\", fmt::format(\"%{}\", *type), inf);\n    char upper = static_cast<char>(std::toupper(*type));\n    EXPECT_PRINTF(\"INF\", fmt::format(\"%{}\", upper), inf);\n  }\n}\n\nTEST(printf_test, char) {\n  EXPECT_PRINTF(\"x\", \"%c\", 'x');\n  int max = max_value<int>();\n  EXPECT_PRINTF(fmt::format(\"{}\", static_cast<char>(max)), \"%c\", max);\n}\n\nTEST(printf_test, string) {\n  EXPECT_PRINTF(\"abc\", \"%s\", \"abc\");\n  const char* null_str = nullptr;\n  EXPECT_PRINTF(\"(null)\", \"%s\", null_str);\n  EXPECT_PRINTF(\"    (null)\", \"%10s\", null_str);\n}\n\nTEST(printf_test, pointer) {\n  int n;\n  void* p = &n;\n  EXPECT_PRINTF(fmt::format(\"{}\", p), \"%p\", p);\n  p = nullptr;\n  EXPECT_PRINTF(\"(nil)\", \"%p\", p);\n  EXPECT_PRINTF(\"     (nil)\", \"%10p\", p);\n  const char* s = \"test\";\n  EXPECT_PRINTF(fmt::format(\"{:p}\", s), \"%p\", s);\n  const char* null_str = nullptr;\n  EXPECT_PRINTF(\"(nil)\", \"%p\", null_str);\n}\n\nenum test_enum { answer = 42 };\nauto format_as(test_enum e) -> int { return e; }\n\nTEST(printf_test, enum) {\n  EXPECT_PRINTF(\"42\", \"%d\", answer);\n  volatile test_enum volatile_enum = answer;\n  EXPECT_PRINTF(\"42\", \"%d\", volatile_enum);\n}\n\n#if FMT_USE_FCNTL\nTEST(printf_test, examples) {\n  const char* weekday = \"Thursday\";\n  const char* month = \"August\";\n  int day = 21;\n  EXPECT_WRITE(stdout, fmt::printf(\"%1$s, %3$d %2$s\", weekday, month, day),\n               \"Thursday, 21 August\");\n}\n\nTEST(printf_test, printf_error) {\n  auto pipe = fmt::pipe();\n  int result = fmt::fprintf(pipe.read_end.fdopen(\"r\").get(), \"test\");\n  EXPECT_LT(result, 0);\n}\n#endif\n\nTEST(printf_test, vprintf) {\n  int n = 42;\n  auto store = fmt::make_format_args<fmt::printf_context>(n);\n  auto args = fmt::basic_format_args<fmt::printf_context>(store);\n  EXPECT_EQ(fmt::vsprintf(fmt::string_view(\"%d\"), args), \"42\");\n  EXPECT_WRITE(stdout, fmt::vfprintf(stdout, fmt::string_view(\"%d\"), args),\n               \"42\");\n}\n\ntemplate <typename... Args>\nvoid check_format_string_regression(fmt::string_view s, const Args&... args) {\n  fmt::sprintf(s, args...);\n}\n\nTEST(printf_test, check_format_string_regression) {\n  check_format_string_regression(\"%c%s\", 'x', \"\");\n}\n\nTEST(printf_test, fixed_large_exponent) {\n  EXPECT_EQ(\"1000000000000000000000\", fmt::sprintf(\"%.*f\", -13, 1e21));\n}\n\nTEST(printf_test, make_printf_args) {\n  int n = 42;\n  EXPECT_EQ(\"[42] something happened\",\n            fmt::vsprintf(fmt::string_view(\"[%d] %s happened\"),\n                          {fmt::make_printf_args(n, \"something\")}));\n  EXPECT_EQ(L\"[42] something happened\",\n            fmt::vsprintf(fmt::basic_string_view<wchar_t>(L\"[%d] %s happened\"),\n                          {fmt::make_printf_args<wchar_t>(n, L\"something\")}));\n}\n"
  },
  {
    "path": "test/ranges-odr-test.cc",
    "content": "// Formatting library for C++ - the core API\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <vector>\n\n#include \"fmt/format.h\"\n#include \"fmt/ranges.h\"\n#include \"gtest/gtest.h\"\n\n// call fmt::format from another translation unit to test ODR\nTEST(ranges_odr_test, format_vector) {\n  auto v = std::vector<int>{1, 2, 3, 5, 7, 11};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"[1, 2, 3, 5, 7, 11]\");\n}\n"
  },
  {
    "path": "test/ranges-test.cc",
    "content": "// Formatting library for C++ - ranges tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/ranges.h\"\n\n#include <array>\n#include <list>\n#include <map>\n#include <numeric>\n#include <queue>\n#include <stack>\n#include <string>\n#include <utility>\n#include <vector>\n\n#if FMT_CPLUSPLUS > 201703L && FMT_HAS_INCLUDE(<ranges>)\n#  include <ranges>\n#endif\n\n#include \"fmt/format.h\"\n#include \"gtest/gtest.h\"\n\n#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601\n#  define FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY\n#endif\n\n#ifdef FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY\nTEST(ranges_test, format_array) {\n  int arr[] = {1, 2, 3, 5, 7, 11};\n  EXPECT_EQ(fmt::format(\"{}\", arr), \"[1, 2, 3, 5, 7, 11]\");\n}\n\nTEST(ranges_test, format_2d_array) {\n  int arr[][2] = {{1, 2}, {3, 5}, {7, 11}};\n  EXPECT_EQ(fmt::format(\"{}\", arr), \"[[1, 2], [3, 5], [7, 11]]\");\n}\n\nTEST(ranges_test, format_array_of_literals) {\n  const char* arr[] = {\"1234\", \"abcd\"};\n  EXPECT_EQ(fmt::format(\"{}\", arr), \"[\\\"1234\\\", \\\"abcd\\\"]\");\n  EXPECT_EQ(fmt::format(\"{:n}\", arr), \"\\\"1234\\\", \\\"abcd\\\"\");\n  EXPECT_EQ(fmt::format(\"{:n:}\", arr), \"1234, abcd\");\n}\n#endif  // FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY\n\nstruct unformattable {};\n\nTEST(ranges_test, format_vector) {\n  auto v = std::vector<int>{1, 2, 3, 5, 7, 11};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"[1, 2, 3, 5, 7, 11]\");\n  EXPECT_EQ(fmt::format(\"{::#x}\", v), \"[0x1, 0x2, 0x3, 0x5, 0x7, 0xb]\");\n  EXPECT_EQ(fmt::format(\"{:n:#x}\", v), \"0x1, 0x2, 0x3, 0x5, 0x7, 0xb\");\n\n  auto vc = std::vector<char>{'a', 'b', 'c'};\n  auto vec = std::vector<char>{'a', '\\n', '\\t'};\n  auto vvc = std::vector<std::vector<char>>{vc, vc};\n  EXPECT_EQ(fmt::format(\"{}\", vc), \"['a', 'b', 'c']\");\n  EXPECT_EQ(fmt::format(\"{:s}\", vc), \"\\\"abc\\\"\");\n  EXPECT_EQ(fmt::format(\"{:?s}\", vec), \"\\\"a\\\\n\\\\t\\\"\");\n  EXPECT_EQ(fmt::format(\"{:s}\", vec), \"\\\"a\\n\\t\\\"\");\n  EXPECT_EQ(fmt::format(\"{::s}\", vvc), \"[\\\"abc\\\", \\\"abc\\\"]\");\n  EXPECT_EQ(fmt::format(\"{}\", vvc), \"[['a', 'b', 'c'], ['a', 'b', 'c']]\");\n  EXPECT_EQ(fmt::format(\"{:n}\", vvc), \"['a', 'b', 'c'], ['a', 'b', 'c']\");\n  EXPECT_EQ(fmt::format(\"{:n:n}\", vvc), \"'a', 'b', 'c', 'a', 'b', 'c'\");\n  EXPECT_EQ(fmt::format(\"{:n:n:}\", vvc), \"a, b, c, a, b, c\");\n\n  EXPECT_FALSE(fmt::is_formattable<unformattable>::value);\n  EXPECT_FALSE(fmt::is_formattable<std::vector<unformattable>>::value);\n}\n\nTEST(ranges_test, format_nested_vector) {\n  auto v = std::vector<std::vector<int>>{{1, 2}, {3, 5}, {7, 11}};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"[[1, 2], [3, 5], [7, 11]]\");\n  EXPECT_EQ(fmt::format(\"{:::#x}\", v), \"[[0x1, 0x2], [0x3, 0x5], [0x7, 0xb]]\");\n  EXPECT_EQ(fmt::format(\"{:n:n:#x}\", v), \"0x1, 0x2, 0x3, 0x5, 0x7, 0xb\");\n}\n\nTEST(ranges_test, to_string_vector) {\n  auto v = std::vector<std::string>{\"a\", \"b\", \"c\"};\n  EXPECT_EQ(fmt::to_string(v), \"[\\\"a\\\", \\\"b\\\", \\\"c\\\"]\");\n}\n\nTEST(ranges_test, format_map) {\n  auto m = std::map<std::string, int>{{\"one\", 1}, {\"two\", 2}};\n  EXPECT_EQ(fmt::format(\"{}\", m), \"{\\\"one\\\": 1, \\\"two\\\": 2}\");\n  EXPECT_EQ(fmt::format(\"{:n}\", m), \"\\\"one\\\": 1, \\\"two\\\": 2\");\n\n  EXPECT_FALSE((fmt::is_formattable<std::map<int, unformattable>>::value));\n}\n\nstruct test_map_value {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<test_map_value> : formatter<string_view> {\n  auto format(test_map_value, format_context& ctx) const\n      -> format_context::iterator {\n    return formatter<string_view>::format(\"foo\", ctx);\n  }\n};\n\ntemplate <typename K>\nstruct formatter<std::pair<K, test_map_value>> : formatter<string_view> {\n  auto format(std::pair<K, test_map_value>, format_context& ctx) const\n      -> format_context::iterator {\n    return ctx.out();\n  }\n};\n\ntemplate <typename K>\nstruct is_tuple_formattable<std::pair<K, test_map_value>, char>\n    : std::false_type {};\n\nFMT_END_NAMESPACE\n\nTEST(ranges_test, format_map_custom_pair) {\n  EXPECT_EQ(fmt::format(\"{}\", std::map<int, test_map_value>{{42, {}}}),\n            \"{42: \\\"foo\\\"}\");\n}\n\nTEST(ranges_test, format_set) {\n  EXPECT_EQ(fmt::format(\"{}\", std::set<std::string>{\"one\", \"two\"}),\n            \"{\\\"one\\\", \\\"two\\\"}\");\n}\n\n// Models std::flat_set close enough to test if no ambiguous lookup of a\n// formatter happens due to the flat_set type matching is_set and\n// is_container_adaptor.\ntemplate <typename T> class flat_set {\n public:\n  using key_type = T;\n  using container_type = std::vector<T>;\n\n  using iterator = typename std::vector<T>::iterator;\n  using const_iterator = typename std::vector<T>::const_iterator;\n\n  template <typename... Ts>\n  explicit flat_set(Ts&&... args) : c{std::forward<Ts>(args)...} {}\n\n  auto begin() -> iterator { return c.begin(); }\n  auto end() -> iterator { return c.end(); }\n\n  auto begin() const -> const_iterator { return c.begin(); }\n  auto end() const -> const_iterator { return c.end(); }\n\n private:\n  std::vector<T> c;\n};\n\nTEST(ranges_test, format_flat_set) {\n  EXPECT_EQ(fmt::format(\"{}\", flat_set<std::string>{\"one\", \"two\"}),\n            \"{\\\"one\\\", \\\"two\\\"}\");\n  EXPECT_FALSE(fmt::is_formattable<flat_set<unformattable>>::value);\n}\n\nnamespace adl {\nstruct box {\n  int value;\n};\n\nauto begin(const box& b) -> const int* { return &b.value; }\nauto end(const box& b) -> const int* { return &b.value + 1; }\n}  // namespace adl\n\nTEST(ranges_test, format_adl_begin_end) {\n  auto b = adl::box{42};\n  EXPECT_EQ(fmt::format(\"{}\", b), \"[42]\");\n}\n\nTEST(ranges_test, format_pair) {\n  auto p = std::pair<int, float>(42, 1.5f);\n  EXPECT_EQ(fmt::format(\"{}\", p), \"(42, 1.5)\");\n  EXPECT_EQ(fmt::format(\"{:}\", p), \"(42, 1.5)\");\n  EXPECT_EQ(fmt::format(\"{:n}\", p), \"421.5\");\n}\n\nTEST(ranges_test, format_tuple) {\n  auto t =\n      std::tuple<int, float, std::string, char>(42, 1.5f, \"this is tuple\", 'i');\n  EXPECT_EQ(fmt::format(\"{}\", t), \"(42, 1.5, \\\"this is tuple\\\", 'i')\");\n  EXPECT_EQ(fmt::format(\"{:n}\", t), \"421.5\\\"this is tuple\\\"'i'\");\n\n  EXPECT_EQ(fmt::format(\"{}\", std::tuple<>()), \"()\");\n\n  EXPECT_TRUE((fmt::is_formattable<std::tuple<>>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::tuple<unformattable>>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::tuple<unformattable, int>>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::tuple<int, unformattable>>::value));\n  EXPECT_FALSE(\n      (fmt::is_formattable<std::tuple<unformattable, unformattable>>::value));\n  EXPECT_TRUE((fmt::is_formattable<std::tuple<int, float>>::value));\n}\n\nstruct not_default_formattable {};\nstruct bad_format {};\n\nFMT_BEGIN_NAMESPACE\ntemplate <> struct formatter<not_default_formattable> {\n  auto parse(format_parse_context&) -> const char* { throw bad_format(); }\n  auto format(not_default_formattable, format_context& ctx)\n      -> format_context::iterator {\n    return ctx.out();\n  }\n};\nFMT_END_NAMESPACE\n\nTEST(ranges_test, tuple_parse_calls_element_parse) {\n  auto f = fmt::formatter<std::tuple<not_default_formattable>>();\n  auto ctx = fmt::format_parse_context(\"\");\n  EXPECT_THROW(f.parse(ctx), bad_format);\n}\n\nstruct tuple_like {\n  int i;\n  std::string str;\n\n  template <size_t N>\n  auto get() const noexcept -> fmt::enable_if_t<N == 0, int> {\n    return i;\n  }\n  template <size_t N>\n  auto get() const noexcept -> fmt::enable_if_t<N == 1, fmt::string_view> {\n    return str;\n  }\n};\n\ntemplate <size_t N>\nauto get(const tuple_like& t) noexcept -> decltype(t.get<N>()) {\n  return t.get<N>();\n}\n\n// https://github.com/llvm/llvm-project/issues/39218\nFMT_PRAGMA_CLANG(diagnostic ignored \"-Wmismatched-tags\")\n\nnamespace std {\ntemplate <>\nstruct tuple_size<tuple_like> : public std::integral_constant<size_t, 2> {};\n\ntemplate <size_t N> struct tuple_element<N, tuple_like> {\n  using type = decltype(std::declval<tuple_like>().get<N>());\n};\n}  // namespace std\n\nTEST(ranges_test, format_struct) {\n  auto t = tuple_like{42, \"foo\"};\n  EXPECT_EQ(fmt::format(\"{}\", t), \"(42, \\\"foo\\\")\");\n}\n\nTEST(ranges_test, format_to) {\n  char buf[10];\n  auto end = fmt::format_to(buf, \"{}\", std::vector<int>{1, 2, 3});\n  *end = '\\0';\n  EXPECT_STREQ(buf, \"[1, 2, 3]\");\n}\n\ntemplate <typename Char> struct path_like {\n  auto begin() const -> const path_like*;\n  auto end() const -> const path_like*;\n\n  operator std::basic_string<Char>() const;\n};\n\nTEST(ranges_test, disabled_range_formatting_of_path) {\n  // Range formatting of path is disabled because of infinite recursion\n  // (path element is itself a path).\n  EXPECT_EQ((fmt::range_format_kind<path_like<char>, char>::value),\n            fmt::range_format::disabled);\n  EXPECT_EQ((fmt::range_format_kind<path_like<wchar_t>, char>::value),\n            fmt::range_format::disabled);\n}\n\nstruct vector_string : std::vector<char> {\n  using base = std::vector<char>;\n  using base::base;\n};\nstruct vector_debug_string : std::vector<char> {\n  using base = std::vector<char>;\n  using base::base;\n};\nFMT_BEGIN_NAMESPACE\ntemplate <>\nstruct range_format_kind<vector_string, char>\n    : std::integral_constant<range_format, range_format::string> {};\ntemplate <>\nstruct range_format_kind<vector_debug_string, char>\n    : std::integral_constant<range_format, range_format::debug_string> {};\nFMT_END_NAMESPACE\n\nTEST(ranges_test, range_format_string) {\n  const vector_string v{'f', 'o', 'o'};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"foo\");\n}\n\nTEST(ranges_test, range_format_debug_string) {\n  const vector_debug_string v{'f', 'o', 'o'};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"\\\"foo\\\"\");\n}\n\n// A range that provides non-const only begin()/end() to test fmt::join\n// handles that.\n//\n// Some ranges (e.g. those produced by range-v3's views::filter()) can cache\n// information during iteration so they only provide non-const begin()/end().\ntemplate <typename T> class non_const_only_range {\n private:\n  std::vector<T> vec;\n\n public:\n  using const_iterator = typename ::std::vector<T>::const_iterator;\n\n  template <typename... Args>\n  explicit non_const_only_range(Args&&... args)\n      : vec(std::forward<Args>(args)...) {}\n\n  auto begin() -> const_iterator { return vec.begin(); }\n  auto end() -> const_iterator { return vec.end(); }\n};\n\ntemplate <typename T> class noncopyable_range {\n private:\n  std::vector<T> vec;\n\n public:\n  using iterator = typename ::std::vector<T>::iterator;\n\n  template <typename... Args>\n  explicit noncopyable_range(Args&&... args)\n      : vec(std::forward<Args>(args)...) {}\n\n  noncopyable_range(const noncopyable_range&) = delete;\n  noncopyable_range(noncopyable_range&) = delete;\n\n  auto begin() -> iterator { return vec.begin(); }\n  auto end() -> iterator { return vec.end(); }\n};\n\nTEST(ranges_test, range) {\n  auto&& w = noncopyable_range<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", w), \"[0, 0, 0]\");\n  EXPECT_EQ(fmt::format(\"{}\", noncopyable_range<int>(3u, 0)), \"[0, 0, 0]\");\n\n  auto x = non_const_only_range<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", x), \"[0, 0, 0]\");\n  EXPECT_EQ(fmt::format(\"{}\", non_const_only_range<int>(3u, 0)), \"[0, 0, 0]\");\n\n  auto y = std::vector<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", y), \"[0, 0, 0]\");\n  EXPECT_EQ(fmt::format(\"{}\", std::vector<int>(3u, 0)), \"[0, 0, 0]\");\n\n  const auto z = std::vector<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", z), \"[0, 0, 0]\");\n}\n\nenum test_enum { foo, bar };\nauto format_as(test_enum e) -> int { return e; }\n\nTEST(ranges_test, enum_range) {\n  auto v = std::vector<test_enum>{test_enum::foo};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"[0]\");\n}\n\n#if !FMT_MSC_VERSION\nTEST(ranges_test, unformattable_range) {\n  EXPECT_FALSE((fmt::is_formattable<std::vector<unformattable>, char>::value));\n}\n#endif\n\nTEST(ranges_test, join) {\n  using fmt::join;\n  int v1[3] = {1, 2, 3};\n  auto v2 = std::vector<float>();\n  v2.push_back(1.2f);\n  v2.push_back(3.4f);\n  void* v3[2] = {&v1[0], &v1[1]};\n\n  EXPECT_EQ(fmt::format(\"({})\", join(v1, v1 + 3, \", \")), \"(1, 2, 3)\");\n  EXPECT_EQ(fmt::format(\"({})\", join(v1, v1 + 1, \", \")), \"(1)\");\n  EXPECT_EQ(fmt::format(\"({})\", join(v1, v1, \", \")), \"()\");\n  EXPECT_EQ(fmt::format(\"({:03})\", join(v1, v1 + 3, \", \")), \"(001, 002, 003)\");\n  EXPECT_EQ(\"(+01.20, +03.40)\",\n            fmt::format(\"({:+06.2f})\", join(v2.begin(), v2.end(), \", \")));\n\n  EXPECT_EQ(fmt::format(\"{0:{1}}\", join(v1, v1 + 3, \", \"), 1), \"1, 2, 3\");\n\n  EXPECT_EQ(fmt::format(\"{}, {}\", v3[0], v3[1]),\n            fmt::format(\"{}\", join(v3, v3 + 2, \", \")));\n\n  EXPECT_EQ(fmt::format(\"({})\", join(v1, \", \")), \"(1, 2, 3)\");\n  EXPECT_EQ(fmt::format(\"({:+06.2f})\", join(v2, \", \")), \"(+01.20, +03.40)\");\n\n  auto v4 = std::vector<test_enum>{foo, bar, foo};\n  EXPECT_EQ(fmt::format(\"{}\", join(v4, \" \")), \"0 1 0\");\n}\n\nTEST(ranges_test, join_tuple) {\n  // Value tuple args.\n  auto t1 = std::tuple<char, int, float>('a', 1, 2.0f);\n  EXPECT_EQ(fmt::format(\"({})\", fmt::join(t1, \", \")), \"(a, 1, 2)\");\n\n  // Testing lvalue tuple args.\n  int x = 4;\n  auto t2 = std::tuple<char, int&>('b', x);\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(t2, \" + \")), \"b + 4\");\n\n  // Empty tuple.\n  auto t3 = std::tuple<>();\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(t3, \"|\")), \"\");\n\n  // Single element tuple.\n  auto t4 = std::tuple<float>(4.0f);\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(t4, \"/\")), \"4\");\n\n  // Tuple-like.\n  auto t5 = tuple_like{42, \"foo\"};\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(t5, \", \")), \"42, foo\");\n\n#if FMT_TUPLE_JOIN_SPECIFIERS\n  // Specs applied to each element.\n  auto t5 = std::tuple<int, int, long>(-3, 100, 1);\n  EXPECT_EQ(fmt::format(\"{:+03}\", fmt::join(t5, \", \")), \"-03, +100, +01\");\n\n  auto t6 = std::tuple<float, double, long double>(3, 3.14, 3.1415);\n  EXPECT_EQ(fmt::format(\"{:5.5f}\", fmt::join(t6, \", \")),\n            \"3.00000, 3.14000, 3.14150\");\n\n  // Testing lvalue tuple args.\n  int y = -1;\n  auto t7 = std::tuple<int, int&, const int&>(3, y, y);\n  EXPECT_EQ(fmt::format(\"{:03}\", fmt::join(t7, \", \")), \"003, -01, -01\");\n#endif\n}\n\nstruct zstring_sentinel {};\n\nbool operator==(const char* p, zstring_sentinel) { return *p == '\\0'; }\nbool operator!=(const char* p, zstring_sentinel) { return *p != '\\0'; }\n\nstruct zstring {\n  const char* p;\n  auto begin() const -> const char* { return p; }\n  auto end() const -> zstring_sentinel { return {}; }\n};\n\n#ifdef __cpp_lib_ranges\nstruct cpp20_only_range {\n  struct iterator {\n    int val = 0;\n\n    using value_type = int;\n    using difference_type = std::ptrdiff_t;\n    using iterator_concept = std::input_iterator_tag;\n\n    iterator() = default;\n    iterator(int i) : val(i) {}\n    auto operator*() const -> int { return val; }\n    auto operator++() -> iterator& {\n      ++val;\n      return *this;\n    }\n    void operator++(int) { ++*this; }\n    auto operator==(const iterator& rhs) const -> bool {\n      return val == rhs.val;\n    }\n  };\n\n  int lo;\n  int hi;\n\n  auto begin() const -> iterator { return iterator(lo); }\n  auto end() const -> iterator { return iterator(hi); }\n};\n\nstatic_assert(std::input_iterator<cpp20_only_range::iterator>);\n#endif\n\nTEST(ranges_test, join_sentinel) {\n  auto hello = zstring{\"hello\"};\n  EXPECT_EQ(fmt::format(\"{}\", hello), \"['h', 'e', 'l', 'l', 'o']\");\n  EXPECT_EQ(fmt::format(\"{::}\", hello), \"[h, e, l, l, o]\");\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(hello, \"_\")), \"h_e_l_l_o\");\n}\n\nTEST(ranges_test, join_range) {\n  auto&& w = noncopyable_range<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(w, \",\")), \"0,0,0\");\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(noncopyable_range<int>(3u, 0), \",\")),\n            \"0,0,0\");\n\n  auto x = non_const_only_range<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(x, \",\")), \"0,0,0\");\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(non_const_only_range<int>(3u, 0), \",\")),\n            \"0,0,0\");\n\n  auto y = std::vector<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(y, \",\")), \"0,0,0\");\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(std::vector<int>(3u, 0), \",\")),\n            \"0,0,0\");\n\n  const auto z = std::vector<int>(3u, 0);\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(z, \",\")), \"0,0,0\");\n\n#ifdef __cpp_lib_ranges\n  EXPECT_EQ(fmt::format(\"{}\", cpp20_only_range{.lo = 0, .hi = 5}),\n            \"[0, 1, 2, 3, 4]\");\n  EXPECT_EQ(\n      fmt::format(\"{}\", fmt::join(cpp20_only_range{.lo = 0, .hi = 5}, \",\")),\n      \"0,1,2,3,4\");\n#endif\n}\n\nnamespace adl {\nstruct vec {\n  int n[2] = {42, 43};\n};\n\nauto begin(const vec& v) -> const int* { return v.n; }\nauto end(const vec& v) -> const int* { return v.n + 2; }\n}  // namespace adl\n\nTEST(ranges_test, format_join_adl_begin_end) {\n  EXPECT_EQ(fmt::format(\"{}\", fmt::join(adl::vec(), \"/\")), \"42/43\");\n}\n\n#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 202207L\nTEST(ranges_test, nested_ranges) {\n  auto l = std::list{1, 2, 3};\n  auto r = std::views::iota(0, 3) | std::views::transform([&l](auto i) {\n             return std::views::take(std::ranges::subrange(l), i);\n           }) |\n           std::views::transform(std::views::reverse);\n  EXPECT_EQ(fmt::format(\"{}\", r), \"[[], [1], [2, 1]]\");\n}\n#endif\n\nTEST(ranges_test, is_printable) {\n  using fmt::detail::is_printable;\n  EXPECT_TRUE(is_printable(0x0323));\n  EXPECT_FALSE(is_printable(0x0378));\n  EXPECT_FALSE(is_printable(0x110000));\n}\n\nTEST(ranges_test, escape) {\n  using vec = std::vector<std::string>;\n  EXPECT_EQ(fmt::format(\"{}\", vec{\"\\n\\r\\t\\\"\\\\\"}), \"[\\\"\\\\n\\\\r\\\\t\\\\\\\"\\\\\\\\\\\"]\");\n  EXPECT_EQ(fmt::format(\"{}\", vec{\"\\x07\"}), \"[\\\"\\\\x07\\\"]\");\n  EXPECT_EQ(fmt::format(\"{}\", vec{\"\\x7f\"}), \"[\\\"\\\\x7f\\\"]\");\n  EXPECT_EQ(fmt::format(\"{}\", vec{\"n\\xcc\\x83\"}), \"[\\\"n\\xcc\\x83\\\"]\");\n\n  if (fmt::detail::use_utf8) {\n    EXPECT_EQ(fmt::format(\"{}\", vec{\"\\xcd\\xb8\"}), \"[\\\"\\\\u0378\\\"]\");\n    // Unassigned Unicode code points.\n    EXPECT_EQ(fmt::format(\"{}\", vec{\"\\xf0\\xaa\\x9b\\x9e\"}), \"[\\\"\\\\U0002a6de\\\"]\");\n    // Broken utf-8.\n    EXPECT_EQ(fmt::format(\"{}\", vec{\"\\xf4\\x8f\\xbf\\xc0\"}),\n              \"[\\\"\\\\xf4\\\\x8f\\\\xbf\\\\xc0\\\"]\");\n    EXPECT_EQ(fmt::format(\"{}\", vec{\"\\xf0\\x28\"}), \"[\\\"\\\\xf0(\\\"]\");\n    EXPECT_EQ(fmt::format(\"{}\", vec{\"\\xe1\\x28\"}), \"[\\\"\\\\xe1(\\\"]\");\n    EXPECT_EQ(fmt::format(\"{}\", vec{std::string(\"\\xf0\\x28\\0\\0anything\", 12)}),\n              \"[\\\"\\\\xf0(\\\\x00\\\\x00anything\\\"]\");\n\n    // Correct utf-8.\n    EXPECT_EQ(fmt::format(\"{}\", vec{\"🦄\"}), \"[\\\"🦄\\\"]\");\n  }\n\n  EXPECT_EQ(fmt::format(\"{}\", std::vector<std::vector<char>>{{'x'}}),\n            \"[['x']]\");\n\n// Disabled due to a clang 17 bug: https://github.com/fmtlib/fmt/issues/4144.\n#if FMT_CLANG_VERSION >= 1800\n  EXPECT_EQ(fmt::format(\"{}\", std::tuple<std::vector<char>>{{'x'}}), \"(['x'])\");\n#endif\n}\n\ntemplate <typename R> struct fmt_ref_view {\n  R* r;\n\n  auto begin() const -> decltype(r->begin()) { return r->begin(); }\n  auto end() const -> decltype(r->end()) { return r->end(); }\n};\n\nTEST(ranges_test, range_of_range_of_mixed_const) {\n  auto v = std::vector<std::vector<int>>{{1, 2, 3}, {4, 5}};\n  EXPECT_EQ(fmt::format(\"{}\", v), \"[[1, 2, 3], [4, 5]]\");\n\n  auto r = fmt_ref_view<decltype(v)>{&v};\n  EXPECT_EQ(fmt::format(\"{}\", r), \"[[1, 2, 3], [4, 5]]\");\n}\n\nTEST(ranges_test, vector_char) {\n  EXPECT_EQ(fmt::format(\"{}\", std::vector<char>{'a', 'b'}), \"['a', 'b']\");\n}\n\nTEST(ranges_test, container_adaptor) {\n  {\n    using T = std::nullptr_t;\n    static_assert(fmt::is_container_adaptor<std::stack<T>>::value, \"\");\n    static_assert(fmt::is_container_adaptor<std::queue<T>>::value, \"\");\n    static_assert(fmt::is_container_adaptor<std::priority_queue<T>>::value, \"\");\n    static_assert(!fmt::is_container_adaptor<std::vector<T>>::value, \"\");\n  }\n\n  {\n    auto s = std::stack<int>();\n    s.push(1);\n    s.push(2);\n    EXPECT_EQ(fmt::format(\"{}\", s), \"[1, 2]\");\n    EXPECT_EQ(fmt::format(\"{}\", const_cast<const decltype(s)&>(s)), \"[1, 2]\");\n  }\n\n  {\n    auto q = std::queue<int>();\n    q.push(1);\n    q.push(2);\n    EXPECT_EQ(fmt::format(\"{}\", q), \"[1, 2]\");\n  }\n\n  {\n    auto q = std::priority_queue<int>();\n    q.push(3);\n    q.push(1);\n    q.push(2);\n    q.push(4);\n    EXPECT_EQ(fmt::format(\"{}\", q), \"[4, 3, 2, 1]\");\n  }\n\n  {\n    auto s = std::stack<char, std::string>();\n    s.push('a');\n    s.push('b');\n    // See https://cplusplus.github.io/LWG/issue3881.\n    EXPECT_EQ(fmt::format(\"{}\", s), \"['a', 'b']\");\n  }\n\n  {\n    struct my_container_adaptor {\n      using value_type = int;\n      using container_type = std::vector<value_type>;\n      void push(const value_type& v) { c.push_back(v); }\n\n     protected:\n      container_type c;\n    };\n\n    auto m = my_container_adaptor();\n    m.push(1);\n    m.push(2);\n    EXPECT_EQ(fmt::format(\"{}\", m), \"[1, 2]\");\n  }\n\n  EXPECT_FALSE(fmt::is_formattable<std::stack<unformattable>>::value);\n}\n\nstruct tieable {\n  int a = 3;\n  double b = 0.42;\n};\n\nauto format_as(const tieable& t) -> std::tuple<int, double> {\n  return std::tie(t.a, t.b);\n}\n\nTEST(ranges_test, format_as_tie) {\n  EXPECT_EQ(fmt::format(\"{}\", tieable()), \"(3, 0.42)\");\n}\n\nstruct lvalue_qualified_begin_end {\n  int arr[5] = {1, 2, 3, 4, 5};\n\n  auto begin() & -> const int* { return arr; }\n  auto end() & -> const int* { return arr + 5; }\n};\n\nTEST(ranges_test, lvalue_qualified_begin_end) {\n  EXPECT_EQ(fmt::format(\"{}\", lvalue_qualified_begin_end{}), \"[1, 2, 3, 4, 5]\");\n}\n\n#if !defined(__cpp_lib_ranges) || __cpp_lib_ranges <= 202106L\n#  define ENABLE_STD_VIEWS_TESTS 0\n#elif FMT_CLANG_VERSION\n#  if FMT_CLANG_VERSION > 1500\n#    define ENABLE_STD_VIEWS_TESTS 1\n#  else\n#    define ENABLE_STD_VIEWS_TESTS 0\n#  endif\n#else\n#  define ENABLE_STD_VIEWS_TESTS 1\n#endif\n\n#if ENABLE_STD_VIEWS_TESTS\nTEST(ranges_test, input_range_join) {\n  auto iss = std::istringstream(\"1 2 3 4 5\");\n  auto view = std::views::istream<std::string>(iss);\n  EXPECT_EQ(\"1, 2, 3, 4, 5\",\n            fmt::format(\"{}\", fmt::join(view.begin(), view.end(), \", \")));\n}\n\nTEST(ranges_test, input_range_join_overload) {\n  auto iss = std::istringstream(\"1 2 3 4 5\");\n  EXPECT_EQ(\n      \"1.2.3.4.5\",\n      fmt::format(\"{}\", fmt::join(std::views::istream<std::string>(iss), \".\")));\n}\n\nnamespace views_filter_view_test {\nstruct codec_mask {\n  static constexpr auto codecs = std::array{0, 1, 2, 3};\n  int except = 0;\n};\n\nauto format_as(codec_mask mask) {\n  // Careful not to capture param by reference here, it will dangle.\n  return codec_mask::codecs |\n         std::views::filter([mask](auto c) { return c != mask.except; });\n}\n}  // namespace views_filter_view_test\n\nTEST(ranges_test, format_as_with_ranges_mutable_begin_end) {\n  using namespace views_filter_view_test;\n  {\n    auto make_filter_view = []() {\n      return codec_mask::codecs |\n             std::views::filter([](auto c) { return c != 2; });\n    };\n    auto r = make_filter_view();\n    EXPECT_EQ(\"[0, 1, 3]\", fmt::format(\"{}\", r));\n    EXPECT_EQ(\"[0, 1, 3]\", fmt::format(\"{}\", make_filter_view()));\n  }\n\n  {\n    auto mask = codec_mask{2};\n    const auto const_mask = codec_mask{2};\n\n    EXPECT_EQ(\"[0, 1, 3]\", fmt::format(\"{}\", mask));\n    EXPECT_EQ(\"[0, 1, 3]\", fmt::format(\"{}\", const_mask));\n    EXPECT_EQ(\"[0, 1, 3]\", fmt::format(\"{}\", codec_mask{2}));\n  }\n}\n\n#endif\n\nTEST(ranges_test, std_istream_iterator_join) {\n  auto&& iss = std::istringstream(\"1 2 3 4 5\");\n  auto first = std::istream_iterator<int>(iss);\n  auto last = std::istream_iterator<int>();\n  EXPECT_EQ(\"1, 2, 3, 4, 5\", fmt::format(\"{}\", fmt::join(first, last, \", \")));\n}\n\n// Mirrors C++20 std::ranges::basic_istream_view::iterator.\nstruct noncopyable_istream_iterator : std::istream_iterator<int> {\n  using base = std::istream_iterator<int>;\n  explicit noncopyable_istream_iterator(std::istringstream& iss) : base{iss} {}\n  noncopyable_istream_iterator(const noncopyable_istream_iterator&) = delete;\n  noncopyable_istream_iterator(noncopyable_istream_iterator&&) = default;\n};\nstatic_assert(!std::is_copy_constructible<noncopyable_istream_iterator>::value,\n              \"\");\n\nTEST(ranges_test, movable_only_istream_iter_join) {\n  auto&& iss = std::istringstream(\"1 2 3 4 5\");\n  auto first = noncopyable_istream_iterator(iss);\n  auto last = std::istream_iterator<int>();\n  EXPECT_EQ(\"1, 2, 3, 4, 5\",\n            fmt::format(\"{}\", fmt::join(std::move(first), last, \", \")));\n}\n\nstruct movable_iter_range {\n  std::istringstream iss{\"1 2 3 4 5\"};\n  noncopyable_istream_iterator begin() {\n    return noncopyable_istream_iterator{iss};\n  }\n  std::istream_iterator<int> end() { return {}; }\n};\n\nTEST(ranges_test, movable_only_istream_iter_join2) {\n  EXPECT_EQ(\"[1, 2, 3, 4, 5]\", fmt::format(\"{}\", movable_iter_range{}));\n}\n\nstruct not_range {\n  void begin() const {}\n  void end() const {}\n};\nstatic_assert(!fmt::is_formattable<not_range>{}, \"\");\n\nstruct test_adaptor {\n  using container_type = std::vector<int>;\n  std::vector<int> c = {1, 2, 3};\n};\n\nnamespace fmt {\ntemplate <> struct is_container_adaptor<test_adaptor> : std::false_type {};\n\ntemplate <> struct formatter<test_adaptor> : formatter<string_view> {\n  auto format(const test_adaptor&, format_context& ctx) const\n      -> format_context::iterator {\n    return formatter<string_view>::format(\"test\", ctx);\n  }\n};\n}  // namespace fmt\n\nTEST(ranges_test, container_adaptor_opt_out) {\n  EXPECT_EQ(fmt::format(\"{}\", test_adaptor()), \"test\");\n}\n"
  },
  {
    "path": "test/scan-test.cc",
    "content": "// Formatting library for C++ - scanning API test\n//\n// Copyright (c) 2019 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"scan.h\"\n\n#include <time.h>\n\n#include <climits>\n#include <thread>\n\n#include \"fmt/os.h\"\n#include \"gmock/gmock.h\"\n#include \"gtest-extra.h\"\n\nTEST(scan_test, read_text) {\n  fmt::string_view s = \"foo\";\n  auto end = fmt::scan_to(s, \"foo\");\n  EXPECT_EQ(end, s.end());\n  EXPECT_THROW_MSG(fmt::scan<int>(\"fob\", \"foo\"), fmt::format_error,\n                   \"invalid input\");\n}\n\nTEST(scan_test, read_int) {\n  EXPECT_EQ(fmt::scan<int>(\"42\", \"{}\")->value(), 42);\n  EXPECT_EQ(fmt::scan<int>(\"-42\", \"{}\")->value(), -42);\n  EXPECT_EQ(fmt::scan<int>(\"42\", \"{:}\")->value(), 42);\n  EXPECT_THROW_MSG(fmt::scan<int>(std::to_string(INT_MAX + 1u), \"{}\"),\n                   fmt::format_error, \"number is too big\");\n}\n\nTEST(scan_test, read_long_long) {\n  EXPECT_EQ(fmt::scan<long long>(\"42\", \"{}\")->value(), 42);\n  EXPECT_EQ(fmt::scan<long long>(\"-42\", \"{}\")->value(), -42);\n}\n\nTEST(scan_test, read_uint) {\n  EXPECT_EQ(fmt::scan<unsigned>(\"42\", \"{}\")->value(), 42);\n  EXPECT_THROW_MSG(fmt::scan<unsigned>(\"-42\", \"{}\"), fmt::format_error,\n                   \"invalid input\");\n}\n\nTEST(scan_test, read_ulong_long) {\n  EXPECT_EQ(fmt::scan<unsigned long long>(\"42\", \"{}\")->value(), 42);\n  EXPECT_THROW_MSG(fmt::scan<unsigned long long>(\"-42\", \"{}\")->value(),\n                   fmt::format_error, \"invalid input\");\n}\n\nTEST(scan_test, read_hex) {\n  EXPECT_EQ(fmt::scan<unsigned>(\"2a\", \"{:x}\")->value(), 42);\n  auto num_digits = std::numeric_limits<unsigned>::digits / 4;\n  EXPECT_THROW_MSG(\n      fmt::scan<unsigned>(fmt::format(\"1{:0{}}\", 0, num_digits), \"{:x}\")\n          ->value(),\n      fmt::format_error, \"number is too big\");\n}\n\nTEST(scan_test, read_floats) {\n  auto float_result = fmt::scan<float>(\"3.14\", \"{}\");\n  EXPECT_TRUE(float_result);\n  EXPECT_FLOAT_EQ(float_result->value(), 3.14f);\n\n  auto double_result = fmt::scan<double>(\"3.14\", \"{}\");\n  EXPECT_TRUE(double_result);\n  EXPECT_DOUBLE_EQ(double_result->value(), 3.14);\n}\n\nTEST(scan_test, read_double_whitespace) {\n  auto result = fmt::scan<double>(\"   2.5   \", \"{}\");\n  EXPECT_TRUE(result);\n  EXPECT_DOUBLE_EQ(result->value(), 2.5);\n}\n\nTEST(scan_test, read_string) {\n  EXPECT_EQ(fmt::scan<std::string>(\"foo\", \"{}\")->value(), \"foo\");\n}\n\nTEST(scan_test, read_string_view) {\n  EXPECT_EQ(fmt::scan<fmt::string_view>(\"foo\", \"{}\")->value(), \"foo\");\n}\n\nTEST(scan_test, separator) {\n  int n1 = 0, n2 = 0;\n  fmt::scan_to(\"10 20\", \"{} {}\", n1, n2);\n  EXPECT_EQ(n1, 10);\n  EXPECT_EQ(n2, 20);\n}\n\nstruct num {\n  int value;\n};\n\nnamespace fmt {\ntemplate <> struct scanner<num> {\n  bool hex = false;\n\n  auto parse(scan_parse_context& ctx) -> scan_parse_context::iterator {\n    auto it = ctx.begin(), end = ctx.end();\n    if (it != end && *it == 'x') {\n      hex = true;\n      ++it;\n    }\n    if (it != end && *it != '}') report_error(\"invalid format\");\n    return it;\n  }\n\n  template <class ScanContext>\n  auto scan(num& n, ScanContext& ctx) const -> typename ScanContext::iterator {\n    return hex ? scan_to(ctx, \"{:x}\", n.value) : scan_to(ctx, \"{}\", n.value);\n  }\n};\n}  // namespace fmt\n\nTEST(scan_test, read_custom) {\n  EXPECT_EQ(fmt::scan<num>(\"42\", \"{}\")->value().value, 42);\n  EXPECT_EQ(fmt::scan<num>(\"2a\", \"{:x}\")->value().value, 42);\n}\n\nTEST(scan_test, invalid_format) {\n  EXPECT_THROW_MSG(fmt::scan_to(\"\", \"{}\"), fmt::format_error,\n                   \"argument index out of range\");\n  EXPECT_THROW_MSG(fmt::scan_to(\"\", \"{\"), fmt::format_error,\n                   \"invalid format string\");\n}\n\nnamespace std {\nusing fmt::scan;\nusing fmt::scan_error;\n}  // namespace std\n\nTEST(scan_test, example) {\n  // Example from https://wg21.link/p1729r3.\n  if (auto result = std::scan<std::string, int>(\"answer = 42\", \"{} = {}\")) {\n    auto range = result->range();\n    EXPECT_EQ(range.begin(), range.end());\n    EXPECT_EQ(result->begin(), result->end());\n#ifdef __cpp_structured_bindings\n    const auto& [key, value] = result->values();\n    EXPECT_EQ(key, \"answer\");\n    EXPECT_EQ(value, 42);\n#endif\n  } else {\n    std::scan_error error = result.error();\n    (void)error;\n    FAIL();\n  }\n}\n\nTEST(scan_test, end_of_input) { fmt::scan<int>(\"\", \"{}\"); }\n\n#if FMT_USE_FCNTL\nTEST(scan_test, file) {\n  auto pipe = fmt::pipe();\n\n  fmt::string_view input = \"10 20\";\n  pipe.write_end.write(input.data(), input.size());\n  pipe.write_end.close();\n\n  int n1 = 0, n2 = 0;\n  fmt::buffered_file f = pipe.read_end.fdopen(\"r\");\n  fmt::scan_to(f.get(), \"{} {}\", n1, n2);\n  EXPECT_EQ(n1, 10);\n  EXPECT_EQ(n2, 20);\n}\n\nTEST(scan_test, lock) {\n  auto pipe = fmt::pipe();\n\n  std::thread producer([&]() {\n    fmt::string_view input = \"42 \";\n    for (int i = 0; i < 1000; ++i)\n      pipe.write_end.write(input.data(), input.size());\n    pipe.write_end.close();\n  });\n\n  std::atomic<int> count(0);\n  fmt::buffered_file f = pipe.read_end.fdopen(\"r\");\n  auto fun = [&]() {\n    int value = 0;\n    while (fmt::scan_to(f.get(), \"{}\", value)) {\n      if (value != 42) {\n        pipe.read_end.close();\n        EXPECT_EQ(value, 42);\n        break;\n      }\n      ++count;\n    }\n  };\n  std::thread consumer1(fun);\n  std::thread consumer2(fun);\n\n  producer.join();\n  consumer1.join();\n  consumer2.join();\n  EXPECT_EQ(count, 1000);\n}\n#endif  // FMT_USE_FCNTL\n"
  },
  {
    "path": "test/scan.h",
    "content": "// Formatting library for C++ - scanning API proof of concept\n//\n// Copyright (c) 2019 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <array>\n#include <cassert>\n#include <climits>\n#include <tuple>\n\n#include \"fmt/format-inl.h\"\n\nFMT_BEGIN_NAMESPACE\nnamespace detail {\n\ninline auto is_whitespace(char c) -> bool { return c == ' ' || c == '\\n'; }\n\n// If c is a hex digit returns its numeric value, otherwise -1.\ninline auto to_hex_digit(char c) -> int {\n  if (c >= '0' && c <= '9') return c - '0';\n  if (c >= 'a' && c <= 'f') return c - 'a' + 10;\n  if (c >= 'A' && c <= 'F') return c - 'A' + 10;\n  return -1;\n}\n\nstruct maybe_contiguous_range {\n  const char* begin;\n  const char* end;\n\n  explicit operator bool() const { return begin != nullptr; }\n};\n\nclass scan_buffer {\n private:\n  const char* ptr_;\n  const char* end_;\n  bool contiguous_;\n\n protected:\n  scan_buffer(const char* ptr, const char* end, bool contiguous)\n      : ptr_(ptr), end_(end), contiguous_(contiguous) {}\n  ~scan_buffer() = default;\n\n  void set(span<const char> buf) {\n    ptr_ = buf.data;\n    end_ = buf.data + buf.size;\n  }\n\n  auto ptr() const -> const char* { return ptr_; }\n\n public:\n  scan_buffer(const scan_buffer&) = delete;\n  void operator=(const scan_buffer&) = delete;\n\n  // Fills the buffer with more input if available.\n  virtual void consume() = 0;\n\n  class sentinel {};\n\n  class iterator {\n   private:\n    const char** ptr_;\n    scan_buffer* buf_;  // This could be merged with ptr_.\n    char value_;\n\n    static auto get_sentinel() -> const char** {\n      static const char* ptr = nullptr;\n      return &ptr;\n    }\n\n    friend class scan_buffer;\n\n    friend auto operator==(iterator lhs, sentinel) -> bool {\n      return *lhs.ptr_ == nullptr;\n    }\n    friend auto operator!=(iterator lhs, sentinel) -> bool {\n      return *lhs.ptr_ != nullptr;\n    }\n\n    iterator(scan_buffer* buf) : buf_(buf) {\n      if (buf->ptr_ == buf->end_) {\n        ptr_ = get_sentinel();\n        return;\n      }\n      ptr_ = &buf->ptr_;\n      value_ = *buf->ptr_;\n    }\n\n    friend scan_buffer& get_buffer(iterator it) { return *it.buf_; }\n\n   public:\n    iterator() : ptr_(get_sentinel()), buf_(nullptr) {}\n\n    auto operator++() -> iterator& {\n      if (!buf_->try_consume()) ptr_ = get_sentinel();\n      value_ = *buf_->ptr_;\n      return *this;\n    }\n    auto operator++(int) -> iterator {\n      iterator copy = *this;\n      ++*this;\n      return copy;\n    }\n    auto operator*() const -> char { return value_; }\n\n    auto base() const -> const char* { return buf_->ptr_; }\n\n    friend auto to_contiguous(iterator it) -> maybe_contiguous_range;\n    friend auto advance(iterator it, size_t n) -> iterator;\n  };\n\n  friend auto to_contiguous(iterator it) -> maybe_contiguous_range {\n    if (it.buf_->is_contiguous()) return {it.buf_->ptr_, it.buf_->end_};\n    return {nullptr, nullptr};\n  }\n  friend auto advance(iterator it, size_t n) -> iterator {\n    FMT_ASSERT(it.buf_->is_contiguous(), \"\");\n    const char*& ptr = it.buf_->ptr_;\n    ptr += n;\n    it.value_ = *ptr;\n    if (ptr == it.buf_->end_) it.ptr_ = iterator::get_sentinel();\n    return it;\n  }\n\n  auto begin() -> iterator { return this; }\n  auto end() -> sentinel { return {}; }\n\n  auto is_contiguous() const -> bool { return contiguous_; }\n\n  // Tries consuming a single code unit. Returns true iff there is more input.\n  auto try_consume() -> bool {\n    FMT_ASSERT(ptr_ != end_, \"\");\n    ++ptr_;\n    if (ptr_ != end_) return true;\n    consume();\n    return ptr_ != end_;\n  }\n};\n\nusing scan_iterator = scan_buffer::iterator;\nusing scan_sentinel = scan_buffer::sentinel;\n\nclass string_scan_buffer final : public scan_buffer {\n private:\n  void consume() override {}\n\n public:\n  explicit string_scan_buffer(string_view s)\n      : scan_buffer(s.begin(), s.end(), true) {}\n};\n\nclass file_scan_buffer final : public scan_buffer {\n private:\n  template <typename F, FMT_ENABLE_IF(sizeof(F::_IO_read_ptr) != 0 &&\n                                      !FMT_USE_FALLBACK_FILE)>\n  static auto get_file(F* f, int) -> glibc_file<F> {\n    return f;\n  }\n  template <typename F,\n            FMT_ENABLE_IF(sizeof(F::_p) != 0 && !FMT_USE_FALLBACK_FILE)>\n  static auto get_file(F* f, int) -> apple_file<F> {\n    return f;\n  }\n  static auto get_file(FILE* f, ...) -> fallback_file<FILE> { return f; }\n\n  decltype(get_file(static_cast<FILE*>(nullptr), 0)) file_;\n\n  // Fills the buffer if it is empty.\n  void fill() {\n    span<const char> buf = file_.get_read_buffer();\n    if (buf.size == 0) {\n      int c = file_.get();\n      // Put the character back since we are only filling the buffer.\n      if (c != EOF) file_.unget(static_cast<char>(c));\n      buf = file_.get_read_buffer();\n    }\n    set(buf);\n  }\n\n  void consume() override {\n    // Consume the current buffer content.\n    size_t n = to_unsigned(ptr() - file_.get_read_buffer().data);\n    for (size_t i = 0; i != n; ++i) file_.get();\n    fill();\n  }\n\n public:\n  explicit file_scan_buffer(FILE* f)\n      : scan_buffer(nullptr, nullptr, false), file_(f) {\n    flockfile(f);\n    fill();\n  }\n  ~file_scan_buffer() {\n    FILE* f = file_;\n    funlockfile(f);\n  }\n};\n}  // namespace detail\n\ntemplate <typename T, typename Char = char> struct scanner {\n  // A deleted default constructor indicates a disabled scanner.\n  scanner() = delete;\n};\n\nclass scan_parse_context {\n private:\n  string_view format_;\n\n public:\n  using iterator = string_view::iterator;\n\n  FMT_CONSTEXPR explicit scan_parse_context(string_view format)\n      : format_(format) {}\n\n  FMT_CONSTEXPR auto begin() const -> iterator { return format_.begin(); }\n  FMT_CONSTEXPR auto end() const -> iterator { return format_.end(); }\n\n  void advance_to(iterator it) {\n    format_.remove_prefix(detail::to_unsigned(it - begin()));\n  }\n};\n\nnamespace detail {\nenum class scan_type {\n  none_type,\n  int_type,\n  uint_type,\n  long_long_type,\n  ulong_long_type,\n  double_type,\n  float_type,\n  string_type,\n  string_view_type,\n  custom_type\n};\n\ntemplate <typename Context> struct custom_scan_arg {\n  void* value;\n  void (*scan)(void* arg, scan_parse_context& parse_ctx, Context& ctx);\n};\n}  // namespace detail\n\n// A scan argument. Context is a template parameter for the compiled API where\n// output can be unbuffered.\ntemplate <typename Context> class basic_scan_arg {\n private:\n  using scan_type = detail::scan_type;\n  scan_type type_;\n  union {\n    int* int_value_;\n    unsigned* uint_value_;\n    long long* long_long_value_;\n    unsigned long long* ulong_long_value_;\n    double* double_value_;\n    float* float_value_;\n    std::string* string_;\n    string_view* string_view_;\n    detail::custom_scan_arg<Context> custom_;\n    // TODO: more types\n  };\n\n  template <typename T>\n  static void scan_custom_arg(void* arg, scan_parse_context& parse_ctx,\n                              Context& ctx) {\n    auto s = scanner<T>();\n    parse_ctx.advance_to(s.parse(parse_ctx));\n    ctx.advance_to(s.scan(*static_cast<T*>(arg), ctx));\n  }\n\n public:\n  FMT_CONSTEXPR basic_scan_arg()\n      : type_(scan_type::none_type), int_value_(nullptr) {}\n  FMT_CONSTEXPR basic_scan_arg(int& value)\n      : type_(scan_type::int_type), int_value_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(unsigned& value)\n      : type_(scan_type::uint_type), uint_value_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(long long& value)\n      : type_(scan_type::long_long_type), long_long_value_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(unsigned long long& value)\n      : type_(scan_type::ulong_long_type), ulong_long_value_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(double& value)\n      : type_(scan_type::double_type), double_value_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(float& value)\n      : type_(scan_type::float_type), float_value_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(std::string& value)\n      : type_(scan_type::string_type), string_(&value) {}\n  FMT_CONSTEXPR basic_scan_arg(string_view& value)\n      : type_(scan_type::string_view_type), string_view_(&value) {}\n  template <typename T>\n  FMT_CONSTEXPR basic_scan_arg(T& value) : type_(scan_type::custom_type) {\n    custom_.value = &value;\n    custom_.scan = scan_custom_arg<T>;\n  }\n\n  constexpr explicit operator bool() const noexcept {\n    return type_ != scan_type::none_type;\n  }\n\n  auto type() const -> detail::scan_type { return type_; }\n\n  template <typename Visitor>\n  auto visit(Visitor&& vis) -> decltype(vis(monostate())) {\n    switch (type_) {\n    case scan_type::none_type:\n      break;\n    case scan_type::int_type:\n      return vis(*int_value_);\n    case scan_type::uint_type:\n      return vis(*uint_value_);\n    case scan_type::long_long_type:\n      return vis(*long_long_value_);\n    case scan_type::ulong_long_type:\n      return vis(*ulong_long_value_);\n    case scan_type::double_type:\n      return vis(*double_value_);\n    case scan_type::float_type:\n      return vis(*float_value_);\n    case scan_type::string_type:\n      return vis(*string_);\n    case scan_type::string_view_type:\n      return vis(*string_view_);\n    case scan_type::custom_type:\n      break;\n    }\n    return vis(monostate());\n  }\n\n  auto scan_custom(const char* parse_begin, scan_parse_context& parse_ctx,\n                   Context& ctx) const -> bool {\n    if (type_ != scan_type::custom_type) return false;\n    parse_ctx.advance_to(parse_begin);\n    custom_.scan(custom_.value, parse_ctx, ctx);\n    return true;\n  }\n};\n\nclass scan_context;\nusing scan_arg = basic_scan_arg<scan_context>;\n\nstruct scan_args {\n  int size;\n  const scan_arg* data;\n\n  template <size_t N>\n  FMT_CONSTEXPR scan_args(const std::array<scan_arg, N>& store)\n      : size(N), data(store.data()) {\n    static_assert(N < INT_MAX, \"too many arguments\");\n  }\n};\n\nclass scan_context {\n private:\n  detail::scan_buffer& buf_;\n  scan_args args_;\n\n public:\n  using iterator = detail::scan_iterator;\n  using sentinel = detail::scan_sentinel;\n\n  FMT_CONSTEXPR explicit scan_context(detail::scan_buffer& buf, scan_args args)\n      : buf_(buf), args_(args) {}\n\n  FMT_CONSTEXPR auto arg(int id) const -> scan_arg {\n    return id < args_.size ? args_.data[id] : scan_arg();\n  }\n\n  auto begin() const -> iterator { return buf_.begin(); }\n  auto end() const -> sentinel { return {}; }\n\n  void advance_to(iterator) { buf_.consume(); }\n};\n\nnamespace detail {\n\nconst char* parse_scan_specs(const char* begin, const char* end,\n                             format_specs& specs, scan_type) {\n  while (begin != end) {\n    switch (to_ascii(*begin)) {\n    // TODO: parse more scan format specifiers\n    case 'x':\n      specs.set_type(presentation_type::hex);\n      ++begin;\n      break;\n    case '}':\n      return begin;\n    }\n  }\n  return begin;\n}\n\ntemplate <typename T, FMT_ENABLE_IF(std::is_unsigned<T>::value)>\nauto read(scan_iterator it, T& value) -> scan_iterator {\n  if (it == scan_sentinel()) return it;\n  char c = *it;\n  if (c < '0' || c > '9') report_error(\"invalid input\");\n\n  int num_digits = 0;\n  T n = 0, prev = 0;\n  char prev_digit = c;\n  do {\n    prev = n;\n    n = n * 10 + static_cast<unsigned>(c - '0');\n    prev_digit = c;\n    c = *++it;\n    ++num_digits;\n    if (c < '0' || c > '9') break;\n  } while (it != scan_sentinel());\n\n  // Check overflow.\n  if (num_digits <= std::numeric_limits<int>::digits10) {\n    value = n;\n    return it;\n  }\n  unsigned max = to_unsigned((std::numeric_limits<int>::max)());\n  if (num_digits == std::numeric_limits<int>::digits10 + 1 &&\n      prev * 10ull + unsigned(prev_digit - '0') <= max) {\n    value = n;\n  } else {\n    report_error(\"number is too big\");\n  }\n  return it;\n}\n\ntemplate <typename T, FMT_ENABLE_IF(std::is_unsigned<T>::value)>\nauto read_hex(scan_iterator it, T& value) -> scan_iterator {\n  if (it == scan_sentinel()) return it;\n  int digit = to_hex_digit(*it);\n  if (digit < 0) report_error(\"invalid input\");\n\n  int num_digits = 0;\n  T n = 0;\n  do {\n    n = (n << 4) + static_cast<unsigned>(digit);\n    ++num_digits;\n    digit = to_hex_digit(*++it);\n    if (digit < 0) break;\n  } while (it != scan_sentinel());\n\n  // Check overflow.\n  if (num_digits <= (std::numeric_limits<T>::digits >> 2))\n    value = n;\n  else\n    report_error(\"number is too big\");\n  return it;\n}\n\ntemplate <typename T, FMT_ENABLE_IF(std::is_unsigned<T>::value)>\nauto read(scan_iterator it, T& value, const format_specs& specs)\n    -> scan_iterator {\n  if (specs.type() == presentation_type::hex) return read_hex(it, value);\n  return read(it, value);\n}\n\ntemplate <typename T, FMT_ENABLE_IF(std::is_signed<T>::value)>\nauto read(scan_iterator it, T& value, const format_specs& specs = {})\n    -> scan_iterator {\n  bool negative = it != scan_sentinel() && *it == '-';\n  if (negative) {\n    ++it;\n    if (it == scan_sentinel()) report_error(\"invalid input\");\n  }\n  using unsigned_type = typename std::make_unsigned<T>::type;\n  unsigned_type abs_value = 0;\n  it = read(it, abs_value, specs);\n  auto n = static_cast<T>(abs_value);\n  value = negative ? -n : n;\n  return it;\n}\n\nauto read(scan_iterator it, double& value, const format_specs& = {})\n    -> scan_iterator {\n  if (it == scan_sentinel()) return it;\n  \n  // Simple floating-point parsing\n  bool negative = *it == '-';\n  if (negative) {\n    ++it;\n    if (it == scan_sentinel()) report_error(\"invalid input\");\n  }\n  \n  double result = 0.0;\n  // Parse integer part\n  while (it != scan_sentinel() && *it >= '0' && *it <= '9') {\n    result = result * 10.0 + (*it - '0');\n    ++it;\n  }\n  \n  // Parse decimal part if present\n  if (it != scan_sentinel() && *it == '.') {\n    ++it;\n    double fraction = 0.1;\n    while (it != scan_sentinel() && *it >= '0' && *it <= '9') {\n      result += (*it - '0') * fraction;\n      fraction *= 0.1;\n      ++it;\n    }\n  }\n  \n  value = negative ? -result : result;\n  return it;\n}\n\nauto read(scan_iterator it, float& value, const format_specs& specs = {})\n    -> scan_iterator {\n  double temp;\n  it = read(it, temp, specs);\n  value = static_cast<float>(temp);\n  return it;\n}\n\nauto read(scan_iterator it, std::string& value, const format_specs& = {})\n    -> scan_iterator {\n  while (it != scan_sentinel() && *it != ' ') value.push_back(*it++);\n  return it;\n}\n\nauto read(scan_iterator it, string_view& value, const format_specs& = {})\n    -> scan_iterator {\n  auto range = to_contiguous(it);\n  // This could also be checked at compile time in scan.\n  if (!range) report_error(\"string_view requires contiguous input\");\n  auto p = range.begin;\n  while (p != range.end && *p != ' ') ++p;\n  size_t size = to_unsigned(p - range.begin);\n  value = {range.begin, size};\n  return advance(it, size);\n}\n\nauto read(scan_iterator it, monostate, const format_specs& = {})\n    -> scan_iterator {\n  return it;\n}\n\n// An argument scanner that uses the default format, e.g. decimal for integers.\nstruct default_arg_scanner {\n  scan_iterator it;\n\n  template <typename T> FMT_INLINE auto operator()(T&& value) -> scan_iterator {\n    return read(it, value);\n  }\n};\n\n// An argument scanner with format specifiers.\nstruct arg_scanner {\n  scan_iterator it;\n  const format_specs& specs;\n\n  template <typename T> auto operator()(T&& value) -> scan_iterator {\n    return read(it, value, specs);\n  }\n};\n\nstruct scan_handler {\n private:\n  scan_parse_context parse_ctx_;\n  scan_context scan_ctx_;\n  int next_arg_id_;\n\n  using sentinel = scan_buffer::sentinel;\n\n public:\n  FMT_CONSTEXPR scan_handler(string_view format, scan_buffer& buf,\n                             scan_args args)\n      : parse_ctx_(format), scan_ctx_(buf, args), next_arg_id_(0) {}\n\n  auto pos() const -> scan_buffer::iterator { return scan_ctx_.begin(); }\n\n  void on_text(const char* begin, const char* end) {\n    if (begin == end) return;\n    auto it = scan_ctx_.begin();\n    for (; begin != end; ++begin, ++it) {\n      if (it == sentinel() || *begin != *it) on_error(\"invalid input\");\n    }\n    scan_ctx_.advance_to(it);\n  }\n\n  FMT_CONSTEXPR auto on_arg_id() -> int { return on_arg_id(next_arg_id_++); }\n  FMT_CONSTEXPR auto on_arg_id(int id) -> int {\n    if (!scan_ctx_.arg(id)) on_error(\"argument index out of range\");\n    return id;\n  }\n  FMT_CONSTEXPR auto on_arg_id(string_view id) -> int {\n    if (id.data()) on_error(\"invalid format\");\n    return 0;\n  }\n\n  void on_replacement_field(int arg_id, const char* begin) {\n    scan_arg arg = scan_ctx_.arg(arg_id);\n    if (arg.scan_custom(begin, parse_ctx_, scan_ctx_)) return;\n    auto it = scan_ctx_.begin();\n    while (it != sentinel() && is_whitespace(*it)) ++it;\n    scan_ctx_.advance_to(arg.visit(default_arg_scanner{it}));\n  }\n\n  auto on_format_specs(int arg_id, const char* begin, const char* end) -> const\n      char* {\n    scan_arg arg = scan_ctx_.arg(arg_id);\n    if (arg.scan_custom(begin, parse_ctx_, scan_ctx_))\n      return parse_ctx_.begin();\n    auto specs = format_specs();\n    begin = parse_scan_specs(begin, end, specs, arg.type());\n    if (begin == end || *begin != '}') on_error(\"missing '}' in format string\");\n    scan_ctx_.advance_to(arg.visit(arg_scanner{scan_ctx_.begin(), specs}));\n    return begin;\n  }\n\n  FMT_NORETURN void on_error(const char* message) { report_error(message); }\n};\n\nvoid vscan(detail::scan_buffer& buf, string_view fmt, scan_args args) {\n  auto h = detail::scan_handler(fmt, buf, args);\n  detail::parse_format_string(fmt, h);\n}\n\ntemplate <size_t I, typename... T, FMT_ENABLE_IF(I == sizeof...(T))>\nvoid make_args(std::array<scan_arg, sizeof...(T)>&, std::tuple<T...>&) {}\n\ntemplate <size_t I, typename... T, FMT_ENABLE_IF(I < sizeof...(T))>\nvoid make_args(std::array<scan_arg, sizeof...(T)>& args,\n               std::tuple<T...>& values) {\n  using element_type = typename std::tuple_element<I, std::tuple<T...>>::type;\n  static_assert(std::is_same<remove_cvref_t<element_type>, element_type>::value,\n                \"\");\n  args[I] = std::get<I>(values);\n  make_args<I + 1>(args, values);\n}\n}  // namespace detail\n\ntemplate <typename Range, typename... T> class scan_data {\n private:\n  std::tuple<T...> values_;\n  Range range_;\n\n public:\n  scan_data() = default;\n  scan_data(T... values) : values_(std::move(values)...) {}\n\n  auto value() const -> decltype(std::get<0>(values_)) {\n    return std::get<0>(values_);\n  }\n\n  auto values() const -> const std::tuple<T...>& { return values_; }\n\n  auto make_args() -> std::array<scan_arg, sizeof...(T)> {\n    auto args = std::array<scan_arg, sizeof...(T)>();\n    detail::make_args<0>(args, values_);\n    return args;\n  }\n\n  auto range() const -> Range { return range_; }\n\n  auto begin() const -> decltype(range_.begin()) { return range_.begin(); }\n  auto end() const -> decltype(range_.end()) { return range_.end(); }\n};\n\ntemplate <typename... T>\nauto make_scan_args(T&... args) -> std::array<scan_arg, sizeof...(T)> {\n  return {{args...}};\n}\n\nclass scan_error {};\n\n// A rudimentary version of std::expected for testing the API shape.\ntemplate <typename T, typename E> class expected {\n private:\n  T value_;\n  bool has_value_ = true;\n\n public:\n  expected(T value) : value_(std::move(value)) {}\n\n  explicit operator bool() const { return has_value_; }\n\n  auto operator->() const -> const T* { return &value_; }\n\n  auto error() -> E const { return E(); }\n};\n\ntemplate <typename Range, typename... T>\nusing scan_result = expected<scan_data<Range, T...>, scan_error>;\n\nauto vscan(string_view input, string_view fmt, scan_args args)\n    -> string_view::iterator {\n  auto&& buf = detail::string_scan_buffer(input);\n  detail::vscan(buf, fmt, args);\n  return input.begin() + (buf.begin().base() - input.data());\n}\n\n// Scans the input and stores the results (in)to args.\ntemplate <typename... T>\nauto scan_to(string_view input, string_view fmt, T&... args)\n    -> string_view::iterator {\n  return vscan(input, fmt, make_scan_args(args...));\n}\n\ntemplate <typename... T>\nauto scan(string_view input, string_view fmt)\n    -> scan_result<string_view, T...> {\n  auto data = scan_data<string_view, T...>();\n  vscan(input, fmt, data.make_args());\n  return data;\n}\n\ntemplate <typename Range, typename... T,\n          FMT_ENABLE_IF(!std::is_convertible<Range, string_view>::value)>\nauto scan_to(Range&& input, string_view fmt, T&... args)\n    -> decltype(std::begin(input)) {\n  auto it = std::begin(input);\n  detail::vscan(get_buffer(it), fmt, make_scan_args(args...));\n  return it;\n}\n\ntemplate <typename... T>\nauto scan_to(FILE* f, string_view fmt, T&... args) -> bool {\n  auto&& buf = detail::file_scan_buffer(f);\n  detail::vscan(buf, fmt, make_scan_args(args...));\n  return buf.begin() != buf.end();\n}\n\nFMT_END_NAMESPACE\n"
  },
  {
    "path": "test/static-export-test/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.8...3.25)\n\nproject(fmt-link CXX)\n\nset(BUILD_SHARED_LIBS OFF)\nset(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)\nset(CMAKE_CXX_VISIBILITY_PRESET \"hidden\")\n\n# Broken LTO on GCC 4\nif (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)\n  set(BROKEN_LTO ON)\nendif ()\n\nif (NOT BROKEN_LTO AND CMAKE_VERSION VERSION_GREATER \"3.8\")\n  # CMake 3.9+\n  include(CheckIPOSupported)\n  check_ipo_supported(RESULT HAVE_IPO)\n  if (HAVE_IPO)\n    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)\n  endif ()\nendif ()\n\nadd_subdirectory(../.. fmt)\nset_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)\n\nadd_library(library-test SHARED library.cc)\ntarget_link_libraries(library-test PRIVATE fmt::fmt)\n\nadd_executable(exe-test main.cc)\ntarget_link_libraries(exe-test PRIVATE library-test)\n"
  },
  {
    "path": "test/static-export-test/library.cc",
    "content": "#include <fmt/compile.h>\n\n__attribute__((visibility(\"default\"))) std::string foo() {\n  return fmt::format(FMT_COMPILE(\"foo bar {}\"), 4242);\n}\n"
  },
  {
    "path": "test/static-export-test/main.cc",
    "content": "#include <iostream>\n#include <string>\n\nextern std::string foo();\n\nint main() { std::cout << foo() << std::endl; }\n"
  },
  {
    "path": "test/std-test.cc",
    "content": "// Formatting library for C++ - tests of formatters for standard library types\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/std.h\"\n\n#include <bitset>\n#include <stdexcept>\n#include <string>\n#include <vector>\n\n#include \"fmt/os.h\"  // fmt::system_category\n#include \"fmt/ranges.h\"\n#include \"gtest-extra.h\"  // StartsWith\n\n#ifdef __cpp_lib_filesystem\nTEST(std_test, path) {\n  using std::filesystem::path;\n  EXPECT_EQ(fmt::format(\"{}\", path(\"/usr/bin\")), \"/usr/bin\");\n\n  // see #4303\n  const path p = \"/usr/bin\";\n  EXPECT_EQ(fmt::format(\"{}\", p), \"/usr/bin\");\n\n  EXPECT_EQ(fmt::format(\"{:?}\", path(\"/usr/bin\")), \"\\\"/usr/bin\\\"\");\n  EXPECT_EQ(fmt::format(\"{:8}\", path(\"foo\")), \"foo     \");\n\n  EXPECT_EQ(fmt::format(\"{}\", path(\"foo\\\"bar\")), \"foo\\\"bar\");\n  EXPECT_EQ(fmt::format(\"{:?}\", path(\"foo\\\"bar\")), \"\\\"foo\\\\\\\"bar\\\"\");\n\n  EXPECT_EQ(fmt::format(\"{:g}\", path(\"/usr/bin\")), \"/usr/bin\");\n#  ifdef _WIN32\n  EXPECT_EQ(fmt::format(\"{}\", path(\"C:\\\\foo\")), \"C:\\\\foo\");\n  EXPECT_EQ(fmt::format(\"{:g}\", path(\"C:\\\\foo\")), \"C:/foo\");\n\n  EXPECT_EQ(fmt::format(\"{}\", path(L\"\\x0428\\x0447\\x0443\\x0447\\x044B\\x043D\\x0448\"\n                                   L\"\\x0447\\x044B\\x043D\\x0430\")),\n            \"Шчучыншчына\");\n  EXPECT_EQ(fmt::format(\"{}\", path(L\"\\xD800\")), \"\\xED\\xA0\\x80\");\n  EXPECT_EQ(fmt::format(\"{}\", path(L\"[\\xD800]\")), \"[\\xED\\xA0\\x80]\");\n  EXPECT_EQ(fmt::format(\"{}\", path(L\"[\\xD83D\\xDE00]\")), \"[\\xF0\\x9F\\x98\\x80]\");\n  EXPECT_EQ(fmt::format(\"{}\", path(L\"[\\xD83D\\xD83D\\xDE00]\")),\n            \"[\\xED\\xA0\\xBD\\xF0\\x9F\\x98\\x80]\");\n  EXPECT_EQ(fmt::format(\"{:?}\", path(L\"\\xD800\")), \"\\\"\\\\ud800\\\"\");\n#  endif\n}\n\n// Intentionally delayed include to test #4303\n#  include \"fmt/ranges.h\"\n\n// Test ambiguity problem described in #2954.\nTEST(ranges_std_test, format_vector_path) {\n  auto p = std::filesystem::path(\"foo/bar.txt\");\n  auto c = std::vector<std::string>{\"abc\", \"def\"};\n  EXPECT_EQ(fmt::format(\"path={}, range={}\", p, c),\n            \"path=foo/bar.txt, range=[\\\"abc\\\", \\\"def\\\"]\");\n}\n\n// Test that path is not escaped twice in the debug mode.\nTEST(ranges_std_test, format_quote_path) {\n  auto vec =\n      std::vector<std::filesystem::path>{\"path1/file1.txt\", \"path2/file2.txt\"};\n  EXPECT_EQ(fmt::format(\"{}\", vec),\n            \"[\\\"path1/file1.txt\\\", \\\"path2/file2.txt\\\"]\");\n#  ifdef __cpp_lib_optional\n  auto o = std::optional<std::filesystem::path>(\"path/file.txt\");\n  EXPECT_EQ(fmt::format(\"{}\", o), \"optional(\\\"path/file.txt\\\")\");\n  EXPECT_EQ(fmt::format(\"{:?}\", o), \"optional(\\\"path/file.txt\\\")\");\n#  endif\n}\n#endif\n\nTEST(std_test, thread_id) {\n  EXPECT_FALSE(fmt::format(\"{}\", std::this_thread::get_id()).empty());\n}\n\nTEST(std_test, complex) {\n  using limits = std::numeric_limits<double>;\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<double>(1, limits::quiet_NaN())),\n            \"(1+nan i)\");\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<double>(1, -limits::infinity())),\n            \"(1-inf i)\");\n\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<int>(1, 2)), \"(1+2i)\");\n\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<double>(1, 2.2)), \"(1+2.2i)\");\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<double>(1, -2.2)), \"(1-2.2i)\");\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<double>(0, 2.2)), \"2.2i\");\n  EXPECT_EQ(fmt::format(\"{}\", std::complex<double>(0, -2.2)), \"-2.2i\");\n\n  EXPECT_EQ(fmt::format(\"{:+}\", std::complex<double>(0, 2.2)), \"+2.2i\");\n  EXPECT_EQ(fmt::format(\"{:+}\", std::complex<double>(0, -2.2)), \"-2.2i\");\n  EXPECT_EQ(fmt::format(\"{:+}\", std::complex<double>(1, -2.2)), \"(+1-2.2i)\");\n  EXPECT_EQ(fmt::format(\"{:+}\", std::complex<double>(1, 2.2)), \"(+1+2.2i)\");\n  EXPECT_EQ(fmt::format(\"{: }\", std::complex<double>(1, 2.2)), \"( 1+2.2i)\");\n  EXPECT_EQ(fmt::format(\"{: }\", std::complex<double>(1, -2.2)), \"( 1-2.2i)\");\n\n  EXPECT_EQ(fmt::format(\"{:8}\", std::complex<double>(1, 2)), \"(1+2i)  \");\n  EXPECT_EQ(fmt::format(\"{:-<8}\", std::complex<double>(1, 2)), \"(1+2i)--\");\n\n  EXPECT_EQ(fmt::format(\"{:>20.2f}\", std::complex<double>(1, 2.2)),\n            \"        (1.00+2.20i)\");\n  EXPECT_EQ(fmt::format(\"{:<20.2f}\", std::complex<double>(1, 2.2)),\n            \"(1.00+2.20i)        \");\n  EXPECT_EQ(fmt::format(\"{:<20.2f}\", std::complex<double>(1, -2.2)),\n            \"(1.00-2.20i)        \");\n  EXPECT_EQ(fmt::format(\"{:<{}.{}f}\", std::complex<double>(1, -2.2), 20, 2),\n            \"(1.00-2.20i)        \");\n}\n\n#ifdef __cpp_lib_source_location\nTEST(std_test, source_location) {\n  std::source_location loc = std::source_location::current();\n  EXPECT_EQ(fmt::format(\"{}\", loc),\n            fmt::format(\"{}:{}:{}: {}\", loc.file_name(), loc.line(),\n                        loc.column(), loc.function_name()));\n}\n#endif\n\nTEST(std_test, optional) {\n#ifdef __cpp_lib_optional\n  EXPECT_EQ(fmt::format(\"{}\", std::optional<int>{}), \"none\");\n  EXPECT_EQ(fmt::format(\"{}\", std::pair{1, \"second\"}), \"(1, \\\"second\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\", std::vector{std::optional{1}, std::optional{2},\n                                          std::optional{3}}),\n            \"[optional(1), optional(2), optional(3)]\");\n  EXPECT_EQ(\n      fmt::format(\"{}\", std::optional<std::optional<const char*>>{{\"nested\"}}),\n      \"optional(optional(\\\"nested\\\"))\");\n  EXPECT_EQ(\n      fmt::format(\"{:<{}}\", std::optional{std::string{\"left aligned\"}}, 30),\n      \"optional(\\\"left aligned\\\"                )\");\n  EXPECT_EQ(\n      fmt::format(\"{::d}\", std::optional{std::vector{'h', 'e', 'l', 'l', 'o'}}),\n      \"optional([104, 101, 108, 108, 111])\");\n  EXPECT_EQ(fmt::format(\"{}\", std::optional{std::string{\"string\"}}),\n            \"optional(\\\"string\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\", std::optional{'C'}), \"optional(\\'C\\')\");\n  EXPECT_EQ(fmt::format(\"{:.{}f}\", std::optional{3.14}, 1), \"optional(3.1)\");\n\n  struct unformattable {};\n  EXPECT_FALSE((fmt::is_formattable<unformattable>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::optional<unformattable>>::value));\n  EXPECT_TRUE((fmt::is_formattable<std::optional<int>>::value));\n  EXPECT_TRUE((fmt::is_formattable<std::optional<const int>>::value));\n#endif\n}\n\nTEST(std_test, expected) {\n#ifdef __cpp_lib_expected\n  EXPECT_EQ(fmt::format(\"{}\", std::expected<void, int>{}), \"expected()\");\n  EXPECT_EQ(fmt::format(\"{}\", std::expected<int, int>{1}), \"expected(1)\");\n  EXPECT_EQ(fmt::format(\"{}\", std::expected<int, int>{std::unexpected(1)}),\n            \"unexpected(1)\");\n  EXPECT_EQ(fmt::format(\"{}\", std::expected<std::string, int>{\"test\"}),\n            \"expected(\\\"test\\\")\");\n  EXPECT_EQ(fmt::format(\n                \"{}\", std::expected<int, std::string>{std::unexpected(\"test\")}),\n            \"unexpected(\\\"test\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\", std::expected<char, int>{'a'}), \"expected('a')\");\n  EXPECT_EQ(fmt::format(\"{}\", std::expected<int, char>{std::unexpected('a')}),\n            \"unexpected('a')\");\n\n  struct unformattable1 {};\n  struct unformattable2 {};\n  EXPECT_FALSE((fmt::is_formattable<unformattable1>::value));\n  EXPECT_FALSE((fmt::is_formattable<unformattable2>::value));\n  EXPECT_FALSE((fmt::is_formattable<\n                std::expected<unformattable1, unformattable2>>::value));\n  EXPECT_FALSE(\n      (fmt::is_formattable<std::expected<unformattable1, int>>::value));\n  EXPECT_FALSE(\n      (fmt::is_formattable<std::expected<int, unformattable2>>::value));\n  EXPECT_TRUE((fmt::is_formattable<std::expected<int, int>>::value));\n  EXPECT_TRUE((fmt::is_formattable<std::expected<void, int>>::value));\n\n  EXPECT_EQ(fmt::format(\"{}\", std::unexpected{1}), \"unexpected(1)\");\n  EXPECT_EQ(fmt::format(\"{}\", std::unexpected<std::string>{\"test\"}),\n            \"unexpected(\\\"test\\\")\");\n\n  EXPECT_EQ(fmt::format(\"{}\", std::unexpected<char>{'a'}), \"unexpected('a')\");\n\n  EXPECT_FALSE((fmt::is_formattable<std::unexpected<unformattable2>>::value));\n#endif\n}\n\nnamespace my_nso {\nenum class my_number {\n  one,\n  two,\n};\nauto format_as(my_number number) -> fmt::string_view {\n  return number == my_number::one ? \"first\" : \"second\";\n}\n\nclass my_class {\n public:\n  int av;\n\n private:\n  friend auto format_as(const my_class& elm) -> std::string {\n    return fmt::to_string(elm.av);\n  }\n};\n\nclass my_class_int {\n public:\n  int av;\n\n private:\n  friend auto format_as(const my_class_int& elm) -> int { return elm.av; }\n};\n}  // namespace my_nso\n\nTEST(std_test, expected_format_as) {\n#ifdef __cpp_lib_expected\n  EXPECT_EQ(\n      fmt::format(\n          \"{}\", std::expected<my_nso::my_number, int>{my_nso::my_number::one}),\n      \"expected(\\\"first\\\")\");\n  EXPECT_EQ(\n      fmt::format(\"{}\",\n                  std::expected<my_nso::my_class, int>{my_nso::my_class{7}}),\n      \"expected(\\\"7\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\",\n                        std::expected<my_nso::my_class_int, int>{\n                            my_nso::my_class_int{8}}),\n            \"expected(8)\");\n#endif\n}\n\nTEST(std_test, optional_format_as) {\n#ifdef __cpp_lib_optional\n  EXPECT_EQ(fmt::format(\"{}\", std::optional<my_nso::my_number>{}), \"none\");\n  EXPECT_EQ(fmt::format(\"{}\", std::optional{my_nso::my_number::one}),\n            \"optional(\\\"first\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\", std::optional<my_nso::my_class>{}), \"none\");\n  EXPECT_EQ(fmt::format(\"{}\", std::optional{my_nso::my_class{7}}),\n            \"optional(\\\"7\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\", std::optional{my_nso::my_class_int{8}}),\n            \"optional(8)\");\n#endif\n}\n\nstruct throws_on_move {\n  throws_on_move() = default;\n\n  [[noreturn]] throws_on_move(throws_on_move&&) {\n    throw std::runtime_error(\"Thrown by throws_on_move\");\n  }\n\n  throws_on_move(const throws_on_move&) = default;\n};\n\nnamespace fmt {\ntemplate <> struct formatter<throws_on_move> : formatter<string_view> {\n  auto format(const throws_on_move&, format_context& ctx) const\n      -> decltype(ctx.out()) {\n    string_view str(\"<throws_on_move>\");\n    return formatter<string_view>::format(str, ctx);\n  }\n};\n}  // namespace fmt\n\nTEST(std_test, variant) {\n#ifdef __cpp_lib_variant\n  EXPECT_EQ(fmt::format(\"{}\", std::monostate{}), \"monostate\");\n  using V0 = std::variant<int, float, std::string, char>;\n  V0 v0(42);\n  V0 v1(1.5f);\n  V0 v2(\"hello\");\n  V0 v3('i');\n  EXPECT_EQ(fmt::format(\"{}\", v0), \"variant(42)\");\n  EXPECT_EQ(fmt::format(\"{}\", v1), \"variant(1.5)\");\n  EXPECT_EQ(fmt::format(\"{}\", v2), \"variant(\\\"hello\\\")\");\n  EXPECT_EQ(fmt::format(\"{}\", v3), \"variant('i')\");\n\n  struct unformattable {};\n  EXPECT_FALSE((fmt::is_formattable<unformattable>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::variant<unformattable>>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::variant<unformattable, int>>::value));\n  EXPECT_FALSE((fmt::is_formattable<std::variant<int, unformattable>>::value));\n  EXPECT_FALSE(\n      (fmt::is_formattable<std::variant<unformattable, unformattable>>::value));\n  EXPECT_TRUE((fmt::is_formattable<std::variant<int, float>>::value));\n\n  using V1 = std::variant<std::monostate, std::string, std::string>;\n  V1 v4{};\n  V1 v5{std::in_place_index<1>, \"yes, this is variant\"};\n\n  EXPECT_EQ(fmt::format(\"{}\", v4), \"variant(monostate)\");\n  EXPECT_EQ(fmt::format(\"{}\", v5), \"variant(\\\"yes, this is variant\\\")\");\n\n  volatile int i = 42;  // Test compile error before GCC 11 described in #3068.\n  EXPECT_EQ(fmt::format(\"{}\", i), \"42\");\n\n  std::variant<std::monostate, throws_on_move> v6;\n\n  try {\n    throws_on_move thrower;\n    v6.emplace<throws_on_move>(std::move(thrower));\n  } catch (const std::runtime_error&) {\n  }\n  // v6 is now valueless by exception\n\n  EXPECT_EQ(fmt::format(\"{}\", v6), \"variant(valueless by exception)\");\n\n#endif\n}\n\nTEST(std_test, variant_format_as) {\n#ifdef __cpp_lib_variant\n\n  EXPECT_EQ(fmt::format(\"{}\", std::variant<my_nso::my_number>{}),\n            \"variant(\\\"first\\\")\");\n  EXPECT_EQ(fmt::format(\n                \"{}\", std::variant<my_nso::my_number>{my_nso::my_number::one}),\n            \"variant(\\\"first\\\")\");\n  EXPECT_EQ(\n      fmt::format(\"{}\", std::variant<my_nso::my_class>{my_nso::my_class{7}}),\n      \"variant(\\\"7\\\")\");\n  EXPECT_EQ(\n      fmt::format(\"{}\",\n                  std::variant<my_nso::my_class_int>{my_nso::my_class_int{8}}),\n      \"variant(8)\");\n#endif\n}\n\nTEST(std_test, error_code) {\n  auto& generic = std::generic_category();\n  EXPECT_EQ(fmt::format(\"{}\", std::error_code(42, generic)), \"generic:42\");\n  EXPECT_EQ(fmt::format(\"{:>12}\", std::error_code(42, generic)),\n            \"  generic:42\");\n  EXPECT_EQ(fmt::format(\"{:12}\", std::error_code(42, generic)), \"generic:42  \");\n  EXPECT_EQ(fmt::format(\"{}\", std::error_code(42, fmt::system_category())),\n            \"system:42\");\n  EXPECT_EQ(fmt::format(\"{}\", std::error_code(-42, fmt::system_category())),\n            \"system:-42\");\n  auto ec = std::make_error_code(std::errc::value_too_large);\n  EXPECT_EQ(fmt::format(\"{:s}\", ec), ec.message());\n  EXPECT_EQ(fmt::format(\"{:?}\", std::error_code(42, generic)),\n            \"\\\"generic:42\\\"\");\n  EXPECT_EQ(fmt::format(\"{}\",\n                        std::map<std::error_code, int>{\n                            {std::error_code(42, generic), 0}}),\n            \"{\\\"generic:42\\\": 0}\");\n}\n\ntemplate <typename Catch> void exception_test() {\n  try {\n    throw std::runtime_error(\"Test Exception\");\n  } catch (const Catch& ex) {\n    EXPECT_EQ(\"Test Exception\", fmt::format(\"{}\", ex));\n    EXPECT_EQ(\"std::runtime_error: Test Exception\", fmt::format(\"{:t}\", ex));\n  }\n}\n\nnamespace my_ns1 {\nnamespace my_ns2 {\nstruct my_exception : public std::exception {\n private:\n  std::string msg;\n\n public:\n  my_exception(const std::string& s) : msg(s) {}\n  const char* what() const noexcept override;\n};\nconst char* my_exception::what() const noexcept { return msg.c_str(); }\n}  // namespace my_ns2\n}  // namespace my_ns1\n\nTEST(std_test, exception) {\n  using testing::StartsWith;\n  exception_test<std::exception>();\n  exception_test<std::runtime_error>();\n\n  try {\n    using namespace my_ns1::my_ns2;\n    throw my_exception(\"My Exception\");\n  } catch (const std::exception& ex) {\n    EXPECT_EQ(\"my_ns1::my_ns2::my_exception: My Exception\",\n              fmt::format(\"{:t}\", ex));\n    EXPECT_EQ(\"My Exception\", fmt::format(\"{:}\", ex));\n  }\n\n  try {\n    throw std::system_error(std::error_code(), \"message\");\n  } catch (const std::system_error& ex) {\n    EXPECT_THAT(fmt::format(\"{:t}\", ex), StartsWith(\"std::system_error: \"));\n  }\n\n#ifdef __cpp_lib_filesystem\n  // Tests that the inline namespace is stripped out, e.g.\n  // std::filesystem::__cxx11::* -> std::filesystem::*.\n  try {\n    throw std::filesystem::filesystem_error(\"message\", std::error_code());\n  } catch (const std::filesystem::filesystem_error& ex) {\n    EXPECT_THAT(fmt::format(\"{:t}\", ex),\n                StartsWith(\"std::filesystem::filesystem_error: \"));\n  }\n#endif\n}\n\n#if FMT_USE_RTTI\nTEST(std_test, type_info) {\n  EXPECT_EQ(fmt::format(\"{}\", typeid(std::runtime_error)),\n            \"std::runtime_error\");\n}\n#endif\n\n#if FMT_USE_BITINT\nFMT_PRAGMA_CLANG(diagnostic ignored \"-Wbit-int-extension\")\n\nTEST(std_test, bitint) {\n  using fmt::detail::bitint;\n  using fmt::detail::ubitint;\n\n  EXPECT_EQ(fmt::format(\"{}\", ubitint<3>(7)), \"7\");\n  EXPECT_EQ(fmt::format(\"{}\", bitint<7>()), \"0\");\n\n  EXPECT_EQ(fmt::format(\"{}\", ubitint<15>(31000)), \"31000\");\n  EXPECT_EQ(fmt::format(\"{}\", bitint<16>(INT16_MIN)), \"-32768\");\n  EXPECT_EQ(fmt::format(\"{}\", bitint<16>(INT16_MAX)), \"32767\");\n\n  EXPECT_EQ(fmt::format(\"{}\", ubitint<32>(4294967295)), \"4294967295\");\n\n  EXPECT_EQ(fmt::format(\"{}\", ubitint<47>(140737488355327ULL)),\n            \"140737488355327\");\n  EXPECT_EQ(fmt::format(\"{}\", bitint<47>(-40737488355327LL)),\n            \"-40737488355327\");\n\n  // Check lvalues and const\n  auto a = bitint<8>(0);\n  auto b = ubitint<32>(4294967295);\n  const auto c = bitint<7>(0);\n  const auto d = ubitint<32>(4294967295);\n  EXPECT_EQ(fmt::format(\"{}\", a), \"0\");\n  EXPECT_EQ(fmt::format(\"{}\", b), \"4294967295\");\n  EXPECT_EQ(fmt::format(\"{}\", c), \"0\");\n  EXPECT_EQ(fmt::format(\"{}\", d), \"4294967295\");\n\n  static_assert(fmt::is_formattable<bitint<64>, char>{}, \"\");\n  static_assert(fmt::is_formattable<ubitint<64>, char>{}, \"\");\n}\n#endif\n\nTEST(std_test, format_bit_reference) {\n  std::bitset<2> bs(1);\n  EXPECT_EQ(fmt::format(\"{} {}\", bs[0], bs[1]), \"true false\");\n  std::vector<bool> v = {true, false};\n  EXPECT_EQ(fmt::format(\"{} {}\", v[0], v[1]), \"true false\");\n}\n\nTEST(std_test, format_const_bit_reference) {\n  const std::bitset<2> bs(1);\n  EXPECT_EQ(fmt::format(\"{} {}\", bs[0], bs[1]), \"true false\");\n  const std::vector<bool> v = {true, false};\n  EXPECT_EQ(fmt::format(\"{} {}\", v[0], v[1]), \"true false\");\n}\n\nTEST(std_test, format_bitset) {\n  auto bs = std::bitset<6>(42);\n  EXPECT_EQ(fmt::format(\"{}\", bs), \"101010\");\n  EXPECT_EQ(fmt::format(\"{:0>8}\", bs), \"00101010\");\n  EXPECT_EQ(fmt::format(\"{:-^12}\", bs), \"---101010---\");\n}\n\n#ifdef __cpp_lib_byte\nTEST(base_test, format_byte) {\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), \"{}\", std::byte(42));\n  EXPECT_EQ(s, \"42\");\n}\n#endif\n\nTEST(std_test, format_atomic) {\n  std::atomic<bool> b(false);\n  EXPECT_EQ(fmt::format(\"{}\", b), \"false\");\n\n  const std::atomic<bool> cb(true);\n  EXPECT_EQ(fmt::format(\"{}\", cb), \"true\");\n}\n\n#ifdef __cpp_lib_atomic_flag_test\nTEST(std_test, format_atomic_flag) {\n  std::atomic_flag f;\n  (void)f.test_and_set();\n  EXPECT_EQ(fmt::format(\"{}\", f), \"true\");\n\n  f.clear();\n  const std::atomic_flag& cf = f;\n  EXPECT_EQ(fmt::format(\"{}\", cf), \"false\");\n}\n#endif  // __cpp_lib_atomic_flag_test\n\nTEST(std_test, format_unique_ptr) {\n  std::unique_ptr<int> up(new int(1));\n  EXPECT_EQ(fmt::format(\"{}\", fmt::ptr(up.get())),\n            fmt::format(\"{}\", fmt::ptr(up)));\n  struct custom_deleter {\n    void operator()(int* p) const { delete p; }\n  };\n  std::unique_ptr<int, custom_deleter> upcd(new int(1));\n  EXPECT_EQ(fmt::format(\"{}\", fmt::ptr(upcd.get())),\n            fmt::format(\"{}\", fmt::ptr(upcd)));\n}\n\nTEST(std_test, format_shared_ptr) {\n  std::shared_ptr<int> sp(new int(1));\n  EXPECT_EQ(fmt::format(\"{}\", fmt::ptr(sp.get())),\n            fmt::format(\"{}\", fmt::ptr(sp)));\n}\n\nTEST(std_test, format_reference_wrapper) {\n  int num = 35;\n  EXPECT_EQ(fmt::to_string(std::cref(num)), \"35\");\n  EXPECT_EQ(fmt::to_string(std::ref(num)), \"35\");\n  EXPECT_EQ(fmt::format(\"{}\", std::cref(num)), \"35\");\n  EXPECT_EQ(fmt::format(\"{}\", std::ref(num)), \"35\");\n}\n\n// Regression test for https://github.com/fmtlib/fmt/issues/4424.\nstruct type_with_format_as {};\nint format_as(type_with_format_as) { return 20; }\n\nTEST(std_test, format_reference_wrapper_with_format_as) {\n  type_with_format_as t;\n  EXPECT_EQ(fmt::to_string(std::cref(t)), \"20\");\n  EXPECT_EQ(fmt::to_string(std::ref(t)), \"20\");\n  EXPECT_EQ(fmt::format(\"{}\", std::cref(t)), \"20\");\n  EXPECT_EQ(fmt::format(\"{}\", std::ref(t)), \"20\");\n}\n\nstruct type_with_format_as_string {};\nstd::string format_as(type_with_format_as_string) { return \"foo\"; }\n\nTEST(std_test, format_reference_wrapper_with_format_as_string) {\n  type_with_format_as_string t;\n  EXPECT_EQ(fmt::to_string(std::cref(t)), \"foo\");\n  EXPECT_EQ(fmt::to_string(std::ref(t)), \"foo\");\n  EXPECT_EQ(fmt::format(\"{}\", std::cref(t)), \"foo\");\n  EXPECT_EQ(fmt::format(\"{}\", std::ref(t)), \"foo\");\n}\n"
  },
  {
    "path": "test/test-assert.h",
    "content": "// Formatting library for C++ - test version of FMT_ASSERT\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#ifndef FMT_TEST_ASSERT_H_\n#define FMT_TEST_ASSERT_H_\n\n#include <stdexcept>\n\nvoid throw_assertion_failure(const char* message);\n#define FMT_ASSERT(condition, message) \\\n  ((condition) ? (void)0 : throw_assertion_failure(message))\n\n#include \"gtest/gtest.h\"\n\nclass assertion_failure : public std::logic_error {\n public:\n  explicit assertion_failure(const char* message) : std::logic_error(message) {}\n\n private:\n  virtual void avoid_weak_vtable();\n};\n\nvoid assertion_failure::avoid_weak_vtable() {}\n\n// We use a separate function (rather than throw directly from FMT_ASSERT) to\n// avoid GCC's -Wterminate warning when FMT_ASSERT is used in a destructor.\ninline void throw_assertion_failure(const char* message) {\n  throw assertion_failure(message);\n}\n\n// Expects an assertion failure.\n#define EXPECT_ASSERT(stmt, message) \\\n  FMT_TEST_THROW_(stmt, assertion_failure, message, GTEST_NONFATAL_FAILURE_)\n\n#endif  // FMT_TEST_ASSERT_H_\n"
  },
  {
    "path": "test/test-main.cc",
    "content": "// Formatting library for C++ - test main function.\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <cstdlib>\n\n#include \"gtest/gtest.h\"\n\n#ifdef _WIN32\n#  include <windows.h>\n#endif\n\n#ifdef _MSC_VER\n#  include <crtdbg.h>\n#endif\n\nint main(int argc, char** argv) {\n#ifdef _WIN32\n  // Don't display any error dialogs. This also suppresses message boxes\n  // on assertion failures in MinGW where _set_error_mode/CrtSetReportMode\n  // doesn't help.\n  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |\n               SEM_NOOPENFILEERRORBOX);\n#endif\n#ifdef _MSC_VER\n  // Disable message boxes on assertion failures.\n  _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);\n  _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);\n  _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);\n  _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);\n#endif\n  try {\n    testing::InitGoogleTest(&argc, argv);\n    testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n    return RUN_ALL_TESTS();\n  } catch (...) {\n    // Catch all exceptions to make Coverity happy.\n  }\n  return EXIT_FAILURE;\n}\n"
  },
  {
    "path": "test/unicode-test.cc",
    "content": "// Formatting library for C++ - Unicode tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <iomanip>\n#include <locale>\n#include <vector>\n\n#include \"fmt/chrono.h\"\n#include \"gmock/gmock.h\"\n#include \"util.h\"  // get_locale\n\nusing testing::Contains;\n\nTEST(unicode_test, use_utf8) { EXPECT_TRUE(fmt::detail::use_utf8); }\n\nTEST(unicode_test, legacy_locale) {\n  auto loc = get_locale(\"be_BY.CP1251\", \"Belarusian_Belarus.1251\");\n  if (loc == std::locale::classic()) return;\n\n  auto s = std::string();\n  try {\n    s = fmt::format(loc, \"Дзень тыдня: {:L}\", fmt::weekday(1));\n  } catch (const fmt::format_error& e) {\n    // Formatting can fail due to an unsupported encoding.\n    fmt::print(\"Format error: {}\\n\", e.what());\n    return;\n  }\n\n#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 500\n  auto&& os = std::ostringstream();\n  os.imbue(loc);\n  auto tm = std::tm();\n  tm.tm_wday = 1;\n  os << std::put_time(&tm, \"%a\");\n  auto wd = os.str();\n  if (wd == \"??\") {\n    EXPECT_EQ(s, \"Дзень тыдня: ??\");\n    fmt::print(\"std::locale gives ?? as a weekday.\\n\");\n    return;\n  }\n#endif\n  EXPECT_THAT((std::vector<std::string>{\"Дзень тыдня: пн\", \"Дзень тыдня: Пан\"}),\n              Contains(s));\n}\n"
  },
  {
    "path": "test/util.cc",
    "content": "// Formatting library for C++ - test utilities\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"util.h\"\n\n#include <cstring>\n\nconst char* const file_content = \"Don't panic!\";\n\nfmt::buffered_file open_buffered_file(FILE** fp) {\n#if FMT_USE_FCNTL\n  auto pipe = fmt::pipe();\n  pipe.write_end.write(file_content, std::strlen(file_content));\n  pipe.write_end.close();\n  fmt::buffered_file f = pipe.read_end.fdopen(\"r\");\n  if (fp) *fp = f.get();\n#else\n  fmt::buffered_file f(\"test-file\", \"w\");\n  fputs(file_content, f.get());\n  if (fp) *fp = f.get();\n#endif\n  return f;\n}\n\nstd::locale do_get_locale(const char* name) {\n  try {\n    return std::locale(name);\n  } catch (const std::runtime_error&) {\n  }\n  return std::locale::classic();\n}\n\nstd::locale get_locale(const char* name, const char* alt_name) {\n  auto loc = do_get_locale(name);\n  if (loc == std::locale::classic() && alt_name) loc = do_get_locale(alt_name);\n#ifdef __OpenBSD__\n  // Locales are not working in OpenBSD:\n  // https://github.com/fmtlib/fmt/issues/3670.\n  loc = std::locale::classic();\n#endif\n  if (loc == std::locale::classic())\n    fmt::print(stderr, \"{} locale is missing.\\n\", name);\n  return loc;\n}\n"
  },
  {
    "path": "test/util.h",
    "content": "// Formatting library for C++ - test utilities\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include <cstdarg>\n#include <cstdio>\n#include <locale>\n#include <string>\n\n#include \"fmt/os.h\"\n\n#ifdef _MSC_VER\n#  define FMT_VSNPRINTF vsprintf_s\n#else\n#  define FMT_VSNPRINTF vsnprintf\n#endif\n\ntemplate <size_t SIZE>\nvoid safe_sprintf(char (&buffer)[SIZE], const char* format, ...) {\n  std::va_list args;\n  va_start(args, format);\n  FMT_VSNPRINTF(buffer, SIZE, format, args);\n  va_end(args);\n}\n\nextern const char* const file_content;\n\n// Opens a buffered file for reading.\nauto open_buffered_file(FILE** fp = nullptr) -> fmt::buffered_file;\n\ntemplate <typename Char> class basic_test_string {\n private:\n  std::basic_string<Char> value_;\n\n  static const Char empty[];\n\n public:\n  explicit basic_test_string(const Char* value = empty) : value_(value) {}\n\n  auto value() const -> const std::basic_string<Char>& { return value_; }\n};\n\ntemplate <typename Char> const Char basic_test_string<Char>::empty[] = {0};\n\nusing test_string = basic_test_string<char>;\nusing test_wstring = basic_test_string<wchar_t>;\n\ntemplate <typename Char>\nauto operator<<(std::basic_ostream<Char>& os, const basic_test_string<Char>& s)\n    -> std::basic_ostream<Char>& {\n  os << s.value();\n  return os;\n}\n\nclass date {\n  int year_, month_, day_;\n\n public:\n  date(int year, int month, int day) : year_(year), month_(month), day_(day) {}\n\n  auto year() const -> int { return year_; }\n  auto month() const -> int { return month_; }\n  auto day() const -> int { return day_; }\n};\n\n// Returns a locale with the given name if available or classic locale\n// otherwise.\nauto get_locale(const char* name, const char* alt_name = nullptr)\n    -> std::locale;\n"
  },
  {
    "path": "test/xchar-test.cc",
    "content": "// Formatting library for C++ - formatting library tests\n//\n// Copyright (c) 2012 - present, Victor Zverovich\n// All rights reserved.\n//\n// For the license information refer to format.h.\n\n#include \"fmt/xchar.h\"\n\n#include <algorithm>\n#include <complex>\n#include <cwchar>\n#include <vector>\n\n#include \"fmt/chrono.h\"\n#include \"fmt/color.h\"\n#include \"fmt/ostream.h\"\n#include \"fmt/ranges.h\"\n#include \"fmt/std.h\"\n#include \"gtest-extra.h\"  // Contains\n#include \"util.h\"         // get_locale\n\nusing fmt::detail::max_value;\nusing testing::Contains;\n\n#if defined(__MINGW32__) && !defined(_UCRT)\n// Only C89 conversion specifiers when using MSVCRT instead of UCRT\n#  define FMT_HAS_C99_STRFTIME 0\n#else\n#  define FMT_HAS_C99_STRFTIME 1\n#endif\n\nstruct non_string {};\n\ntemplate <typename T> class has_to_string_view_test : public testing::Test {};\n\nusing string_char_types = testing::Types<char, wchar_t, char16_t, char32_t>;\nTYPED_TEST_SUITE(has_to_string_view_test, string_char_types);\n\ntemplate <typename Char>\nstruct derived_from_string_view : fmt::basic_string_view<Char> {};\n\nTYPED_TEST(has_to_string_view_test, has_to_string_view) {\n  EXPECT_TRUE(fmt::detail::has_to_string_view<TypeParam*>::value);\n  EXPECT_TRUE(fmt::detail::has_to_string_view<const TypeParam*>::value);\n  EXPECT_TRUE(fmt::detail::has_to_string_view<TypeParam[2]>::value);\n  EXPECT_TRUE(fmt::detail::has_to_string_view<const TypeParam[2]>::value);\n  EXPECT_TRUE(\n      fmt::detail::has_to_string_view<std::basic_string<TypeParam>>::value);\n  EXPECT_TRUE(fmt::detail::has_to_string_view<\n              fmt::basic_string_view<TypeParam>>::value);\n  EXPECT_TRUE(fmt::detail::has_to_string_view<\n              derived_from_string_view<TypeParam>>::value);\n  using fmt_string_view = fmt::detail::std_string_view<TypeParam>;\n  EXPECT_TRUE(std::is_empty<fmt_string_view>::value !=\n              fmt::detail::has_to_string_view<fmt_string_view>::value);\n  EXPECT_FALSE(fmt::detail::has_to_string_view<non_string>::value);\n}\n\n// std::is_constructible is broken in MSVC until version 2015.\n#if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1900\nstruct explicitly_convertible_to_wstring_view {\n  explicit operator fmt::wstring_view() const { return L\"foo\"; }\n};\n\nTEST(xchar_test, format_explicitly_convertible_to_wstring_view) {\n  // Types explicitly convertible to wstring_view are not formattable by\n  // default because it may introduce ODR violations.\n  static_assert(\n      !fmt::is_formattable<explicitly_convertible_to_wstring_view>::value, \"\");\n}\n#endif\n\nTEST(xchar_test, format) {\n  EXPECT_EQ(fmt::format(L\"{}\", 42), L\"42\");\n  EXPECT_EQ(fmt::format(L\"{}\", 4.2), L\"4.2\");\n  EXPECT_EQ(fmt::format(L\"{}\", 1e100), L\"1e+100\");\n  EXPECT_EQ(fmt::format(L\"{}\", L\"abc\"), L\"abc\");\n  EXPECT_EQ(fmt::format(L\"{}\", L'z'), L\"z\");\n  EXPECT_THROW(fmt::format(fmt::runtime(L\"{:*\\x343E}\"), 42), fmt::format_error);\n  EXPECT_EQ(fmt::format(L\"{}\", true), L\"true\");\n  EXPECT_EQ(fmt::format(L\"{0}\", L'a'), L\"a\");\n  EXPECT_EQ(fmt::format(L\"Letter {}\", L'\\x40e'), L\"Letter \\x40e\");  // Ў\n  if (sizeof(wchar_t) == 4)\n    EXPECT_EQ(fmt::format(fmt::runtime(L\"{:𓀨>3}\"), 42), L\"𓀨42\");\n  EXPECT_EQ(fmt::format(L\"{}c{}\", L\"ab\", 1), L\"abc1\");\n}\n\nTEST(xchar_test, is_formattable) {\n  static_assert(!fmt::is_formattable<const wchar_t*>::value, \"\");\n}\n\nTEST(xchar_test, compile_time_string) {\n  EXPECT_EQ(fmt::format(fmt::wformat_string<int>(L\"{}\"), 42), L\"42\");\n#if defined(FMT_USE_STRING_VIEW) && FMT_CPLUSPLUS >= 201703L\n  EXPECT_EQ(fmt::format(FMT_STRING(std::wstring_view(L\"{}\")), 42), L\"42\");\n#endif\n}\n\nTEST(xchar_test, format_to) {\n  auto buf = std::vector<wchar_t>();\n  fmt::format_to(std::back_inserter(buf), L\"{}{}\", 42, L'\\0');\n  EXPECT_STREQ(buf.data(), L\"42\");\n}\n\nTEST(xchar_test, compile_time_string_format_to) {\n  std::wstring ws;\n  fmt::format_to(std::back_inserter(ws), FMT_STRING(L\"{}\"), 42);\n  EXPECT_EQ(L\"42\", ws);\n}\n\nTEST(xchar_test, vformat_to) {\n  int n = 42;\n  auto args = fmt::make_wformat_args(n);\n  auto w = std::wstring();\n  fmt::vformat_to(std::back_inserter(w), L\"{}\", args);\n  EXPECT_EQ(L\"42\", w);\n}\n\nnamespace test {\nstruct struct_as_wstring_view {};\nauto format_as(struct_as_wstring_view) -> fmt::wstring_view { return L\"foo\"; }\n}  // namespace test\n\nTEST(xchar_test, format_as) {\n  EXPECT_EQ(fmt::format(L\"{}\", test::struct_as_wstring_view()), L\"foo\");\n}\n\nTEST(format_test, wide_format_to_n) {\n  wchar_t buffer[4];\n  buffer[3] = L'x';\n  auto result = fmt::format_to_n(buffer, 3, L\"{}\", 12345);\n  EXPECT_EQ(5u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(L\"123x\", fmt::wstring_view(buffer, 4));\n  buffer[0] = L'x';\n  buffer[1] = L'x';\n  buffer[2] = L'x';\n  result = fmt::format_to_n(buffer, 3, L\"{}\", L'A');\n  EXPECT_EQ(1u, result.size);\n  EXPECT_EQ(buffer + 1, result.out);\n  EXPECT_EQ(L\"Axxx\", fmt::wstring_view(buffer, 4));\n  result = fmt::format_to_n(buffer, 3, L\"{}{} \", L'B', L'C');\n  EXPECT_EQ(3u, result.size);\n  EXPECT_EQ(buffer + 3, result.out);\n  EXPECT_EQ(L\"BC x\", fmt::wstring_view(buffer, 4));\n}\n\nTEST(xchar_test, named_arg_udl) {\n  using namespace fmt::literals;\n  auto udl_a =\n      fmt::format(L\"{first}{second}{first}{third}\", L\"first\"_a = L\"abra\",\n                  L\"second\"_a = L\"cad\", L\"third\"_a = 99);\n  EXPECT_EQ(\n      fmt::format(L\"{first}{second}{first}{third}\", fmt::arg(L\"first\", L\"abra\"),\n                  fmt::arg(L\"second\", L\"cad\"), fmt::arg(L\"third\", 99)),\n      udl_a);\n}\n\nTEST(xchar_test, print) {\n  // Check that the wide print overload compiles.\n  if (false) {\n    fmt::print(L\"test\");\n    fmt::println(L\"test\");\n  }\n}\n\nTEST(xchar_test, join) {\n  int v[3] = {1, 2, 3};\n  EXPECT_EQ(fmt::format(u\"({})\", fmt::join(v, v + 3, u\", \")), u\"(1, 2, 3)\");\n  EXPECT_EQ(fmt::format(U\"({})\", fmt::join(v, v + 3, U\", \")), U\"(1, 2, 3)\");\n  EXPECT_EQ(fmt::format(L\"({})\", fmt::join(v, v + 3, L\", \")), L\"(1, 2, 3)\");\n  auto vector = std::vector<int>{1, 2, 3};\n  EXPECT_EQ(fmt::format(u\"({})\", fmt::join(vector, u\", \")), u\"(1, 2, 3)\");\n  EXPECT_EQ(fmt::format(U\"({})\", fmt::join(vector, U\", \")), U\"(1, 2, 3)\");\n  EXPECT_EQ(fmt::format(L\"({})\", fmt::join(vector, L\", \")), L\"(1, 2, 3)\");\n  auto tuple_char16 = std::tuple<char16_t, int, float>(u'a', 1, 2.0f);\n  EXPECT_EQ(fmt::format(u\"({})\", fmt::join(tuple_char16, u\", \")), u\"(a, 1, 2)\");\n  auto tuple_char32 = std::tuple<char32_t, int, float>(U'a', 1, 2.0f);\n  EXPECT_EQ(fmt::format(U\"({})\", fmt::join(tuple_char32, U\", \")), U\"(a, 1, 2)\");\n  auto tuple_wchar = std::tuple<wchar_t, int, float>(L'a', 1, 2.0f);\n  EXPECT_EQ(fmt::format(L\"({})\", fmt::join(tuple_wchar, L\", \")), L\"(a, 1, 2)\");\n}\n\n#ifdef __cpp_lib_byte\nTEST(xchar_test, join_bytes) {\n  auto v = std::vector<std::byte>{std::byte(1), std::byte(2), std::byte(3)};\n  EXPECT_EQ(fmt::format(L\"{}\", fmt::join(v, L\", \")), L\"1, 2, 3\");\n}\n#endif\n\nenum streamable_enum {};\n\nstd::wostream& operator<<(std::wostream& os, streamable_enum) {\n  return os << L\"streamable_enum\";\n}\n\nnamespace fmt {\ntemplate <>\nstruct formatter<streamable_enum, wchar_t> : basic_ostream_formatter<wchar_t> {\n};\n}  // namespace fmt\n\nenum unstreamable_enum {};\nauto format_as(unstreamable_enum e) -> int { return e; }\n\nTEST(xchar_test, enum) {\n  EXPECT_EQ(L\"streamable_enum\", fmt::format(L\"{}\", streamable_enum()));\n  EXPECT_EQ(L\"0\", fmt::format(L\"{}\", unstreamable_enum()));\n}\n\nstruct streamable_and_unformattable {};\n\nauto operator<<(std::wostream& os, streamable_and_unformattable)\n    -> std::wostream& {\n  return os << L\"foo\";\n}\n\nTEST(xchar_test, streamed) {\n  EXPECT_FALSE(fmt::is_formattable<streamable_and_unformattable>());\n  EXPECT_EQ(fmt::format(L\"{}\", fmt::streamed(streamable_and_unformattable())),\n            L\"foo\");\n}\n\nTEST(xchar_test, sign_not_truncated) {\n  wchar_t format_str[] = {\n      L'{', L':',\n      '+' | static_cast<wchar_t>(1 << fmt::detail::num_bits<char>()), L'}', 0};\n  EXPECT_THROW(fmt::format(fmt::runtime(format_str), 42), fmt::format_error);\n}\n\nTEST(xchar_test, chrono) {\n  auto tm = std::tm();\n  tm.tm_year = 116;\n  tm.tm_mon = 3;\n  tm.tm_mday = 25;\n  tm.tm_hour = 11;\n  tm.tm_min = 22;\n  tm.tm_sec = 33;\n  EXPECT_EQ(fmt::format(\"The date is {:%Y-%m-%d %H:%M:%S}.\", tm),\n            \"The date is 2016-04-25 11:22:33.\");\n  EXPECT_EQ(L\"42s\", fmt::format(L\"{}\", std::chrono::seconds(42)));\n  EXPECT_EQ(fmt::format(L\"{:%F}\", tm), L\"2016-04-25\");\n  EXPECT_EQ(fmt::format(L\"{:%T}\", tm), L\"11:22:33\");\n\n  auto t = fmt::sys_time<std::chrono::seconds>(std::chrono::seconds(290088000));\n  EXPECT_EQ(fmt::format(\"{:%Y-%m-%d %H:%M:%S}\", t), \"1979-03-12 12:00:00\");\n}\n\nTEST(xchar_test, color) {\n  EXPECT_EQ(fmt::format(fg(fmt::rgb(255, 20, 30)), L\"rgb(255,20,30) wide\"),\n            L\"\\x1b[38;2;255;020;030mrgb(255,20,30) wide\\x1b[0m\");\n}\n\nTEST(xchar_test, ostream) {\n#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 409\n  {\n    std::wostringstream wos;\n    fmt::print(wos, L\"Don't {}!\", L\"panic\");\n    EXPECT_EQ(wos.str(), L\"Don't panic!\");\n  }\n\n  {\n    std::wostringstream wos;\n    fmt::println(wos, L\"Don't {}!\", L\"panic\");\n    EXPECT_EQ(wos.str(), L\"Don't panic!\\n\");\n  }\n#endif\n}\n\nTEST(xchar_test, format_map) {\n  auto m = std::map<std::wstring, int>{{L\"one\", 1}, {L\"t\\\"wo\", 2}};\n  EXPECT_EQ(fmt::format(L\"{}\", m), L\"{\\\"one\\\": 1, \\\"t\\\\\\\"wo\\\": 2}\");\n}\n\nTEST(xchar_test, escape_string) {\n  using vec = std::vector<std::wstring>;\n  EXPECT_EQ(fmt::format(L\"{}\", vec{L\"\\n\\r\\t\\\"\\\\\"}), L\"[\\\"\\\\n\\\\r\\\\t\\\\\\\"\\\\\\\\\\\"]\");\n  EXPECT_EQ(fmt::format(L\"{}\", vec{L\"понедельник\"}), L\"[\\\"понедельник\\\"]\");\n}\n\nTEST(xchar_test, to_wstring) { EXPECT_EQ(L\"42\", fmt::to_wstring(42)); }\n\n#ifndef FMT_STATIC_THOUSANDS_SEPARATOR\n\ntemplate <typename Char> struct numpunct : std::numpunct<Char> {\n protected:\n  Char do_decimal_point() const override { return '?'; }\n  std::string do_grouping() const override { return \"\\03\"; }\n  Char do_thousands_sep() const override { return '~'; }\n};\n\ntemplate <typename Char> struct no_grouping : std::numpunct<Char> {\n protected:\n  Char do_decimal_point() const override { return '.'; }\n  std::string do_grouping() const override { return \"\"; }\n  Char do_thousands_sep() const override { return ','; }\n};\n\ntemplate <typename Char> struct special_grouping : std::numpunct<Char> {\n protected:\n  Char do_decimal_point() const override { return '.'; }\n  std::string do_grouping() const override { return \"\\03\\02\"; }\n  Char do_thousands_sep() const override { return ','; }\n};\n\ntemplate <typename Char> struct small_grouping : std::numpunct<Char> {\n protected:\n  Char do_decimal_point() const override { return '.'; }\n  std::string do_grouping() const override { return \"\\01\"; }\n  Char do_thousands_sep() const override { return ','; }\n};\n\nTEST(locale_test, localized_double) {\n  auto loc = std::locale(std::locale(), new numpunct<char>());\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", 1.23), \"1?23\");\n  EXPECT_EQ(fmt::format(loc, \"{:Lf}\", 1.23), \"1?230000\");\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", 1234.5), \"1~234?5\");\n  EXPECT_EQ(fmt::format(loc, \"{:L}\", 12000.0), \"12~000\");\n  EXPECT_EQ(fmt::format(loc, \"{:8L}\", 1230.0), \"   1~230\");\n  EXPECT_EQ(fmt::format(loc, \"{:15.6Lf}\", 0.1), \"       0?100000\");\n  EXPECT_EQ(fmt::format(loc, \"{:15.6Lf}\", 1.0), \"       1?000000\");\n  EXPECT_EQ(fmt::format(loc, \"{:15.6Lf}\", 1e3), \"   1~000?000000\");\n}\n\nTEST(locale_test, format) {\n  auto loc = std::locale(std::locale(), new numpunct<char>());\n  EXPECT_EQ(\"1234567\", fmt::format(std::locale(), \"{:L}\", 1234567));\n  EXPECT_EQ(\"1~234~567\", fmt::format(loc, \"{:L}\", 1234567));\n  EXPECT_EQ(\"-1~234~567\", fmt::format(loc, \"{:L}\", -1234567));\n  EXPECT_EQ(\"-256\", fmt::format(loc, \"{:L}\", -256));\n  auto n = 1234567;\n  EXPECT_EQ(\"1~234~567\", fmt::vformat(loc, \"{:L}\", fmt::make_format_args(n)));\n  auto s = std::string();\n  fmt::format_to(std::back_inserter(s), loc, \"{:L}\", 1234567);\n  EXPECT_EQ(\"1~234~567\", s);\n\n  auto no_grouping_loc = std::locale(std::locale(), new no_grouping<char>());\n  EXPECT_EQ(\"1234567\", fmt::format(no_grouping_loc, \"{:L}\", 1234567));\n\n  auto special_grouping_loc =\n      std::locale(std::locale(), new special_grouping<char>());\n  EXPECT_EQ(\"1,23,45,678\", fmt::format(special_grouping_loc, \"{:L}\", 12345678));\n  EXPECT_EQ(\"12,345\", fmt::format(special_grouping_loc, \"{:L}\", 12345));\n\n  auto small_grouping_loc =\n      std::locale(std::locale(), new small_grouping<char>());\n  EXPECT_EQ(\"4,2,9,4,9,6,7,2,9,5\",\n            fmt::format(small_grouping_loc, \"{:L}\", max_value<uint32_t>()));\n}\n\nTEST(locale_test, format_default_align) {\n  auto loc = std::locale({}, new special_grouping<char>());\n  EXPECT_EQ(\"  12,345\", fmt::format(loc, \"{:8L}\", 12345));\n}\n\nTEST(locale_test, format_plus) {\n  auto loc = std::locale({}, new special_grouping<char>());\n  EXPECT_EQ(\"+100\", fmt::format(loc, \"{:+L}\", 100));\n}\n\nTEST(locale_test, wformat) {\n  auto loc = std::locale(std::locale(), new numpunct<wchar_t>());\n  EXPECT_EQ(L\"1234567\", fmt::format(std::locale(), L\"{:L}\", 1234567));\n  EXPECT_EQ(L\"1~234~567\", fmt::format(loc, L\"{:L}\", 1234567));\n  int n = 1234567;\n  EXPECT_EQ(L\"1~234~567\",\n            fmt::vformat(loc, L\"{:L}\", fmt::make_wformat_args(n)));\n  EXPECT_EQ(L\"1234567\", fmt::format(std::locale(\"C\"), L\"{:L}\", 1234567));\n\n  auto no_grouping_loc = std::locale(std::locale(), new no_grouping<wchar_t>());\n  EXPECT_EQ(L\"1234567\", fmt::format(no_grouping_loc, L\"{:L}\", 1234567));\n\n  auto special_grouping_loc =\n      std::locale(std::locale(), new special_grouping<wchar_t>());\n  EXPECT_EQ(L\"1,23,45,678\",\n            fmt::format(special_grouping_loc, L\"{:L}\", 12345678));\n\n  auto small_grouping_loc =\n      std::locale(std::locale(), new small_grouping<wchar_t>());\n  EXPECT_EQ(L\"4,2,9,4,9,6,7,2,9,5\",\n            fmt::format(small_grouping_loc, L\"{:L}\", max_value<uint32_t>()));\n}\n\nTEST(locale_test, int_formatter) {\n  auto loc = std::locale(std::locale(), new special_grouping<char>());\n  auto f = fmt::formatter<int>();\n  auto parse_ctx = fmt::format_parse_context(\"L\");\n  f.parse(parse_ctx);\n  auto buf = fmt::memory_buffer();\n  fmt::basic_format_context<fmt::appender, char> format_ctx(\n      fmt::appender(buf), {}, fmt::locale_ref(loc));\n  f.format(12345, format_ctx);\n  EXPECT_EQ(fmt::to_string(buf), \"12,345\");\n}\n\nTEST(locale_test, chrono_weekday) {\n  auto loc = get_locale(\"es_ES.UTF-8\", \"Spanish_Spain.1252\");\n  auto loc_old = std::locale::global(loc);\n  auto sat = fmt::weekday(6);\n  EXPECT_EQ(fmt::format(L\"{}\", sat), L\"Sat\");\n  if (loc != std::locale::classic()) {\n    // L'\\341' is 'á'.\n    auto saturdays =\n        std::vector<std::wstring>{L\"s\\341b\", L\"s\\341.\", L\"s\\341b.\"};\n    EXPECT_THAT(saturdays, Contains(fmt::format(loc, L\"{:L}\", sat)));\n  }\n  std::locale::global(loc_old);\n}\n\nTEST(locale_test, sign) {\n  EXPECT_EQ(fmt::format(std::locale(), L\"{:L}\", -50), L\"-50\");\n}\n\nTEST(std_test_xchar, format_bitset) {\n  auto bs = std::bitset<6>(42);\n  EXPECT_EQ(fmt::format(L\"{}\", bs), L\"101010\");\n  EXPECT_EQ(fmt::format(L\"{:0>8}\", bs), L\"00101010\");\n  EXPECT_EQ(fmt::format(L\"{:-^12}\", bs), L\"---101010---\");\n}\n\nTEST(std_test_xchar, complex) {\n  auto s = fmt::format(L\"{}\", std::complex<double>(1, 2));\n  EXPECT_EQ(s, L\"(1+2i)\");\n  EXPECT_EQ(fmt::format(L\"{:.2f}\", std::complex<double>(1, 2)),\n            L\"(1.00+2.00i)\");\n  EXPECT_EQ(fmt::format(L\"{:8}\", std::complex<double>(1, 2)), L\"(1+2i)  \");\n  EXPECT_EQ(fmt::format(L\"{:-<8}\", std::complex<double>(1, 2)), L\"(1+2i)--\");\n}\n\nTEST(std_test_xchar, optional) {\n#  ifdef __cpp_lib_optional\n  EXPECT_EQ(fmt::format(L\"{}\", std::optional{L'C'}), L\"optional(\\'C\\')\");\n  EXPECT_EQ(fmt::format(L\"{}\", std::optional{std::wstring{L\"wide string\"}}),\n            L\"optional(\\\"wide string\\\")\");\n#  endif\n}\n\n#endif  // FMT_STATIC_THOUSANDS_SEPARATOR\n"
  }
]