@@ -27,10 +27,10 @@ class string_view {
27
27
#endif
28
28
29
29
public:
30
- string_view () noexcept = default ;
31
- string_view (const string_view &strn) noexcept = default ;
32
- string_view (string_view &&strn) noexcept = default ;
33
- string_view (std::string_view strn) noexcept
30
+ constexpr string_view () noexcept = default;
31
+ constexpr string_view (const string_view &strn) noexcept = default;
32
+ constexpr string_view (string_view &&strn) noexcept = default;
33
+ constexpr string_view (std::string_view strn) noexcept
34
34
: str(strn.data())
35
35
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
36
36
,
@@ -47,10 +47,10 @@ class string_view {
47
47
{
48
48
}
49
49
50
- string_view &operator =(string_view &&strn) noexcept = default ;
50
+ constexpr string_view &operator =(string_view &&strn) noexcept = default ;
51
51
string_view &operator =(const string_view &strn) noexcept = default ;
52
52
53
- string_view &operator =(std::string_view strn) noexcept {
53
+ constexpr string_view &operator =(std::string_view strn) noexcept {
54
54
str = strn.data ();
55
55
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
56
56
len = strn.size ();
@@ -66,9 +66,9 @@ class string_view {
66
66
return *this ;
67
67
}
68
68
69
- const char *data () const noexcept { return str ? str : " " ; }
69
+ constexpr const char *data () const noexcept { return str ? str : " " ; }
70
70
71
- explicit operator std::string_view () const noexcept {
71
+ constexpr explicit operator std::string_view () const noexcept {
72
72
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
73
73
return std::string_view (str, len);
74
74
#else
@@ -77,31 +77,39 @@ class string_view {
77
77
}
78
78
79
79
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
80
- friend bool operator ==(string_view lhs, std::string_view rhs) noexcept {
80
+ friend constexpr bool operator ==(string_view lhs,
81
+ std::string_view rhs) noexcept {
81
82
return rhs == std::string_view (lhs);
82
83
}
83
- friend bool operator ==(std::string_view lhs, string_view rhs) noexcept {
84
+ friend constexpr bool operator ==(std::string_view lhs,
85
+ string_view rhs) noexcept {
84
86
return lhs == std::string_view (rhs);
85
87
}
86
88
87
- friend bool operator !=(string_view lhs, std::string_view rhs) noexcept {
89
+ friend constexpr bool operator !=(string_view lhs,
90
+ std::string_view rhs) noexcept {
88
91
return rhs != std::string_view (lhs);
89
92
}
90
- friend bool operator !=(std::string_view lhs, string_view rhs) noexcept {
93
+ friend constexpr bool operator !=(std::string_view lhs,
94
+ string_view rhs) noexcept {
91
95
return lhs != std::string_view (rhs);
92
96
}
93
97
#else
94
- friend bool operator ==(string_view lhs, std::string_view rhs) noexcept {
98
+ friend constexpr bool operator ==(string_view lhs,
99
+ std::string_view rhs) noexcept {
95
100
return rhs == lhs.data ();
96
101
}
97
- friend bool operator ==(std::string_view lhs, string_view rhs) noexcept {
102
+ friend constexpr bool operator ==(std::string_view lhs,
103
+ string_view rhs) noexcept {
98
104
return lhs == rhs.data ();
99
105
}
100
106
101
- friend bool operator !=(string_view lhs, std::string_view rhs) noexcept {
107
+ friend constexpr bool operator !=(string_view lhs,
108
+ std::string_view rhs) noexcept {
102
109
return rhs != lhs.data ();
103
110
}
104
- friend bool operator !=(std::string_view lhs, string_view rhs) noexcept {
111
+ friend constexpr bool operator !=(std::string_view lhs,
112
+ string_view rhs) noexcept {
105
113
return lhs != rhs.data ();
106
114
}
107
115
#endif
0 commit comments