MySQL 9.6.0
Source Code Documentation
empty_sequence_iterator.h
Go to the documentation of this file.
1// Copyright (c) 2025, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24#ifndef MYSQL_ITERATORS_EMPTY_SEQUENCE_ITERATOR_H
25#define MYSQL_ITERATORS_EMPTY_SEQUENCE_ITERATOR_H
26
27/// @file
28/// Experimental API header
29
30#include <cassert> // assert
31#include <iterator> // random_access_iterator_tag
32#include "mysql/iterators/iterator_interface.h" // Iterator_interface
33
34/// @addtogroup GroupLibsMysqlIterators
35/// @{
36
38
39/// Iterator over an empty sequence.
40///
41/// @tparam Value_tp Type of values returned from the iterator. Although no
42/// values are returned, this is required in order to define the return type for
43/// the dereference iterator.
44template <class Value_tp>
46 : public Iterator_interface<Empty_sequence_iterator<Value_tp>> {
47 public:
48 using Value_t = Value_tp;
49
50 [[nodiscard]] constexpr Value_t get() const {
51 Value_t *tmp{}; // default-constructed = null
52 assert(false);
53 return *tmp;
54 }
55
56 constexpr void advance(std::ptrdiff_t) {}
57
58 [[nodiscard]] constexpr std::ptrdiff_t distance_from(
59 const Empty_sequence_iterator &) const {
60 return 0;
61 }
62
63 [[nodiscard]] constexpr std::ptrdiff_t distance_from_sentinel() const {
64 return 0;
65 }
66};
67
68} // namespace mysql::iterators
69
70// addtogroup GroupLibsMysqlIterators
71/// @}
72
73#endif // ifndef MYSQL_ITERATORS_EMPTY_SEQUENCE_ITERATOR_H
Iterator over an empty sequence.
Definition: empty_sequence_iterator.h:46
constexpr std::ptrdiff_t distance_from_sentinel() const
Definition: empty_sequence_iterator.h:63
constexpr Value_t get() const
Definition: empty_sequence_iterator.h:50
constexpr std::ptrdiff_t distance_from(const Empty_sequence_iterator &) const
Definition: empty_sequence_iterator.h:58
constexpr void advance(std::ptrdiff_t)
Definition: empty_sequence_iterator.h:56
Value_tp Value_t
Definition: empty_sequence_iterator.h:48
CRTP base class (mixin) that makes your class a standard-compliant iterator, given only a minimal set...
Definition: iterator_interface.h:370
Experimental API header.
Definition: empty_sequence_iterator.h:37