// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2017 Gael Guennebaud // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #ifndef EIGEN_INTEGRAL_CONSTANT_H #define EIGEN_INTEGRAL_CONSTANT_H namespace Eigen { namespace internal { template struct fix_t { static const int value = N; operator int() const { return value; } fix_t (fix_t (*)() ) {} fix_t() {} // Needed in C++14 to allow fix(): fix_t operator() () const { return *this; } }; template struct get_compile_time { enum { value = Default }; }; template struct get_compile_time,Default> { enum { value = N }; }; template struct is_compile_time { enum { value = false }; }; template struct is_compile_time > { enum { value = true }; }; } // end namespace internal #ifndef EIGEN_PARSED_BY_DOXYGEN #if __cplusplus > 201103L template static const internal::fix_t fix{}; #else template inline internal::fix_t fix() { return internal::fix_t(); } #endif #else // EIGEN_PARSED_BY_DOXYGEN /** \var fix * \ingroup Core_Module * * This \em identifier permits to construct an object embedding a compile-time integer \c N. * * \tparam N the compile-time integer value * * It is typically used in conjunction with the Eigen::seq and Eigen::seqN functions to pass compile-time values to them: * \code * seqN(10,fix<4>,fix<-3>) // <=> [10 7 4 1] * \endcode * * In c++14, it is implemented as: * \code * template static const internal::fix_t fix{}; * \endcode * where internal::fix_t is an internal template class similar to * \c std::integral_constant * Here, \c fix is thus an object of type \c internal::fix_t. * * In c++98/11, it is implemented as a function: * \code * template inline internal::fix_t fix(); * \endcode * Here internal::fix_t is thus a pointer to function. * * If for some reason you want a true object in c++98 then you can write: \code fix() \endcode which is also valid in c++14. */ template static const auto fix; #endif // EIGEN_PARSED_BY_DOXYGEN } // end namespace Eigen #endif // EIGEN_INTEGRAL_CONSTANT_H