Monday 15 March 2010

c++ - How to fix clang libc++ error on Mac: calling private constructor -



c++ - How to fix clang libc++ error on Mac: calling private constructor -

i'm trying compile (private) c++ software clang , libc++ on mac os x 10.10 , getting error:

error: calling private constructor of class 'std::__1::__wrap_iter<unsigned short *>'

full error message here.

can explain error , how prepare it? little self-contained code illustration results in error , alternative how re-write works great!

you're asking self-contained illustration showing error haven't provided own example? that's not how stackoverflow works, meant show code not create people guess @ problem!

this produces error:

#include <vector> void f(unsigned short* p) { std::vector<unsigned short>::iterator i(p); }

looks though you're trying build iterator pointer, not valid (it might work compilers, not portable).

you seek using pointer arithmetic iterator instead:

std::ptrdiff_t d = std::distance(vec.data(), p); std::vector<unsigned short>::iterator = vec.begin() + d;

this assumes p point element of vector, otherwise distance(vec.data(), p) undefined.

c++ osx compiler-errors clang++ libc++

No comments:

Post a Comment