Archicad C++ API
About Archicad add-on development using the C++ API.

C++API: GS::Array Begin() vs. begin()

Sam Karli
Enthusiast

Something strange I don't understand (but I'm a beginner)

 

For being able to iterate through an iterable object using a for each-style loop, the object must define the begin() and the end() methods. GS::Array does this, but as Begin() and End() strictly following the naming conventions. But as C++ is case sensitive, this doesn't meet requirement for the for each loops, so it cannot be done.

 

So I tried to create an inherited Array class (now S::Array) and defining the begin() and end() methods, and voilá, for each started to work.

 

I don't believe that it's a real issue and I try to understand where I'm wrong.

-is it meant to work? (I use a Community Edition of VS and Windows SDK 7.1, for my old Archicad SE 2016 ~ AC19, so not a vanilla environment, this might be responsible for the difference, at least in theory)

-I haven't seen any for each, or for (auto this:that) -style looping, so it's possible that in Graphisoft folks don't use this style of loooping (only the indexed or using the blablaIterator, both are quite long and more error-prone, I guess). Is this the case?

-one extra thing, for meg the for each (auto this in that) works, while for (auto this:that) not, what can be the root of the problem? for each is discouraged / deprecated by M$, as I have read, what can be the root of the problem?

 

I think all these are a beginner's lamentations, but maybe worth of answeing it

GDL/Python/C++ dev
2 REPLIES 2
Akos Somorjai
Graphisoft
Graphisoft

Hi Sam,

I'm afraid you are out of luck with our Array in older versions of the development kit (AC19 _is_ old for us 😉). The latest Development Kit for Archicad 25 does support modern C++ (C++14, to be precise), like the for (const auto& elem: array) syntax.

Best, Akos

Thanks,

then I'll have to break my piggy-bank to upgrade to a newer AC 🙂

Now I'm about to sort my Array based on a (preferably lambda) function.

GDL/Python/C++ dev