[antlr-interest] C++ puzzle

David Wigg wiggjd at lsbu.ac.uk
Wed Jun 29 05:17:09 PDT 2005


Hi,

I'm trying to parse the following extract from a C++
preprocessed file. I wonder if someone could explain what the
problem statement indicated might mean.

#line 6 "C:\\Program Files\\Microsoft Visual Studio .NET
2003\\VC7\\INCLUDE\\xstring"

#pragma pack(push,8)
#pragma warning(push,3)
namespace std {

#pragma warning(disable:4251)

class  _String_base
      {
public:
      void _Xlen() const;
      void _Xran() const;
      };

template<class _Ty,
      class _Alloc>
      class _String_val
          : public _String_base
      {
protected:
      typedef typename _Alloc::template
          rebind<_Ty>::other _Alty;    // Problem statement

      _String_val(_Alty _Al = _Alty())
          : _Alval(_Al)
          {
          }

      _Alty _Alval;
      };
etc.


I can't see how "_Alloc::template" can be a typename
("template" is a reserved word), but what does it mean?

I presume the syntax is legal but I have not been able to find
any similar examples either in my include files in ...\Microsoft
Visual Studio\VC98\include or in Stroustrup, Third Edition, 
Deitel & Deitel, Third Edition, or in "C++ in a Nutshell" First
Edition.

This preprocessed file was sent to me as a problem. It is
interesting that I have not received this problem from anyone
else.

I wonder if anyone can identify the compiler and version?

I also find it confusing that _Alty is a type as well as the 
name of a function and _Alval is a variable as well as the name 
of a function!

Thanks,

David.











More information about the antlr-interest mailing list