<commit_before>#ifndef GUARD_optional_hpp
#define GUARD_optional_hpp

/** \file optional.hpp
 *
 * \brief Provides functions to be used with boost::optional.
 *
 * \author <NAME>
 * \date 2012-11-06
 * 
 * Copyright (c) 2012, <NAME>. All rights reserved.
 */

#include "exception.hpp"
#include <boost/optional.hpp>

namespace jewel
{


// Declarations

/**
 * @returns The value stored in x
 *
 * @throws UninitializedOptionalException if x is
 * uninitialized.
 *
 * This provides a wrapper around boost::optional<T>::operator*.
 * Using boost::optional<T>::operator* without
 * this wrapper to obtain the value of x will result in an assertion
 * failure (rather than an exception being thrown) in the event that
 * x is uninitialized. This wrapper throws an exception instead. There
 * is a small performance penalty from using this wrapper, however.
 */
template <typename T>
T
value(boost::optional<T> x);


JEWEL_DERIVED_EXCEPTION(UninitializedOptionalException, Exception);



// Implementations

template <typename T>
inline
T
value(boost::optional<T> x)
{
	if (x)
	{
		return *x;
	}
	throw UninitializedOptionalException();
}


}  // namespace jewel
<commit_msg>Tidied wording in API documentation of jewel::value.<commit_after>#ifndef GUARD_optional_hpp
#define GUARD_optional_hpp

/** \file optional.hpp
 *
 * \brief Provides functions to be used with boost::optional.
 *
 * \author <NAME>
 * \date 2012-11-06
 * 
 * Copyright (c) 2012, <NAME>. All rights reserved.
 */

#include "exception.hpp"
#include <boost/optional.hpp>

namespace jewel
{


// Declarations

/**
 * @returns The value stored in x
 *
 * @throws UninitializedOptionalException if x is
 * uninitialized.
 *
 * This provides a wrapper around boost::optional<T>::operator*.
 * Using boost::optional<T>::operator* without
 * this wrapper to obtain the value of x will result in an assertion
 * failure in the event that
 * x is uninitialized. This wrapper throws an exception instead. There
 * is a small performance penalty from using this wrapper, however.
 */
template <typename T>
T
value(boost::optional<T> x);


JEWEL_DERIVED_EXCEPTION(UninitializedOptionalException, Exception);



// Implementations

template <typename T>
inline
T
value(boost::optional<T> x)
{
	if (x)
	{
		return *x;
	}
	throw UninitializedOptionalException();
}


}  // namespace jewel

{'fraction_non_alphanumeric': 0.10721913712088851, 'fraction_numerical': 0.010252029047415635, 'mean_word_length': 4.251121076233184, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1618859', 'n_tokens_mistral': 733, 'n_tokens_neox': 698, 'n_words': 242}