0

I have to build a soft with XCode 4 + Base SDK 10.5 for legacy support.

It seems that I cannot turn on C++11 as detailed here (i.e. by setting "C++ Language Dialect" to "C++11" and "C++ Standard Library" to "libc++"), because when I do it, I get

clang error invalid deployment target for stdlib libc++ (requires OS 10.7 or later)

Then, as I can't load C++11 (thus, the answers of my previous question here cannot be used), how should I modify:

std::valarray<float> v(32);
std::sort(begin(v), end(v));            # Use of undeclared identifier 'begin'
std::sort(std::begin(v), std::end(v));  # No member named 'begin' in namespace 'std'

to make it work ?

Community
  • 1
  • 1
Basj
  • 41,386
  • 99
  • 383
  • 673
  • 2
    "Buy a new computer." -- Apple – Ryan Bemrose Oct 05 '16 at 20:37
  • @RyanBemrose I have one, but I need to compile with legacy support ;) – Basj Oct 05 '16 at 20:38
  • `v.begin()` and `v.end()` as described by an answer on your previous question – asu Oct 05 '16 at 20:47
  • @Asu This doesn't seem to work for `valarray` : `v.begin() : No member named 'begin' in 'std::valarray'` – Basj Oct 05 '16 at 20:48
  • Ah yes, has a non-member `begin` (as of C++11), but not a member one. Makes sense. XD This class is incredibly broken, almost no one uses that for a reason. – Baum mit Augen Oct 05 '16 at 20:54
  • Seems correct. Honestly, I've never heard of valarray before this question. I wonder why C++11 introduced non-members `begin` and `end` without their member counterparts... – asu Oct 05 '16 at 20:56
  • @TreeWithEyes Yes, I also heard about this :). Would you have a solution, without having to move from valarray to vector? – Basj Oct 05 '16 at 21:03
  • I fail to see why [this answer you already have](http://stackoverflow.com/a/39875156/4342498) does not work for you. – NathanOliver Oct 05 '16 at 21:52
  • @NathanOliver True. At the time of writing this question, I tried, it worked, but wasn't sure if it was the most natural way of doing it. Now, it works and I understand it better, so you're right : this gives the answer. I'll close this one myself. – Basj Oct 05 '16 at 22:07

0 Answers0