diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-08 03:09:47 +0000 |
---|---|---|
committer | <> | 2015-05-05 14:37:32 +0000 |
commit | f2541bb90af059680aa7036f315f052175999355 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/logic | |
parent | ed232fdd34968697a68783b3195b1da4226915b5 (diff) | |
download | boost-tarball-master.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/logic')
-rw-r--r-- | libs/logic/doc/Jamfile.v2 | 10 | ||||
-rw-r--r-- | libs/logic/doc/tribool.boostbook | 12 | ||||
-rw-r--r-- | libs/logic/meta/libraries.json | 15 | ||||
-rw-r--r-- | libs/logic/test/tribool_test.cpp | 20 |
4 files changed, 57 insertions, 0 deletions
diff --git a/libs/logic/doc/Jamfile.v2 b/libs/logic/doc/Jamfile.v2 index 422ea5e83..5088a46c0 100644 --- a/libs/logic/doc/Jamfile.v2 +++ b/libs/logic/doc/Jamfile.v2 @@ -1,3 +1,13 @@ +# 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 ; import boostbook ; import doxygen ; diff --git a/libs/logic/doc/tribool.boostbook b/libs/logic/doc/tribool.boostbook index 1fa199aa0..80da3971e 100644 --- a/libs/logic/doc/tribool.boostbook +++ b/libs/logic/doc/tribool.boostbook @@ -138,6 +138,18 @@ if (<functionname>indeterminate</functionname>(x)) { else { // report success or failure of x }</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> diff --git a/libs/logic/meta/libraries.json b/libs/logic/meta/libraries.json new file mode 100644 index 000000000..d7e4934fe --- /dev/null +++ b/libs/logic/meta/libraries.json @@ -0,0 +1,15 @@ +{ + "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>" + ] +} diff --git a/libs/logic/test/tribool_test.cpp b/libs/logic/test/tribool_test.cpp index f25d51202..be8fd185d 100644 --- a/libs/logic/test/tribool_test.cpp +++ b/libs/logic/test/tribool_test.cpp @@ -114,6 +114,26 @@ int test_main(int, char*[]) 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"; return 0; } |