54a7fce3e0
GSL 3, the next major version of GSL after the one we're using, replaced their local implementation of `span` with one that more closely mimics C++20's span. Unfortunately, that is a breaking change for all of GSL's consumers. This commit updates our use of span to comply with the new changes in GSL 3. Chief among those breaking changes is: * `span::at` no longer exists; I replaced many instances of `span::at` with `gsl::at(x)` * `span::size_type` has finally given up on `ptrdiff_t` and become `size_t` like all other containers While I was here, I also made the following mechanical replacements: * In some of our "early standardized" code, we used std::optional's `has_value` and `value` back-to-back. Each `value` incurs an additional presence test. * Change: `x.value().member` -> `x->member` (`optional::operator->` skips the presence test) * Change: `x.value()` -> `*x` (as above) * GSL 3 uses `size_t` for `size_type`. * Change: `gsl::narrow<size_t>(x.size())` -> `x.size()` * Change: `gsl::narrow<ptrdiff_t>(nonSpan.size())` -> `nonSpan.size()` during span construction I also replaced two instances of `x[x.size() - 1]` with `x.back()` and one instance of a manual array walk (for comparison) with a direct comparison. NOTE: Span comparison and `make_span` are not part of the C++20 span library. Fixes #6251
116 lines
2.5 KiB
C++
116 lines
2.5 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
// clang-format off
|
|
|
|
#pragma once
|
|
|
|
|
|
#pragma warning(push)
|
|
|
|
// C
|
|
#include <climits>
|
|
#include <cwchar>
|
|
#include <cwctype>
|
|
|
|
// STL
|
|
|
|
// Block minwindef.h min/max macros to prevent <algorithm> conflict
|
|
#define NOMINMAX
|
|
|
|
#include <algorithm>
|
|
#include <atomic>
|
|
#include <deque>
|
|
#include <list>
|
|
#include <memory>
|
|
#include <map>
|
|
#include <mutex>
|
|
#include <shared_mutex>
|
|
#include <new>
|
|
#include <optional>
|
|
#include <queue>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <thread>
|
|
#include <tuple>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <iterator>
|
|
#include <cmath>
|
|
#include <sstream>
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <filesystem>
|
|
#include <functional>
|
|
#include <set>
|
|
#include <unordered_set>
|
|
#include <regex>
|
|
|
|
// WIL
|
|
#include <wil/Common.h>
|
|
#include <wil/Result.h>
|
|
#include <wil/resource.h>
|
|
#include <wil/wistd_memory.h>
|
|
#include <wil/stl.h>
|
|
#include <wil/com.h>
|
|
#include <wil/filesystem.h>
|
|
#include <wil/win32_helpers.h>
|
|
|
|
// GSL
|
|
// Block GSL Multi Span include because it both has C++17 deprecated iterators
|
|
// and uses the C-namespaced "max" which conflicts with Windows definitions.
|
|
#ifndef BLOCK_GSL
|
|
#define GSL_MULTI_SPAN_H
|
|
#include <gsl/gsl>
|
|
#include <gsl/span_ext>
|
|
#endif
|
|
|
|
// CppCoreCheck
|
|
#include <CppCoreCheck/Warnings.h>
|
|
|
|
// Chromium Numerics (safe math)
|
|
#pragma warning(push)
|
|
#pragma warning(disable:4100) // unreferenced parameter
|
|
#include <base/numerics/safe_math.h>
|
|
#pragma warning(pop)
|
|
|
|
// IntSafe
|
|
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
|
|
#include <intsafe.h>
|
|
|
|
// LibPopCnt - Fast C/C++ bit population count library (on bits in an array)
|
|
#include <libpopcnt.h>
|
|
|
|
// Dynamic Bitset (optional dependency on LibPopCnt for perf at bit counting)
|
|
// Variable-size compressed-storage header-only bit flag storage library.
|
|
#pragma warning(push)
|
|
#pragma warning(disable:4702) // unreachable code
|
|
#include <dynamic_bitset.hpp>
|
|
#pragma warning(pop)
|
|
|
|
// {fmt}, a C++20-compatible formatting library
|
|
#include <fmt/format.h>
|
|
|
|
// SAL
|
|
#include <sal.h>
|
|
|
|
// WRL
|
|
#include <wrl.h>
|
|
|
|
// WEX/TAEF testing
|
|
// Include before TIL if we're unit testing so it can light up WEX/TAEF template extensions
|
|
#ifdef UNIT_TESTING
|
|
#include <WexTestClass.h>
|
|
#endif
|
|
|
|
// TIL - Terminal Implementation Library
|
|
#ifndef BLOCK_TIL // Certain projects may want to include TIL manually to gain superpowers
|
|
#include "til.h"
|
|
#endif
|
|
|
|
#pragma warning(pop)
|
|
|
|
// clang-format on
|