Allow asGetTypeTraits to be called in constexpr contexts#74
Open
CasualYT31 wants to merge 1 commit into
Open
Conversation
|
I'm also working on a wrapper library for AngelScript using C++20. I've reimplemented a constexpr version of |
Owner
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.