boostorg / boostorg/date_time

time_duration is not a complete partial order regarding time_duration(not_a_date_time)

Open
#104 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
70
Forks
99
PR merge metrics
No merged PRs in 30d

Description

hi

please compile this program:

#include
#include
#include

using namespace boost::posix_time;
using namespace std;

#define x(v) cout << #v << " : " << (v) << '\n';

int main(int argc, char *argv[])
{
time_duration a(not_a_date_time);
time_duration b;
x(ab);
x(a<=b);
x(a>=b);
x(ba);
x(b<=a);
x(b>=a);
x(a==b);
x(b==a);
x(a.is_special());
x(b.is_special());
vector v0, v1;
v0.push_back(time_duration());
v0.push_back(time_duration(not_a_date_time));
sort(v0.begin(), v0.end());
v1.push_back(time_duration(not_a_date_time));
v1.push_back(time_duration());
sort(v1.begin(), v1.end());
x(v0==v1);

map c,d;
c[time_duration()]=5;
c[time_duration(not_a_date_time)]=7;
d[time_duration(not_a_date_time)]=7;
d[time_duration()]=5;
x(c==d);

return 0;
}

the output is:

ab : 0
a<=b : 1
a>=b : 1
ba : 0
b<=a : 1
b>=a : 1
a==b : 0
b==a : 0
a.is_special() : 1
b.is_special() : 0
v0==v1 : 0
c==d : 0

if the time_duration datatype is a complete partial order which is for
example needed for it to be able to be sorted, then the above output is
partly illegal:

if not a

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.