| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2018 StatPro Italia srl |
| 5 | |
| 6 | This file is part of QuantLib, a free-software/open-source library |
| 7 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 8 | |
| 9 | QuantLib is free software: you can redistribute it and/or modify it |
| 10 | under the terms of the QuantLib license. You should have received a |
| 11 | copy of the license along with this program; if not, please email |
| 12 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 13 | <http://quantlib.org/license.shtml>. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 18 | */ |
| 19 | |
| 20 | /*! \file ql/functional.hpp |
| 21 | \brief Maps function, bind and cref to either the boost or std implementation |
| 22 | */ |
| 23 | |
| 24 | #ifndef quantlib_functional_hpp |
| 25 | #define quantlib_functional_hpp |
| 26 | |
| 27 | #include <ql/qldefines.hpp> |
| 28 | |
| 29 | #if defined(QL_USE_STD_FUNCTION) |
| 30 | #include <functional> |
| 31 | #else |
| 32 | #include <boost/function.hpp> |
| 33 | #include <boost/bind/bind.hpp> |
| 34 | #include <boost/ref.hpp> |
| 35 | #endif |
| 36 | |
| 37 | namespace QuantLib { |
| 38 | |
| 39 | namespace ext { |
| 40 | |
| 41 | #if defined(QL_USE_STD_FUNCTION) |
| 42 | using std::function; // NOLINT(misc-unused-using-decls) |
| 43 | using std::bind; // NOLINT(misc-unused-using-decls) |
| 44 | using std::ref; // NOLINT(misc-unused-using-decls) |
| 45 | using std::cref; // NOLINT(misc-unused-using-decls) |
| 46 | namespace placeholders { |
| 47 | using namespace std::placeholders; // NOLINT(misc-unused-using-decls) |
| 48 | } |
| 49 | /*! \deprecated To check if a function is empty, use it in a bool context |
| 50 | instead of comparing it to QL_NULL_FUNCTION. |
| 51 | Deprecated in version 1.32. |
| 52 | */ |
| 53 | #define QL_NULL_FUNCTION nullptr |
| 54 | #else |
| 55 | using boost::function; // NOLINT(misc-unused-using-decls) |
| 56 | using boost::bind; // NOLINT(misc-unused-using-decls) |
| 57 | using boost::ref; // NOLINT(misc-unused-using-decls) |
| 58 | using boost::cref; // NOLINT(misc-unused-using-decls) |
| 59 | namespace placeholders { |
| 60 | #if BOOST_VERSION >= 106000 |
| 61 | using namespace boost::placeholders; // NOLINT(misc-unused-using-decls) |
| 62 | #else |
| 63 | using ::_1; // NOLINT(misc-unused-using-decls) |
| 64 | using ::_2; // NOLINT(misc-unused-using-decls) |
| 65 | using ::_3; // NOLINT(misc-unused-using-decls) |
| 66 | using ::_4; // NOLINT(misc-unused-using-decls) |
| 67 | using ::_5; // NOLINT(misc-unused-using-decls) |
| 68 | using ::_6; // NOLINT(misc-unused-using-decls) |
| 69 | using ::_7; // NOLINT(misc-unused-using-decls) |
| 70 | using ::_8; // NOLINT(misc-unused-using-decls) |
| 71 | using ::_9; // NOLINT(misc-unused-using-decls) |
| 72 | #endif |
| 73 | } |
| 74 | /*! \deprecated To check if a function is empty, use it in a bool context |
| 75 | instead of comparing it to QL_NULL_FUNCTION. |
| 76 | Deprecated in version 1.32. |
| 77 | */ |
| 78 | #define QL_NULL_FUNCTION 0 |
| 79 | #endif |
| 80 | |
| 81 | } |
| 82 | |
| 83 | } |
| 84 | |
| 85 | |
| 86 | #endif |
| 87 | |
| 88 | |