小编Ser*_*gio的帖子

缺少C++ 11中的std :: u8string

为什么C++ 11提供std::u16stringstd::u32stringstd::u8string?我们需要实现utf-8编码或使用其他库吗?

unicode utf-8 c++11

8
推荐指数
1
解决办法
2600
查看次数

如何在 Visual Studio 2019 中启用 c++20(16.3 预览版 4)

如何在 Visual Studio 2019(16.3 预览版 4)中启用 c++20?
我对测试一些 C++20 特性很感兴趣。

c++ c++20 visual-studio-2019

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

从字符串向量中删除_if

如果任何字符串包含某个单词,我需要从字符串向量中删除一些元素.

我怎样才能写出一元谓词remove_if

这是代码示例:

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool remove_if_found(string word)
{
   // ???
}

int main()
{
vector<string> data {
                        { "the guitar has six strings" },
                        { "the violin has four strings" },
                        { "the the violin is more difficult to learn" },
                        { "saxophones are a family of instruments" },
                        { "the drum is a set of percussions" },
                        { "the trumpet is a brass" }
};

cout << …
Run Code Online (Sandbox Code Playgroud)

algorithm c++11

2
推荐指数
1
解决办法
428
查看次数

How to print a range of elements (std::pair&lt;size_t, std::string&gt;) belonging to a map (not all elements)

How can I print a range of elements (key and value) belonging to a std::map<size_t, std::string>?
I don't need to print all elements.
Every suggestion using C++11, C++14 or C++17, without boost libraries, is appreciated.

#include <iostream>
#include <iomanip>
#include <string>
#include <map>

using namespace std;

void print(map<size_t, string> & m)
{
    for(auto & [key, value] : m)
    {
        cout << setw(6) << left << key << value << endl;
    }
}

void print_range(map<size_t, string> & m, size_t first, size_t …
Run Code Online (Sandbox Code Playgroud)

c++ c++11 c++14 c++17

2
推荐指数
1
解决办法
114
查看次数

使用 Inkscape 从批处理文件转换 Svg 到 png 多个文件

我有一个包含许多 svg 文件的文件夹,我想使用带有批处理脚本(Windows 10*.bat文件)的inkscape 将它们转换为png 文件。以下脚本适用于单个文件,但是,如何为目录中的数百个文件迭代相同的命令?

PATH = "C:\Program Files\Inkscape"

inkscape myfile.svg --export-png=myfile.png
Run Code Online (Sandbox Code Playgroud)

batch-file inkscape

1
推荐指数
1
解决办法
3612
查看次数

如何在成员函数内将函数及其参数传递给 std::async

我尝试std::async按以下方式在成员函数内部使用:

#include <iostream>
#include <vector>
#include <string>
#include <future>

using namespace std;

class splitter
{
    public:
    splitter() = default;
    virtual ~splitter() = default;
    bool execute(vector<string> &vstr);
    bool split_files(vector<string> &vstr);
};

bool splitter::split_files(vector<string> &vstr)
{
    for(auto & file : vstr)
    {
        // do something
        cout << file << endl;
    }
    return true;
}

bool splitter::execute(vector<string> &vstr)
{
    auto fut = std::async(std::launch::async, split_files, vstr);
    bool good = fut.get();
    return good;
}

int main()
{
    vector<string> filenames {
                                "file1.txt",
                                "file2.txt",
                                "file3.txt" …
Run Code Online (Sandbox Code Playgroud)

c++ c++11 c++14 c++17

0
推荐指数
1
解决办法
3214
查看次数