Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/profiling/src/gap_cpp_headers/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 21.5.2025 mit Größe 1017 B image not shown  

Quelle  optional.hpp   Sprache: C

 
//  Please refer to the COPYRIGHT file of the profiling package for details.
//  SPDX-License-Identifier: MIT
#ifndef OPTIONAL_HPP
#define OPTIONAL_HPP

#include <assert.h>

template<typename T>
class optional
{
    T t;
    bool present;


    typedef void (optional::*bool_type)() const;
    void random_function_name() const {}
public:
    operator bool_type() const
    {
        bool_type tr = &optional::random_function_name;
        bool_type f(0);
        return present ? tr : f;
    }

    void clear()
    { present = false; }

    T& operator*()
    {
        assert(present);
        return t;
    }

    const T& operator*() const
    {
        assert(present);
        return t;
    }

    optional() : present(false)
    { }

    optional(const T& _t) : t(_t), present(true)
    { }

    optional(const optional& o) : t(o.t), present(o.present)
    { }

};

// This function is just to provide nicer looking notation
template<typename T>
optional<T> empty_optional()
return optional<T>(); }

#endif

99%


¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.