std: prevent instantiation of atomic.Int with non-integral types

This commit is contained in:
LemonBoy 2020-12-09 20:47:56 +01:00
parent ef7db9717e
commit 5844511408

View File

@ -10,6 +10,9 @@ const testing = std.testing;
/// Thread-safe, lock-free integer /// Thread-safe, lock-free integer
pub fn Int(comptime T: type) type { pub fn Int(comptime T: type) type {
if (!std.meta.trait.isIntegral(T))
@compileError("Expected integral type, got '" ++ @typeName(T) ++ "'");
return extern struct { return extern struct {
unprotected_value: T, unprotected_value: T,