mirror of
https://github.com/boostorg/logic.git
synced 2025-06-26 20:41:34 +02:00
Compare commits
1 Commits
boost-1.62
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
3781ee6709 |
@ -1,13 +1,3 @@
|
|||||||
# Tribool library
|
|
||||||
|
|
||||||
# Copyright (C) 2002-2003 Douglas Gregor
|
|
||||||
|
|
||||||
# Use, modification and distribution is subject to the Boost Software License,
|
|
||||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
# For more information, see http://www.boost.org/
|
|
||||||
|
|
||||||
project boost-sandbox/utility/doc ;
|
project boost-sandbox/utility/doc ;
|
||||||
import boostbook ;
|
import boostbook ;
|
||||||
import doxygen ;
|
import doxygen ;
|
||||||
@ -16,11 +6,4 @@ doxygen reference : [ glob ../../../boost/logic/tribool.hpp ]
|
|||||||
[ glob ../../../boost/logic/tribool_fwd.hpp ]
|
[ glob ../../../boost/logic/tribool_fwd.hpp ]
|
||||||
[ glob ../../../boost/logic/tribool_io.hpp ]
|
[ glob ../../../boost/logic/tribool_io.hpp ]
|
||||||
;
|
;
|
||||||
boostbook tribool
|
boostbook tribool : tribool.boostbook ;
|
||||||
:
|
|
||||||
tribool.boostbook
|
|
||||||
:
|
|
||||||
<xsl:param>boost.root=../../../..
|
|
||||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
|
|
||||||
<dependency>reference
|
|
||||||
;
|
|
||||||
|
@ -138,18 +138,6 @@ if (<functionname>indeterminate</functionname>(x)) {
|
|||||||
else {
|
else {
|
||||||
// report success or failure of x
|
// report success or failure of x
|
||||||
}</programlisting>
|
}</programlisting>
|
||||||
|
|
||||||
<para> All the logical operators and methods of <code><classname>tribool</classname></code> are marked
|
|
||||||
as <code>constexpr</code> in C++11. It means that <code><classname>tribool</classname></code> can
|
|
||||||
be used in compile time expressions:</para>
|
|
||||||
|
|
||||||
<programlisting>constexpr <classname>tribool</classname> x = (tribool(true) || tribool(indeterminate));
|
|
||||||
<functionname>static_assert</functionname>(x, "Must be true!");
|
|
||||||
</programlisting>
|
|
||||||
|
|
||||||
<note>Some compilers may have troubles with evaluating <code>tribool::operator safe_bool()</code> at compile time.</note>
|
|
||||||
|
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
|
|
||||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
#if BOOST_WORKAROUND(_MSC_VER, >= 1200)
|
||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ typedef bool (*indeterminate_keyword_t)(tribool, detail::indeterminate_t);
|
|||||||
* \returns <tt>x.value == tribool::indeterminate_value</tt>
|
* \returns <tt>x.value == tribool::indeterminate_value</tt>
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline bool
|
inline bool
|
||||||
indeterminate(tribool x,
|
indeterminate(tribool x,
|
||||||
detail::indeterminate_t dummy = detail::indeterminate_t()) BOOST_NOEXCEPT;
|
detail::indeterminate_t dummy = detail::indeterminate_t());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A 3-state boolean type.
|
* \brief A 3-state boolean type.
|
||||||
@ -85,7 +85,7 @@ public:
|
|||||||
*
|
*
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR tribool() BOOST_NOEXCEPT : value(false_value) {}
|
tribool() : value(false_value) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new 3-state boolean value with the given boolean
|
* Construct a new 3-state boolean value with the given boolean
|
||||||
@ -93,14 +93,14 @@ public:
|
|||||||
*
|
*
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR tribool(bool initial_value) BOOST_NOEXCEPT : value(initial_value? true_value : false_value) {}
|
tribool(bool value) : value(value? true_value : false_value) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new 3-state boolean value with an indeterminate value.
|
* Construct a new 3-state boolean value with an indeterminate value.
|
||||||
*
|
*
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR tribool(indeterminate_keyword_t) BOOST_NOEXCEPT : value(indeterminate_value) {}
|
tribool(indeterminate_keyword_t) : value(indeterminate_value) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a 3-state boolean in a boolean context. Will evaluate true in a
|
* Use a 3-state boolean in a boolean context. Will evaluate true in a
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
* \returns true if the 3-state boolean is true, false otherwise
|
* \returns true if the 3-state boolean is true, false otherwise
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR operator safe_bool() const BOOST_NOEXCEPT
|
operator safe_bool() const
|
||||||
{
|
{
|
||||||
return value == true_value? &dummy::nonnull : 0;
|
return value == true_value? &dummy::nonnull : 0;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
|
|
||||||
// Check if the given tribool has an indeterminate value. Also doubles as a
|
// Check if the given tribool has an indeterminate value. Also doubles as a
|
||||||
// keyword for the 'indeterminate' value
|
// keyword for the 'indeterminate' value
|
||||||
BOOST_CONSTEXPR inline bool indeterminate(tribool x, detail::indeterminate_t) BOOST_NOEXCEPT
|
inline bool indeterminate(tribool x, detail::indeterminate_t)
|
||||||
{
|
{
|
||||||
return x.value == tribool::indeterminate_value;
|
return x.value == tribool::indeterminate_value;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ BOOST_CONSTEXPR inline bool indeterminate(tribool x, detail::indeterminate_t) BO
|
|||||||
* </table>
|
* </table>
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator!(tribool x) BOOST_NOEXCEPT
|
inline tribool operator!(tribool x)
|
||||||
{
|
{
|
||||||
return x.value == tribool::false_value? tribool(true)
|
return x.value == tribool::false_value? tribool(true)
|
||||||
:x.value == tribool::true_value? tribool(false)
|
:x.value == tribool::true_value? tribool(false)
|
||||||
@ -196,36 +196,38 @@ BOOST_CONSTEXPR inline tribool operator!(tribool x) BOOST_NOEXCEPT
|
|||||||
* </table>
|
* </table>
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator&&(tribool x, tribool y) BOOST_NOEXCEPT
|
inline tribool operator&&(tribool x, tribool y)
|
||||||
{
|
{
|
||||||
return (static_cast<bool>(!x) || static_cast<bool>(!y))
|
if (static_cast<bool>(!x) || static_cast<bool>(!y))
|
||||||
? tribool(false)
|
return false;
|
||||||
: ((static_cast<bool>(x) && static_cast<bool>(y)) ? tribool(true) : indeterminate)
|
else if (static_cast<bool>(x) && static_cast<bool>(y))
|
||||||
;
|
return true;
|
||||||
|
else
|
||||||
|
return indeterminate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator&&(tribool x, bool y) BOOST_NOEXCEPT
|
inline tribool operator&&(tribool x, bool y)
|
||||||
{ return y? x : tribool(false); }
|
{ return y? x : tribool(false); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator&&(bool x, tribool y) BOOST_NOEXCEPT
|
inline tribool operator&&(bool x, tribool y)
|
||||||
{ return x? y : tribool(false); }
|
{ return x? y : tribool(false); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator&&(indeterminate_keyword_t, tribool x) BOOST_NOEXCEPT
|
inline tribool operator&&(indeterminate_keyword_t, tribool x)
|
||||||
{ return !x? tribool(false) : tribool(indeterminate); }
|
{ return !x? tribool(false) : tribool(indeterminate); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator&&(tribool x, indeterminate_keyword_t) BOOST_NOEXCEPT
|
inline tribool operator&&(tribool x, indeterminate_keyword_t)
|
||||||
{ return !x? tribool(false) : tribool(indeterminate); }
|
{ return !x? tribool(false) : tribool(indeterminate); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,36 +263,38 @@ BOOST_CONSTEXPR inline tribool operator&&(tribool x, indeterminate_keyword_t) BO
|
|||||||
* </table>
|
* </table>
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator||(tribool x, tribool y) BOOST_NOEXCEPT
|
inline tribool operator||(tribool x, tribool y)
|
||||||
{
|
{
|
||||||
return (static_cast<bool>(!x) && static_cast<bool>(!y))
|
if (static_cast<bool>(!x) && static_cast<bool>(!y))
|
||||||
? tribool(false)
|
return false;
|
||||||
: ((static_cast<bool>(x) || static_cast<bool>(y)) ? tribool(true) : tribool(indeterminate))
|
else if (static_cast<bool>(x) || static_cast<bool>(y))
|
||||||
;
|
return true;
|
||||||
|
else
|
||||||
|
return indeterminate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator||(tribool x, bool y) BOOST_NOEXCEPT
|
inline tribool operator||(tribool x, bool y)
|
||||||
{ return y? tribool(true) : x; }
|
{ return y? tribool(true) : x; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator||(bool x, tribool y) BOOST_NOEXCEPT
|
inline tribool operator||(bool x, tribool y)
|
||||||
{ return x? tribool(true) : y; }
|
{ return x? tribool(true) : y; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator||(indeterminate_keyword_t, tribool x) BOOST_NOEXCEPT
|
inline tribool operator||(indeterminate_keyword_t, tribool x)
|
||||||
{ return x? tribool(true) : tribool(indeterminate); }
|
{ return x? tribool(true) : tribool(indeterminate); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator||(tribool x, indeterminate_keyword_t) BOOST_NOEXCEPT
|
inline tribool operator||(tribool x, indeterminate_keyword_t)
|
||||||
{ return x? tribool(true) : tribool(indeterminate); }
|
{ return x? tribool(true) : tribool(indeterminate); }
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
@ -327,34 +331,34 @@ BOOST_CONSTEXPR inline tribool operator||(tribool x, indeterminate_keyword_t) BO
|
|||||||
* </table>
|
* </table>
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator==(tribool x, tribool y) BOOST_NOEXCEPT
|
inline tribool operator==(tribool x, tribool y)
|
||||||
{
|
{
|
||||||
return (indeterminate(x) || indeterminate(y))
|
if (indeterminate(x) || indeterminate(y))
|
||||||
? indeterminate
|
return indeterminate;
|
||||||
: ((x && y) || (!x && !y))
|
else
|
||||||
;
|
return (x && y) || (!x && !y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator==(tribool x, bool y) BOOST_NOEXCEPT { return x == tribool(y); }
|
inline tribool operator==(tribool x, bool y) { return x == tribool(y); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator==(bool x, tribool y) BOOST_NOEXCEPT { return tribool(x) == y; }
|
inline tribool operator==(bool x, tribool y) { return tribool(x) == y; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator==(indeterminate_keyword_t, tribool x) BOOST_NOEXCEPT
|
inline tribool operator==(indeterminate_keyword_t, tribool x)
|
||||||
{ return tribool(indeterminate) == x; }
|
{ return tribool(indeterminate) == x; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator==(tribool x, indeterminate_keyword_t) BOOST_NOEXCEPT
|
inline tribool operator==(tribool x, indeterminate_keyword_t)
|
||||||
{ return tribool(indeterminate) == x; }
|
{ return tribool(indeterminate) == x; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -390,34 +394,34 @@ BOOST_CONSTEXPR inline tribool operator==(tribool x, indeterminate_keyword_t) BO
|
|||||||
* </table>
|
* </table>
|
||||||
* \throws nothrow
|
* \throws nothrow
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator!=(tribool x, tribool y) BOOST_NOEXCEPT
|
inline tribool operator!=(tribool x, tribool y)
|
||||||
{
|
{
|
||||||
return (indeterminate(x) || indeterminate(y))
|
if (indeterminate(x) || indeterminate(y))
|
||||||
? indeterminate
|
return indeterminate;
|
||||||
: !((x && y) || (!x && !y))
|
else
|
||||||
;
|
return !((x && y) || (!x && !y));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator!=(tribool x, bool y) BOOST_NOEXCEPT { return x != tribool(y); }
|
inline tribool operator!=(tribool x, bool y) { return x != tribool(y); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator!=(bool x, tribool y) BOOST_NOEXCEPT { return tribool(x) != y; }
|
inline tribool operator!=(bool x, tribool y) { return tribool(x) != y; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator!=(indeterminate_keyword_t, tribool x) BOOST_NOEXCEPT
|
inline tribool operator!=(indeterminate_keyword_t, tribool x)
|
||||||
{ return tribool(indeterminate) != x; }
|
{ return tribool(indeterminate) != x; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \overload
|
* \overload
|
||||||
*/
|
*/
|
||||||
BOOST_CONSTEXPR inline tribool operator!=(tribool x, indeterminate_keyword_t) BOOST_NOEXCEPT
|
inline tribool operator!=(tribool x, indeterminate_keyword_t)
|
||||||
{ return x != tribool(indeterminate); }
|
{ return x != tribool(indeterminate); }
|
||||||
|
|
||||||
} } // end namespace boost::logic
|
} } // end namespace boost::logic
|
||||||
@ -448,7 +452,7 @@ namespace boost {
|
|||||||
#define BOOST_TRIBOOL_THIRD_STATE(Name) \
|
#define BOOST_TRIBOOL_THIRD_STATE(Name) \
|
||||||
inline bool \
|
inline bool \
|
||||||
Name(boost::logic::tribool x, \
|
Name(boost::logic::tribool x, \
|
||||||
boost::logic::detail::indeterminate_t = \
|
boost::logic::detail::indeterminate_t dummy = \
|
||||||
boost::logic::detail::indeterminate_t()) \
|
boost::logic::detail::indeterminate_t()) \
|
||||||
{ return x.value == boost::logic::tribool::indeterminate_value; }
|
{ return x.value == boost::logic::tribool::indeterminate_value; }
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if BOOST_WORKAROUND(_MSC_VER, >= 1200)
|
||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -104,11 +104,17 @@ template<>
|
|||||||
inline std::basic_string<char> get_default_indeterminate_name<char>()
|
inline std::basic_string<char> get_default_indeterminate_name<char>()
|
||||||
{ return "indeterminate"; }
|
{ return "indeterminate"; }
|
||||||
|
|
||||||
#ifndef BOOST_NO_WCHAR_T
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||||
|
// VC++ 6.0 chokes on the specialization below, so we're stuck without
|
||||||
|
// wchar_t support. What a pain. TODO: it might just need a the template
|
||||||
|
// parameter as function parameter...
|
||||||
|
#else
|
||||||
|
# ifndef BOOST_NO_WCHAR_T
|
||||||
/// Returns the wide character string L"indeterminate".
|
/// Returns the wide character string L"indeterminate".
|
||||||
template<>
|
template<>
|
||||||
inline std::basic_string<wchar_t> get_default_indeterminate_name<wchar_t>()
|
inline std::basic_string<wchar_t> get_default_indeterminate_name<wchar_t>()
|
||||||
{ return L"indeterminate"; }
|
{ return L"indeterminate"; }
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// http://www.cantrip.org/locale.html
|
// http://www.cantrip.org/locale.html
|
||||||
@ -134,8 +140,7 @@ public:
|
|||||||
indeterminate_name() : name_(get_default_indeterminate_name<CharT>()) {}
|
indeterminate_name() : name_(get_default_indeterminate_name<CharT>()) {}
|
||||||
|
|
||||||
/// Construct the facet with the given name for the indeterminate value
|
/// Construct the facet with the given name for the indeterminate value
|
||||||
explicit indeterminate_name(const string_type& initial_name)
|
explicit indeterminate_name(const string_type& name) : name_(name) {}
|
||||||
: name_(initial_name) {}
|
|
||||||
|
|
||||||
/// Returns the name for the indeterminate value
|
/// Returns the name for the indeterminate value
|
||||||
string_type name() const { return name_; }
|
string_type name() const { return name_; }
|
||||||
@ -279,9 +284,9 @@ operator>>(std::basic_istream<CharT, Traits>& in, tribool& x)
|
|||||||
bool falsename_ok = true, truename_ok = true, othername_ok = true;
|
bool falsename_ok = true, truename_ok = true, othername_ok = true;
|
||||||
|
|
||||||
// Modeled after the code from Library DR 17
|
// Modeled after the code from Library DR 17
|
||||||
while ((falsename_ok && pos < falsename.size())
|
while (falsename_ok && pos < falsename.size()
|
||||||
|| (truename_ok && pos < truename.size())
|
|| truename_ok && pos < truename.size()
|
||||||
|| (othername_ok && pos < othername.size())) {
|
|| othername_ok && pos < othername.size()) {
|
||||||
typename Traits::int_type c = in.get();
|
typename Traits::int_type c = in.get();
|
||||||
if (c == Traits::eof())
|
if (c == Traits::eof())
|
||||||
return in;
|
return in;
|
||||||
|
16
index.html
16
index.html
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
<!--
|
|
||||||
Copyright 2011 Daniel James.
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
-->
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/tribool.html">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
Automatic redirection failed, please go to
|
|
||||||
<a href="../../doc/html/tribool.html">../../doc/html/tribool.html</a>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"key": "logic/tribool",
|
|
||||||
"name": "Tribool",
|
|
||||||
"authors": [
|
|
||||||
"Doug Gregor"
|
|
||||||
],
|
|
||||||
"description": "3-state boolean type library.",
|
|
||||||
"documentation": "/doc/html/tribool.html",
|
|
||||||
"category": [
|
|
||||||
"Miscellaneous"
|
|
||||||
],
|
|
||||||
"maintainers": [
|
|
||||||
"Douglas Gregor <dgregor -at- cs.indiana.edu>"
|
|
||||||
]
|
|
||||||
}
|
|
@ -114,26 +114,6 @@ int test_main(int, char*[])
|
|||||||
BOOST_CHECK(false);
|
BOOST_CHECK(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
|
||||||
constexpr bool res_ors = indeterminate(false || tribool(false) || false || indeterminate); // true
|
|
||||||
BOOST_CHECK(res_ors);
|
|
||||||
char array_ors[res_ors ? 2 : 3];
|
|
||||||
BOOST_CHECK(sizeof(array_ors) / sizeof(char) == 2);
|
|
||||||
|
|
||||||
constexpr bool res_ands = !indeterminate(!(true && tribool(true) && true && indeterminate)); // false
|
|
||||||
BOOST_CHECK(!res_ands);
|
|
||||||
char array_ands[res_ands ? 2 : 3];
|
|
||||||
BOOST_CHECK(sizeof(array_ands) / sizeof(char) == 3);
|
|
||||||
|
|
||||||
// We avoid checking the tribool::operator safe_bool(),
|
|
||||||
// because GCC-4.8 fails to evaluate it at compile-time.
|
|
||||||
// Clang compiles well.
|
|
||||||
//
|
|
||||||
// constexpr bool res_safe_bool = tribool(true); // false
|
|
||||||
// constexpr tribool xxx = (tribool(true) || tribool(indeterminate));
|
|
||||||
// static_assert(xxx, "Must be true!");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::cout << "no errors detected\n";
|
std::cout << "no errors detected\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user