Abr*_*ile 5 c++ boost-date-time boost-unordered
我想存储boost::gregorian::date为一个键,boost::unordered_map但我无法编译代码,因为它缺少这个类的正确哈希函数.
std::string并存储它.我可能想避免这种解决方案,因为使用字符串非常昂贵.day()函数,我不确定这是否真的合适.有没有其他更好的方法来存储日期或功能导出日期作为数字?
为它实现哈希函数:
namespace boost { namespace gregorian {
inline size_t hash_value(date const& date)
{
return boost::hash_value(date.julian_day());
}
} } // boost::gregorian
Run Code Online (Sandbox Code Playgroud)
julian_day 简直就是朱利安时代开始以来的日间指数(无论是什么).
| 归档时间: |
|
| 查看次数: |
397 次 |
| 最近记录: |