小编dav*_*ear的帖子

std::ranges::copy 在 Visual Studio 中不会接受 std::vector

下面的代码不能在 Visual Studio 中编译,给出

错误 C2672 'operator __surrogate_func':未找到匹配的重载函数 sortms C:\Users\David\source\repos\sortms\sortms.cpp 103

当我使用 C 风格数组时,该函数按照编写的方式工作。如果我使用指定的注释代码,该函数也可以工作input.begin(), input.end(), output.begin()。

我使用的是 Visual Studio Community 2019 v16.8.6,使用该/std:c++latest选项进行编译。我认为标准容器是基于范围的?

std::range::copy()有人可以帮助我更好地理解vsstd::copy()在处理向量或其他标准容器时的优势吗?

#include <iostream>
#include <ranges>
#include <algorithm>
#include <array>
#include <utility>
#include <vector>
#include <functional>
#include <string>
#include <concepts>

void ranges_copy_demo()
{
    std::cout << "\nstd::ranges::copy()\n";

/*
    int const input[] = { 1, 2, 3, 5, 8, 13, 21, 34, 45, 79 };
    int output[10] = { 0 };
*/
    std::vector<int> input …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors c++20 std-ranges

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

标签 统计

c++ ×1

c++20 ×1

compiler-errors ×1

std-ranges ×1