project-navigation
Personal tools

Author Topic: ANSI C99 guideline & c++ generics language feature  (Read 6019 times)

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
ANSI C99 guideline & c++ generics language feature
« 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

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: ANSI C99 guideline & c++ generics language feature
« Reply #1 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 if you want)

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: ANSI C99 guideline & c++ generics language feature
« Reply #2 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

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: ANSI C99 guideline & c++ generics language feature
« Reply #3 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 ::<>::<>::<>

Offline xray

  • Rookie
  • ***
  • Posts: 72
    • View Profile
Re: ANSI C99 guideline & c++ generics language feature
« Reply #4 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