Logo ROOT   6.16/01
Reference Guide
RStringView.hxx
Go to the documentation of this file.
1// -*- C++ -*-
2// Author: Philippe Canal, March 2015
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef RStringView_H
13#define RStringView_H
14
15#include "RConfigure.h"
16
17#ifdef R__HAS_STD_STRING_VIEW
18
19#include <string_view>
20
21#else
22
23# if defined(R__HAS_STD_EXPERIMENTAL_STRING_VIEW)
24# include <experimental/string_view>
25# else
27# endif
28
29namespace std {
30
31 template<class _CharT, class _Traits = std::char_traits<_CharT> >
32 using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
33
34 // basic_string_view typedef names
35 typedef basic_string_view<char> string_view;
36 typedef basic_string_view<char16_t> u16string_view;
37 typedef basic_string_view<char32_t> u32string_view;
38 typedef basic_string_view<wchar_t> wstring_view;
39
40// template<class _CharT, class _Traits = std::char_traits<_CharT> >
41// basic_string_view<_CharT,_Traits>
42// &operator=(basic_string_view<_CharT,_Traits> &lhs, const TString &rsh) {
43// *lhs = basic_string_view<_CharT,_Traits>(rsh);
44// return *lhs;
45// }
46
47#ifndef R__HAS_STOD_STRING_VIEW
48 inline double stod(std::string_view str, size_t *pos)
49 {
50 return std::stod(std::string(str.data(), str.size()),pos);
51 }
52#endif
53
54}
55
56#endif // ifdef else R__HAS_STD_STRING_VIEW
57
58namespace ROOT {
59namespace Internal {
61 const char *fData{nullptr};
62 size_t fLength{0};
63
64 public:
65 explicit TStringView(const char *cstr, size_t len) : fData(cstr), fLength(len) {}
66
67 operator std::string_view() const { return std::string_view(fData,fLength); }
68 };
69} // namespace Internal
70} // namespace ROOT
71#endif // RStringView_H
TStringView(const char *cstr, size_t len)
Definition: RStringView.hxx:65
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
STL namespace.
basic_string_view< wchar_t > wstring_view
Definition: RStringView.hxx:38
::std::experimental::basic_string_view< _CharT, _Traits > basic_string_view
Definition: RStringView.hxx:32
basic_string_view< char16_t > u16string_view
Definition: RStringView.hxx:36
double stod(std::string_view str, size_t *pos)
Definition: RStringView.hxx:48
basic_string_view< char > string_view
Definition: RStringView.hxx:35
basic_string_view< char32_t > u32string_view
Definition: RStringView.hxx:37