C++17 constexpr everything, or as much as the compiler can
solarianprogrammer.com
C++17 constexpr everything, or as much as the compiler can
1–10 of 120 posts
Re: C++17 constexpr everything, or as much as the compiler can
#2Re: C++17 constexpr everything, or as much as the compiler can
#3What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
Re: C++17 constexpr everything, or as much as the compiler can
#4What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
In the context of the linked article, take the first example and modify it, by reading a number at runtime with std::cin and call factorial or fibonacci with this number as an argument.
Something like this https://godbolt.org/g/CT5M6f
Re: C++17 constexpr everything, or as much as the compiler can
#5What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
A compile time debugger for the CTFE interpreter is on our extended feature list for the current interpreter rewrite, but it's less of a priority atm.
Re: C++17 constexpr everything, or as much as the compiler can
#6What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
that's up to the compiler actually. For instance, in debug mode visual studio skips constexpr and does everything at runtime (which sucks if you depend on stuff being constexpr).
Re: C++17 constexpr everything, or as much as the compiler can
#7What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
So you can use regular tests/debugging to debug your function.
Re: C++17 constexpr everything, or as much as the compiler can
#8Write a table generator program, have output create a table, splice in the order into make and/or make replacement.
Sure it's three extra steps, but it's small steps that can be debugged. It also doesn't require any advanced compiler tricks that may or may not actually run at compile.
Re: C++17 constexpr everything, or as much as the compiler can
#9What about debugging? If the code to generate the data is large and complex, how do you debug it when it only runs at compile time? Is the solution to start with two programs like the author and then merge them? That still seems like a maintainability issue.
In D which has CTFE support since ages, you'd debug such functions by invoking them at runtime. https://tour.dlang.org/tour/en/gems/compile-time-function-ev... There are also tools to print values at compile time. A compile time debugger for the CTFE interpreter is on our extended feature list for the current interpreter rewrite, but it's less of a priority atm.