Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 9fa5ca8

Browse files
committed
[string_view] add description for methods in string_view
Added missing description for methods and comment fix.
1 parent 14677b5 commit 9fa5ca8

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

include/libpmemobj++/string_view.hpp

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2020, Intel Corporation */
2+
/* Copyright 2020-2021, Intel Corporation */
33

44
/**
55
* @file
@@ -67,8 +67,18 @@ class basic_string_view {
6767
constexpr basic_string_view(const std::basic_string<CharT, Traits> &s);
6868
constexpr basic_string_view(const CharT *data);
6969

70+
/** Constructor initialized with the basic_string_view *rhs*.
71+
*
72+
* @param[in] rhs basic_string_view to initialize with
73+
*/
7074
constexpr basic_string_view(const basic_string_view &rhs) noexcept =
7175
default;
76+
77+
/**
78+
* Replaces the view with that of *rhs*.
79+
*
80+
* @param[in] rhs basic_string_view to replace with
81+
*/
7282
basic_string_view &
7383
operator=(const basic_string_view &rhs) noexcept = default;
7484

@@ -165,7 +175,7 @@ constexpr inline basic_string_view<CharT, Traits>::basic_string_view() noexcept
165175
}
166176

167177
/**
168-
* Constructor initialized by *data* and its *size*.
178+
* Constructor initialized with *data* and its *size*.
169179
*
170180
* @param[in] data pointer to the C-like string to initialize with,
171181
* it can contain null characters.
@@ -256,27 +266,59 @@ basic_string_view<CharT, Traits>::cend() const noexcept
256266
return data_ + size_;
257267
}
258268

269+
/**
270+
* Returns a reverse_iterator to the character following the last character of
271+
* the view (reverse beginning). Reverse iterators iterate backwards: increasing
272+
* them moves them towards the beginning of the string.
273+
*
274+
* @return const_reverse_iterator to the character following the last character.
275+
*/
259276
template <typename CharT, typename Traits>
260277
constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
261278
basic_string_view<CharT, Traits>::rbegin() const noexcept
262279
{
263280
return reverse_iterator(cend());
264281
}
265282

283+
/**
284+
* Returns a reverse_iterator to the character following the last character of
285+
* the view (reverse beginning). Reverse iterators iterate backwards: increasing
286+
* them moves them towards the beginning of the string.
287+
*
288+
* @return const_reverse_iterator to the character following the last character.
289+
*/
266290
template <typename CharT, typename Traits>
267291
constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
268292
basic_string_view<CharT, Traits>::crbegin() const noexcept
269293
{
270294
return reverse_iterator(cend());
271295
}
272296

297+
/**
298+
* Returns an iterator to the first character of the view.
299+
* Reverse iterators iterate backwards: increasing
300+
* them moves them towards the beginning of the string.
301+
* This character acts as a placeholder, attempting to access it results
302+
* in undefined behavior.
303+
*
304+
* @return const_reverse_iterator to the first character
305+
*/
273306
template <typename CharT, typename Traits>
274307
constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
275308
basic_string_view<CharT, Traits>::rend() const noexcept
276309
{
277310
return reverse_iterator(cbegin());
278311
}
279312

313+
/**
314+
* Returns an iterator to the first character of the view.
315+
* Reverse iterators iterate backwards: increasing
316+
* them moves them towards the beginning of the string.
317+
* This character acts as a placeholder, attempting to access it results
318+
* in undefined behavior.
319+
*
320+
* @return const_reverse_iterator to the first character
321+
*/
280322
template <typename CharT, typename Traits>
281323
constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
282324
basic_string_view<CharT, Traits>::crend() const noexcept
@@ -444,7 +486,7 @@ basic_string_view<CharT, Traits>::swap(
444486
std::swap(size_, v.size_);
445487
}
446488

447-
/*
489+
/**
448490
* Finds the first substring equal to str.
449491
*
450492
* @param[in] str string to search for

0 commit comments

Comments
 (0)