mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::fs: Add boolean operators for fd.
This commit is contained in:
parent
6b6106499f
commit
c0e92eb2a1
1 changed files with 24 additions and 4 deletions
|
@ -29,10 +29,9 @@ struct ircd::fs::fd
|
||||||
int fdno{-1};
|
int fdno{-1};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
operator const int &() const
|
operator const int &() const;
|
||||||
{
|
operator bool() const;
|
||||||
return fdno;
|
bool operator!() const;
|
||||||
}
|
|
||||||
|
|
||||||
fd(const string_view &path, const opts &);
|
fd(const string_view &path, const opts &);
|
||||||
fd(const string_view &path);
|
fd(const string_view &path);
|
||||||
|
@ -69,3 +68,24 @@ struct ircd::fs::fd::opts
|
||||||
opts(const std::ios::openmode &);
|
opts(const std::ios::openmode &);
|
||||||
opts() = default;
|
opts() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
ircd::fs::fd::operator!()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return !bool(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ircd::fs::fd::operator
|
||||||
|
bool()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return int(*this) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ircd::fs::fd::operator
|
||||||
|
const int &()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return fdno;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue