Added any_cast_test, don't throw on failed pointer cast, equality operator #6
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 added a few features to the class, I know these are not in the standard so I don't expect you to merge them into master but putting them here in case someone else needs them.
I think in most situations, if you're using any for storage, you don't know the type in advance so you want to check what type it is and exceptions are way too inconvenient (and slow), so I've added
any_cast_testthat returns a bool determining the success of the cast.I've also adjusted
any_castto not throw an exception in case the type stored is a pointer (it returns nullptr instead).Finally I've added an equality operator so you can test whether two different
anyinstances contain the same data (either the same pointer or same value).