以下代码在MSVC2017和GCC11上都无法编译:
#include <deque>
#include <chrono>
#include <algorithm>
using Clock = std::chrono::system_clock;
using TimePoint = std::chrono::time_point<Clock>;
struct PricePoint
{
TimePoint dt;
double buy;
double sell;
};
inline bool operator < (const TimePoint & dt, const PricePoint & a)
{
return a.dt < dt;
}
int main()
{
std::deque<PricePoint> priceSequence;
const auto begin = std::lower_bound(priceSequence.begin(), priceSequence.end(), Clock::now());
return 0;
}
但是如果我将std::lower_bound
替换为std::upper_bound
,它就开始编译了。两者有什么区别?