I am trying to compile some piece of code referencing QuantLib, using Visual Studio 2017 and the Microsoft C++ compiler.
Whilst I do not get any specific compilation error flagged in the code I've written, I am stuck with the following compilation error:
Error C2676: binary '<': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator
Visual Studio seems to point to the implementation of the templated std::min()
function, found at line 5426 in the algorithm
file:
c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\algorithm 5426
However, the full output stack from Visual Studio is as follows - and more specifically, it points to the placeholders.hpp
header for boost
, as well as the fact that QuantLib::Date
seems to be involved:
1>QLTest.cpp
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\algorithm(5426): error C2676: binary '<': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator
1> with
1> [
1> _Ty=QuantLib::Date
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\algorithm(5425): note: see reference to function template instantiation 'const _Ty &std::min<QuantLib::Date>(const _Ty &,const _Ty &) noexcept(<expr>)' being compiled
1> with
1> [
1> _Ty=QuantLib::Date
1> ]
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(66): note: see reference to class template instantiation 'boost::arg<9>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(65): note: see reference to class template instantiation 'boost::arg<8>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(64): note: see reference to class template instantiation 'boost::arg<7>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(63): note: see reference to class template instantiation 'boost::arg<6>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(62): note: see reference to class template instantiation 'boost::arg<5>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(61): note: see reference to class template instantiation 'boost::arg<4>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(60): note: see reference to class template instantiation 'boost::arg<3>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(59): note: see reference to class template instantiation 'boost::arg<2>' being compiled
1>c:\local\boost_1_76_0\boost\bind\placeholders.hpp(58): note: see reference to class template instantiation 'boost::arg<1>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.16.27023\include\algorithm(5426): error C2056: illegal expression
I am not sure I understand the issue here, especially because QuantLib::Date
indeed implements overloads for the binary <
operator.
EDIT 14 Jul 2021:
Here is a minimal piece of code that reproduces the compilation error on my side - I have collated the various include
and using
statements throughout the headers in my code in a single place. Also note that I have removed the using namespace std
as suggested, but the error remained:
#ifdef BOOST_MSVC
# include <ql/auto_link.hpp>
#endif
#include <ql/termstructures/yieldtermstructure.hpp>
#include <ql/math/interpolations/cubicinterpolation.hpp>
#include <ql/math/interpolations/backwardflatinterpolation.hpp>
#include <ql/math/optimization/simplex.hpp>
#include <ql/math/integrals/gausslobattointegral.hpp>
#include <ql/termstructures/yield/discountcurve.hpp>
#include <ql/interestrate.hpp>
#include <string>
#include <iostream>
#include <ql/quantlib.hpp>
#include <ql/qldefines.hpp>
#include <ql/termstructures/iterativebootstrap.hpp>
#include <ql/termstructures/yield/piecewiseyieldcurve.hpp>
#include <ql/termstructures/yieldtermstructure.hpp>
#include <ql/termstructures/yield/ratehelpers.hpp>
#include <ql/time/daycounters/actual360.hpp>
#include <ql/time/daycounters/thirty360.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
#include <ql/math/solvers1d/newton.hpp>
#include <ql/math/interpolations/linearinterpolation.hpp>
#include <ql/termstructures/ErisRangeFitting.hpp>
#include <map>
#include <vector>
#include <exception>
#include <filesystem>
#include <ql/indexes/ibor/fedfunds.hpp>
#include <ql/indexes/ibor/sofr.hpp>
#include <ql/indexes/ibor/usdlibor.hpp>
#include <ql/math/interpolations/all.hpp>
#include <ql/termstructures/iterativebootstrap.hpp>
#include <ql/instruments/bonds/fixedratebond.hpp>
#include <ql/math/integrals/trapezoidintegral.hpp>
#include <ql/pricingengines/bond/bondfunctions.hpp>
#include <ql/time/calendars/jointcalendar.hpp>
#include <ql/time/calendars/unitedkingdom.hpp>
#include <ql/time/calendars/unitedstates.hpp>
#include <ql/time/daycounters/actualactual.hpp>
#include <ql/time/imm.hpp>
#include <ctime>
#include <iomanip>
#include <ql\termstructures\yield\fittedbonddiscountcurve.hpp>
#include <ql\termstructures\yield\nonlinearfittingmethods.hpp>
#include <ql\termstructures\yield\piecewiseyieldcurve.hpp>
#include <sys/stat.h>
using namespace QuantLib;
int main()
{
}