<commit_before>#include <monsoon/history/dir/dirhistory.h>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <monsoon/history/collect_history.h>
#include <monsoon/history/dir/tsdata.h>
#include <monsoon/interpolate.h>
#include <monsoon/objpipe/callback.h>
#include "v2/tsdata.h"

namespace monsoon::history {
namespace {


struct merge_emit_greater_ {
  template<typename X, typename Y>
  auto operator()(const X& x, const Y& y) const
  noexcept
  -> bool {
    return tp(x) > tp(y);
  }

  static auto tp(const time_point& x)
  noexcept
  -> const time_point& {
    return x;
  }

  template<typename T>
  static auto tp(const std::pair<time_point, T>& x)
  noexcept
  -> const time_point& {
    return x.first;
  }

  template<typename... T>
  static auto tp(const std::tuple<time_point, T...>& x)
  noexcept
  -> const time_point& {
    return std::get<0>(x);
  }

  static auto tp(const tsdata& tsd)
  noexcept(noexcept(std::declval<const tsdata&>().time()))
  -> const time_point& {
    return std::get<0>(tsd.time());
  }

  template<typename T>
  static auto tp(const std::shared_ptr<T>& ptr)
  noexcept(noexcept(tp(std::declval<std::add_lvalue_reference_t<std::add_const_t<T>>>())))
  -> const time_point& {
    return tp(*ptr);
  }

  template<typename T>
  static auto tp(const objpipe::detail::adapter_t<T>& pipe)
  -> const time_point& {<commit_msg>Fix: a dangling reference in greater::tp caused dirhistory traversal to see all files start at 1 second after unix epoch.<commit_after>#include <monsoon/history/dir/dirhistory.h>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iomanip>
#include <iterator>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <sstream>
#include <stdexcept>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <monsoon/history/collect_history.h>
#include <monsoon/history/dir/tsdata.h>
#include <monsoon/interpolate.h>
#include <monsoon/objpipe/callback.h>
#include "v2/tsdata.h"

namespace monsoon::history {
namespace {


struct merge_emit_greater_ {
  template<typename X, typename Y>
  auto operator()(const X& x, const Y& y) const
  noexcept
  -> bool {
    return tp(x) > tp(y);
  }

  static auto tp(const time_point& x)
  noexcept
  -> const time_point& {
    return x;
  }

  template<typename T>
  static auto tp(const std::pair<time_point, T>& x)
  noexcept
  -> const time_point& {
    return x.first;
  }

  template<typename... T>
  static auto tp(const std::tuple<time_point, T...>& x)
  noexcept
  -> const time_point& {
    return std::get<0>(x);
  }

  static auto tp(const tsdata& tsd)
  noexcept(noexcept(std::declval<const tsdata&>().time()))
  -> time_point {
    return std::get<0>(tsd.time());
  }

  template<typename T>
  static auto tp(const std::shared_ptr<T>& ptr)
  noexcept(noexcept(tp(std::declval<std::add_lvalue_reference_t<std::add_const_t<T>>>())))
  -> time_point {
    return tp(*ptr);
  }

  template<typename T>
  static auto tp(const objpipe::detail::adapter_t<T>& pipe)
  -> time_point {
{'fraction_non_alphanumeric': 0.1498390400936494, 'fraction_numerical': 0.002048580626280363, 'mean_word_length': 4.73489932885906, 'pattern_counts': {'":': 0, '<': 78, '<?xml version=': 0, '>': 94, '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': '507331', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1235, 'n_words': 290}