CCF
Loading...
Searching...
No Matches
nonstd.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4#include <string>
5
6namespace ccf::nonstd
7{
8 // Iterators for map-keys and map-values
9 template <typename TMapIterator>
10 class KeyIterator : public TMapIterator
11 {
12 public:
13 KeyIterator() : TMapIterator() {}
14 KeyIterator(TMapIterator it) : TMapIterator(it) {}
15
16 using Key =
17 typename std::iterator_traits<TMapIterator>::value_type::first_type;
18 using value_type = Key;
19
21 {
22 return TMapIterator::operator->()->first;
23 }
24
25 // NOLINTNEXTLINE(readability-const-return-type)
27 {
28 return TMapIterator::operator*().first;
29 }
30 };
31
32 template <typename TMapIterator>
33 class ValueIterator : public TMapIterator
34 {
35 public:
36 ValueIterator() : TMapIterator() {}
37 ValueIterator(TMapIterator it) : TMapIterator(it) {}
38
39 using Value =
40 typename std::iterator_traits<TMapIterator>::value_type::second_type;
42
44 {
45 return TMapIterator::operator->()->second;
46 }
47
49 {
50 return TMapIterator::operator*().second;
51 }
52 };
53}
Definition nonstd.h:11
KeyIterator(TMapIterator it)
Definition nonstd.h:14
typename std::iterator_traits< TMapIterator >::value_type::first_type Key
Definition nonstd.h:17
Key value_type
Definition nonstd.h:18
KeyIterator()
Definition nonstd.h:13
Key operator*()
Definition nonstd.h:26
Key * operator->()
Definition nonstd.h:20
Definition nonstd.h:34
Value * operator->()
Definition nonstd.h:43
Value value_type
Definition nonstd.h:41
typename std::iterator_traits< TMapIterator >::value_type::second_type Value
Definition nonstd.h:40
ValueIterator()
Definition nonstd.h:36
Value operator*()
Definition nonstd.h:48
ValueIterator(TMapIterator it)
Definition nonstd.h:37
Definition nonstd.h:24