trueblacker (trueblacker) wrote,
trueblacker
trueblacker

Внезапно псто

Социум подобен сиплюсплюсу - граница между first-class citizens и second-class citizens размывается, но равноправия всё равно нет.

typedef int (*fp)(int);

int f_test(int a) {
    return a;
}

auto l_test = [](int a) -> int {
    return a;
};

int main(int, char**) {

    fp f1 = l_test;
    fp f2 = f_test;

    decltype(l_test) f3 = l_test;
    decltype(l_test) f4 = f_test; // error: conversion from ‘int(int)’ to non-scalar type ‘<lambda(int)>’ requested

    decltype(f_test) f5 = l_test; // warning: declaration of ‘int f5(int)’ has ‘extern’ and is initialized [enabled by default]
                                  // error: function ‘int f5(int)’ is initialized like a variable
    decltype(f_test) f6 = f_test; // warning: declaration of ‘int f6(int)’ has ‘extern’ and is initialized [enabled by default]
                                  // error: function ‘int f6(int)’ is initialized like a variable

    return 0;
}

Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 8 comments