Skip to content

about constexpr to define string& variable #94

Description

@huidui

why i can define :
const std::string& s1 = "test";
or
const std::string s1 = "test";
but if i try to define s1 with constexpr, my VS2019 report error
constexpr std::string& s1 ="test'; (due to constexpr only can define reference , pointer, or literal values, so i define string&.
i am confused, why const define pass, but constexpr will fail ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions