<commit_before>
#ifndef UTILITY_BITSET_HPP_
#define UTILITY_BITSET_HPP_

#include <bitset>

namespace bitset {
namespace {

// We use a class here because unfortunately, C++ doesn't 
// support partial specialization of template functions

template <std::size_t N>
class bit_finder {
public:	
	int operator()(const std::bitset<N> &bs) const {
		if(bs.none()) {
			return N;
		}

		std::size_t i;
		for(i = 0; i < N; ++i) {
			if(bs[i]) {
				break;
			}
		}

		return i;	
	}
};

#if defined(__GNUC__)
template <>
class bit_finder<32> {
	static const std::size_t N = 32;
public:
	int operator()(const std::bitset<N> &bs) const {
		if(bs.none()) {
			return N;
		}
		return __builtin_ctz(static_cast<uint32_t>(bs.to_ulong()));	
	}
};

#if __cplusplus >= 201103L
template <>
class bit_finder<64> {
	static const std::size_t N = 64;
public:
	int operator()(const std::bitset<N> &bs) const {
		if(bs.none()) {
			return N;
		}
		return __builtin_ctzll(static_cast<uint64_t>(bs.to_ullong()));
	}
};
#endif
#endif

}

template <size_t N>
int find_first(const std::bitset<N> &bs) {
	auto finder = bit_finder<N>();
	return finder(bs);
}

}

#endif<commit_msg>simplified the implementation a lot :-)<commit_after>
#ifndef UTILITY_BITSET_HPP_
#define UTILITY_BITSET_HPP_

#include <bitset>

namespace bitset {

template <size_t N>
int find_first(const std::bitset<N> &bs) {
		if(bs.none()) {
			return N;
		}

		std::size_t i;
		for(i = 0; i < N; ++i) {
			if(bs[i]) {
				break;
			}
		}

		return i;	
}

#if defined(__GNUC__)
template <>
inline int find_first(const std::bitset<32> &bs) {
	if(bs.none()) {
		return bs.size();
	}
	return __builtin_ctz(static_cast<uint32_t>(bs.to_ulong()));	
}
#if __cplusplus >= 201103L
template <>
inline int find_first(const std::bitset<64> &bs) {
	if(bs.none()) {
		return bs.size();
	}
	return __builtin_ctzll(static_cast<uint64_t>(bs.to_ullong()));
}
#endif
#endif

}

#endif
{'fraction_non_alphanumeric': 0.16018907563025211, 'fraction_numerical': 0.017857142857142856, 'mean_word_length': 4.233516483516484, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '3976995', 'n_tokens_mistral': 867, 'n_tokens_neox': 778, 'n_words': 172}