Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5753

Re: templates

From Ruben Safir <mrbrklyn@panix.com>
Newsgroups comp.lang.c++
Subject Re: templates
Date 2011-05-28 03:57 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <irprqn$lno$1@reader1.panix.com> (permalink)
References (1 earlier) <yuudnc2f-aRuaCvQnZ2dnUVZ8q2dnZ2d@giganews.com> <ip717g$uri$1@dont-email.me> <974848c0-b748-41ef-acd3-b870bd3eee3e@n2g2000prj.googlegroups.com> <slrnirfef7.gtj.grahn+nntp@frailea.sa.invalid> <b78c1a85-5af9-4dbb-add7-4c5fcc7d7aae@a21g2000prj.googlegroups.com>

Show all headers | View raw


graham <gjw369@gmail.com> wrote:
> On Apr 27, 8:38 am, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:
>> On Tue, 2011-04-26, graham wrote:
>> > On Apr 26, 8:00 pm, Jeff Flinn <TriumphSprint2...@hotmail.com> wrote:
>> >> Leigh Johnston wrote:
>> >> > On 26/04/2011 17:30, graham wrote:
>> >> >> hi ,
>>
>> >> >> I'm written a template for my applications options. Options are like
>> >> >> this;
>>
>> >> [...]
>>
>> >> >> Could anybody help me out?
>>
>> >> >> thanks and have a nice evening.
>>
>> >> > Take a look at boost.variant; it will allow you to have a single
>> >> > container for all your option types without you having to use inheritance.
>>
>> >> And while he's there he can take a look at boost.program_options. ;-)
>>
>> >> See:http://www.boost.org/doc/libs/1_44_0/doc/html/program_options.html
>>
>> >> Jeff
>>
>> > thanks Jeff and Leigh but boost is out of the question. I have to code
>> > this up as simply as possible on my own.
>>
>> Personally I find that using the OS's mechanism (getopt(3) on Unix in
>> my case) is the simplest. Unless you have to write dozens of
>> similar parsers, writing your own template-based one is almost
>> certainly a waste of time. (Unless it's an exercise, but that doesn't
>> seem to be the case here.)
>>
>> You have to do the conversion from string to e.g. integer yourself,
>> but IMO you often have to do application logic things here like "-f
>> and -g are mutually exclusive, unless -o is also given".
>>
>> By the way, the example you gave:
>>   -option1 stringValue -option2 23.5 -option3  -option3 'c'
>> looks really old-fashioned if you're on Unix. "Long options"
>> are written --option1 these days, not -option1.
>>
>> /Jorgen
>>
>> --
>>   // Jorgen Grahn <grahn@  Oo  o.   .  .
>> \X/     snipabacken.se>   O  o   .
> 
> Thanks for that reply,
> 
> I'm sorta trying to ramp up on templates when coding all this.
> Don't need any of the template stuff ultimately... but its interesting
> stuff so
> I'm going that route ;)
> 
> What's the best book out there on template (meta) programming?
> 

http://www.josuttis.com/tmplbook/

> Cheers,
> 
> Graham

Back to comp.lang.c++ | Previous | Next | Find similar


Thread

Re: templates Ruben Safir <mrbrklyn@panix.com> - 2011-05-28 03:57 +0000

csiph-web