Boost logo

Boost Users :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2007-11-06 16:49:45


The solution proposed here is by no means perfect, because if for any reason
I wasn't using RTTI in my application this method wouldn't be acceptable.
However, I suppose I got lucky. I think it would be useful to find a
compile-time alternative to converting a type to a string. The second reason
why the typeid() approach isn't perfect is because it contains the entire
decorated name in the string. In other words, for a class named
"CFooSomeClass" the string returned by typeid( CFooSomeClass).name() is
"class CFooSomeClass" instead of just "CFooSomeClass".

I'm using typeid() as a hack/workaround at the moment until I find something
I'm satisfied with being a permanent solution. I'd appreciate it if you guys
would continue throwing thoughts at this thread so I can check up on it and
maybe get some more ideas.

So far this thread has been a bit off topic in that we've not really
utilized boost at all. Perhaps this is a hint that boost could excel in this
area (assuming it hasn't already)? Maybe there's something boost can do for
me that would help out? I'll review the MPL portion of boost and see what I
can dig up.

Thanks again for everyone's help, I really do appreciate the quick
responses!

On 11/6/07, Olivier Tournaire <olitour_at_[hidden]> wrote:
>
>
>
> 2007/11/6, Mike Marchywka <marchywka_at_[hidden]>:
> >
> >
> > I happen to skim this thread and had a related question.
> >
> > > > > Maybe you can try with typeid(t_type).name(), included in
> > <typeinfo>.
> >
> > Is this evaluated at compile time ( I thought the OP said something
> > about
> > macros )?
>
>
>
> No, evaluated at run time
>
> I was looking for template programming ideas and I hit
> > a case where I needed compile-time type information and I didn't know
> > offhand how to do it so I gave up ( for some reason a specialization
> > didn't seem like an easy thing to do).
> >
> > Does anyone have a good reference link on interesting (portable)
> > template
> > programming
> > approaches ? I found a few things on google but nothing stuck me as
> > being a complete reference.
> >
> >
> > Thanks.
> >
> >
> >
> >
> > >From: "Olivier Tournaire" < olitour_at_[hidden]>
> > >Reply-To: boost-users_at_[hidden]
> > >To: boost-users_at_[hidden]
> > >Subject: Re: [Boost-users] Template type to constant string
> > >Date: Tue, 6 Nov 2007 01:53:04 +0100
> > >
> > >Hi,
> > >
> > >This is not MS specific. It works with many compilers, and at least
> > with
> > >gcc
> > >(do not remember the exact version). However, I think "name()" return
> > value
> > >is not standard and can vary between platforms.
> > >
> > >Regards
> > >
> > >2007/11/6, Robert Dailey <rcdailey_at_[hidden]>:
> > > >
> > > > Thanks!
> > > >
> > > > This seems to work, however looking at the implementation of
> > <typeinfo>
> > >I
> > > > don't see the keyword "typeid" anywhere. Where in the world is it
> > coming
> > > > from? Is <typeinfo> part of the standard? It's obviously not in STL
> > >since it
> > > > lacks the namespace. I'm a little confused as to where the file
> > comes
> > >from,
> > > > as I've never heard of it before. I'm guessing it is a microsoft
> > >specific
> > > > thing.
> > > >
> > > > Let me know. Thanks again.
> > > >
> > > > On 11/5/07, Olivier Tournaire <olitour_at_[hidden]> wrote:
> > > > >
> > > > > Maybe you can try with typeid(t_type).name(), included in
> > <typeinfo>.
> > > > >
> > > > > Regards,
> > > > >
> > > > > Olivier
> > > > >
> > > > > 2007/11/5, Robert Dailey < rcdailey_at_[hidden] >:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > As you know, with Microsoft VS preprocessor operators you can
> > >convert
> > > > > > a type passed in to a macro to a string. For example:
> > > > > >
> > > > > > #define TO_STRING( type ) #type
> > > > > >
> > > > > > I would like to do the same thing with a template type:
> > > > > >
> > > > > > template< typename t_type >
> > > > > > void TO_STRING()
> > > > > > {
> > > > > > // Do something here with t_type to make it a string and then
> > >return
> > > > > > it
> > > > > > }
> > > > > >
> > > > > > Is there something in boost that can facilitate the behavior I'm
> > > > > > describing? Thanks.
> > > > > >
> > > > > > _______________________________________________
> > > > > > Boost-users mailing list
> > > > > > Boost-users_at_[hidden]
> > > > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Le temps des cerises reviendra. Dans l'immédiat, c'est le temps
> > des
> > > > > noyaux. Courage.
> > > > > _______________________________________________
> > > > > Boost-users mailing list
> > > > > Boost-users_at_[hidden]
> > > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Boost-users mailing list
> > > > Boost-users_at_[hidden]
> > > > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> > > >
> > >
> > >
> > >
> > >--
> > >Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des
> > noyaux.
> > >Courage.
> >
> >
> > >_______________________________________________
> > >Boost-users mailing list
> > >Boost-users_at_[hidden]
> > >http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
> > _________________________________________________________________
> > See what you're getting into…before you go there
> > http://newlivehotmail.com/?ocid=TXT_TAGHM_migration_HM_viral_preview_0507
> >
> >
> >
> > _______________________________________________
> > Boost-users mailing list
> > Boost-users_at_[hidden]
> > http://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
>
>
>
> --
> Le temps des cerises reviendra. Dans l'immédiat, c'est le temps des
> noyaux. Courage.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net