<commit_before># Optional
> An implementation of the C++17 optional pattern.

![Production ready](https://img.shields.io/badge/production-ready-brightgreen.svg)

Current version: **1.0.0**

Lead Maintainer: [<NAME>](mailto:<EMAIL>)

## Description

This project consists of a header-only minimalist implementation of the [optional pattern](https://en.cppreference.com/w/cpp/utility/optional) introduced by the C++17 standard library. This pattern makes it possible to manipulate values that may, or may not be available and provides therefore the appropriate semantics to deal with optional values in a type-safe manner.

## Example

Imagine that you would like to override the behaviour of the `strtol` function so that it returns a *not-an-int* value if the input is invalid. Here is how you would do that using `Optional` :

```c++
#include "optional.hpp"
#include <string>
#include <iostream>

/**
 * \return an optional long integer which contains the integer
 * value extracted from the given string on success, a not
 * a number value otherwise.
 */
static experimental::Optional<int> integer_of(const char* value) {
  try {
    return (std::stoi(value, nullptr, 10));
  } catch (std::invalid_argument&) {
    return experimental::Optional<int>();
  }
}<commit_msg>Removed includes<commit_after># Optional
> An implementation of the C++17 optional pattern.

![Production ready](https://img.shields.io/badge/production-ready-brightgreen.svg)

Current version: **1.0.0**

Lead Maintainer: [<NAME>](mailto:<EMAIL>)

## Description

This project consists of a header-only minimalist implementation of the [optional pattern](https://en.cppreference.com/w/cpp/utility/optional) introduced by the C++17 standard library. This pattern makes it possible to manipulate values that may, or may not be available and provides therefore the appropriate semantics to deal with optional values in a type-safe manner.

## Example

Imagine that you would like to override the behaviour of the `strtol` function so that it returns a *not-an-int* value if the input is invalid. Here is how you would do that using `Optional` :

```c++
/**
 * \return an optional long integer which contains the integer
 * value extracted from the given string on success, a not
 * a number value otherwise.
 */
static experimental::Optional<int> integer_of(const char* value) {
  try {
    return (std::stoi(value, nullptr, 10));
  } catch (std::invalid_argument&) {
    return experimental::Optional<int>();
  }
}
{'fraction_non_alphanumeric': 0.10386473429951691, 'fraction_numerical': 0.007246376811594203, 'mean_word_length': 4.77906976744186, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 4, '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': '4751397', 'n_tokens_mistral': 693, 'n_tokens_neox': 665, 'n_words': 285}