Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const std = @import("std");
- const builtin = @import("builtin");
- //Id like to print the arg types of this function
- fn foo(n: usize, comptime T: type) usize {
- return n;
- }
- fn makefunc(comptime func: var) type {
- const TargetFnType = @typeOf(func);
- const target_fn_info = @typeInfo(TargetFnType).Fn;
- const args = target_fn_info.args;
- return struct {
- fn call(n: args[0].arg_type.?, comptime t: args[1].arg_type.?) void {
- std.debug.warn("{} {}", n, @typeName(t));
- }
- };
- }
- pub fn main() void {
- comptime var f = makefunc(foo);
- f.call(10, @typeOf(foo));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement