mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
std: prevent instantiation of atomic.Int with non-integral types
This commit is contained in:
parent
ef7db9717e
commit
5844511408
@ -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,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user