| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
| 7 | 7 |
| 8 #include <type_traits> | 8 #include <type_traits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 MaybeConstUserType& input_; | 39 MaybeConstUserType& input_; |
| 40 MaybeConstIterator iter_; | 40 MaybeConstIterator iter_; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Used as the UserTypeReader template parameter of ArraySerializer. | 43 // Used as the UserTypeReader template parameter of ArraySerializer. |
| 44 template <typename MaybeConstUserType> | 44 template <typename MaybeConstUserType> |
| 45 class MapKeyReader : public MapReaderBase<MaybeConstUserType> { | 45 class MapKeyReader : public MapReaderBase<MaybeConstUserType> { |
| 46 public: | 46 public: |
| 47 using Base = MapReaderBase<MaybeConstUserType>; | 47 using Base = MapReaderBase<MaybeConstUserType>; |
| 48 using Traits = typename Base::Traits; | 48 using Traits = typename Base::Traits; |
| 49 using MaybeConstIterator = typename Base::MaybeConstIterator; |
| 49 | 50 |
| 50 explicit MapKeyReader(MaybeConstUserType& input) : Base(input) {} | 51 explicit MapKeyReader(MaybeConstUserType& input) : Base(input) {} |
| 51 ~MapKeyReader() {} | 52 ~MapKeyReader() {} |
| 52 | 53 |
| 53 const typename Traits::Key& GetNext() { | 54 using GetNextResult = |
| 54 const typename Traits::Key& key = Traits::GetKey(this->iter_); | 55 decltype(Traits::GetKey(std::declval<MaybeConstIterator&>())); |
| 56 GetNextResult GetNext() { |
| 57 GetNextResult key = Traits::GetKey(this->iter_); |
| 55 Traits::AdvanceIterator(this->iter_); | 58 Traits::AdvanceIterator(this->iter_); |
| 56 return key; | 59 return key; |
| 57 } | 60 } |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 // Used as the UserTypeReader template parameter of ArraySerializer. | 63 // Used as the UserTypeReader template parameter of ArraySerializer. |
| 61 template <typename MaybeConstUserType> | 64 template <typename MaybeConstUserType> |
| 62 class MapValueReader : public MapReaderBase<MaybeConstUserType> { | 65 class MapValueReader : public MapReaderBase<MaybeConstUserType> { |
| 63 public: | 66 public: |
| 64 using Base = MapReaderBase<MaybeConstUserType>; | 67 using Base = MapReaderBase<MaybeConstUserType>; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 return false; | 173 return false; |
| 171 } | 174 } |
| 172 return true; | 175 return true; |
| 173 } | 176 } |
| 174 }; | 177 }; |
| 175 | 178 |
| 176 } // namespace internal | 179 } // namespace internal |
| 177 } // namespace mojo | 180 } // namespace mojo |
| 178 | 181 |
| 179 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ | 182 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MAP_SERIALIZATION_H_ |
| OLD | NEW |