-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Constexpr parsing: non-constexpr containers #32
Comments
Hold on. There is an example of constexpr usage of ctpg, it works just fine. Did you examine constexpr parsing used in simple-expr-parser.cpp? (lines 65 - 69) Constexpr vector is a c++20 thing, ctpg relies entirely on c++17 |
In my case I'm getting this error becaused ctpg uses
I did, I'm trying to make a similar example where expressions are stored as a regular AST. |
Yes. So this is not an issue with std::vector or std::optional. This is true, CTPG examines the value types of symbols and all of them need to be What you need is an AST representation as a literal type. By the way std::optional in c++17 is partially constexpr already, and CTPG uses just these parts, and they are all implemented in all standard libraries that CTPG supports. |
I figured I got confused while working on making constexpr nterm<int> root("root");
constexpr parser p1(root, terms('0', '1', '2'), nterms(root),
rules(root('0', '1', '2') >= val(42)));
constexpr auto foo() {
constexpr nterm<int> root("root");
parser p2(root, terms('0', '1', '2'), nterms(root),
rules(root('0', '1', '2') >= val(42)));
}
The use cases that interest me the most are the latter, therefore I will be working on a fork of Is it something you would like mainline |
You would have to relax the requirement for the cvector compatibility ad switch to the std vector (or implement once yourself). I would gladly take a look at the progress when you have something. Such feature would be very nice. I will consider moving it into mainline once you actually have something supported by 3 major compilers (gcc, clang and msvc). I can see a ctpg v2.0 moved to c++20 entirely. There is a possibility to allow your feature conditionally if compiled with appropriate standard (c++20) options. |
I'm currently facing an issue while using
ctpg::parser
:libstdc++
doesn't have a constexpr-ready version ofstd::optional
libc++
doesn't have a constexpr-ready version ofstd::vector
This makes
ctpg::parser
currently unusable in constexpr functions since both are required but no standard library implementation has them both constexpr-ready.There could several ways to make constexpr ctpg happen, being:
std::optional
implementation (libstdc++ compatible)std::vector
implementation (libc++ compatible)std::optional
(libstdc++ compatible)I will probably go for one of these options on my side because I need ctpg to work in constexpr contexts for my research, but I would like to know if merging one of these changes on your side sounds reasonable to you, and eventually which one you prefer so I can put my focus on it.
Regards,
Jules
The text was updated successfully, but these errors were encountered: