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 #include <numeric>
37 #include <vector>
38 #include <queue>
39 
40 // But if it's not defined, we'll do it.
41 #ifndef M_PI
42  #define M_PI 3.141592653589793238462643383279
43 #endif
44 
45 // MLPACK_COUT_STREAM is used to change the default stream for printing
46 // purpose.
47 #if !defined(MLPACK_COUT_STREAM)
48  #define MLPACK_COUT_STREAM std::cout
49 #endif
50 
51 // MLPACK_CERR_STREAM is used to change the stream for printing warnings
52 // and errors.
53 #if !defined(MLPACK_CERR_STREAM)
54  #define MLPACK_CERR_STREAM std::cerr
55 #endif
56 
57 // Give ourselves a nice way to force functions to be inline if we need.
58 #define force_inline
59 #if defined(__GNUG__) && !defined(DEBUG)
60  #undef force_inline
61  #define force_inline __attribute__((always_inline))
62 #elif defined(_MSC_VER) && !defined(DEBUG)
63  #undef force_inline
64  #define force_inline __forceinline
65 #endif
66 
67 // Backport this functionality from C++14, if it doesn't exist.
68 #if __cplusplus <= 201103L
69 #if !defined(_MSC_VER) || _MSC_VER <= 1800
70 namespace std {
71 
72 template<bool B, class T = void>
73 using enable_if_t = typename enable_if<B, T>::type;
74 
75 }
76 #endif
77 #endif
78 
79 // Backport std::any from C+17 to C++11 to replace boost::any.
80 // Use mnmlstc backport implementation only if compiler does not
81 // support C++17.
82 #if __cplusplus < 201703L
85  #define ANY core::v2::any
86  #define ANY_CAST core::v2::any_cast
87  #define STRING_VIEW core::v2::string_view
88 #else
89  #include <any>
90  #include <string_view>
91  #define ANY std::any
92  #define ANY_CAST std::any_cast
93  #define STRING_VIEW std::string_view
94 #endif
95 
96 // Increase the number of template arguments for the boost list class.
97 #undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
98 #undef BOOST_MPL_LIMIT_LIST_SIZE
99 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
100 #define BOOST_MPL_LIMIT_LIST_SIZE 50
101 
102 // Now include Armadillo through the special mlpack extensions.
103 #include <mlpack/core/arma_extend/arma_extend.hpp>
105 
106 #include <cereal/archives/binary.hpp>
107 #include <cereal/archives/json.hpp>
108 #include <cereal/archives/portable_binary.hpp>
109 #include <cereal/archives/xml.hpp>
110 #include <cereal/types/array.hpp>
111 #include <cereal/types/string.hpp>
112 #include <cereal/types/tuple.hpp>
114 #include <cereal/types/utility.hpp>
115 #include <cereal/types/vector.hpp>
116 
119 #include <mlpack/core/arma_extend/serialize_armadillo.hpp>
124 
125 // On Visual Studio, disable C4519 (default arguments for function templates)
126 // since it's by default an error, which doesn't even make any sense because
127 // it's part of the C++11 standard.
128 #ifdef _MSC_VER
129  #pragma warning(disable : 4519)
130  #define ARMA_USE_CXX11
131 #endif
132 
133 // Ensure that the user isn't doing something stupid with their Armadillo
134 // defines.
136 
137 // All code should have access to logging.
138 #include <mlpack/core/util/log.hpp>
140 
141 // This can be removed with Visual Studio supports an OpenMP version with
142 // unsigned loop variables.
143 #ifdef _WIN32
144  #define omp_size_t intmax_t
145 #else
146  #define omp_size_t size_t
147 #endif
148 
149 // We need to be able to mark functions deprecated.
151 
152 // Include ready to use utility function to check sizes of datasets.
154 
155 #endif
typename enable_if< B, T >::type enable_if_t
Definition: prereqs.hpp:73
This file is backported from cereal 1.3 to support the serialization of objects of type associative c...