0

I'm writing this small header-mostly library, which has to support C++11. Unfortunately, it turns out that I need an index_sequence somewhere in there. I can "lift" an implementation from somewhere (e.g. this one, here on SO); but of course I would rather not burden the users' code with yet another impromptu definition of an index_sequence when another one might already have been made.

Now, the first thing I'll do is a C++ version check, so for C++14 and onwards I'll do nothing. But if it's C++11 - how should I make a best effort to check that it hasn't been defined already? Is there some feature macro that people (= library authors) tend to use for this case?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    Standard is [`__cpp_lib_integer_sequence`](http://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros). – Zereges Feb 13 '18 at 23:01
  • " I would rather not burden the users' code with yet another impromptu definition " Why not? Do you think it hinders them in some way? – Mooing Duck Feb 13 '18 at 23:03
  • @MooingDuck: It's unseemly/wasteful for every library to reinvent the wheel by defining its own private version of `make_index_sequence`. – einpoklum Feb 13 '18 at 23:04
  • Unrelated, I just found this: http://www.boost.org/doc/libs/1_64_0/boost/context/detail/index_sequence.hpp – Mooing Duck Feb 14 '18 at 00:43

0 Answers0