UFO:Alien Invasion

Development => Newbie Coding => Topic started by: xray on July 11, 2014, 08:38:35 pm

Title: ANSI C99 guideline & c++ generics language feature
Post by: xray on July 11, 2014, 08:38:35 pm
Hi,

I noticed in the source of list.h the following code:

Code: [Select]
template<typename T> inline T& LIST_Add(linkedList_t** const list, T const& data)
{
return *static_cast<T*>(LIST_Add(list, &data, sizeof(data))->data);
}

To my knowledge, templates are a C++ language feature. The coding guidelines state: use ANSI C99 only. I'm asking this because
I'm working on a hash table implementation. A generic hash table could be much easier written if we could use some of the C++ language features like "generics". How strict should I follow the guideline?

Any thoughts?

xray
Title: Re: ANSI C99 guideline & c++ generics language feature
Post by: DarkRain on July 11, 2014, 11:52:51 pm
Hi,

The coding guidelines state: use ANSI C99 only.

Disregard that, the coding guidelines are out of date, the project has since then been "converted" to C++, but the new guidelines were never fully agreed on (you can see some discussion on it here (http://ufoai.org/wiki/Talk:Coding/Guidelines) if you want)
Title: Re: ANSI C99 guideline & c++ generics language feature
Post by: xray on July 12, 2014, 09:34:09 am
Great. This simplifies some things a lot.

Does this mean the STL can also be used? This way, I can skip working on the hash table since STL already has excellent associative containers ready for use.

xray
Title: Re: ANSI C99 guideline & c++ generics language feature
Post by: Sandro on July 13, 2014, 09:26:51 pm
about half of the programming team (including me) are against using stl

my personal reasons are: not thread safe, unsafe iterators, unsafe realloc behaviour. Not to mention compiler errors which do not fit into 256 characters and consist mostly of ::<>::<>::<>
Title: Re: ANSI C99 guideline & c++ generics language feature
Post by: xray on July 14, 2014, 10:42:39 am
about half of the programming team (including me) are against using stl

my personal reasons are: not thread safe, unsafe iterators, unsafe realloc behaviour. Not to mention compiler errors which do not fit into 256 characters and consist mostly of ::<>::<>::<>

A clear statement. Hadn't thought about these issues.

xray