我发现在 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 中使用“+”有什么好处呢?您能否提供示例或将我链接到解释?
我正在尝试在 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)