no type named ‘iterator_category’ in ‘struct std::iterator_traits<std::__cxx11::basic_string<char> >’

Environment: Linux Mint 20.1, Code::Blocks, gcc 10.3.0

I am trying to copy files with some copy_options included but as soon as I include one the compiler throws errors:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  int main(int argc, char *argv[])
{
    using namespace std;
    using namespace std::filesystem;
    namespace fs = std::filesystem;


    path p = "/home/hbatalha/Documents//lib";
    path p1 = "/home/hbatalha/Qt/6.2.0/gcc_64/lib";

    create_directories(p);

    ifstream in("/home/hbatalha/Documents/libs.txt");

    string line;

    vector<string> vecStr;

    while (getline(in, line))
    {
        vecStr.push_back(line);
    }

    const auto copyOptions = fs::copy_options::update_existing
                             | fs::copy_options::recursive
                             | fs::copy_options::directories_only
                             ;

    for(auto const& e : directory_iterator(p1))
    {

        copy(e.path().string(), p.string() + "/" + e.path().filename().string(), copyOptions);

    }

    return 0;
}


The errors thrown:
1
2
3
4
5
/usr/local/include/c++/10.3.0/bits/stl_algobase.h|465|error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<std::__cxx11::basic_string<char> >’|
/usr/local/include/c++/10.3.0/bits/stl_algobase.h|469|error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<std::__cxx11::basic_string<char> >’|
/usr/local/include/c++/10.3.0/bits/stl_algobase.h|472|error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<std::__cxx11::basic_string<char> >’|
||=== Build failed: 3 error(s), 5 warning(s) (0 minute(s), 1 second(s)) ===|
Last edited on
Should it be fs::copy ? Atm it is std::copy because of line 3. Really got to stop doing line 3.

Are you compiling with c++17 ?

You didn't show the include files.

There is also std::filesystem::recursive_directory_iterator
Should it be fs::copy ?

Oh that solved the problem.

Thank you.
Topic archived. No new replies allowed.