|
||||
Warning, file /include/eigen3/unsupported/Eigen/CXX11/src/util/CXX11Workarounds.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // This file is part of Eigen, a lightweight C++ template library 0002 // for linear algebra. 0003 // 0004 // Copyright (C) 2013 Christian Seiler <christian@iwakd.de> 0005 // 0006 // This Source Code Form is subject to the terms of the Mozilla 0007 // Public License v. 2.0. If a copy of the MPL was not distributed 0008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 0009 0010 #ifndef EIGEN_CXX11WORKAROUNDS_H 0011 #define EIGEN_CXX11WORKAROUNDS_H 0012 0013 /* COMPATIBILITY CHECKS 0014 * (so users of compilers that are too old get some realistic error messages) 0015 */ 0016 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1310) 0017 #error Intel Compiler only supports required C++ features since version 13.1. 0018 // note that most stuff in principle works with 13.0 but when combining 0019 // some features, at some point 13.0 will just fail with an internal assertion 0020 #elif defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) 0021 // G++ < 4.6 by default will continue processing the source files - even if we use #error to make 0022 // it error out. For this reason, we use the pragma to make sure G++ aborts at the first error 0023 // it sees. Unfortunately, that is still not our #error directive, but at least the output is 0024 // short enough the user has a chance to see that the compiler version is not sufficient for 0025 // the funky template mojo we use. 0026 #pragma GCC diagnostic error "-Wfatal-errors" 0027 #error GNU C++ Compiler (g++) only supports required C++ features since version 4.6. 0028 #endif 0029 0030 /* Check that the compiler at least claims to support C++11. It might not be sufficient 0031 * because the compiler may not implement it correctly, but at least we'll know. 0032 * On the other hand, visual studio still doesn't claim to support C++11 although it's 0033 * compliant enugh for our purpose. 0034 */ 0035 #if (EIGEN_COMP_CXXVER < 11) 0036 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) 0037 #pragma GCC diagnostic error "-Wfatal-errors" 0038 #endif 0039 #error This library needs at least a C++11 compliant compiler. If you use g++/clang, please enable the -std=c++11 compiler flag. (-std=c++0x on older versions.) 0040 #endif 0041 0042 namespace Eigen { 0043 0044 namespace internal { 0045 0046 /* std::get is only constexpr in C++14, not yet in C++11 0047 */ 0048 0049 0050 template<std::size_t I_, class T> constexpr inline T& array_get(std::vector<T>& a) { return a[I_]; } 0051 template<std::size_t I_, class T> constexpr inline T&& array_get(std::vector<T>&& a) { return a[I_]; } 0052 template<std::size_t I_, class T> constexpr inline T const& array_get(std::vector<T> const& a) { return a[I_]; } 0053 0054 /* Suppose you have a template of the form 0055 * template<typename T> struct X; 0056 * And you want to specialize it in such a way: 0057 * template<typename S1, typename... SN> struct X<Foo<S1, SN...>> { ::: }; 0058 * template<> struct X<Foo<>> { ::: }; 0059 * This will work in Intel's compiler 13.0, but only to some extent in g++ 4.6, since 0060 * g++ can only match templates called with parameter packs if the number of template 0061 * arguments is not a fixed size (so inside the first specialization, referencing 0062 * X<Foo<Sn...>> will fail in g++). On the other hand, g++ will accept the following: 0063 * template<typename S...> struct X<Foo<S...>> { ::: }: 0064 * as an additional (!) specialization, which will then only match the empty case. 0065 * But Intel's compiler 13.0 won't accept that, it will only accept the empty syntax, 0066 * so we have to create a workaround for this. 0067 */ 0068 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) 0069 #define EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) mt... n 0070 #define EIGEN_TPL_PP_SPEC_HACK_DEFC(mt, n) , EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) 0071 #define EIGEN_TPL_PP_SPEC_HACK_USE(n) n... 0072 #define EIGEN_TPL_PP_SPEC_HACK_USEC(n) , n... 0073 #else 0074 #define EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) 0075 #define EIGEN_TPL_PP_SPEC_HACK_DEFC(mt, n) 0076 #define EIGEN_TPL_PP_SPEC_HACK_USE(n) 0077 #define EIGEN_TPL_PP_SPEC_HACK_USEC(n) 0078 #endif 0079 0080 } // end namespace internal 0081 0082 } // end namespace Eigen 0083 0084 #endif // EIGEN_CXX11WORKAROUNDS_H 0085 0086 /* 0087 * kate: space-indent on; indent-width 2; mixedindent off; indent-mode cstyle; 0088 */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |