SpECTRE Documentation Coverage Report
Current view: top level - Utilities - OptionalHelpers.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 85.7 % 7 6
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            0 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : #pragma once
       5              : 
       6              : #include <optional>
       7              : 
       8              : /// @{
       9              : /*!
      10              :  * \ingroup UtilitiesGroup
      11              :  * \brief Returns `t.has_value()` if `t` is a `std::optional` otherwise returns
      12              :  * `true`.
      13              :  */
      14              : template <typename T>
      15            1 : constexpr bool has_value(const T& /*t*/) {
      16              :   return true;
      17              : }
      18              : 
      19              : template <typename T>
      20            1 : constexpr bool has_value(const std::optional<T>& t) {
      21              :   return t.has_value();
      22              : }
      23              : /// @}
      24              : 
      25              : /// @{
      26              : /*!
      27              :  * \ingroup UtilitiesGroup
      28              :  * \brief Returns `t.value()` if `t` is a `std::optional` otherwise returns
      29              :  * `t`.
      30              :  */
      31              : template <typename T>
      32            1 : constexpr T& value(T& t) {
      33              :   return t;
      34              : }
      35              : 
      36              : template <typename T>
      37            1 : constexpr const T& value(const T& t) {
      38              :   return t;
      39              : }
      40              : 
      41              : template <typename T>
      42            1 : constexpr const T& value(const std::optional<T>& t) {
      43              :   return t.value();
      44              : }
      45              : 
      46              : template <typename T>
      47            1 : constexpr T& value(std::optional<T>& t) {
      48              :   return t.value();
      49              : }
      50              : /// @}
        

Generated by: LCOV version 2.0-1