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