Date: Fri, 25 Nov 2022 09:12:49 -0800
On Friday, 25 November 2022 01:45:01 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> That forward slash is supposed to be a dot, right? Anyway if I try to
> compile the following standalone function:
>
> void Red( std::variant<wxControl,wxTextEntry> &p )
> {
> std::visit(([](auto &p) {
> p.SetBackgroundColour( *wxRED );
> p.SetValue("pending");
> p.Refresh();
> }, p);
> }
>
> then I get:
>
> cannot declare field
> '__gnu_cxx::__aligned_membuf<wxTextEntry>::_Tp2::_M_t' to be of abstract
> type 'wxTextEntry'
Then use std::variant<wxControl *,wxTextEntry *> instead of a variant of the
actual types. I have no clue how WX works, so I was only guessing at the API.
However, this would be even closer to what your chimeric pointer would be,
because the variant would be storing the pointer and the discrimination of
what type it is, instead of the objects.
> So the types inside a variant cannot be abstract. I'll try your code
> snippet with two concrete types instead:
>
> void Red( std::variant<std::string, std::exception> &p )
> {
> std::visit([](auto &p) {
> p.size(); // from std::string
> p.what(); // from std::exception
> } , p);
> }
>
> This fails to compile with the following error:
>
> 'class std::__cxx11::basic_string<char>' has no member named 'what'
>
> I'm not sure how your code snippet was supposed to work. Right now I
> can't fathom how it could possibly work.
You can't call a method that doesn't exist in all bases. Your code wouldn't
have fixed that either. I can't fathom how you think the above should work.
Proposals wrote:
> That forward slash is supposed to be a dot, right? Anyway if I try to
> compile the following standalone function:
>
> void Red( std::variant<wxControl,wxTextEntry> &p )
> {
> std::visit(([](auto &p) {
> p.SetBackgroundColour( *wxRED );
> p.SetValue("pending");
> p.Refresh();
> }, p);
> }
>
> then I get:
>
> cannot declare field
> '__gnu_cxx::__aligned_membuf<wxTextEntry>::_Tp2::_M_t' to be of abstract
> type 'wxTextEntry'
Then use std::variant<wxControl *,wxTextEntry *> instead of a variant of the
actual types. I have no clue how WX works, so I was only guessing at the API.
However, this would be even closer to what your chimeric pointer would be,
because the variant would be storing the pointer and the discrimination of
what type it is, instead of the objects.
> So the types inside a variant cannot be abstract. I'll try your code
> snippet with two concrete types instead:
>
> void Red( std::variant<std::string, std::exception> &p )
> {
> std::visit([](auto &p) {
> p.size(); // from std::string
> p.what(); // from std::exception
> } , p);
> }
>
> This fails to compile with the following error:
>
> 'class std::__cxx11::basic_string<char>' has no member named 'what'
>
> I'm not sure how your code snippet was supposed to work. Right now I
> can't fathom how it could possibly work.
You can't call a method that doesn't exist in all bases. Your code wouldn't
have fixed that either. I can't fathom how you think the above should work.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2022-11-25 17:12:51