mlpack  master
prereqs.hpp
Go to the documentation of this file.
1 
11 #ifndef MLPACK_PREREQS_HPP
12 #define MLPACK_PREREQS_HPP
13 
14 // Defining _USE_MATH_DEFINES should set M_PI.
15 #define _USE_MATH_DEFINES
16 #include <cmath>
17 
18 // First, check if Armadillo was included before, warning if so.
19 #ifdef ARMA_INCLUDES
20 #pragma message "Armadillo was included before mlpack; this can sometimes cause\
21  problems. It should only be necessary to include <mlpack/core.hpp> and not \
22 <armadillo>."
23 #endif
24 
25 // Next, standard includes.
26 #include <cstdlib>
27 #include <cstdio>
28 #include <cstring>
29 #include <cctype>
30 #include <climits>
31 #include <cfloat>
32 #include <cstdint>
33 #include <iostream>
34 #include <stdexcept>
35 #include <tuple>
36 #include <queue>
37 
38 // But if it's not defined, we'll do it.
39 #ifndef M_PI
40  #define M_PI 3.141592653589793238462643383279
41 #endif
42 
43 // Give ourselves a nice way to force functions to be inline if we need.
44 #define force_inline
45 #if defined(__GNUG__) && !defined(DEBUG)
46  #undef force_inline
47  #define force_inline __attribute__((always_inline))
48 #elif defined(_MSC_VER) && !defined(DEBUG)
49  #undef force_inline
50  #define force_inline __forceinline
51 #endif
52 
53 // Backport this functionality from C++14, if it doesn't exist.
54 #if __cplusplus <= 201103L
55 #if !defined(_MSC_VER) || _MSC_VER <= 1800
56 namespace std {
57 
58 template<bool B, class T = void>
59 using enable_if_t = typename enable_if<B, T>::type;
60 
61 }
62 #endif
63 #endif
64 
65 // Increase the number of template arguments for the boost list class.
66 #undef BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
67 #undef BOOST_MPL_LIMIT_LIST_SIZE
68 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
69 #define BOOST_MPL_LIMIT_LIST_SIZE 40
70 
71 // We'll need the necessary boost::serialization features, as well as what we
72 // use with mlpack. In Boost 1.59 and newer, the BOOST_PFTO code is no longer
73 // defined, but we still need to define it (as nothing) so that the mlpack
74 // serialization shim compiles.
75 #include <boost/serialization/serialization.hpp>
76 #include <boost/serialization/vector.hpp>
77 #include <boost/serialization/map.hpp>
78 // boost_backport.hpp handles the version and backporting of serialization (and
79 // other) features.
80 #include "mlpack/core/boost_backport/boost_backport_serialization.hpp"
81 // Boost 1.59 and newer don't use BOOST_PFTO, but our shims do. We can resolve
82 // any issue by setting BOOST_PFTO to nothing.
83 #ifndef BOOST_PFTO
84  #define BOOST_PFTO
85 #endif
88 
89 // Now include Armadillo through the special mlpack extensions.
90 #include <mlpack/core/arma_extend/arma_extend.hpp>
92 
93 // Ensure that the user isn't doing something stupid with their Armadillo
94 // defines.
96 
97 // All code should have access to logging
98 #include <mlpack/core/util/log.hpp>
100 
101 // On Visual Studio, disable C4519 (default arguments for function templates)
102 // since it's by default an error, which doesn't even make any sense because
103 // it's part of the C++11 standard.
104 #ifdef _MSC_VER
105  #pragma warning(disable : 4519)
106  #define ARMA_USE_CXX11
107 #endif
108 
109 #endif
Definition: prereqs.hpp:56
typename enable_if< B, T >::type enable_if_t
Definition: prereqs.hpp:59