<commit_before>//===-- STLExtras.h - Useful functions when working with the STL --*- C++ -*--=//
//
// This file contains some templates that are useful if you are working with the
// STL at all.
//
// No library is required when using these functinons.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TOOLS_STL_EXTRAS_H
#define LLVM_TOOLS_STL_EXTRAS_H

#include <functional>

//===----------------------------------------------------------------------===//
//     Extra additions to <functional>
//===----------------------------------------------------------------------===//

// bind_obj - Often times you want to apply the member function of an object
// as a unary functor.  This macro is shorthand that makes it happen less
// verbosely.
//
// Example:
//  struct Summer { void accumulate(int x); }
//  vector<int> Numbers;
//  Summer MyS;
//  for_each(Numbers.begin(), Numbers.end(),
//           bind_obj(&MyS, &Summer::accumulate));
//
// TODO: When I get lots of extra time, convert this from an evil macro
//
#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ)


// bitwise_or - This is a simple functor that applys operator| on its two 
// arguments to get a boolean result.
//
template<class Ty>
struct bitwise_or : public binary_function<Ty, Ty, bool> {
  bool operator()(const Ty& left, const Ty& right) const {
    return left | right;
  }
};


//===----------------------------------------------------------------------===//
//     Extra additions to <iterator>
//===----------------------------------------------------------------------===//

// mapped_iterator - This is a simple iterator adapter that causes a function to
// be dereferenced whenever operator* is invoked on the iterator.<commit_msg>Addition of 'deleter' function.<commit_after>//===-- STLExtras.h - Useful functions when working with the STL --*- C++ -*--=//
//
// This file contains some templates that are useful if you are working with the
// STL at all.
//
// No library is required when using these functinons.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TOOLS_STL_EXTRAS_H
#define LLVM_TOOLS_STL_EXTRAS_H

#include <functional>

//===----------------------------------------------------------------------===//
//     Extra additions to <functional>
//===----------------------------------------------------------------------===//

// bind_obj - Often times you want to apply the member function of an object
// as a unary functor.  This macro is shorthand that makes it happen less
// verbosely.
//
// Example:
//  struct Summer { void accumulate(int x); }
//  vector<int> Numbers;
//  Summer MyS;
//  for_each(Numbers.begin(), Numbers.end(),
//           bind_obj(&MyS, &Summer::accumulate));
//
// TODO: When I get lots of extra time, convert this from an evil macro
//
#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ)


// bitwise_or - This is a simple functor that applys operator| on its two 
// arguments to get a boolean result.
//
template<class Ty>
struct bitwise_or : public binary_function<Ty, Ty, bool> {
  bool operator()(const Ty& left, const Ty& right) const {
    return left | right;
  }
};


// deleter - Very very very simple method that is used to invoke operator
// delete on something.  It is used like this: 
//
//   for_each(V.begin(), B.end(), deleter<cfg::Interval>);
//
template <class T> 
static inline void deleter(T *Ptr) { 
  delete Ptr; 
}



//===----------------------------------------------------------------------===//
//     Extra additions to <iterator>
//===----------------------------------------------------------------------===//

// mapped_iterator - This is a simple iterator adapter that causes a function to
// be dereferenced whenever operator* is invoked on the iterator.
{'fraction_non_alphanumeric': 0.3010111485610578, 'fraction_numerical': 0.0005185377236193933, 'mean_word_length': 1.6244897959183673, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5753931', 'n_tokens_mistral': 1044, 'n_tokens_neox': 989, 'n_words': 369}