Skip to content

Instantly share code, notes, and snippets.

@jmlvanre
Last active August 29, 2015 14:19
Show Gist options
  • Save jmlvanre/b533778d65947205d316 to your computer and use it in GitHub Desktop.
Save jmlvanre/b533778d65947205d316 to your computer and use it in GitHub Desktop.
lambda style
auto lambda = [] () { return true };

auto lambda = [] () {
  ...;
};

socket.send([] () {
  ...;
});

socket.send([] () {
  ...
}).then([] () {
  ...
});

socket.send([
    =,
    &someLongCapture1,
    &someLongCapture2,
    &someLongCapture3,
    &someLongCapture4] () {
  ...
});


socket.send([
    =,
    &someLongCapture1,
    &someLongCapture2,
    &someLongCapture3,
    &someLongCapture4] () {
  ...
});
OR
socket.send(
  [=, &someLongCapture1, &someLongCapture2, &someLongCapture3] (const T& arg) {
  ...
});


socket.send([
    =,
    &someLongCapture1,
    &someLongCapture2,
    someLongCapture3] mutable () {
  ...
});
OR
socket.send(
  [=, &someLongCapture1, &someLongCapture2, someLongCapture3] mutable () {
  ...
});


socket.send([
    =,
    &someLongCapture,
    &someLongCapture2,
    &someLongCapture3] (const T& someParam) {
  ...
});
OR
socket.send([
    =,
    &someLongCapture,
    &someLongCapture2,
    &someLongCapture3] (
        const T& someLongParam1,
        const T& someLongParam2,
        const T& someLongParam3) {
  ...
});
@mpark
Copy link

mpark commented Apr 23, 2015

A few more cases. Note that the known limitation of "jaggedness" is still present.

  socket.send([=, &someLongCapture, &someLongCapture2, &someLongCapture3](
    const T& someLongParam1,
    const T& someLongParam2,
    const T& someLongParam3,
    const T& someLongParam4) {
    s1;
    s2;
    s3;
  });

  socket.send([=, &someLongCapture](const T& someLongParam1,
                                    const T& someLongParam2,
                                    const T& someLongParam3,
                                    const T& someLongParam4) {
    s1;
    s2;
    s3;
  });

  socket.send([=,
               &someLongCapture,
               &someLongCapture2,
               &someLongCapture3,
               &someLongCapture4](const T& someLongParam1,
                                  const T& someLongParam2,
                                  const T& someLongParam3,
                                  const T& someLongParam4) {
    s1;
    s2;
    s3;
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment