Logo ROOT  
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#if defined(_MSVC_LANG)
18# define R__MSVC_LANG _MSVC_LANG
19#else
20# define R__MSVC_LANG 0
21#endif
22
23#if defined(R__HAS_STD_STRING_VIEW) || R__MSVC_LANG >= 201703L || __cplusplus >= 201703L
24
25#include <string_view>
26
27#else
28
29# if defined(R__HAS_STD_EXPERIMENTAL_STRING_VIEW)
30# include <experimental/string_view>
31# else
33# endif
34
35namespace std {
36
37 template<class _CharT, class _Traits = std::char_traits<_CharT> >
38 using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
39
40 // basic_string_view typedef names
45
46// template<class _CharT, class _Traits = std::char_traits<_CharT> >
47// basic_string_view<_CharT,_Traits>
48// &operator=(basic_string_view<_CharT,_Traits> &lhs, const TString &rsh) {
49// *lhs = basic_string_view<_CharT,_Traits>(rsh);
50// return *lhs;
51// }
52
53#ifndef R__HAS_STOD_STRING_VIEW
54 inline double stod(std::string_view str, size_t *pos)
55 {
56 return std::stod(std::string(str.data(), str.size()),pos);
57 }
58#endif
59
60}
61
62#endif // ifdef else R__HAS_STD_STRING_VIEW
63
64#if !(defined(R__HAS_OP_EQUAL_PLUS_STRING_VIEW) || R__MSVC_LANG >= 201703L || __cplusplus >= 201703L)
65
66#include <string>
67
68namespace std {
69inline namespace __ROOT {
70
71inline std::string &operator+=(std::string &left, std::string_view right)
72{
73 return left.append(right.data(), right.size());
74}
75
76} // namespace __ROOT
77} // namespace std
78
79#endif // ifndef R__HAS_OP_EQUAL_PLUS_STRING_VIEW
80
81namespace ROOT {
82namespace Internal {
84 const char *fData{nullptr};
85 size_t fLength{0};
86
87 public:
88 explicit TStringView(const char *cstr, size_t len) : fData(cstr), fLength(len) {}
89
90 operator std::string_view() const { return std::string_view(fData,fLength); }
91 };
92} // namespace Internal
93} // namespace ROOT
94#endif // RStringView_H
std::string & operator+=(std::string &left, const TString &right)
Definition: TString.h:478
TStringView(const char *cstr, size_t len)
Definition: RStringView.hxx:88
basic_string_view< char32_t > u32string_view
basic_string_view< char > string_view
basic_string_view< char16_t > u16string_view
basic_string_view< wchar_t > wstring_view
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: RNumpyDS.hxx:30