}
On 28/06/2010, Daniel Gutson <
danielgutson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> 2010/6/28 Nicolás Brailovsky <
nicolasbrailo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
>> Si me dejás cambiar un poco a Pepe creo que te lo resuelvo :D
>> Algo así?
>>
>> class Pp {
>> public:
>> template <class T> void f(T t);
>> private:
>> template <class T> void g();
>> };
>>
>> template <int N> class Int {};
>>
>
> (esta clase, en tanto es un helper, debería ser inner y private)
>
>
>> template <class T> void Pp::f(T t) { return g< Int<sizeof(T)> >(); }
>> template <> void Pp::g< Int<4> >() { cout << "con 4\n"; }
>> template <class T> void Pp::g() { cout << "no 4\n"; }
>>
>>
> Muy bueno. Next: y cómo sería para distinguir en base a una propiedad de T?
> (suponéte q existe attribute<T>::value, donde value castea a bool).
> Constraint: g necesita recibir el T además.
>
> Daniel.
>
>
>
>>
>>
>> On 25/06/2010, Daniel Gutson <
danielgutson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> > supónganse
>> >
>> > class Pepe
>> > {
>> > public:
>> > template <class T> void f();
>> > private:
>> > template <class T> void f_4() { cout << "con 4;" }
>> > template <class T> void f_x() { cout << "no 4"; }
>> > };
>> >
>> > cómo hacer para que si llamo a f con un tipo de dato T, se llame a
>> > f_4 si sizeof(T) es 4, o a f_x otherwise, OBVIAMENTE en tiempo de
>> > compilación.
>> >
>> > Notar q simplifiqué de pura benevolencia nomás, podría haber dicho
>> > "cómo especializar f dependiendo si el sizeof del T es 4 o no", dándoles
>> el
>> > hint de q f sea un dispatcher nomás.
>> >
>> > Dato: en *este* C++ , no en 0x :)
>> >
>> > Daniel.
>> >
>> > --
>> > Who’s got the sweetest disposition?
>> > One guess, that’s who?
>> > Who’d never, ever start an argument?
>> > Who never shows a bit of temperament?
>> > Who's never wrong but always right?
>> > Who'd never dream of starting a fight?
>> > Who get stuck with all the bad luck?
>> >
>> > --
>> > ¿Eres miembro de "CyC++ Buenos Aires" verdad? Si no lo eres, has
>> > recibido
>> > este mesaje por error.
>> > En caso de duda visita "
http://groups.google.com/group/cppba"
>>
>>
>> --
>> Nicolás Brailovsky
>>
>> - Tech blog
http://nicolasb.com.ar/
>> - Blog personal
http://monosinfinitos.com.ar/
>>
>> --
>> ¿Eres miembro de "CyC++ Buenos Aires" verdad? Si no lo eres, has recibido
>> este mesaje por error.
>> En caso de duda visita "
http://groups.google.com/group/cppba"
>
>
>
>
> --
> Who’s got the sweetest disposition?
> One guess, that’s who?
> Who’d never, ever start an argument?
> Who never shows a bit of temperament?
> Who's never wrong but always right?
> Who'd never dream of starting a fight?
> Who get stuck with all the bad luck?
>
> --
> ¿Eres miembro de "CyC++ Buenos Aires" verdad? Si no lo eres, has recibido
> este mesaje por error.
> En caso de duda visita "
http://groups.google.com/group/cppba"