prereqs.hpp
Go to the documentation of this file.
1 
11 #ifndef MLPACK_PREREQS_HPP
12 #define MLPACK_PREREQS_HPP
13 
14 // First, check if Armadillo was included before, warning if so.
15 #ifdef ARMA_INCLUDES
16 #pragma message "Armadillo was included before mlpack; this can sometimes cause\
17  problems. It should only be necessary to include <mlpack/core.hpp> and not \
18 <armadillo>."
19 #endif
20 
21 // Defining _USE_MATH_DEFINES should set M_PI.
22 #define _USE_MATH_DEFINES
23 #include <cmath>
24 
25 // Next, standard includes.
26 #include <cctype>
27 #include <cfloat>
28 #include <climits>
29 #include <cstdint>
30 #include <cstdio>
31 #include <cstdlib>
32 #include <cstring>
33 #include <stdexcept>
34 #include <tuple>
35 #include <utility>
36 
37 // But if it's not defined, we'll do it.
38 #ifndef M_PI
39  #define M_PI 3.141592653589793238462643383279
40 #endif
41 
42 // MLPACK_COUT_STREAM is used to change the default stream for printing
43 // purpose.
44 #if !defined(MLPACK_COUT_STREAM)
45  #define MLPACK_COUT_STREAM std::cout
46 #endif
47 
48 // MLPACK_CERR_STREAM is used to change the stream for printing warnings
49 // and errors.
50 #if !defined(MLPACK_CERR_STREAM)
51  #define MLPACK_CERR_STREAM std::cerr
52 #endif
53 
54 // Give ourselves a nice way to force functions to be inline if we need.
55 #define force_inline
56 #if defined(__GNUG__) && !defined(DEBUG)
57  #undef force_inline
58  #define force_inline __attribute__((always_inline))
59 #elif defined(_MSC_VER) && !defined(DEBUG)
60  #undef force_inline
61  #define force_inline __forceinline
62 #endif
63 
64 // Backport this functionality from C++14, if it doesn't exist.
65 #if __cplusplus <= 201103L
66 #if !defined(_MSC_VER) || _MSC_VER <= 1800
67 namespace std {
68 
69 template<bool B, class T = void>
70 using enable_if_t = typename enable_if<B, T>::type;
71 
72 }
73 #endif
74 #endif
75 
76 // Backport std::any from C+17 to C++11 to replace boost::any.
77 // Use mnmlstc backport implementation only if compiler does not
78 // support C++17.
79 #if __cplusplus < 201703L
82  #define ANY core::v2::any
83  #define ANY_CAST core::v2::any_cast
84  #define STRING_VIEW core::v2::string_view
85 #else
86  #include <any>
87  #include <string_view>
88  #define ANY std::any
89  #define ANY_CAST std::any_cast
90  #define STRING_VIEW std::string_view
91 #endif
92 
93 // Increase the number of template arguments for the boost list class.
94 #undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
95 #undef BOOST_MPL_LIMIT_LIST_SIZE
96 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
97 #define BOOST_MPL_LIMIT_LIST_SIZE 50
98 
99 // Now include Armadillo through the special mlpack extensions.
100 #include <mlpack/core/arma_extend/arma_extend.hpp>
102 
103 #include <cereal/archives/binary.hpp>
104 #include <cereal/archives/json.hpp>
105 #include <cereal/archives/portable_binary.hpp>
106 #include <cereal/archives/xml.hpp>
107 #include <cereal/types/array.hpp>
108 #include <cereal/types/boost_variant.hpp>
109 #include <cereal/types/string.hpp>
110 #include <cereal/types/tuple.hpp>
112 #include <cereal/types/utility.hpp>
113 #include <cereal/types/vector.hpp>
114 
117 #include <mlpack/core/arma_extend/serialize_armadillo.hpp>
124 
125 // If we have Boost 1.58 or older and are using C++14, the compilation is likely
126 // to fail due to boost::visitor issues. We will pre-emptively fail.
127 #if __cplusplus > 201103L && BOOST_VERSION < 105900
128 #error Use of C++14 mode with Boost < 1.59 is known to cause compilation \
129 problems. Instead specify the C++11 standard (-std=c++11 with gcc or clang), \
130 or upgrade Boost to 1.59 or newer.
131 #endif
132 
133 // On Visual Studio, disable C4519 (default arguments for function templates)
134 // since it's by default an error, which doesn't even make any sense because
135 // it's part of the C++11 standard.
136 #ifdef _MSC_VER
137  #pragma warning(disable : 4519)
138  #define ARMA_USE_CXX11
139 #endif
140 
141 // Ensure that the user isn't doing something stupid with their Armadillo
142 // defines.
144 
145 // All code should have access to logging.
146 #include <mlpack/core/util/log.hpp>
148 
149 // This can be removed with Visual Studio supports an OpenMP version with
150 // unsigned loop variables.
151 #ifdef _WIN32
152  #define omp_size_t intmax_t
153 #else
154  #define omp_size_t size_t
155 #endif
156 
157 // We need to be able to mark functions deprecated.
159 
160 // Include ready to use utility function to check sizes of datasets.
162 
163 #endif
typename enable_if< B, T >::type enable_if_t
Definition: prereqs.hpp:70
This file is backported from cereal 1.3 to support the serialization of objects of type associative c...