OVH Cloud OVH Cloud

affichage d un set

11 réponses
Avatar
horneta2005
je voudrais trier et afficher un set de vector
je n arrive pas a trier un set
et je n arrive pas a l afficher
soit le code suivant

std::vecor<int>MonVector
std::set<std::vector<int> >MonSet

do
{......
MonSet.insert(MonVector);//a chaque fois un Monvector different est
inserer dans le Set
....
}
while ()


je veut maintenant le trier (le set )et l afficher
c est la que sa coince
Sort (MonSet.begin(),Monset.end());
copy (MonSet.begin(),Monset.end(),affichage());//je n arrive pas
a ecrire affichage

merci de votre aide

10 réponses

1 2
Avatar
Arnaud Debaene
wrote:
je voudrais trier et afficher un set de vector
je n arrive pas a trier un set
Normal : un std::set est toujours trié, par définition.


et je n arrive pas a l afficher
soit le code suivant

std::vecor<int>MonVector
std::set<std::vector<int> >MonSet

do
{......
MonSet.insert(MonVector);//a chaque fois un Monvector different est
inserer dans le Set
....
}
while ()


je veut maintenant le trier (le set )et l afficher
c est la que sa coince
Sort (MonSet.begin(),Monset.end());
Inutile vu que le set est trié.


copy (MonSet.begin(),Monset.end(),affichage());//je n arrive pas
a ecrire affichage
affichage est défini comment? Ce doit être un foncteur capable de prendre un

std::vector<int> en entrée.

Arnaud

Avatar
Fabien LE LEZ
On 2 Oct 2005 15:05:12 -0700, ""
:

je veut maintenant le trier (le set )et l afficher
c est la que sa coince

Sort (MonSet.begin(),Monset.end());


Mauvais pour deux raisons :

- d'une part, un std::set est automatiquement trié ;
- d'autre part, la fonction "Sort" n'a jamais existé.

copy (MonSet.begin(),Monset.end(),affichage());//je n arrive pas


Par exemple :

ostream& operator << (ostream& os, vector<int> const& v)
{
copy (v.begin(), v.end(), ostream_iterator<int>(os," "));
}

ostream& operator << (ostream& os, set<vector<int> > const& s)
{
copy (s.begin(), s.end(), ostream_iterator<int>(os,"n"));
}

Avatar
Fabien LE LEZ
On 2 Oct 2005 15:05:12 -0700, ""
:

copy (MonSet.begin(),Monset.end(),affichage());//je n arrive pas


Soit le code suivant :

#include <set>
#include <vector>
#include <iterator>
#include <iostream>
using namespace std;

ostream& operator << (ostream& os, vector<int> const& v)
{
copy (v.begin(), v.end(), ostream_iterator<int>(os," "));
return os;
}

ostream& operator << (ostream& os, set<vector<int> > const& s)
{
copy (s.begin(), s.end(), ostream_iterator<vector<int> > (os,"n"));
return os;
}

J'aimerais bien savoir pourquoi, bien que BC++ 5.5 l'accepte sans
broncher, Comeau le refuse (avec un message d'erreur de 367 lignes).

Merci d'avance...

E:temp>como -n temp.cpp
Comeau C/C++ 4.3.3 (Jan 13 2004 11:29:09) for MS_WINDOWS_x86
Copyright 1988-2003 Comeau Computing. All rights reserved.
MODE:non-strict warnings borland C++

"V:Comeaulibcomostl_iterator.h", line 695: error: no operator "<<" matches
these operands
operand types are: std::ostream_iterator<std::vector<int,
std::allocator<int>>, char,
std::char_traits<char>>::ostream_type << const
std::vector<int, std::allocator<int>>
*_M_stream << __value;
^
detected during:
instantiation of "std::ostream_iterator<_Tp, _CharT, _Traits>
&std::ostream_iterator<_Tp, _CharT,
_Traits>::operator=(const _Tp &) [with
_Tp=std::vector<int, std::allocator<int>>, _CharT=char,
_Traits=std::char_traits<char>]" at line 157 of
"V:Comeaulibcomostl_algobase.h"
instantiation of "_OutputIter std::__copy(_InputIter, _InputIter,
_OutputIter, std::input_iterator_tag, _Distance *) [with
_InputIter=std::_Rb_tree_iterator<std::_Rb_tree<std::set<
std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_reference,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_pointer>,
_OutputIter=std::ostream_iterator<std::vector<int,
std::allocator<int>>, char, std::char_traits<char>>,
_Distance=std::iterator_traits<std::_Rb_tree_iterator<std
::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_reference,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_pointer>>::difference_type]
" at line 188 of "V:Comeaulibcomostl_algobase.h"
instantiation of "_OutputIter std::__copy_aux2(_InputIter,
_InputIter, _OutputIter, __false_type) [with
_InputIter=std::_Rb_tree_iterator<std::_Rb_tree<std::set<
std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_reference,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_pointer>,
_OutputIter=std::ostream_iterator<std::vector<int,
std::allocator<int>>, char, std::char_traits<char>>]" at
line 221 of "V:Comeaulibcomostl_algobase.h"
instantiation of "_OutputIter std::__copy_aux(_InputIter,
_InputIter, _OutputIter, _Tp *) [with
_InputIter=std::_Rb_tree_iterator<std::_Rb_tree<std::set<
std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_reference,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_pointer>,
_OutputIter=std::ostream_iterator<std::vector<int,
std::allocator<int>>, char, std::char_traits<char>>,
_Tp=std::iterator_traits<std::_Rb_tree_iterator<std::_Rb_
tree<std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_reference,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_pointer>>::value_type]" at
line 229 of "V:Comeaulibcomostl_algobase.h"
instantiation of "_OutputIter std::copy(_InputIter, _InputIter,
_OutputIter) [with
_InputIter=std::_Rb_tree_iterator<std::_Rb_tree<std::set<
std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_reference,
std::_Rb_tree<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::key_type,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::value_type,
std::_Identity<std::set<std::vector<int,
std::allocator<int>>, std::less<std::vector<int,
std::allocator<int>>>, std::allocator<std::vector<int,
std::allocator<int>>>>::value_type>,
std::set<std::vector<int, std::allocator<int>>,
std::less<std::vector<int, std::allocator<int>>>,
std::allocator<std::vector<int,
std::allocator<int>>>>::key_compare,
std::allocator<std::vector<int,
std::allocator<int>>>>::const_pointer>,
_OutputIter=std::ostream_iterator<std::vector<int,
std::allocator<int>>, char, std::char_traits<char>>]" at
line 15 of "temp.cpp"

1 error detected in the compilation of "temp.cpp".


Avatar
kanze
Fabien LE LEZ wrote:
On 2 Oct 2005 15:05:12 -0700, ""
:

copy (MonSet.begin(),Monset.end(),affichage());//je n arrive pas


Soit le code suivant :

#include <set>
#include <vector>
#include <iterator>
#include <iostream>
using namespace std;

ostream& operator << (ostream& os, vector<int> const& v)
{
copy (v.begin(), v.end(), ostream_iterator<int>(os," "));
return os;
}

ostream& operator << (ostream& os, set<vector<int> > const& s)
{
copy (s.begin(), s.end(), ostream_iterator<vector<int> > (os,"n"));
return os;
}

J'aimerais bien savoir pourquoi, bien que BC++ 5.5 l'accepte sans
broncher, Comeau le refuse (avec un message d'erreur de 367 lignes).


Parce que le code n'est pas légal, et que Comeau enforce les
nouvelles règles.

Le problème, c'est que c'est dans l'instantiation de
ostream_iterator que le compilateur va chercher l'opérateur <<.
Et que c'est une récherche dépendante, ce qui veut dire que le
compilateur ne cherche QUE dans les éspaces référentiels des
paramètres. Ici, donc, std (parce que vector s'y trouve), mais
nulle part ailleurs (parce que int n'est pas dans un éspace
référentiel, même pas dans l'éspace global).

La solution évidente, c'est de définir l'opérateur << pour
vector<int> dans l'éspace référentiel std::. Ce qui donne un
comportement indéfini (mais qui ne risque pas de ne pas marcher
dans la pratique).

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


Avatar
Fabien LE LEZ
On 4 Oct 2005 01:01:44 -0700, "kanze" :

La solution évidente, c'est de définir l'opérateur << pour
vector<int> dans l'éspace référentiel std::. Ce qui donne un
comportement indéfini


Si jamais on voulait suivre la norme à la lettre (i.e. pas de
comportement indéfini), y aurait-il une solution élégante au
problème ?

Avatar
Jean-Marc Bourguet
Fabien LE LEZ writes:

On 4 Oct 2005 01:01:44 -0700, "kanze" :

La solution évidente, c'est de définir l'opérateur << pour
vector<int> dans l'éspace référentiel std::. Ce qui donne un
comportement indéfini


Si jamais on voulait suivre la norme à la lettre (i.e. pas de
comportement indéfini), y aurait-il une solution élégante au
problème ?


Definir ton propre iterateur a la place de ostream_iterator. C'est
d'ailleurs ce que tu vas faire des que ostream_iterator ne te convient
pas (par exemple parce que tu veux mettre une virgule entre les
elements du vecteurs plutot qu'un blanc apres chacun de ceux-ci).

A+

--
Jean-Marc
FAQ de fclc++: http://www.cmla.ens-cachan.fr/~dosreis/C++/FAQ
C++ FAQ Lite en VF: http://www.ifrance.com/jlecomte/c++/c++-faq-lite/index.html
Site de usenet-fr: http://www.usenet-fr.news.eu.org


Avatar
kanze
Fabien LE LEZ wrote:
On 4 Oct 2005 01:01:44 -0700, "kanze" :

La solution évidente, c'est de définir l'opérateur << pour
vector<int> dans l'éspace référentiel std::. Ce qui donne un
comportement indéfini


Si jamais on voulait suivre la norme à la lettre (i.e. pas de
comportement indéfini), y aurait-il une solution élégante au
problème ?


Créer un wrapper pour le vecteur.

Note qu'indépendamment de la norme, tu ne voudrais jamais créer
un << pour std::vector<int> dans du vrai code de production.
C'est une chose qui passe pour des petits exemples et des
essais, qu'on va jeter tout de suite. Et alors, l'effraction à
la norme n'a vraiment pas d'importance. Mais dans le code de
production, même si la norme le permettait, ça serait un
desastre.

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


Avatar
Fabien LE LEZ
On 5 Oct 2005 00:47:06 -0700, "kanze" :

Note qu'indépendamment de la norme, tu ne voudrais jamais créer
un << pour std::vector<int> dans du vrai code de production.


Effectivement, maintenant que tu le dis...

En fait, la plupart du temps, quand je définis un opérateur <<, c'est
pour du débogage.

Avatar
AG
kanze wrote
Note qu'indépendamment de la norme, tu ne voudrais jamais créer
un << pour std::vector<int> dans du vrai code de production.
C'est une chose qui passe pour des petits exemples et des
essais, qu'on va jeter tout de suite. Et alors, l'effraction à
la norme n'a vraiment pas d'importance. Mais dans le code de
production, même si la norme le permettait, ça serait un
desastre.
Pourquoi ?


Avatar
kanze
AG wrote:
kanze wrote

Note qu'indépendamment de la norme, tu ne voudrais jamais
créer un << pour std::vector<int> dans du vrai code de
production. C'est une chose qui passe pour des petits
exemples et des essais, qu'on va jeter tout de suite. Et
alors, l'effraction à la norme n'a vraiment pas
d'importance. Mais dans le code de production, même si la
norme le permettait, ça serait un desastre.


Pourquoi ?


Parce que si toi, tu le veux, tu peux être sûr que tes collègues
aussi vont le vouloir. Et avoir plusieurs définitions pour la
même fonction, ça ne marche pas bien.

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


1 2