Search code examples
c++raiistring-view

Does C++ 17 STL std::string_view fulfill RAII design philosiphy?


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?


Solution

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