<commit_before>/*
 * Copyright 2015 - 2018 <EMAIL>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#pragma once

#include "memops.hpp"
#include "types.hpp"
#include "typetraits.hpp"

namespace ox {

template<typename To, typename From>
constexpr typename enable_if<sizeof(To) == sizeof(From), To>::type bit_cast(From src) noexcept {
	To dst;
	memcpy(&dst, &src, sizeof(src));
	return dst;
}

template<typename T>
[[nodiscard]] constexpr T rotl(T i, int shift) noexcept {
	constexpr auto bits = sizeof(i) * 8;
	return (i << shift) | (i >> (bits - shift));
}

template<typename T>
[[nodiscard]] constexpr T onMask(int bits = sizeof(T) << 3 /* *8 */) noexcept {
	T out = T(0);
	for (auto i = 0; i < bits; i++) {
		out |= static_cast<T>(1) << i;
	}
	return out;
}

template<typename T>
constexpr auto MaxValue = onMask<T>();

static_assert(onMask<int>(1) == 1);
static_assert(onMask<int>(2) == 3);
static_assert(onMask<int>(3) == 7);
static_assert(onMask<int>(4) == 15);

}
<commit_msg>[ox/std] Remove constexpr from ox::bit_cast<commit_after>/*
 * Copyright 2015 - 2018 <EMAIL>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#pragma once

#include "memops.hpp"
#include "types.hpp"
#include "typetraits.hpp"

namespace ox {

template<typename To, typename From>
typename enable_if<sizeof(To) == sizeof(From), To>::type bit_cast(From src) noexcept {
	To dst = {};
	memcpy(&dst, &src, sizeof(src));
	return dst;
}

template<typename T>
[[nodiscard]] constexpr T rotl(T i, int shift) noexcept {
	constexpr auto bits = sizeof(i) * 8;
	return (i << shift) | (i >> (bits - shift));
}

template<typename T>
[[nodiscard]] constexpr T onMask(int bits = sizeof(T) << 3 /* *8 */) noexcept {
	T out = T(0);
	for (auto i = 0; i < bits; i++) {
		out |= static_cast<T>(1) << i;
	}
	return out;
}

template<typename T>
constexpr auto MaxValue = onMask<T>();

static_assert(onMask<int>(1) == 1);
static_assert(onMask<int>(2) == 3);
static_assert(onMask<int>(3) == 7);
static_assert(onMask<int>(4) == 15);

}

{'fraction_non_alphanumeric': 0.16774751405101598, 'fraction_numerical': 0.023346303501945526, 'mean_word_length': 4.344110854503464, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 31, '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': '486240', 'n_tokens_mistral': 890, 'n_tokens_neox': 836, 'n_words': 261}