我对ctor明确违约时会发生什么感到困惑.
这两个代码示例是否相同?
Y能够使用第一个选项是否有任何限制?
class X
{
public:
X() = default;
private:
Y m_y;
};
class X
{
public:
X() : m_y() {}
private:
Y m_y;
};
Run Code Online (Sandbox Code Playgroud) 使用Amazon EC2我已成功启动Windows Server 2012实例并将其配置为运行Tomcat Web服务器.
从VPS本身,我知道网络服务器正在运行,因为我在键入时在Web浏览器中看到了Tomcat页面http://localhost:8080.
但是,即使我在安全组中创建了一条规则,允许来自所有地址(0.0.0.0/0)的端口8080上的传入流量,我也无法从外部访问它.
打字'curl -v http://ec2-54-194-6-178.eu-west-1.compute.amazonaws.com:8080 '返回:
我还运行了一个使用相同安全组的Linux实例.我能够连接到那就好了.
我对配置Tomcat知之甚少,但我还在配置文件server.xml中添加了address ="0.0.0.0"以防万一这是一个潜在的原因.
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
address="0.0.0.0" />
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题的任何想法将不胜感激.
更新
我最终想通了.我可以通过关闭Windows防火墙连接到Tomcat Web服务器.
curl tomcat amazon-ec2 amazon-web-services windows-server-2012
以下是根据http://jsonlint.com/和http://jsonschemalint.com/draft4/#的有效JSON架构.
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"required": ["results"],
"additionalProperties": false,
"properties": {
"results": {
"type": "string",
"oneOf": [
{ "result": "1" },
{ "result": "2" },
{ "result": "3" },
{ "result": "4" }
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下JSON results is the wrong type在针对上述架构进行验证时报告错误():
{
"results" : {
"result": "1"
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我如何解决此错误?
我试图在下面的代码片段中理解lambda表达式的含义.
lambda表达式按值而不是通过引用捕获变量,否则message在foo退出时会破坏局部变量.
我不明白的是捕获m_impl.如果Impl删除了复制文件,如何通过值捕获?请有人开导我吗?
void Foo::foo(std::shared_ptr<std::string> message)
{
m_impl->m_thread.send([=] { m_impl->handleMessage(message); });
}
Run Code Online (Sandbox Code Playgroud)
handleMessage 声明为:
void handleMessage(std::shared_ptr<std::string> message)
Run Code Online (Sandbox Code Playgroud)
并m_impl作为:
std::unique_ptr<Impl> m_impl;
Run Code Online (Sandbox Code Playgroud)
Impl 删除了其复制构造函数和赋值运算符.
我是Java和Maven的新手,我对默认的清单文件有疑问.
据我所知,当使用maven构建Java应用程序时会创建清单,并将其添加到生成的jar文件中.
我也看到过很多对manifest.mf文件的引用,可以在一个名为的目录中找到meta-inf.但我无法在任何地方找到它.
我已经使用成功构建了我的Java应用程序mvn package.我可以看到jar文件,但我无法在任何地方找到清单文件.构建完成后会自动删除吗?
下面的代码成功地向给定端点发送异步消息.
// message is a boost::shared_ptr<std::string>
// open a UDP socket
boost::asio::ip::udp::socket socket(ioService);
socket.open(boost::asio::ip::udp::v4());
// create the remote endpoint
boost::asio::ip::udp::endpoint remoteEndpoint(boost::asio::ip::address_v4::from_string(address), port);
// asynchronously send a datagram to the remote endpoint
socket.async_send_to(boost::asio::buffer(*message),
remoteEndpoint,
boost::bind(&MyClass::handler,
this,
message,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
socket.close();
Run Code Online (Sandbox Code Playgroud)
但是,如果我将类型更改message为a std::shared_ptr<std::string>而不是a boost::shared_ptr<std::string>则调用async_send_to不会编译.
错误是:
boost/boost/bind/bind.hpp:457:9: No matching function for call to object of type 'boost::_mfi::mf3<void, MyClass, const boost::shared_ptr<std::__1::basic_string<char> > &, const boost::system::error_code &, unsigned long>'.
Run Code Online (Sandbox Code Playgroud)
有人可以解释什么是错的吗?可能是因为我正在使用boost :: bind吗?
请考虑以下代码段:
#include <map>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
using TargetsType = std::map<float, std::string>;
using TimesType = std::set<float>;
void foo (const TargetsType& targets,
const TimesType& times)
{
for (const auto& target : targets)
{
// fails to compile
TimesType::const_iterator iter1 = std::find_if(times.begin(),
times.end(),
[&(target.first)](float item)
{
return std::fabs(item - target.first) < 0.1f;
});
// compiles OK
TimesType::const_iterator iter2 = std::find_if(times.begin(),
times.end(),
[&](float item)
{
return std::fabs(item - target.first) < 0.1f;
});
}
}
Run Code Online (Sandbox Code Playgroud)
iter1无法编译的声明,出现以下错误:
error: expected ',' …Run Code Online (Sandbox Code Playgroud) c++ ×4
c++11 ×4
lambda ×2
amazon-ec2 ×1
boost-asio ×1
boost-bind ×1
c++14 ×1
constructor ×1
curl ×1
java ×1
json ×1
jsonschema ×1
manifest.mf ×1
maven ×1
shared-ptr ×1
tomcat ×1