bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I use decltype?


From: 長田偉伸
Subject: Re: Can I use decltype?
Date: Tue, 23 Oct 2018 01:23:37 +0900

I do not need the fourth method.

I asked a question from curiosity.

Thanks!
2018年10月23日(火) 1:16 Akim Demaille <address@hidden>:
>
> Hi!
>
> > Le 22 oct. 2018 à 09:48, 長田偉伸 <address@hidden> a écrit :
> >
> > [Description]
> >  Please confirm the attached file
> >
> > [Cause location]
> >  $base = std::static_pointer_cast<decltype($base)::element_type>($sub);
> >
> > [Error Message]
> >  $ bison parser.yy; clang++-6.0 -std=c++17 -Wall -Wextra -g -O0 parser.cc
> >  parser.yy:87:79: error:
> > 'decltype(yylhs.value.as<std::shared_ptr<Baseclass> >())' (aka
> > 'std::shared_ptr<Baseclass> &')
> >        is not a class, namespace, or enumeration
> >                          yylhs.value.as< std::shared_ptr<Baseclass> >
> > () = std::static_pointer_cast<decltype(yylh…
>
> Your file:
>
> > rule1[base]
> >       : rule2[sub]
> >               {
> >                       //
> >                       // * Upcast from [Subclass] to [Baseclass]
> >                       //
> >
> >                       // 1) OK
> >                       //$base = $sub;
> >
> >                       // 2) OK
> >                       //$base = std::static_pointer_cast<Baseclass>($sub);
> >
> >                       // 3) OK
> >                       //auto base{ $base };
> >                       //$base = 
> > std::static_pointer_cast<decltype(base)::element_type>($sub);
> >
> >                       // 4) NG
> >                       $base = 
> > std::static_pointer_cast<decltype($base)::element_type>($sub);
> >               }
> >       ;
>
> Wow…  Why are you looking for something so complex?  What is wrong with 1?
>
> You need to get rid of the reference.  That’s what « 
> ’std::shared_ptr<Baseclass> &’ is not a class, namespace, or enumeration » is 
> telling you:
>
> $base = 
> std::static_pointer_cast<std::remove_reference_t<decltype($base)>::element_type>($sub);
>
> Cheers!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]