Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2004-02-24 09:49:28


At 04:12 AM 2/24/2004, David Abrahams wrote:

>Actually, if that's the way tokenizer works, you can do it, I'm pretty
>sure:
>
>---

I changed main() slightly (see below) and tried with several compilers:

g++ 3.3.1:
   lvalue.cpp: In function `int main()':
   lvalue.cpp:32: error: syntax error before `)' token

bcc32:
   error E2188 lvalue.cpp 32: Expression syntax in function main()
   error E2293 lvalue.cpp 32: ) expected in function main()

Codewarrior 8.3:
   lvalue
   rvalue
   lvalue
   rvalue

Intel 8.0 and VC++ 7.1:
   lvalue
   rvalue
   lvalue

Note 4th output line missing for Intel 8.0 and VC++ 7.1 What's going on
here?

Mystified-in-Virginia,

--Beman

#include <vector>
#include <iostream>

template <class TokenizerFunc>
struct tokenizer
{
     struct rvalue
     {
         template <class T>
         rvalue(T const&) {}
     };

     // handle lvalues
     template <typename Container>
     explicit tokenizer(Container& c, const TokenizerFunc& f =
TokenizerFunc())
     {
         std::cout << "lvalue\n";
     }

     // handle rvalues
     explicit tokenizer(rvalue const& rval, const TokenizerFunc& f =
TokenizerFunc())
     {
         std::cout << "rvalue\n";
     }
};

int main()
{
     std::vector<int> const x;
     tokenizer<int> z( (x) );
     tokenizer<int> z2( (std::vector<int>()) );
     tokenizer<int> z3( x );
     tokenizer<int> z4( std::vector<int>() );
     return 0;
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk