Convert base::size to std::size from C++17 (see issue #3362)
This commit is contained in:
parent
12fc72147c
commit
5ea0c141b5
|
@ -17,7 +17,6 @@
|
|||
'include/base/cef_callback_list.h',
|
||||
'include/base/cef_cancelable_callback.h',
|
||||
'include/base/cef_compiler_specific.h',
|
||||
'include/base/cef_cxx17_backports.h',
|
||||
'include/base/cef_lock.h',
|
||||
'include/base/cef_logging.h',
|
||||
'include/base/cef_macros.h',
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2021
|
||||
// Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_BASE_CEF_CXX17_BACKPORTS_H_
|
||||
#define CEF_INCLUDE_BASE_CEF_CXX17_BACKPORTS_H_
|
||||
#pragma once
|
||||
|
||||
#if defined(USING_CHROMIUM_INCLUDES)
|
||||
// When building CEF include the Chromium header directly.
|
||||
#include "base/cxx17_backports.h"
|
||||
#else // !USING_CHROMIUM_INCLUDES
|
||||
// The following was removed from Chromium in https://crrev.com/78734f77be.
|
||||
|
||||
namespace base {
|
||||
|
||||
// C++14 implementation of C++17's std::size():
|
||||
// http://en.cppreference.com/w/cpp/iterator/size
|
||||
template <typename Container>
|
||||
constexpr auto size(const Container& c) -> decltype(c.size()) {
|
||||
return c.size();
|
||||
}
|
||||
|
||||
template <typename T, size_t N>
|
||||
constexpr size_t size(const T (&array)[N]) noexcept {
|
||||
return N;
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
#endif // !USING_CHROMIUM_INCLUDES
|
||||
|
||||
#endif // CEF_INCLUDE_BASE_CEF_CXX17_BACKPORTS_H_
|
|
@ -15,7 +15,6 @@
|
|||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "include/base/cef_cxx17_backports.h"
|
||||
#include "include/internal/cef_string_types.h"
|
||||
|
||||
namespace cef {
|
||||
|
@ -210,7 +209,7 @@ std::string SystemErrorCodeToString(SystemErrorCode error_code) {
|
|||
char msgbuf[error_message_buffer_size];
|
||||
DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
|
||||
DWORD len = FormatMessageA(flags, NULL, error_code, 0, msgbuf,
|
||||
static_cast<DWORD>(base::size(msgbuf)), NULL);
|
||||
static_cast<DWORD>(std::size(msgbuf)), NULL);
|
||||
std::stringstream ss;
|
||||
if (len) {
|
||||
std::string s(msgbuf);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "include/base/cef_cxx17_backports.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
|
@ -791,7 +790,7 @@ KeyboardCode GdkEventToWindowsKeyCode(const GdkEventKey* event) {
|
|||
if (windows_key_code)
|
||||
return windows_key_code;
|
||||
|
||||
if (event->hardware_keycode < base::size(kHardwareCodeToGDKKeyval)) {
|
||||
if (event->hardware_keycode < std::size(kHardwareCodeToGDKKeyval)) {
|
||||
int keyval = kHardwareCodeToGDKKeyval[event->hardware_keycode];
|
||||
if (keyval)
|
||||
return KeyboardCodeFromXKeysym(keyval);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <string>
|
||||
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_cxx17_backports.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_command_ids.h"
|
||||
#include "include/cef_frame.h"
|
||||
|
@ -1469,7 +1468,7 @@ bool ClientHandler::IsAllowedCommandId(int command_id) {
|
|||
IDC_CONTENT_CONTEXT_UNDO,
|
||||
IDC_CONTENT_CONTEXT_REDO,
|
||||
};
|
||||
for (size_t i = 0; i < base::size(kAllowedCommandIds); ++i) {
|
||||
for (size_t i = 0; i < std::size(kAllowedCommandIds); ++i) {
|
||||
if (command_id == kAllowedCommandIds[i])
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_cxx17_backports.h"
|
||||
#include "include/cef_app.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
#include "tests/cefclient/browser/client_handler_std.h"
|
||||
|
@ -486,7 +485,7 @@ void RootWindowViews::InitOnUIThread(
|
|||
|
||||
// Populate the default image cache.
|
||||
ImageCache::ImageInfoSet image_set;
|
||||
for (size_t i = 0U; i < base::size(kDefaultImageCache); ++i)
|
||||
for (size_t i = 0U; i < std::size(kDefaultImageCache); ++i)
|
||||
image_set.push_back(ImageCache::ImageInfo::Create2x(kDefaultImageCache[i]));
|
||||
|
||||
image_cache_->LoadImages(
|
||||
|
@ -504,8 +503,8 @@ void RootWindowViews::CreateViewsWindow(
|
|||
|
||||
#ifndef NDEBUG
|
||||
// Make sure the default images loaded successfully.
|
||||
DCHECK_EQ(images.size(), base::size(kDefaultImageCache));
|
||||
for (size_t i = 0U; i < base::size(kDefaultImageCache); ++i) {
|
||||
DCHECK_EQ(images.size(), std::size(kDefaultImageCache));
|
||||
for (size_t i = 0U; i < std::size(kDefaultImageCache); ++i) {
|
||||
DCHECK(images[i]) << "Default image " << i << " failed to load";
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include "include/base/cef_cxx17_backports.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_task.h"
|
||||
#include "include/cef_waitable_event.h"
|
||||
|
@ -193,7 +192,7 @@ void RunHelperMultiple(bool https_server) {
|
|||
|
||||
TestState states[3];
|
||||
size_t count = 0;
|
||||
const size_t size = base::size(states);
|
||||
const size_t size = std::size(states);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
std::stringstream ss;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <memory>
|
||||
|
||||
#include "include/base/cef_callback.h"
|
||||
#include "include/base/cef_cxx17_backports.h"
|
||||
#include "include/cef_parser.h"
|
||||
#include "include/cef_path_util.h"
|
||||
#include "include/wrapper/cef_closure_task.h"
|
||||
|
@ -124,7 +123,7 @@ bool IsInternalExtension(const std::string& extension_path) {
|
|||
static const char* extensions[] = {"set_page_color"};
|
||||
|
||||
const std::string& internal_path = GetInternalPath(extension_path);
|
||||
for (size_t i = 0; i < base::size(extensions); ++i) {
|
||||
for (size_t i = 0; i < std::size(extensions); ++i) {
|
||||
// Exact match or first directory component.
|
||||
const std::string& extension = extensions[i];
|
||||
if (internal_path == extension ||
|
||||
|
|
Loading…
Reference in New Issue