mlpack 3.4.2
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 <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
67namespace std {
68
69template<bool B, class T = void>
70using 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// We'll need the necessary boost::serialization features, as well as what we
83// use with mlpack. In Boost 1.59 and newer, the BOOST_PFTO code is no longer
84// defined, but we still need to define it (as nothing) so that the mlpack
85// serialization shim compiles.
86#include <boost/serialization/serialization.hpp>
87// We are not including boost/serialization/vector.hpp here. It is included in
88// mlpack/core/boost_backport/boost_backport_serialization.hpp because of
89// different behaviors of vector serialization in different versions of boost.
90// #include <boost/serialization/vector.hpp>
91#include <boost/serialization/map.hpp>
92// boost_backport.hpp handles the version and backporting of serialization (and
93// other) features.
94#include "mlpack/core/boost_backport/boost_backport_serialization.hpp"
95// Boost 1.59 and newer don't use BOOST_PFTO, but our shims do. We can resolve
96// any issue by setting BOOST_PFTO to nothing.
97#ifndef BOOST_PFTO
98 #define BOOST_PFTO
99#endif
102
103// If we have Boost 1.58 or older and are using C++14, the compilation is likely
104// to fail due to boost::visitor issues. We will pre-emptively fail.
105#if __cplusplus > 201103L && BOOST_VERSION < 105900
106#error Use of C++14 mode with Boost < 1.59 is known to cause compilation \
107problems. Instead specify the C++11 standard (-std=c++11 with gcc or clang), \
108or upgrade Boost to 1.59 or newer.
109#endif
110
111// On Visual Studio, disable C4519 (default arguments for function templates)
112// since it's by default an error, which doesn't even make any sense because
113// it's part of the C++11 standard.
114#ifdef _MSC_VER
115 #pragma warning(disable : 4519)
116 #define ARMA_USE_CXX11
117#endif
118
119// Now include Armadillo through the special mlpack extensions.
120#include <mlpack/core/arma_extend/arma_extend.hpp>
122
123// Ensure that the user isn't doing something stupid with their Armadillo
124// defines.
126
127// All code should have access to logging.
130
131// This can be removed with Visual Studio supports an OpenMP version with
132// unsigned loop variables.
133#ifdef _WIN32
134 #define omp_size_t intmax_t
135#else
136 #define omp_size_t size_t
137#endif
138
139// We need to be able to mark functions deprecated.
141
142#endif
Definition: prereqs.hpp:67
typename enable_if< B, T >::type enable_if_t
Definition: prereqs.hpp:70