You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] How to use std::function in pure cpp2 ? #711
example.cpp2(6,26): error: missing ';' at end of declaration or '=' at start of initializer (at '<')
example.cpp2(5,19): error: ill-formed initializer (at '{')
example.cpp2(5,1): error: unexpected text at end of Cpp2 code section (at 'main')
example.cpp2(2,0): error: parse failed for section starting here
Thanks! Your original code is now working with PR #1183, except you have to remove the : because : always means declaring a new thing and here you're only using the type so no : is needed:
fun: (x: int) -> int = 2 * x;
main: () -> i32 = {
p_fun1: std::function<(x: int) -> int> = fun&; // works with PR #1183
std::cout << p_fun1(3); // prints 6
}
Activity
[-][BUG] How to use std::function in cpp2 ?[/-][+][BUG] How to use std::function in pure cpp2 ?[/+]JohelEGP commentedon Sep 29, 2023
This is #343.
hsutter commentedon Jul 27, 2024
Thanks! Your original code is now working with PR #1183, except you have to remove the
:because:always means declaring a new thing and here you're only using the type so no:is needed: