thelink2012 / any

Implementation of std::experimental::any, including small object optimization, for C++11 compilers
Boost Software License 1.0
144 stars 37 forks source link

Consider compilation for embedded platforms #9

Closed trueqbit closed 5 years ago

trueqbit commented 5 years ago

Compilation for embedded platforms is typically missing exception handling and RTTI. It would be nice to check the availability of those features like gcc does.

Furthermore, a different implementation of any_cast would solve the performance cost incurred by type_id comparisons.

See pull request #8

trueqbit commented 5 years ago

Repeating my comment I originally placed on the PR:

I was following gcc's approach here, but I know that especially Visual C++ didn't implement those back in the days.

What if we 'macro'nize the standard test macros? I see two approaches here:

  1. Either use one macro ANY_IMPL_EMBEDDED that can be set
  2. Or use two macros ANY_IMPL_NO_RTTI and ANY_IMPL_NO_EXCEPTIONS, which can be defined automatically if the standard test macros are available
thelink2012 commented 5 years ago

Hi trueqbit,

I'm very sorry for the late reply. I'm in such a hurry this month. Apologizes.

I think two separate macros would be better, thus even other fields that dislike these features (e.g. games) can disable them independently.

I'm all in for merging the PR given that it passes the unit test (may need some adaptation when these flags are active?).

Thank you for the interest. Wish you the best.

trueqbit commented 5 years ago

No worries, I am just trying to collaborate in one spot rather than forking and buggering off :)

From the environment I am currently coming from (Particle workbench), I actually would like to opt-out by default rather than manually. This is because Particle doesn't allow to pass any additional CPP macros to the compilation step. This decision means that on compilers without the standard macros people would have to explicitly opt-in.

Can you take another review to PR #11, please? I also added unit tests to ensure the decayed type is actually both stored and retrieved, plus a unit test asserting access violations, which are expected in place of throwing bad_any_cast.

thelink2012 commented 5 years ago

Closed as seems to be resolved by #11