Skip to content

Commit

Permalink
Use std headers; deprecate unnecessary macros
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed May 1, 2022
1 parent bbf40d4 commit 349e732
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
11 changes: 9 additions & 2 deletions ql/qldefines.hpp
Expand Up @@ -168,16 +168,23 @@
/*! \def QL_EPSILON
Defines the machine precision for operations over doubles
*/
#include <boost/limits.hpp>
#include <limits>
// limits used as such
#define QL_MIN_INTEGER ((std::numeric_limits<QL_INTEGER>::min)())
#define QL_MAX_INTEGER ((std::numeric_limits<QL_INTEGER>::max)())
#define QL_MIN_REAL -((std::numeric_limits<QL_REAL>::max)())
#define QL_MAX_REAL ((std::numeric_limits<QL_REAL>::max)())
#define QL_MIN_POSITIVE_REAL ((std::numeric_limits<QL_REAL>::min)())
#define QL_EPSILON ((std::numeric_limits<QL_REAL>::epsilon)())
// specific values---these should fit into any Integer or Real
/*! \def QL_NULL_INTEGER
\deprecated Don't use this macro.
Deprecated in version 1.27.
*/
#define QL_NULL_INTEGER ((std::numeric_limits<int>::max)())
/*! \def QL_NULL_REAL
\deprecated Don't use this macro.
Deprecated in version 1.27.
*/
#define QL_NULL_REAL ((std::numeric_limits<float>::max)())
/*! @} */

Expand Down
7 changes: 3 additions & 4 deletions ql/timeseries.hpp
Expand Up @@ -35,6 +35,7 @@
#include <algorithm>
#include <map>
#include <vector>
#include <type_traits>

namespace QuantLib {

Expand Down Expand Up @@ -147,10 +148,8 @@ namespace QuantLib {
// bidirectional_iterator_tag category.
typedef typename boost::mpl::if_ <
boost::mpl::or_ <
boost::is_same<iterator_category,
std::bidirectional_iterator_tag>,
boost::is_base_of<std::bidirectional_iterator_tag,
iterator_category> >,
std::is_same<iterator_category, std::bidirectional_iterator_tag>,
std::is_base_of<std::bidirectional_iterator_tag, iterator_category> >,
std::bidirectional_iterator_tag,
std::input_iterator_tag>::type enable_reverse;

Expand Down
2 changes: 1 addition & 1 deletion ql/utilities/dataformatters.hpp
Expand Up @@ -25,7 +25,7 @@
#define quantlib_data_formatters_hpp

#include <ql/utilities/null.hpp>
#include <iosfwd>
#include <ostream>

namespace QuantLib {

Expand Down
22 changes: 7 additions & 15 deletions ql/utilities/null.hpp
Expand Up @@ -27,17 +27,8 @@
#define quantlib_null_hpp

#include <ql/types.hpp>

#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif

#include <boost/type_traits.hpp>

#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4))
#pragma GCC diagnostic pop
#endif
#include <type_traits>
#include <limits>

namespace QuantLib {

Expand All @@ -55,15 +46,17 @@ namespace QuantLib {
template <>
struct FloatingPointNull<true> {
constexpr static float nullValue() {
return QL_NULL_REAL;
// a specific values that should fit into any Real
return (std::numeric_limits<float>::max)();
}
};

// null value for integer types
template <>
struct FloatingPointNull<false> {
constexpr static int nullValue() {
return QL_NULL_INTEGER;
// a specific values that should fit into any Integer
return (std::numeric_limits<int>::max)();
}
};

Expand All @@ -75,8 +68,7 @@ namespace QuantLib {
public:
constexpr Null() = default;
constexpr operator T() const {
return T(detail::FloatingPointNull<
boost::is_floating_point<T>::value>::nullValue());
return T(detail::FloatingPointNull<std::is_floating_point<T>::value>::nullValue());
}
};

Expand Down

0 comments on commit 349e732

Please sign in to comment.