Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about constexpr to define string& variable #94

Open
huidui opened this issue Aug 11, 2024 · 0 comments
Open

about constexpr to define string& variable #94

huidui opened this issue Aug 11, 2024 · 0 comments

Comments

@huidui
Copy link

huidui commented Aug 11, 2024

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant