In RAII(Resource Acquisition Is Initialization), an object obtain piece of resource is the procedure of initialization itself, and resource will be held as life cycle of object, but resource in string_view only includes char * and size, which means the address could be free to invalidation and object couldn't be conscious about it. And does it make the object never closure?
Asked
Active
Viewed 130 times
0
-
10`std::string_view` doesn't Acquire Resource, it is not a RAII object. – Jarod42 Jun 15 '21 at 07:21
-
@Jarod42 isn't this an answer than? – user1810087 Jun 15 '21 at 08:03
2 Answers
0
Implicitly it is part of the RAII principle that you do not aquire a resource that you do not own. And thats what a view is: It does not participate in ownership, it only provides a view to an object owned by someone else.

463035818_is_not_an_ai
- 109,796
- 11
- 89
- 185