1 // Copyright 2020 The Pigweed Authors
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
18 #include "pw_polyfill/standard_library/namespace.h"
20 _PW_POLYFILL_BEGIN_NAMESPACE_STD
22 #define __cpp_lib_nonmember_container_access 201411L
25 auto begin(C& container) -> decltype(container.begin()) {
26 return container.begin();
30 auto begin(const C& container) -> decltype(container.begin()) {
31 return container.begin();
35 constexpr auto data(C& container) -> decltype(container.data()) {
36 return container.data();
40 constexpr auto data(const C& container) -> decltype(container.data()) {
41 return container.data();
44 template <typename T, decltype(sizeof(int)) kSize>
45 constexpr T* data(T (&array)[kSize]) noexcept {
50 auto end(C& container) -> decltype(container.end()) {
51 return container.end();
55 auto end(const C& container) -> decltype(container.end()) {
56 return container.end();
60 constexpr auto size(const C& container) -> decltype(container.size()) {
61 return container.size();
64 template <typename T, decltype(sizeof(int)) kSize>
65 constexpr decltype(sizeof(int)) size(const T (&)[kSize]) noexcept {
69 // NOT IMPLEMENTED: iterator_traits does not work
71 struct iterator_traits {};
73 // NOT IMPLEMENTED: Reverse iterators are not implemented.
75 struct reverse_iterator;
77 _PW_POLYFILL_END_NAMESPACE_STD