Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
include
hebi
Eigen
unsupported
Eigen
CXX11
src
util
CXX11Workarounds.h
Go to the documentation of this file.
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
4
// Copyright (C) 2013 Christian Seiler <christian@iwakd.de>
5
//
6
// This Source Code Form is subject to the terms of the Mozilla
7
// Public License v. 2.0. If a copy of the MPL was not distributed
8
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10
#ifndef EIGEN_CXX11WORKAROUNDS_H
11
#define EIGEN_CXX11WORKAROUNDS_H
12
13
/* COMPATIBILITY CHECKS
14
* (so users of compilers that are too old get some realistic error messages)
15
*/
16
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1310)
17
#error Intel Compiler only supports required C++ features since version 13.1.
18
// note that most stuff in principle works with 13.0 but when combining
19
// some features, at some point 13.0 will just fail with an internal assertion
20
#elif defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
21
// G++ < 4.6 by default will continue processing the source files - even if we use #error to make
22
// it error out. For this reason, we use the pragma to make sure G++ aborts at the first error
23
// it sees. Unfortunately, that is still not our #error directive, but at least the output is
24
// short enough the user has a chance to see that the compiler version is not sufficient for
25
// the funky template mojo we use.
26
#pragma GCC diagnostic error "-Wfatal-errors"
27
#error GNU C++ Compiler (g++) only supports required C++ features since version 4.6.
28
#endif
29
30
/* Check that the compiler at least claims to support C++11. It might not be sufficient
31
* because the compiler may not implement it correctly, but at least we'll know.
32
* On the other hand, visual studio still doesn't claim to support C++11 although it's
33
* compliant enugh for our purpose.
34
*/
35
#if (__cplusplus <= 199711L) && (EIGEN_COMP_MSVC < 1900)
36
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
37
#pragma GCC diagnostic error "-Wfatal-errors"
38
#endif
39
#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.)
40
#endif
41
42
namespace
Eigen
{
43
44
namespace
internal
{
45
46
/* std::get is only constexpr in C++14, not yet in C++11
47
*/
48
49
50
template
<std::
size_t
I,
class
T> constexpr
inline
T&
array_get
(std::vector<T>& a) {
return
a[I]; }
51
template
<std::
size_t
I,
class
T> constexpr
inline
T&&
array_get
(std::vector<T>&& a) {
return
a[I]; }
52
template
<std::
size_t
I,
class
T> constexpr
inline
T
const
&
array_get
(std::vector<T>
const
& a) {
return
a[I]; }
53
54
/* Suppose you have a template of the form
55
* template<typename T> struct X;
56
* And you want to specialize it in such a way:
57
* template<typename S1, typename... SN> struct X<Foo<S1, SN...>> { ::: };
58
* template<> struct X<Foo<>> { ::: };
59
* This will work in Intel's compiler 13.0, but only to some extent in g++ 4.6, since
60
* g++ can only match templates called with parameter packs if the number of template
61
* arguments is not a fixed size (so inside the first specialization, referencing
62
* X<Foo<Sn...>> will fail in g++). On the other hand, g++ will accept the following:
63
* template<typename S...> struct X<Foo<S...>> { ::: }:
64
* as an additional (!) specialization, which will then only match the empty case.
65
* But Intel's compiler 13.0 won't accept that, it will only accept the empty syntax,
66
* so we have to create a workaround for this.
67
*/
68
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
69
#define EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n) mt... n
70
#define EIGEN_TPL_PP_SPEC_HACK_DEFC(mt, n) , EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n)
71
#define EIGEN_TPL_PP_SPEC_HACK_USE(n) n...
72
#define EIGEN_TPL_PP_SPEC_HACK_USEC(n) , n...
73
#else
74
#define EIGEN_TPL_PP_SPEC_HACK_DEF(mt, n)
75
#define EIGEN_TPL_PP_SPEC_HACK_DEFC(mt, n)
76
#define EIGEN_TPL_PP_SPEC_HACK_USE(n)
77
#define EIGEN_TPL_PP_SPEC_HACK_USEC(n)
78
#endif
79
80
}
// end namespace internal
81
82
}
// end namespace Eigen
83
84
#endif // EIGEN_CXX11WORKAROUNDS_H
85
86
/*
87
* kate: space-indent on; indent-width 2; mixedindent off; indent-mode cstyle;
88
*/
Eigen
Definition:
LDLT.h:16
internal
Definition:
Eigen_Colamd.h:50
Eigen::internal::array_get
const Index array_get(DimensionList< Index, Rank > &)
Definition:
TensorDimensionList.h:39
hebiros
Author(s): Xavier Artache
, Matthew Tesch
autogenerated on Thu Sep 3 2020 04:08:09