-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- pw::span is identical to Pigweed's polyfilled std::span, but in a different namespace. Implicit converions between std::span and pw::span are supported inherently. pw::span and std::span are maintained as separate classes, with shared code in a .inc file. This is done instead of aliasing since C++17 does not support class template argument decuction with aliases. Also, it is simpler to have separate implementations to avoid circular dependencies while migrating code to pw::span. - Add DEFINES to the pw_add_test() CMake function to support defining preprocessor macros for the pw_span test. - Move '.inc' and '.inl' extensions from CPP_HEADER_EXTS to CPP_SOURCE_EXTS, since these should be treated like sources not headers (no include guards). Bug: b/235237667 Change-Id: I4d76fb373cdaa4d3a5d72a0537bea492b5c06814 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/98160 Commit-Queue: Wyatt Hepler <[email protected]> Pigweed-Auto-Submit: Wyatt Hepler <[email protected]> Reviewed-by: Ted Pudlik <[email protected]>
- Loading branch information
Showing
11 changed files
with
259 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2020 The Pigweed Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
// use this file except in compliance with the License. You may obtain a copy of | ||
// the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations under | ||
// the License. | ||
|
||
// std::span is a stand-in for C++20's std::span. Do NOT include this header | ||
// directly; instead, include it as <span>. | ||
// | ||
// A span is a non-owning array view class. It refers to an external array by | ||
// storing a pointer and length. Unlike std::array, the size does not have to be | ||
// a template parameter, so this class can be used to without stating its size. | ||
// | ||
// This file a modified version of base::span from Chromium: | ||
// https://chromium.googlesource.com/chromium/src/+/d93ae920e4309682deb9352a4637cfc2941c1d1f/base/containers/span.h | ||
// | ||
// In order to minimize changes from the original, this file does NOT fully | ||
// adhere to Pigweed's style guide. | ||
// | ||
// A few changes were made to the Chromium version of span. These include: | ||
// - Use std::data and std::size instead of base::* versions. | ||
// - Rename base namespace to std. | ||
// - Rename internal namespace to pw_span_internal. | ||
// - Remove uses of checked_iterators.h and CHECK. | ||
// - Replace make_span functions with C++17 class template deduction guides. | ||
// - Use std::byte instead of uint8_t for compatibility with std::span. | ||
// | ||
#pragma once | ||
|
||
#include "pw_polyfill/standard_library/namespace.h" | ||
|
||
#ifndef __cpp_lib_span | ||
#define __cpp_lib_span 202002L | ||
|
||
#define _PW_SPAN_COMMON_NAMEPACE_BEGIN _PW_POLYFILL_BEGIN_NAMESPACE_STD | ||
#define _PW_SPAN_COMMON_NAMEPACE_END _PW_POLYFILL_END_NAMESPACE_STD | ||
|
||
#include "pw_span/internal/span_common.inc" | ||
|
||
#undef _PW_SPAN_COMMON_NAMEPACE_BEGIN | ||
#undef _PW_SPAN_COMMON_NAMEPACE_END | ||
|
||
#endif // __cpp_lib_span |
Oops, something went wrong.