

ça aide encore moins)
) que sont les templates du C++, enfin bref je pense qu'il y aurais eu de moyens de faire mieux, c'est tout, enfin bref, j'ai pas très envie de débattre sur des choses sans trop d'intérêt autre que les goûts et les couleurs
template<class T> struct Complexe { T re; T img; };
type 'a complexe = { re:'a; img:'a }
Fab_ (./5474) :
il est déjà en couple

Godzil (./5498) :
ya d'autre moyen pour factoriser que les templates
Zephyr (./5499) :
cf edit, tu as un exemple précis en tête ou tu penses que ça existe ?


int a, b; int c = min(a, b);


very (./5501) :
Genre au lieu de faire
template<class T> struct Complexe { T re; T img; };
on faittype 'a complexe = { re:'a; img:'a }
type 'a complexe = { re: (< .. > as 'a); img:'a } ;;
type 'a complexe = { re: 'a; img:'a } constraint 'a = < .. >;;
$ cat test.cc
#include <iostream>
template<class T>
class A
{
public:
void print (const T& t) const
{
std::cout << t << std::endl;
}
};
int main ()
{
A<int> a;
a.print (17);
}
$ g++ test.cc
$ ./a.out
17
$Zephyr (./5504) :
mais bien sûr, v lire ta source de 2000 lignes

/* manip.c: Routines to manipulate the internal data Copyright (C) 2002-2004 Sebastian Reichelt Copyright (C) 2003-2007 Kevin Kofler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
// Find the item preceding or following the given location. May return NULL.
#define DefineFindItemAtPos(Type,Item,LocationSuffix) \
Type *Find##Item##AtPos (const SECTION *Section, OFFSET Location, BOOLEAN Following) \
{ \
/* Find the place so that Item->Location is always less than Location */ \
/* and Next##Item->Location is always greater or equal. */ \
Type *Item = NULL, *Next##Item = NULL; \
if (Location > Section->Size >> 1) \
{ \
Item = GetLast (Section->Item##s); \
while (Item && (Item->Location LocationSuffix >= Location)) \
{ \
Next##Item = Item; \
Item = GetPrev (Item); \
} \
} \
else \
{ \
Next##Item = GetFirst (Section->Item##s); \
while (Next##Item && (Next##Item->Location LocationSuffix < Location)) \
{ \
Item = Next##Item; \
Next##Item = GetNext (Next##Item); \
} \
} \
/* If we are looking for something that follows, the case is clear. */ \
/* Otherwise, we need to check whether the next item is also OK. */ \
if (Following || (Next##Item && (Next##Item->Location LocationSuffix <= Location))) \
return Next##Item; \
else \
return Item; \
}
DefineFindItemAtPos (SYMBOL, Symbol, );
DefineFindItemAtPos (RELOC, Reloc, );
DefineFindItemAtPos (ROM_CALL, ROMCall, );
DefineFindItemAtPos (RAM_CALL, RAMCall, );
DefineFindItemAtPos (LIB_CALL, LibCall, );
DefineFindItemAtPos (SEGMENT, Segment, .Start->Location);
#undef DefineFindItemAtPosZephyr (./5514) :
(de toutes façons le "class" comme le "typename" ne sont là que pour désambiguïser la syntaxe, et pourraient d'ailleurs être complètement supprimés ici)
aze (./6) :
et tu veux nous faire croire que tu ne racontes pas n'importe quoi ?
