#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #if !defined(NUCLEX_SUPPORT_SERVICES_LAZYSERVICEINJECTOR_H) #error This header must be included via LazyServiceInjector.h #endif #include namespace Nuclex { namespace Support { namespace Services { // ------------------------------------------------------------------------------------------- // namespace Private { /// Vardiadic template whose arguments are a generated integer sequence /// Sequential integers as variadic argument list template class IntegerSequence { /// The type of the integer sequence public: typedef IntegerSequence Type; /// Helper that prepends another integer to the sequence public: template using Prepend = IntegerSequence; }; } // namespace Private // ------------------------------------------------------------------------------------------- // namespace Private { /// /// Recursively constructs a variadic template whose arguments are an integer sequence /// /// Largest integer (inclusive) in the sequence /// /// Integer sequence constructed by previous recursions or empty of this is the first /// template class IntegerSequenceBuilder { /// The recursively formed integer sequence /// /// This recursively defines itself all the way down until the integer is zero, /// building an IntegerSequence along the way (prepending the value so /// that it still produces an ascending sequence). /// public: typedef typename IntegerSequenceBuilder< MaximumInteger - 1, typename TIntegerSequence::template Prepend >::Type Type; }; /// Specialization for the final recursion that just returns the sequence template class IntegerSequenceBuilder<0, TIntegerSequence> { /// The integer sequence the template was instantiated with public: typedef TIntegerSequence Type; }; } // namespace Private // ------------------------------------------------------------------------------------------- // namespace Private { /// Builds variadic template whose parameters are a sequence of integers /// /// Integer up to which a sequence will be formed (inclusive) /// template using BuildIntegerSequence = typename IntegerSequenceBuilder< MaximumInteger, IntegerSequence<> >::Type; } // namespace Private // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Services