// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/types/to_address.h" #include <array> #include <memory> #include <type_traits> namespace base { namespace { // A constant whose definition will fail to compile if `to_address()` is not // SFINAE-compatible. kIsPtr; kIsPtr; struct FancyPointer { … }; struct NotPointer { … }; enum class EnumClass { … }; // Like `std::to_address()`, `to_address()` should correctly handle things // that can act like pointers: // * Raw pointers static_assert …; // * Iterators static_assert …; // * STL-provided smart pointers static_assert …; // * User-defined smart pointers, as long as they have `operator->()` static_assert …; // Unlike `std::to_address()`, `to_address()` is guaranteed to be // SFINAE-compatible with things that don't act like pointers: // * Basic types static_assert …; // * Enum classes static_assert …; // * Structs without an `operator->()` static_assert …; } // namespace } // namespace base