小编Ale*_*lex的帖子

为什么要在 C++ lambda 前面放置一元加 (+) 运算符?

我发现在 C++ 中我们可以+在 lambda 函数中使用+[]{} 文章中的示例:

#include <iostream>
#include <type_traits>
int main()
{
    auto funcPtr = +[] {};
    static_assert(std::is_same<decltype(funcPtr), void (*)()>::value);
}
Run Code Online (Sandbox Code Playgroud)

lambda中+号的主要思想

您可以通过在前面添加 + 来强制编译器将 lambda 生成为函数指针而不是闭包,如上所示。

但是在 lambda 中使用“+”有什么好处呢?您能否提供示例或将我链接到解释?

c++ lambda

17
推荐指数
2
解决办法
1434
查看次数

Django + Docker:连接到“localhost”(127.0.0.1)服务器,端口 5432 失败

我正在尝试在 docker 中运行我的 Django 应用程序(Nginx、Gunicorn)。

但对于请求http://167.99.137.32/admin/我有错误:(完整日志https://pastebin.com/0f8CqCQM)

onnection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
    Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (::1), port 5432 failed: Address not available
    Is the server running on that host and accepting TCP/IP connections?
Run Code Online (Sandbox Code Playgroud)

我正在尝试Can't run the server on Django (connection returned)的答案,但没有解决我的问题

设置.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'lk_potok_2',
        'USER': 'postgres',
        'PASSWORD': 'post222',
        'HOST': 'localhost', …
Run Code Online (Sandbox Code Playgroud)

django postgresql nginx docker

12
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×1

django ×1

docker ×1

lambda ×1

nginx ×1

postgresql ×1