Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class tribool

boost::logic::tribool — A 3-state boolean type.


class tribool {
// construct/copy/destruct

// public member functions
operator safe_bool() const;

enum boost::logic::tribool::value_t value;


3-state boolean values are either true, false, or indeterminate.

tribool construct/copy/destruct

  1. tribool();

    Construct a new 3-state boolean value with the value 'false'.

    Throws: Will not throw.

  2. tribool(bool value);

    Construct a new 3-state boolean value with the given boolean value, which may be true or false .

    Throws: Will not throw.

  3. tribool(indeterminate_keyword_t );

    Construct a new 3-state boolean value with an indeterminate value.

    Throws: Will not throw.

tribool public member functions

  1. operator safe_bool() const;

    Use a 3-state boolean in a boolean context. Will evaluate true in a boolean context only when the 3-state boolean is definitely true.

    Returns: true if the 3-state boolean is true, false otherwise
    Throws: Will not throw.

Copyright 2002-2004 Douglas Gregor