Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
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
58#ifndef R__HAS_OP_EQUAL_PLUS_STRING_VIEW
59
60#include <string>
61
62namespace std {
63inline namespace __ROOT {
64
65inline std::string &operator+=(std::string &left, std::string_view right)
66{
67 return left.append(right.data(), right.size());
68}
69
70} // namespace __ROOT
71} // namespace std
72
73#endif // ifndef R__HAS_OP_EQUAL_PLUS_STRING_VIEW
74
75namespace ROOT {
76namespace Internal {
78 const char *fData{nullptr};
79 size_t fLength{0};
80
81 public:
82 explicit TStringView(const char *cstr, size_t len) : fData(cstr), fLength(len) {}
83
84 operator std::string_view() const { return std::string_view(fData,fLength); }
85 };
86} // namespace Internal
87} // namespace ROOT
88#endif // RStringView_H
std::string & operator+=(std::string &left, const TString &right)
Definition TString.h:478
TStringView(const char *cstr, size_t len)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...