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 // Increase the number of template arguments for the boost list class.
77 #undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
78 #undef BOOST_MPL_LIMIT_LIST_SIZE
79 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
80 #define BOOST_MPL_LIMIT_LIST_SIZE 50
81 
82 // Now include Armadillo through the special mlpack extensions.
83 #include <mlpack/core/arma_extend/arma_extend.hpp>
85 
86 #include <cereal/archives/binary.hpp>
87 #include <cereal/archives/json.hpp>
88 #include <cereal/archives/portable_binary.hpp>
89 #include <cereal/archives/xml.hpp>
90 #include <cereal/types/array.hpp>
91 #include <cereal/types/boost_variant.hpp>
92 #include <cereal/types/string.hpp>
93 #include <cereal/types/tuple.hpp>
95 #include <cereal/types/utility.hpp>
96 #include <cereal/types/vector.hpp>
97 
100 #include <mlpack/core/arma_extend/serialize_armadillo.hpp>
107 
108 // If we have Boost 1.58 or older and are using C++14, the compilation is likely
109 // to fail due to boost::visitor issues. We will pre-emptively fail.
110 #if __cplusplus > 201103L && BOOST_VERSION < 105900
111 #error Use of C++14 mode with Boost < 1.59 is known to cause compilation \
112 problems. Instead specify the C++11 standard (-std=c++11 with gcc or clang), \
113 or upgrade Boost to 1.59 or newer.
114 #endif
115 
116 // On Visual Studio, disable C4519 (default arguments for function templates)
117 // since it's by default an error, which doesn't even make any sense because
118 // it's part of the C++11 standard.
119 #ifdef _MSC_VER
120  #pragma warning(disable : 4519)
121  #define ARMA_USE_CXX11
122 #endif
123 
124 // Ensure that the user isn't doing something stupid with their Armadillo
125 // defines.
127 
128 // All code should have access to logging.
129 #include <mlpack/core/util/log.hpp>
131 
132 // This can be removed with Visual Studio supports an OpenMP version with
133 // unsigned loop variables.
134 #ifdef _WIN32
135  #define omp_size_t intmax_t
136 #else
137  #define omp_size_t size_t
138 #endif
139 
140 // We need to be able to mark functions deprecated.
142 
143 #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...