Allow asGetTypeTraits to be called in constexpr contexts - #74
CasualYT31 wants to merge 1 commit into
Conversation
|
I'm also working on a wrapper library for AngelScript using C++20. I've reimplemented a constexpr version of |
|
Thanks for submitting this PR. I can't think of any issue with declaring asGetTypeTraits as a constexpr. I'll review the PR and merge it when possible. |
|
Please do not. It would break compatibility with some pre c++14 compilers and all pre c++11 compilers as well. Do not force C++ latest standard shenanigans into AngelScript library, it does not need it at all. |
I've decided to move on to supporting value types in my reflective wrapper library early. As part of this, I'm working on the logic that determines which flags to apply to a given value type at compile time (which you were particularly keen on seeing implemented 👀).
Ideally, my implementation would first call
asGetTypeTraits<T>(), and then compute the flags that said function cannot detect. The problem is that I only just found out thatasGetTypeTraits()cannot be called at compile time. I took a quick look at its implementation and I couldn't find a reason why it shouldn't be callable at compile time, so I'm proposing that we make this functionconstexpr. It won't impact the way it's used today (as aconstexprfunction only specifies that it may be called at compile time), but it will allow me and others to call it withinconstevalfunctions, etc., should they wish to.And seeing as
constexprwas introduced in C++11, it should be perfectly fine to include it in a function that is excluded if the developer is working with an older version of the standard. But in fairness I haven't tried compiling this with anything other than the very new 16.1.0 version of GCC on Ubuntu that I'm working with.