如何用std::distance对c风格数组类型使用std::copy输出
How to use std::copy output with std::distance for a C-style array type
如何存储从std::copy
返回的OutputIterator用作以后std::distance
调用的参数?
我不能在c++ 11中使用auto,我需要使用C风格的数组。
这就是我要做的:
unsigned char data[MAX_DATA_LEN];
unsigned char x[MAX_X_LEN], y[MAX_Y_LEN];
// I cannot use auto here
auto out =
std::copy ( x,
x + runtime_x_len ,
std::copy ( y,
y + runtime_y_len ,
data ) );
size_t data_size = std::distance ( data , out );
对于c风格的数组,返回的'迭代器'只是一个指向元素类型的指针。
那么在您的例子中,std::copy()
的返回值将是unsigned char*
相关文章:
- 如何获取std::result_of函数的返回类型
- 如何在c++迭代器类型中包装std::chrono
- 在C++中对T*类型执行std::move的意外行为
- 检查 std::shared_ptr<> 的当前底层类型是否为 T
- 在一个模板函数中,若输入的类型是enum类,我该如何使用std::underlying_type
- 为什么 std::optional::operator=(U&&) 要求你是非标量类型?
- std::visit无法识别类型
- 哪些类型可以转换为std::any
- 从类型std::函数传递变量失败,尽管调用方期望的类型完全相同
- ";结果类型必须是可从输入范围的值类型""构造的;创建std::vector时
- <Windows>为什么 std::thread::native_handle 返回类型为"long long unsigned int"的值,而不是 void*(又名 HANDLE)?
- r语言 - C++ 类型为"const std ::?
- C++中"std::sort"比较器的不同类型
- C++11 中不同类型的对象的 std::array 的替代方案
- 检查某些类型是否是模板类 std::optional 的实例化
- clion 无法解析 std 类型
- 使用 std 类型的 ADL 无法找到运算符
- 为什么 std 类型不提供来自分配器不同源的转换构造函数/赋值
- 哪些 std 类型在移动构造函数中用作 arg 后保证为空/空
- Qt -混合Qt和std:: c++类型