这不是一个突破性的问题,但我喜欢从警告中清除我的代码,所以这让我很紧张.
我一直在使用c ++ 11版本的pimpl成语以通常的方式隐藏我的库的类实现.
// dll header
class FrameworkImpl;
class EXPORT_API Framework
{
Framework(const Framework&) = delete;
Framework& operator=(const Framework&) = delete;
Framework(Framework&&) = delete;
Framework& operator=(Framework&&) = delete;
public:
Framework();
~Framework();
private:
std::unique_ptr<FrameworkImpl> impl_;
};
// application implementation
int main()
{
std::unique_ptr<Framework> test = std::make_unique<Framework>();
}
Run Code Online (Sandbox Code Playgroud)
一切都会好的,但我会继续收到警告:
warning C4251: 'Framework::impl_': class 'std::unique_ptr<FrameworkImpl,std::default_delete<_Ty>>' needs to have dll-interface to be used by clients of class 'Framework'
Run Code Online (Sandbox Code Playgroud)
所以我试着添加:
template class EXPORT_API std::unique_ptr<FrameworkImpl>;
Run Code Online (Sandbox Code Playgroud)
在前向声明之前,警告只会改为:
warning C4251: 'std::_Unique_ptr_base<_Ty,_Dx>::_Mypair': class 'std::_Compressed_pair<_Dx,FrameworkImpl *,true>' needs to have …Run Code Online (Sandbox Code Playgroud) 我有一个输入定义为
workflow_dispatch:
inputs:
level:
description: 'level to process'
type: number
required: false
Run Code Online (Sandbox Code Playgroud)
我想在步骤中运行命名操作,具体取决于值是否已设置,但我不知道如何
这可能有效:
if: ${{ github.event.inputs.level}}
Run Code Online (Sandbox Code Playgroud)
但我找不到相反的版本,这是无效的:
if: !${{ github.event.inputs.level}}
Run Code Online (Sandbox Code Playgroud) 我正在使用Boost :: Program_options来解析我的命令行,并修改了教程中的一些代码,如下所示:
try {
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "output help message")
("width,w", po::value<int>()->required(), " width")
;
po::positional_options_description p;
p.add("width", 1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).
options(desc).positional(p).run(), vm);
if (vm.count("help")) {
std::cout << "USAGE: " << av[0] << &p << std::endl;
return 0;
}
po::notify(vm);
if (vm.count("width")) {
std::cout << "width: " << vm["width"].as<int>() << "\n";
}
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
return 1;
} catch (...) {
std::cout << "Exception of unknown type!" << …Run Code Online (Sandbox Code Playgroud) 假设我有一个字典声明如下:
Dictionary<string, IData> map;
Run Code Online (Sandbox Code Playgroud)
我希望使用包含特定子字符串的键获取所有值,例如函数
public IEnumerable<IData> GetContains(string pattern) {}
Run Code Online (Sandbox Code Playgroud)
我想了解如何使用匹配模式的密钥列表
var result = mapData.Keys.Where(a => a.Contains(pattern)).ToArray()
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何重用返回的键来获取一个查询中的所有相应值.
我需要从1D阵列中提取4D位置.我可以看到2D和3D是怎么回事,但是我很难将头围绕在第四维度上.
对于2D:
int* array = new int[width * height];
int index = y * width + x;
int x = index / height
int y = index - x * height;
Run Code Online (Sandbox Code Playgroud)
对于3D:
int* array = new int[width * height * depth];
int index = z * width * height + y * width + z;
int x = index / (height * depth);
int y = index - (x * height * depth) / depth;
int z = index - …Run Code Online (Sandbox Code Playgroud) 尝试序列化此简单类:
class Data
{
public:
Data();
Data(boost::uuids::uuid id);
Data(const Data&) = delete;
Data& operator=(const Data&) = delete;
inline boost::uuids::uuid getGuid() { return guid; }
template <class Archive>
void serialize(Archive & ar)
{
ar(guid);
}
private:
boost::uuids::uuid guid;
};
Run Code Online (Sandbox Code Playgroud)
但我收到此错误消息
error C2338: Trying to serialize an unserializable type with an output archive.
Run Code Online (Sandbox Code Playgroud)
潜伏到uuid。实现此目的的Boost序列化方法是添加
#include <boost/uuid/uuid_serialize.hpp>
Run Code Online (Sandbox Code Playgroud)
但这不适用于开箱即用的谷物。谷物文件说
谷物存档在std :: ostream或std :: istream对象上运行。
所以我尝试在已定义但没有运气的地方添加标题
#include <boost/uuid/uuid_io.hpp>
Run Code Online (Sandbox Code Playgroud) 我正在尝试转换相对路径并将其转换为绝对路径以使用 boost 文件系统传递给 SQLite。这应该适用于 windows 和 linux
boost::filesystem::path path("../../data/dominion");
boost::filesystem::path file("dominion.db");
boost::filesystem::path canonical = boost::filesystem::canonical(dataPath / file);
Run Code Online (Sandbox Code Playgroud)
规范回报
m_pathname=L"D:/Users\\me\\Documents\\tonkatsu\\data\\dominion\\dominion.db"
Run Code Online (Sandbox Code Playgroud)
如您所见,路径“D:/”的开头不正确。我也尝试调用 normalize() 没有成功
有没有办法解决这个问题?
c++ ×4
3d ×1
arrays ×1
boost ×1
boost-uuid ×1
c# ×1
c++11 ×1
cereal ×1
dictionary ×1
linq ×1
pimpl-idiom ×1
visual-c++ ×1