25#ifndef SVNXX_TRISTATE_HPP
26#define SVNXX_TRISTATE_HPP
32#if defined(SVNXX_USE_BOOST) || defined(DOXYGEN)
33#include <boost/logic/tribool.hpp>
75 using safe_bool = void (impl::*)();
78 constexpr tristate() noexcept
79 : value(unknown_value)
86 static constexpr tristate
unknown() noexcept
94 constexpr tristate(
bool initial_value) noexcept
95 : value(initial_value ? true_value : false_value)
103 constexpr operator safe_bool() const noexcept
105 return value == true_value ? &impl::trueval : 0;
133 return (value == false_value ? tristate(
true)
134 : (value == true_value ? tristate(
false)
140 enum : std::uint8_t {
146#if defined(SVNXX_USE_BOOST) || defined(DOXYGEN)
154 : value(boost::indeterminate(t) ? unknown_value
155 : (t ? true_value : false_value))
164 constexpr operator boost::tribool() const noexcept
166 return (value == true_value ? boost::tribool(
true)
167 : (value == false_value ? boost::tribool(
false)
168 : boost::tribool(boost::indeterminate)));
178constexpr inline bool unknown(tristate t)
noexcept
180 return bool(t) == bool(!t);
215constexpr inline tristate
operator&&(tristate t, tristate u)
noexcept
217 return (
bool(!t) ||
bool(!u) ? tristate(
false)
218 : (
bool(t) &&
bool(u) ? tristate(
true)
226constexpr inline tristate
operator&&(tristate t,
bool b)
noexcept
228 return b ? t : tristate(
false);
235constexpr inline tristate
operator&&(
bool b, tristate t)
noexcept
237 return b ? t : tristate(
false);
240#if defined(SVNXX_USE_BOOST) || defined(DOXYGEN)
246constexpr inline tristate
operator&&(tristate t, boost::tribool b)
noexcept
248 return t && tristate(b);
256constexpr inline tristate
operator&&(boost::tribool b, tristate t)
noexcept
258 return tristate(b) && t;
294constexpr inline tristate
operator||(tristate t, tristate u)
noexcept
296 return (
bool(!t) &&
bool(!u) ? tristate(
false)
297 : (
bool(t) ||
bool(u) ? tristate(
true)
305constexpr inline tristate
operator||(tristate t,
bool b)
noexcept
307 return b ? tristate(
true) : t;
314constexpr inline tristate
operator||(
bool b, tristate t)
noexcept
316 return b ? tristate(
true) : t;
319#if defined(SVNXX_USE_BOOST) || defined(DOXYGEN)
325constexpr inline tristate
operator||(tristate t, boost::tribool b)
noexcept
327 return t || tristate(b);
335constexpr inline tristate
operator||(boost::tribool b, tristate t)
noexcept
337 return tristate(b) || t;
373constexpr inline tristate
operator==(tristate t, tristate u)
noexcept
376 : ((t && u) || (!t && !u)));
383constexpr inline tristate
operator==(tristate t,
bool b)
noexcept
385 return t == tristate(b);
392constexpr inline tristate
operator==(
bool b, tristate t)
noexcept
394 return tristate(b) == t;
397#if defined(SVNXX_USE_BOOST) || defined(DOXYGEN)
403constexpr inline tristate
operator==(tristate t, boost::tribool b)
noexcept
405 return t == tristate(b);
413constexpr inline tristate
operator==(boost::tribool b, tristate t)
noexcept
415 return tristate(b) == t;
451constexpr inline tristate
operator!=(tristate t, tristate u)
noexcept
454 : !((t && u) || (!t && !u)));
461constexpr inline tristate
operator!=(tristate t,
bool b)
noexcept
463 return t != tristate(b);
470constexpr inline tristate
operator!=(
bool b, tristate t)
noexcept
472 return tristate(b) != t;
475#if defined(SVNXX_USE_BOOST) || defined(DOXYGEN)
481constexpr inline tristate
operator!=(tristate t, boost::tribool b)
noexcept
483 return t != tristate(b);
491constexpr inline tristate
operator!=(boost::tribool b, tristate t)
noexcept
493 return tristate(b) != t;
constexpr bool unknown(tristate t) noexcept
Test for the unknown tristate state.
static constexpr tristate unknown() noexcept
Factory method for the unknown state.
constexpr tristate operator==(tristate t, bool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator!=(tristate t, boost::tribool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator||(boost::tribool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator&&(boost::tribool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator&&(tristate t, bool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator==(boost::tribool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate(bool initial_value) noexcept
Constructor for the true and false states.
constexpr tristate operator&&(bool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator!=(tristate t, bool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator!=(tristate t, tristate u) noexcept
Inquality comparison.
constexpr tristate operator||(bool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator||(tristate t, tristate u) noexcept
Logical disjunction.
constexpr tristate operator||(tristate t, bool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate(boost::tribool t) noexcept
Conversion from boost::tribool.
constexpr tristate operator&&(tristate t, boost::tribool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator==(tristate t, tristate u) noexcept
Equality comparison.
constexpr tristate operator&&(tristate t, tristate u) noexcept
Logical conjunction.
constexpr tristate operator!=(boost::tribool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator!() const noexcept
Logical negation.
constexpr tristate operator==(bool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator==(tristate t, boost::tribool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator!=(bool b, tristate t) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr tristate operator||(tristate t, boost::tribool b) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Subversion's data types (common implementation)
@ svn_tristate_unknown
state could be true or false
@ svn_tristate_true
state known to be true
@ svn_tristate_false
state known to be false (the constant does not evaulate to false)