public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Loki's tricky templates
@ 2001-04-21  7:27 Kriang Lerdsuwanakij
  2001-04-21  8:49 ` Paolo Carlini
  0 siblings, 1 reply; 15+ messages in thread
From: Kriang Lerdsuwanakij @ 2001-04-21  7:27 UTC (permalink / raw)
  To: pcarlini, gcc

Paolo Carlini wrote:

>Yes, I agree that most probably it is valid. But Gcc don't like the 
>association
>of template-templates *and* the VisitorBinder pattern.
>It is amazing how many weird template tricks Andrei has developed!
>
>If someone else, more into template-template parameters will agree with us, I
>may file a GNATS PR and then begin investigating a couple of other problems in
>the Loki headers.

Hi

Your code relies on a template template parameter feature (template
template argument which scope is template parameter dependent) that
has not been implemented in gcc yet.  It was missing from the C++
standard as the language grammar doesn't allow it.  This now appears
as an issue in the C++ standard committee.  The correct version
of problematic code is shown below.

template <typename R, class TList>
class CyclicVisitor
     : public GenScatterHierarchy<TList, VisitorBinder<R>::template Result>
                                                                             ^^^^^^^
                                                                         keyword 
required

--Kriang

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Loki's tricky templates
@ 2001-04-20 14:14 Paolo Carlini
  2001-04-20 14:48 ` Phil Edwards
  0 siblings, 1 reply; 15+ messages in thread
From: Paolo Carlini @ 2001-04-20 14:14 UTC (permalink / raw)
  To: gcc; +Cc: gdr, pme, stephen

Hi all,

in the last few days, also encouraged by "Gaby" Dos Reis, I tried to
compile Alexandrescu's Loki library (*) with current Gcc3.0 (Gcc3.1).
Having cleaned a fair amount of typos and trivial errors (e.g., many
missing "typename", a missing <typeninfo>... I can send a complete list
to the interested), I eventually got a segmentation fault for the
Visitor.h header (I will report about other problems in the next weeks)

I clarify, right at the beginning, that this *cannot* be a regression
from Gcc2.95.2, which in this case issues an ICE 980422, but I would
like to ask your advice to understand *if eventually* Gcc3.x should be
able to compile such kind of template structures or viceversa those are
not, strictly speaking, legal ANSI/ISO C++.

From the Visitor.h (and therein included headers), I distilled the
following critical snippet:

------------

template <class AtomicType, template <class> class Unit>
class GenScatterHierarchy : public Unit<AtomicType>
{
};

template <class T, typename R>
class Visitor
{
public:
    typedef R ReturnType;
};

template <typename R>
struct VisitorBinder
{
    template <class T>
    struct Result : public Visitor<T, R>
    {
    };
};

template <typename R, class TList>
class CyclicVisitor
    : public GenScatterHierarchy<TList, VisitorBinder<R>::Result>
{
public:
    typedef R ReturnType;
};

class DocElement
{
public:
    CyclicVisitor<void, DocElement>::ReturnType fun() {}
};

------------

Before bothering the list, I cross-checked with 4 other compilers
(running under Linux and Windoze), and I must say that the results are
discordant: two, not very compliant indeed, reject the code, one well
respected compiles it, another not.

Opinions???

P.

(*) http://www.awl.com/cseng/titles/0-201-70431-5

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2001-04-24  0:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-21  7:27 Loki's tricky templates Kriang Lerdsuwanakij
2001-04-21  8:49 ` Paolo Carlini
2001-04-22  1:39   ` Kriang Lerdsuwanakij
2001-04-22 13:48     ` Paolo Carlini
2001-04-23  9:05       ` Kriang Lerdsuwanakij
2001-04-23  9:23         ` Paolo Carlini
2001-04-23  9:44           ` Gabriel Dos Reis
2001-04-23 10:06             ` Long long & templates (was: Re: Loki's tricky templates) Paolo Carlini
2001-04-23 10:49               ` Gabriel Dos Reis
2001-04-23 11:05                 ` Paolo Carlini
2001-04-23 13:39               ` Phil Edwards
2001-04-24  0:54                 ` Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
2001-04-20 14:14 Loki's tricky templates Paolo Carlini
2001-04-20 14:48 ` Phil Edwards
2001-04-20 16:36   ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).