<commit_before>#ifndef FUTURE_H
#define FUTURE_H

#include <future>
#include <memory>
#include <type_traits>

template <typename T>
class result {
public:
  result(result&& rhs)
    : promise_made(rhs.promise_made)
  {
    if (rhs.promise_made) {
      new (&storage) std::promise<T>(std::move(rhs.promise_ref()));
    }
  }

  result& operator=(result&& rhs)
  {
    if (rhs.promise_made)
    {
      if (promise_made)
      {
        promise_ref() = std::move(rhs.promise_ref());
      }
      else
      {
        new (&storage) std::promise<T>(std::move(rhs.promise_ref()));
        promise_made = true;
      }
    }
    else
    {
      destroy();
    }

    return *this;
  }

  ~result()
  {
    destroy();
  }

  std::future<T> get_local() {
    if (!promise_made) {
      new (&storage) std::promise<T>();
      promise_made = true;
      // TODO: signal to the remote that we actually wish to receive the value associated with this.
    }

    return promise_ref().get_future();
  }

private:
  void destroy()
  {
    if (promise_made) {
      promise_ref().~promise<T>();
      promise_made = false;
    }
  }

  std::promise<T>& promise_ref()
  {
    return *reinterpret_cast<std::promise<T>*>(&storage);
  }

private:<commit_msg>Strip future<commit_after>#ifndef FUTURE_H
#define FUTURE_H

#include <future>
#include <memory>
#include <type_traits>

template <typename T>
class result {
public:
  result(result&& rhs) = delete;
  result& operator=(result&& rhs) = delete;
  ~result()
  {
    if (promise_made) {
      promise_ref().~promise<T>();
    }
  }
  std::future<T> get_local() {
    if (!promise_made) {
      new (&storage) std::promise<T>();
      promise_made = true;
      // TODO: signal to the remote that we actually wish to receive the value associated with this.
    }

    return promise_ref().get_future();
  }

private:
  std::promise<T>& promise_ref()
  {
    return *reinterpret_cast<std::promise<T>*>(&storage);
  }

private:
{'fraction_non_alphanumeric': 0.152317880794702, 'fraction_numerical': 0.0, 'mean_word_length': 2.9596774193548385, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '458821', 'n_tokens_mistral': 697, 'n_tokens_neox': 701, 'n_words': 145}