Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_string.hpp
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_STRING_HPP
11#define TEUCHOS_STRING_HPP
12
13#include <string>
14#include <Teuchos_Assert.hpp>
15
16namespace Teuchos {
17
18/* some wrappers over std::string to let us
19 do all indexing with int */
20
21inline int size(std::string const& s) {
22 return int(s.size());
23}
24
25inline std::string::reference at(std::string& s, int i) {
26 TEUCHOS_DEBUG_ASSERT(0 <= i);
27 TEUCHOS_DEBUG_ASSERT(i < int(s.size()));
28 return s[std::size_t(i)];
29}
30
31inline std::string::const_reference at(std::string const& s, int i) {
32 TEUCHOS_DEBUG_ASSERT(0 <= i);
33 TEUCHOS_DEBUG_ASSERT(i < int(s.size()));
34 return s[std::size_t(i)];
35}
36
37inline void resize(std::string& s, int n) {
38 TEUCHOS_DEBUG_ASSERT(0 <= n);
39 s.resize(std::size_t(n));
40}
41
42}
43
44#endif
45
46
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...