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
26 {
27 return TMapIterator::operator*().first;
28 }
29 };
30
31 template <typename TMapIterator>
32 class ValueIterator : public TMapIterator
33 {
34 public:
35 ValueIterator() : TMapIterator() {}
36 ValueIterator(TMapIterator it) : TMapIterator(it) {}
37
38 using Value =
39 typename std::iterator_traits<TMapIterator>::value_type::second_type;
41
43 {
44 return TMapIterator::operator->()->second;
45 }
46
48 {
49 return TMapIterator::operator*().second;
50 }
51 };
52}
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:25
Key * operator->()
Definition nonstd.h:20
Definition nonstd.h:33
Value * operator->()
Definition nonstd.h:42
Value value_type
Definition nonstd.h:40
typename std::iterator_traits< TMapIterator >::value_type::second_type Value
Definition nonstd.h:39
ValueIterator()
Definition nonstd.h:35
Value operator*()
Definition nonstd.h:47
ValueIterator(TMapIterator it)
Definition nonstd.h:36
Definition nonstd.h:24