Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Parsing (a Series of) Variables

Reply
Thread Tools

Parsing (a Series of) Variables

 
 
Tobias Müller
Guest
Posts: n/a
 
      03-25-2013
Haochen Xie <(E-Mail Removed)> wrote:
> Mike Copeland wrote:
>> In article <(E-Mail Removed)-
>> september.org>, http://www.velocityreviews.com/forums/(E-Mail Removed) says...
>>>
>>>> Follow up question: is there a way to use this technique to parse
>>>> non-integer values, such as doubles? I can't seem to get my compiler to
>>>> accept something like this:
>>>> for(number int, double xx; source >> xx
>>>
>>> how did you come to that solution?

>>
>> I just tried to use what I know of for loop syntax in an
>> extrapolation of this new form. (Obviously, it didn't compile...)
>>>
>>>> so I don't see how this technique can be applied.
>>>
>>> Just change 'int' for 'double' and you're done:
>>> using number = double;

>>
>> In my system (both VS6.0 and VS10.0 Express) the "using number = x"
>> nomenclature doesn't compile. That's why I tried the above. 8<{{
>>

>
> Tobias must not have read your whole code snippet.


I did, but you obviously didn't read _my_ entire post, especially the
quotes that you snipped away.

> You should write the for loop like this:
>
> for(double xx; source >> xx; )
>
> He must have thought your code is like "for(number xx; source >> xx".
> In this case, simply adding "using name = double;" would work.


I was referring to the following original snippet from Stefan Ram:

Haochen Xie <(E-Mail Removed)> omitted the quote:
>Mike Copeland <(E-Mail Removed)> wrote:
>> In article <(E-Mail Removed)-
>> september.org>, (E-Mail Removed) says...
>>> Mike Copeland <(E-Mail Removed)> wrote:
>>>> In article <(E-Mail Removed)-berlin.de>,
>>>> http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de says...
>>>>> #include <sstream>
>>>>> #include <vector>
>>>>>
>>>>> int main()
>>>>> { using number = int;
>>>>> ::std::stringstream source{ "1 37 36 4 7 5 6 8 9 10 20 32 23 16" };
>>>>> ::std::vector<number> target;
>>>>> for( number num; source >> num; )target.push_back( num ); }
>>>>>
>>>> That's perfect!


So if this works with int, it should also work with double.

Tobi
 
Reply With Quote
 
 
 
 
Tobias Müller
Guest
Posts: n/a
 
      03-25-2013
Mike Copeland <(E-Mail Removed)> wrote:
> In article <(E-Mail Removed)-
> september.org>, (E-Mail Removed) says...
>> Just change 'int' for 'double' and you're done:
>> using number = double;

>
> In my system (both VS6.0 and VS10.0 Express) the "using number = x"
> nomenclature doesn't compile. That's why I tried the above. 8<{{


"using number = x" is C++11 and equivalent to
"typedef x number".

Tobi
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Anyone clustering ASA5000-series boxes with 3000-series VPN concentrators Heath Roberts Cisco 0 10-27-2006 02:45 PM
Difference between Kodak CX series and LS series zxcvar Digital Photography 3 11-05-2004 02:10 PM
2600 series and 1700 series godwill Cisco 4 04-09-2004 08:38 PM
What is the difference between A Series, G Series and S series of Canon Cameras zxcvar Digital Photography 3 09-09-2003 01:30 AM



Advertisments