Is std::string a literal type?

Viewed 139

https://en.cppreference.com/w/cpp/named_req/LiteralType

Here they write that

Literal types are the types of constexpr variables

However it seems to me that I can't define a constexpr string (it doesn't matter if it has static storage duration or is just a stack-allocated constexpr var).

But there are the requirements for literal types:

A literal type is any of the following:

  • possibly cv-qualified class type that has all of the following properties:
    • has a [trivial (until C++20) | constexpr (since C++20)] destructor,
    • is one of
      • a type with at least one constexpr (possibly template) constructor that is not a copy or move constructor,

Does std::string satisfy these requirements? Or does it maybe fast a non-conformant destructor?

There seems to be no link to the dtor here https://en.cppreference.com/w/cpp/string/basic_string.

I understand that it can't be made fully constexpr (at least for now) because of free store allocation.

I'm just asking whether it is a literal type.

1 Answers
Related