Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> but it does guarantee that it could be.

in which sense do you mean this? consider for instance

    constexpr int foo(int x) 
    { if(x < 0) throw "error"; return x; }
I would say that "guarantee that it could be" means that as long as the function definition itself "builds" / is validated by the compiler, you can use it in a constexpr context yet this is not the case here:

    constexpr int a = foo(123); // works fine
    constexpr int b = foo(-123); // compile error
    int c = foo(-123); // works fine
so having "constexpr" in the API does not mean that your code will always build ; as soon as you have constexpr the entire implementation of the function is part of the API, thus making the keyword moot like gpderetta says



Yup. Turns out, I was wrong.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: