Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cpp2rust/converter/converter_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,9 @@ void ForEachLambdaCallOperator(
return;
}
for (auto spec : decl->getDependentLambdaCallOperator()->specializations()) {
fn(clang::cast<clang::CXXMethodDecl>(spec));
if (spec->hasBody()) {
fn(clang::cast<clang::CXXMethodDecl>(spec));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ADDITIONAL_COMPILE_FLAGS: -std=c++23
#include <cassert>

// N4950 [expr.prim.lambda.closure]/3: the closure type of a generic lambda has
// a function call operator template whose return type is described by the
// trailing-return-type.
namespace p3_call_operator_template_named_in_decltype {
void test() {
auto twice = [](auto x) -> int { return x * 2; };
decltype(twice(2.5)) n = 4;
assert(n == 4);
assert(twice(3) == 6);
}
} // namespace p3_call_operator_template_named_in_decltype

int main() {
p3_call_operator_template_named_in_decltype::test();
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
extern crate libcc2rs;
use libcc2rs::*;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::io::prelude::*;
use std::io::{Read, Seek, Write};
use std::os::fd::AsFd;
use std::rc::{Rc, Weak};
pub fn test_0() {
let twice: Value<FnPtr<Generic>> =
Rc::new(RefCell::new(lambda!(Generic, {}, |mut x: i32| -> i32 {
return (x * 2);
})));
let mut n: i32 = 4;
assert!((n == 4));
assert!(({ (({ (*twice.borrow()).spec::<fn(i32) -> i32>(0).call(3,) }) == 6) }));
}
pub fn main() {
__cpp2rust_init_globals();
std::process::exit(main_0());
}
fn main_0() -> i32 {
({ test_0() });
return 0;
}
pub fn __cpp2rust_init_globals() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
extern crate libc;
use libc::*;
extern crate libcc2rs;
use libcc2rs::*;
use std::collections::BTreeMap;
use std::io::{Read, Seek, Write};
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
use std::rc::Rc;
pub unsafe fn test_0() {
let mut twice: FnPtr<Generic> = lambda_unsafe!(Generic, {}, |mut x: i32| -> i32 {
return ((x) * (2));
});
let mut n: i32 = 4;
assert!(((n) == (4)));
assert!(((unsafe { twice.spec::<fn(i32) -> i32>(0).call(3,) }) == (6)));
}
pub fn main() {
unsafe {
__cpp2rust_init_globals();
std::process::exit(main_0() as i32);
}
}
unsafe fn main_0() -> i32 {
(unsafe { test_0() });
return 0;
}
pub unsafe fn __cpp2rust_init_globals() {}
Loading