File indexing completed on 2025-01-18 10:11:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef roofit_roofitcore_RooStringView_h
0014 #define roofit_roofitcore_RooStringView_h
0015
0016 #include <string_view>
0017 #include <TString.h>
0018
0019 #include <string>
0020
0021
0022
0023
0024
0025
0026
0027 class RooStringView {
0028 public:
0029 RooStringView(const char *str) : _cstr{str} {}
0030 RooStringView(TString const &str) : _cstr{str} {}
0031 RooStringView(std::string const &str) : _cstr{str.c_str()} {}
0032
0033 RooStringView(std::string &&str) : _strp{std::make_shared<std::string>(std::move(str))}, _cstr{_strp->c_str()} {}
0034 const char * c_str() const { return _cstr; }
0035 operator const char *() { return _cstr; }
0036 operator std::string_view() { return _cstr; }
0037
0038 private:
0039 std::shared_ptr<std::string> _strp;
0040 const char *_cstr;
0041 };
0042
0043 #endif