This file is indexed.

/usr/include/mircore/mir/optional_value.h is in libmircore-dev 0.26.3+16.04.20170605-0ubuntu1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * Copyright © 2014 Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Alberto Aguirre <alberto.aguirre@canonical.com>
 */

#ifndef MIR_OPTIONAL_VALUE_H_
#define MIR_OPTIONAL_VALUE_H_

#include "mir/fatal.h"
#include <utility>

namespace mir
{
template<typename T>
class optional_value
{
public:
    optional_value() = default;
    optional_value(T const& value) : value_(value), is_set_{true} {}

    optional_value& operator=(T const& value)
    {
        value_ = value;
        is_set_ = true;
        return *this;
    }

    bool is_set() const { return is_set_; }

    T const& value() const
    {
        die_if_unset();
        return value_;
    }

    T& value()
    {
        die_if_unset();
        return value_;
    }

    T&& consume()
    {
        die_if_unset();
        is_set_ = false;
        return std::move(value_);
    }

private:
    void die_if_unset() const
    {
        if (!is_set())
        {
            (*fatal_error)("Accessing value of unset optional");
        }
    }

    T value_;
    bool is_set_{false};
};


template<typename T>
inline bool operator == (optional_value<T> const& lhs, optional_value<T> const& rhs)
{
    return lhs.is_set() == rhs.is_set() &&
           (!lhs.is_set() || lhs.value() == rhs.value());
}

template<typename T>
inline bool operator != (optional_value<T> const& lhs, optional_value<T> const& rhs)
{
    return !(lhs == rhs);
}

template<typename T>
inline bool operator == (optional_value<T> const& lhs, T const& rhs)
{
    return lhs.is_set() && (lhs.value() == rhs);
}

template<typename T>
inline bool operator != (optional_value<T> const& lhs, T const& rhs)
{
    return !(lhs == rhs);
}

template<typename T>
inline bool operator == (T const& lhs, optional_value<T> const& rhs)
{
    return rhs == lhs;
}

template<typename T>
inline bool operator != (T const& lhs, optional_value<T> const& rhs)
{
    return rhs != lhs;
}
}

#endif /* MIR_OPTIONAL_VALUE_H_ */