我在尝试创建使用C++ 11标准线程的VC++静态库时遇到问题.
我目前有两个类,我能够声明并稍后在我的起始类(最后声明的)上定义一个线程.在此阶段,代码只是一个套接字侦听器,然后创建另一个类的对象来处理接受的每个客户端.这些子对象应该创建并行数据捕获,编码和传输所需的线程.
问题是:如果我在我的另一个类上声明一个std :: thread,即使我完全像在我的start类上那样,无论如何,我在构建时遇到这个错误 error C2280: 'std::thread::thread(const std::thread &)' : attempting to reference a deleted function [...]\vc\include\functional 1124 1
我能够解决这个错误的唯一方法是std::thread根据我想要它做的事情,根本不在后一个类中声明一个对象,这是不可能的.
我正在使用VS2013,我的来源是:
stdafx.h中
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <Windows.h>
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <thread>
#include <iostream>
#include <vector>
Run Code Online (Sandbox Code Playgroud)
StreamServer.h
#pragma once
#define DEFAULT_BUFLEN 65535
#define DEFAULT_PORT "5649"
class StreamServerClient
{
public:
bool* terminate;
//std::thread client; //If I comment this line out, it builds just fine.
void DoNothing(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试将 XML 解组为一个我期望应该具有特定字段的对象。但是,我不想将该对象编组到包含它的 XML 中。我喜欢的是类似于这样的:
@XmlRootElement(name = "User")
public class User {
private String name;
@XmlTransient
public String getName() {
return this.name
}
@XmlElement(name = "Name")
public void setName(String name) {
this.name = name
}
}
Run Code Online (Sandbox Code Playgroud)
但是,由于注释冲突,这不起作用,因为我无法将任何其他 XML 注释与@XmlTransient. 我还尝试@XmlTransient在字段本身而不是 getter 上添加注释,并设置了此选项:
XmlAccessorType(XmlAccessType.FIELD)
此外,我将@XmlElement注释保留在设置器上,这对于排除该字段进行编组绝对没有任何作用。
我想保留@XmlElement注释,因为我希望能够将具有不同名称的字段(这里只是大小写差异)翻译成我想要的任何字段。
我也无法删除 getter,因为我确实在应用程序中使用了它。
鉴于此,我不知道此时我的选择是什么,除了编写一个适配器(我可以这样做,但如果有另一种解决方案,我宁愿不使用自定义适配器,因为这个字段)。任何帮助将不胜感激。