0

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?

benedict97
  • 25
  • 4

2 Answers2

1

std::string_view doesn't Acquire Resource, it is not a RAII object.

Jarod42
  • 203,559
  • 14
  • 181
  • 302
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