How to determine if std :: chrono :: monotonic_clock is available?

C ++ 0x N3092 states that monotonic_clock is optional:

20.10.5.2 The monotonic_clock class [time.clock.monotonic]

  • Monotonic_clock objects represent a clock for which time_point never decreases as physical time advances. monotonic_clock may be synonymous with system_clock if system_clock :: is_monotonic is true.

  • The monotonic_clock class is conditionally supported.

Is it possible to use SFINAE or another method to define a feature class to determine if monotonic_clock is defined?

If not, shouldn't there be a standard macro indicating if monotonic_clock is available?

+5
source share
2 answers

There is no fully standards-compliant presence detection method std::chrono::monotonic_clock. As can be seen from the discussions on comp.std.C ++, there are some non-standard methods, including declaring new code in the namespace std.

+3
source

Look at BOOST_MPL_HAS_XXX_TRAIT_DEF and look at the thread to compile detection of temporary elements . I know that VisualStudio has a non-standard keyword __if_exists, but AFAIK is not available in other compilers.

0
source

All Articles