What is consteval?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







16















Apparently, consteval is going to be a keyword in C++20. The cppreference page for it is currently blank. What is it going to be and how does it relate to constexpr?










share|improve this question























  • "Apparently, consteval is going to be a keyword in C++20" - provide a link to support this assertion.

    – Neil Butterworth
    Nov 17 '18 at 1:17






  • 3





    @NeilButterworth The cppreference page I already linked to claims it to be.

    – KevinZ
    Nov 17 '18 at 1:19











  • decltype(std::declval<f()>)'ish but .. fun stuff.

    – Ted Lyngmo
    Nov 17 '18 at 1:20








  • 4





    Bah, you're quick. I'll write it up this weekend.

    – T.C.
    Nov 17 '18 at 1:29






  • 7





    @NeilButterworth: By that reasoning, nobody can even call it "C++20" or say that there will even be a next version of C++. It is not unreasonable to ask about upcoming features that have been approved in accord with WG21 procedures at the various meetings. Like the most recent one.

    – Nicol Bolas
    Nov 17 '18 at 1:36


















16















Apparently, consteval is going to be a keyword in C++20. The cppreference page for it is currently blank. What is it going to be and how does it relate to constexpr?










share|improve this question























  • "Apparently, consteval is going to be a keyword in C++20" - provide a link to support this assertion.

    – Neil Butterworth
    Nov 17 '18 at 1:17






  • 3





    @NeilButterworth The cppreference page I already linked to claims it to be.

    – KevinZ
    Nov 17 '18 at 1:19











  • decltype(std::declval<f()>)'ish but .. fun stuff.

    – Ted Lyngmo
    Nov 17 '18 at 1:20








  • 4





    Bah, you're quick. I'll write it up this weekend.

    – T.C.
    Nov 17 '18 at 1:29






  • 7





    @NeilButterworth: By that reasoning, nobody can even call it "C++20" or say that there will even be a next version of C++. It is not unreasonable to ask about upcoming features that have been approved in accord with WG21 procedures at the various meetings. Like the most recent one.

    – Nicol Bolas
    Nov 17 '18 at 1:36














16












16








16








Apparently, consteval is going to be a keyword in C++20. The cppreference page for it is currently blank. What is it going to be and how does it relate to constexpr?










share|improve this question














Apparently, consteval is going to be a keyword in C++20. The cppreference page for it is currently blank. What is it going to be and how does it relate to constexpr?







c++ c++20






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 17 '18 at 1:13









KevinZKevinZ

1,2121219




1,2121219













  • "Apparently, consteval is going to be a keyword in C++20" - provide a link to support this assertion.

    – Neil Butterworth
    Nov 17 '18 at 1:17






  • 3





    @NeilButterworth The cppreference page I already linked to claims it to be.

    – KevinZ
    Nov 17 '18 at 1:19











  • decltype(std::declval<f()>)'ish but .. fun stuff.

    – Ted Lyngmo
    Nov 17 '18 at 1:20








  • 4





    Bah, you're quick. I'll write it up this weekend.

    – T.C.
    Nov 17 '18 at 1:29






  • 7





    @NeilButterworth: By that reasoning, nobody can even call it "C++20" or say that there will even be a next version of C++. It is not unreasonable to ask about upcoming features that have been approved in accord with WG21 procedures at the various meetings. Like the most recent one.

    – Nicol Bolas
    Nov 17 '18 at 1:36



















  • "Apparently, consteval is going to be a keyword in C++20" - provide a link to support this assertion.

    – Neil Butterworth
    Nov 17 '18 at 1:17






  • 3





    @NeilButterworth The cppreference page I already linked to claims it to be.

    – KevinZ
    Nov 17 '18 at 1:19











  • decltype(std::declval<f()>)'ish but .. fun stuff.

    – Ted Lyngmo
    Nov 17 '18 at 1:20








  • 4





    Bah, you're quick. I'll write it up this weekend.

    – T.C.
    Nov 17 '18 at 1:29






  • 7





    @NeilButterworth: By that reasoning, nobody can even call it "C++20" or say that there will even be a next version of C++. It is not unreasonable to ask about upcoming features that have been approved in accord with WG21 procedures at the various meetings. Like the most recent one.

    – Nicol Bolas
    Nov 17 '18 at 1:36

















"Apparently, consteval is going to be a keyword in C++20" - provide a link to support this assertion.

– Neil Butterworth
Nov 17 '18 at 1:17





"Apparently, consteval is going to be a keyword in C++20" - provide a link to support this assertion.

– Neil Butterworth
Nov 17 '18 at 1:17




3




3





@NeilButterworth The cppreference page I already linked to claims it to be.

– KevinZ
Nov 17 '18 at 1:19





@NeilButterworth The cppreference page I already linked to claims it to be.

– KevinZ
Nov 17 '18 at 1:19













decltype(std::declval<f()>)'ish but .. fun stuff.

– Ted Lyngmo
Nov 17 '18 at 1:20







decltype(std::declval<f()>)'ish but .. fun stuff.

– Ted Lyngmo
Nov 17 '18 at 1:20






4




4





Bah, you're quick. I'll write it up this weekend.

– T.C.
Nov 17 '18 at 1:29





Bah, you're quick. I'll write it up this weekend.

– T.C.
Nov 17 '18 at 1:29




7




7





@NeilButterworth: By that reasoning, nobody can even call it "C++20" or say that there will even be a next version of C++. It is not unreasonable to ask about upcoming features that have been approved in accord with WG21 procedures at the various meetings. Like the most recent one.

– Nicol Bolas
Nov 17 '18 at 1:36





@NeilButterworth: By that reasoning, nobody can even call it "C++20" or say that there will even be a next version of C++. It is not unreasonable to ask about upcoming features that have been approved in accord with WG21 procedures at the various meetings. Like the most recent one.

– Nicol Bolas
Nov 17 '18 at 1:36












1 Answer
1






active

oldest

votes


















17














It declares immediate functions, that is, functions that must be evaluated at compile time to produce a constant. (It used to be spelled constexpr! in a previous revision of the paper.) In contrast, constexpr functions may be evaluated at compile time or run time, and need not produce a constant in all cases.



The adopted paper is P1073R3, which is not yet publicly available, but a previous revision is available and the introductory (motivation and high-level description) portion is about the same (except that the "Source Locations" section is deleted in R3).






share|improve this answer


























  • Can we overload based on consteval-ness?

    – geza
    Nov 17 '18 at 10:15






  • 1





    No, you can't, just like constexpr.

    – T.C.
    Nov 18 '18 at 6:21






  • 1





    It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

    – Davis Herring
    Dec 24 '18 at 21:08











  • @geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

    – Andry
    Jan 28 at 15:07











  • @Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

    – geza
    Jan 28 at 15:35












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347298%2fwhat-is-consteval%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









17














It declares immediate functions, that is, functions that must be evaluated at compile time to produce a constant. (It used to be spelled constexpr! in a previous revision of the paper.) In contrast, constexpr functions may be evaluated at compile time or run time, and need not produce a constant in all cases.



The adopted paper is P1073R3, which is not yet publicly available, but a previous revision is available and the introductory (motivation and high-level description) portion is about the same (except that the "Source Locations" section is deleted in R3).






share|improve this answer


























  • Can we overload based on consteval-ness?

    – geza
    Nov 17 '18 at 10:15






  • 1





    No, you can't, just like constexpr.

    – T.C.
    Nov 18 '18 at 6:21






  • 1





    It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

    – Davis Herring
    Dec 24 '18 at 21:08











  • @geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

    – Andry
    Jan 28 at 15:07











  • @Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

    – geza
    Jan 28 at 15:35
















17














It declares immediate functions, that is, functions that must be evaluated at compile time to produce a constant. (It used to be spelled constexpr! in a previous revision of the paper.) In contrast, constexpr functions may be evaluated at compile time or run time, and need not produce a constant in all cases.



The adopted paper is P1073R3, which is not yet publicly available, but a previous revision is available and the introductory (motivation and high-level description) portion is about the same (except that the "Source Locations" section is deleted in R3).






share|improve this answer


























  • Can we overload based on consteval-ness?

    – geza
    Nov 17 '18 at 10:15






  • 1





    No, you can't, just like constexpr.

    – T.C.
    Nov 18 '18 at 6:21






  • 1





    It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

    – Davis Herring
    Dec 24 '18 at 21:08











  • @geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

    – Andry
    Jan 28 at 15:07











  • @Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

    – geza
    Jan 28 at 15:35














17












17








17







It declares immediate functions, that is, functions that must be evaluated at compile time to produce a constant. (It used to be spelled constexpr! in a previous revision of the paper.) In contrast, constexpr functions may be evaluated at compile time or run time, and need not produce a constant in all cases.



The adopted paper is P1073R3, which is not yet publicly available, but a previous revision is available and the introductory (motivation and high-level description) portion is about the same (except that the "Source Locations" section is deleted in R3).






share|improve this answer















It declares immediate functions, that is, functions that must be evaluated at compile time to produce a constant. (It used to be spelled constexpr! in a previous revision of the paper.) In contrast, constexpr functions may be evaluated at compile time or run time, and need not produce a constant in all cases.



The adopted paper is P1073R3, which is not yet publicly available, but a previous revision is available and the introductory (motivation and high-level description) portion is about the same (except that the "Source Locations" section is deleted in R3).







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 17 '18 at 10:02









Rakete1111

35.8k1086123




35.8k1086123










answered Nov 17 '18 at 1:28









T.C.T.C.

108k14222331




108k14222331













  • Can we overload based on consteval-ness?

    – geza
    Nov 17 '18 at 10:15






  • 1





    No, you can't, just like constexpr.

    – T.C.
    Nov 18 '18 at 6:21






  • 1





    It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

    – Davis Herring
    Dec 24 '18 at 21:08











  • @geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

    – Andry
    Jan 28 at 15:07











  • @Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

    – geza
    Jan 28 at 15:35



















  • Can we overload based on consteval-ness?

    – geza
    Nov 17 '18 at 10:15






  • 1





    No, you can't, just like constexpr.

    – T.C.
    Nov 18 '18 at 6:21






  • 1





    It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

    – Davis Herring
    Dec 24 '18 at 21:08











  • @geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

    – Andry
    Jan 28 at 15:07











  • @Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

    – geza
    Jan 28 at 15:35

















Can we overload based on consteval-ness?

– geza
Nov 17 '18 at 10:15





Can we overload based on consteval-ness?

– geza
Nov 17 '18 at 10:15




1




1





No, you can't, just like constexpr.

– T.C.
Nov 18 '18 at 6:21





No, you can't, just like constexpr.

– T.C.
Nov 18 '18 at 6:21




1




1





It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

– Davis Herring
Dec 24 '18 at 21:08





It might be worth pointing out that the motivation is to have functions that rely on compiler data structures that need not be preserved in the binary.

– Davis Herring
Dec 24 '18 at 21:08













@geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

– Andry
Jan 28 at 15:07





@geza You don't need to, but instead of overloading you can test an expression on compile-timeness by usage either noexcept operator (for msvc or gcc) or through the __builtin_constant_p operator (for clang or gcc). Read these for details: * stackoverflow.com/questions/13299394/… * reddit.com/r/cpp/comments/7c208c/…

– Andry
Jan 28 at 15:07













@Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

– geza
Jan 28 at 15:35





@Andry: I don't think that these are 100% suited for the task. noexcept has its problems, as far as I remember. And __builtin_constant_p is not usable with gcc, as its output depends on optimization level.

– geza
Jan 28 at 15:35




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347298%2fwhat-is-consteval%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine