![]() |
Eigen-unsupported
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2013 Christian Seiler <christian@iwakd.de> 00005 // 00006 // This Source Code Form is subject to the terms of the Mozilla 00007 // Public License v. 2.0. If a copy of the MPL was not distributed 00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00009 00010 #ifndef EIGEN_CXX11WORKAROUNDS_H 00011 #define EIGEN_CXX11WORKAROUNDS_H 00012 00013 /* COMPATIBILITY CHECKS 00014 * (so users of compilers that are too old get some realistic error messages) 00015 */ 00016 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1310) 00017 #error Intel Compiler only supports required C++ features since version 13.1. 00018 // note that most stuff in principle works with 13.0 but when combining 00019 // some features, at some point 13.0 will just fail with an internal assertion 00020 #elif defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)) 00021 // G++ < 4.6 by default will continue processing the source files - even if we use #error to make 00022 // it error out. For this reason, we use the pragma to make sure G++ aborts at the first error 00023 // it sees. Unfortunately, that is still not our #error directive, but at least the output is 00024 // short enough the user has a chance to see that the compiler version is not sufficient for 00025 // the funky template mojo we use. 00026 #pragma GCC diagnostic error "-Wfatal-errors" 00027 #error GNU C++ Compiler (g++) only supports required C++ features since version 4.6. 00028 #endif 00029 00030 /* Check that the compiler at least claims to support C++11. It might not be sufficient 00031 * because the compiler may not implement it correctly, but at least we'll know. 00032 * On the other hand, visual studio still doesn't claim to support C++11 although it's 00033 * compliant enugh for our purpose. 00034 */ 00035 #if (__cplusplus <= 199711L) && (EIGEN_COMP_MSVC < 1900) 00036 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) 00037 #pragma GCC diagnostic error "-Wfatal-errors" 00038 #endif 00039 #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.) 00040 #endif 00041 00042 namespace Eigen { 00043 00044 namespace internal { 00045 00046 /* std::get is only constexpr in C++14, not yet in C++11 00047 */ 00048 00049 00050 template<std::size_t I, class T> constexpr inline T& array_get(std::vector<T>& a) { return a[I]; } 00051 template<std::size_t I, class T> constexpr inline T&& array_get(std::vector<T>&& a) { return a[I]; } 00052 template<std::size_t I, class T> constexpr inline T const& array_get(std::vector<T> const& a) { return a[I]; } 00053 00054 /* Suppose you have a template of the form 00055 * template<typename T> struct X; 00056 * And you want to specialize it in such a way: 00057 * template<typename S1, typename... SN> struct X<Foo<S1, SN...>> { ::: }; 00058 * template<> struct X<Foo<>> { ::: }; 00059 * This will work in Intel's compiler 13.0, but only to some extent in g++ 4.6, since 00060 * g++ can only match templates called with parameter packs if the number of template 00061 * arguments is not a fixed size (so inside the first specialization, referencing 00062 * X<Foo<Sn...>> will fail in g++). On the other hand, g++ will accept the following: 00063 * template<typename S...> struct X<Foo<S...>> { ::: }: 00064 * as an additional (!) specialization, which will then only match the empty case. 00065 * But Intel's compiler 13.0 won't accept that, it will only accept the empty syntax, 00066 * so we have to create a workaround for this. 00067 */ 00068 #if defined(__GNUC__) && !defined(__INTEL_COMPILER) 00069 #define EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) mt... n 00070 #define EIGEN_TPL_PP_SPEC_HACK_DEFC(mt, n) , EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) 00071 #define EIGEN_TPL_PP_SPEC_HACK_USE(n) n... 00072 #define EIGEN_TPL_PP_SPEC_HACK_USEC(n) , n... 00073 #else 00074 #define EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) 00075 #define EIGEN_TPL_PP_SPEC_HACK_DEFC(mt, n) 00076 #define EIGEN_TPL_PP_SPEC_HACK_USE(n) 00077 #define EIGEN_TPL_PP_SPEC_HACK_USEC(n) 00078 #endif 00079 00080 } // end namespace internal 00081 00082 } // end namespace Eigen 00083 00084 #endif // EIGEN_CXX11WORKAROUNDS_H 00085 00086 /* 00087 * kate: space-indent on; indent-width 2; mixedindent off; indent-mode cstyle; 00088 */