Coverage Report

Created: 2025-12-12 07:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hermes/include/hermes/ADT/HalfPairIterator.h
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#ifndef HERMES_ADT_HALFPAIRITERATOR_H
9
#define HERMES_ADT_HALFPAIRITERATOR_H
10
11
#include <iterator>
12
13
namespace hermes {
14
15
/// Declare iterators over a single field in a tuple.
16
#define HERMES_DECLARE_PARTIAL_ITERATOR(Field, FIELD)                          \
17
  template <class IT>                                                          \
18
  class Pair##Field##Iterator {                                                \
19
    IT it_;                                                                    \
20
                                                                               \
21
   public:                                                                     \
22
    using iterator_category = std::input_iterator_tag;                         \
23
    using value_type = decltype(std::iterator_traits<IT>::value_type::FIELD);  \
24
    using difference_type = std::ptrdiff_t;                                    \
25
    using pointer = value_type *;                                              \
26
    using reference = value_type &;                                            \
27
                                                                               \
28
0
    Pair##Field##Iterator(const IT &it) : it_(it) {}                           \
Unexecuted instantiation: hermes::PairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::PairFirstIterator(std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>* const&)
Unexecuted instantiation: hermes::PairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::PairSecondIterator(std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>* const&)
29
    Pair##Field##Iterator(const Pair##Field##Iterator &) = default;            \
30
    Pair##Field##Iterator &operator=(const Pair##Field##Iterator &) = default; \
31
                                                                               \
32
0
    Pair##Field##Iterator &operator++() {                                      \
33
0
      ++it_;                                                                   \
34
0
      return *this;                                                            \
35
0
    }                                                                          \
Unexecuted instantiation: hermes::PairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::operator++()
Unexecuted instantiation: hermes::PairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::operator++()
36
    bool operator==(const Pair##Field##Iterator &a) const {                    \
37
      return it_ == a.it_;                                                     \
38
    }                                                                          \
39
0
    bool operator!=(const Pair##Field##Iterator &a) const {                    \
40
0
      return it_ != a.it_;                                                     \
41
0
    }                                                                          \
Unexecuted instantiation: hermes::PairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::operator!=(hermes::PairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*> const&) const
Unexecuted instantiation: hermes::PairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::operator!=(hermes::PairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*> const&) const
42
                                                                               \
43
0
    decltype((*it_).FIELD) operator*() {                                       \
44
0
      return (*it_).FIELD;                                                     \
45
0
    }                                                                          \
Unexecuted instantiation: hermes::PairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::operator*()
Unexecuted instantiation: hermes::PairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>::operator*()
46
                                                                               \
47
    ptrdiff_t operator-(const Pair##Field##Iterator &it) const {               \
48
      return std::distance(it_, it.it_);                                       \
49
    }                                                                          \
50
  };                                                                           \
51
  template <class IT>                                                          \
52
0
  Pair##Field##Iterator<IT> makePair##Field##Iterator(const IT &it) {          \
53
0
    return Pair##Field##Iterator<IT>(it);                                      \
54
0
  }
Unexecuted instantiation: hermes::PairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*> hermes::makePairFirstIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>(std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>* const&)
Unexecuted instantiation: hermes::PairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*> hermes::makePairSecondIterator<std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>*>(std::__1::pair<hermes::parser::JSONString*, hermes::parser::JSONValue*>* const&)
55
56
/// PairFirstIterator: iterate over pair::first.
57
HERMES_DECLARE_PARTIAL_ITERATOR(First, first);
58
/// PairSecondIterator: iterate over pair::second.
59
HERMES_DECLARE_PARTIAL_ITERATOR(Second, second);
60
61
} // namespace hermes
62
63
#endif // HERMES_ADT_HALFPAIRITERATOR_H