<commit_before>#include <iostream>

template <typename F_t>
class ScopeExitRunner
{
  F_t f;
  bool run;

public:
  ScopeExitRunner(F_t f_) : f(f_), run(true)
  {
  }

  ~ScopeExitRunner()
  {
    if (run)
      f();
  }

  ScopeExitRunner(const ScopeExitRunner& s) = delete;
  ScopeExitRunner(ScopeExitRunner&& s) : f(std::move(s.f)), run(s.run)
  {
    s.run = false;
  }

  ScopeExitRunner& operator=(const ScopeExitRunner& s) = delete;

  ScopeExitRunner& operator=(ScopeExitRunner&& s)
  {
    if (&s == this)
      return *this;

    f = std::move(s.f);
    run = s.run;
    s.run = false;
    return *this;
  }

  void Release()
  {
    run = false;
  }
};

template <typename F_t>
ScopeExitRunner<F_t> run_on_scope_exit(F_t f)
{
  return ScopeExitRunner<F_t>(f);
}

void f()
{
  std::cout << "Can I use a function pointer as a template argument? : Yes "
            << std::endl;
}

int main(int argc, char* argv[])
{
  auto printHelloWorldOnExit = run_on_scope_exit([]
  { std::cout << "Hello world" << std::endl; });
  auto printGoodbyeWorldOnExit = run_on_scope_exit([]
  { std::cout << "Goodbye cruel world" << std::endl; });
  auto functionPointerTest = run_on_scope_exit(&f);
  printGoodbyeWorldOnExit.Release();
}
<commit_msg>formatting changes to scope exit runner<commit_after>#include <iostream>

template <typename F_t>
class ScopeExitRunner
{
  F_t f;
  bool run;

public:
  ScopeExitRunner(F_t f_) : f(f_), run(true)
  {
  }

  ~ScopeExitRunner()
  {
    if (run) { f(); }
  }

  ScopeExitRunner(const ScopeExitRunner& s) = delete;
  ScopeExitRunner(ScopeExitRunner&& s) : f(std::move(s.f)), run(s.run)
  {
    s.run = false;
  }

  ScopeExitRunner& operator=(const ScopeExitRunner& s) = delete;

  ScopeExitRunner& operator=(ScopeExitRunner&& s)
  {
    if (&s == this)
      return *this;

    f = std::move(s.f);
    run = s.run;
    s.run = false;
    return *this;
  }

  void Release()
  {
    run = false;
  }
};

template <typename F_t>
ScopeExitRunner<F_t> run_on_scope_exit(F_t f)
{
  return ScopeExitRunner<F_t>(f);
}

void f()
{
  std::cout << "Can I use a function pointer as a template argument? : Yes "
            << std::endl;
}

int main(int argc, char* argv[])
{
  auto printHelloWorldOnExit = run_on_scope_exit([]{ std::cout << "Hello world" << std::endl; });
  auto printGoodbyeWorldOnExit = run_on_scope_exit([]{ std::cout << "Goodbye cruel world" << std::endl; });
  auto functionPointerTest = run_on_scope_exit(&f);
  printGoodbyeWorldOnExit.Release();
}

{'fraction_non_alphanumeric': 0.1512, 'fraction_numerical': 0.0, 'mean_word_length': 3.614391143911439, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 13, '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': '4124814', 'n_tokens_mistral': 955, 'n_tokens_neox': 932, 'n_words': 209}