<commit_before>#pragma once
//  bitblock.hpp : bitblock class
//
// Copyright (C) 2017-2019 Stillwater Supercomputing, Inc.
//
// This file is part of the universal numbers project, which is released under an MIT Open Source license.

#include <sstream>
#include <iostream>
#include <iomanip>
// this should be removed when we have made the transition away from std::bitset to sw::unum::bitblock
#include <cassert>
#include <bitset>

namespace sw {
	namespace unum {

		// bitblock is a template class implementing efficient multi-precision binary arithmetic and logic
		template<size_t nbits>
		class bitblock : public std::bitset<nbits> {
                    using base= std::bitset<nbits>;
		public:
			constexpr bitblock() : base(0ull) {}

			constexpr bitblock(const bitblock&) = default;
			constexpr bitblock(bitblock&&) = default;

			constexpr bitblock& operator=(const bitblock&) = default;
			constexpr bitblock& operator=(bitblock&&) = default;

			constexpr bitblock& operator=(unsigned long long rhs) {
				return (bitblock&)std::bitset<nbits>::operator=(rhs);
			}

			constexpr base& reset() { *this= bitblock{}; return *this; }
			using base::reset; // make unary reset visible
			
			
			void setToZero() { std::bitset<nbits>::reset(); }
			constexpr bool load_bits(const std::string& string_of_bits) {
				if (string_of_bits.length() != nbits) return false;
				setToZero();
				int msb = nbits - 1;
				for (std::string::const_iterator it = string_of_bits.begin(); it != string_of_bits.end(); ++it) {
					if (*it == '0') {
						this->reset(msb--);
					}
					else if (*it == '1') {
						this->set(msb--);
					}
					else {
						return false;
					}
				}
				return true;
			}
		};

		// logic operators

		// this comparison is for a two's complement number only
		template<size_t nbits>
		bool twosComplementLessThan(const bitblock<nbits>& lhs, const bitblock<nbits>& rhs) {
			// comparison of the sign bit
			if (lhs[nbits - 1] == 0 && rhs[nbits - 1] == 1)	return false;
			if (lhs[nbits - 1] == 1 && rhs[nbits - 1] == 0) return true;<commit_msg>removing constexpr from loadbits to support old clang compilers<commit_after>#pragma once
//  bitblock.hpp : bitblock class
//
// Copyright (C) 2017-2019 Stillwater Supercomputing, Inc.
//
// This file is part of the universal numbers project, which is released under an MIT Open Source license.

#include <sstream>
#include <iostream>
#include <iomanip>
// this should be removed when we have made the transition away from std::bitset to sw::unum::bitblock
#include <cassert>
#include <bitset>

namespace sw {
	namespace unum {

		// bitblock is a template class implementing efficient multi-precision binary arithmetic and logic
		template<size_t nbits>
		class bitblock : public std::bitset<nbits> {
                    using base= std::bitset<nbits>;
		public:
			constexpr bitblock() : base(0ull) {}

			constexpr bitblock(const bitblock&) = default;
			constexpr bitblock(bitblock&&) = default;

			constexpr bitblock& operator=(const bitblock&) = default;
			constexpr bitblock& operator=(bitblock&&) = default;

			constexpr bitblock& operator=(unsigned long long rhs) {
				return (bitblock&)std::bitset<nbits>::operator=(rhs);
			}

			constexpr base& reset() { *this= bitblock{}; return *this; }
			using base::reset; // make unary reset visible
			
			void setToZero() { std::bitset<nbits>::reset(); }
			bool load_bits(const std::string& string_of_bits) {
				if (string_of_bits.length() != nbits) return false;
				setToZero();
				int msb = nbits - 1;
				for (std::string::const_iterator it = string_of_bits.begin(); it != string_of_bits.end(); ++it) {
					if (*it == '0') {
						this->reset(msb--);
					}
					else if (*it == '1') {
						this->set(msb--);
					}
					else {
						return false;
					}
				}
				return true;
			}
		};

		// logic operators

		// this comparison is for a two's complement number only
		template<size_t nbits>
		bool twosComplementLessThan(const bitblock<nbits>& lhs, const bitblock<nbits>& rhs) {
			// comparison of the sign bit
			if (lhs[nbits - 1] == 0 && rhs[nbits - 1] == 1)	return false;
			if (lhs[nbits - 1] == 1 && rhs[nbits - 1] == 0) return true;
{'fraction_non_alphanumeric': 0.13228271251193888, 'fraction_numerical': 0.009551098376313277, 'mean_word_length': 3.372651356993737, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 33, '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': '4997623', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1322, 'n_words': 410}