Topic: Question about N4447


Author: gufideg@gmail.com
Date: Fri, 22 Jan 2016 10:52:20 -0800 (PST)
Raw View
------=_Part_975_379361640.1453488740671
Content-Type: text/plain; charset=UTF-8

Hi. I've been thinking about N4447 lately. First, this proposal is wonderful. It's something I dreamt of a long time. Thanks everyone.

I have a question about it: the syntax use the `...` To expand the result. Does this mean it follows all the same rules as the parameter pack expansion? Let me explain.

Let's say we have this struct:

    template<typename Class, typename T>
    struct Member {
        constexpr Memeber(T Class::*aMember, const char* aName) : member{aMember}, name{aName} {}

        using Type = T;

        T Class::*member;
        const char* name;
    };

    template<typename Class, typename T>
    constexpr auto makeMember(T Class::*member, const char* name) {
        return Member<Class, T>{member, name};
    }

With the current proposal, is it possible to write something like this?

    constexpr auto members = std::make_tuple( makeMember(typedef<AClass>, typeid<AClass>)... );

Note that I used both `typedef<...>`and `typeid<...>` with the same expansion.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_975_379361640.1453488740671--

.


Author: Cleiton Santoia Silva <cleitonsantoia@gmail.com>
Date: Mon, 25 Jan 2016 03:45:00 -0200
Raw View
     That would be good, make the expansion in "lock".
     I gave some thoughts on this matter, however there is a problem
with you syntax, what happens if you ask for typedef<> and typeid<> of
different classes ?
     This problem can be solved in other way, you can ask for typeid< M
 >  on each member of typedef<T>, and make other class ( descendant of
yours ) to encapsulate that :

     template<typename _Member>
     struct Member_son : Member {
         constexpr Memeber(_Member m) : Member(m, typeid<_Member>...) {}
     };


     vector<Member_son> members = { typedef<T>... };

     This should give what you want.


Cleiton

Em 22/01/2016 16:52, gufideg@gmail.com escreveu:
> Hi. I've been thinking about N4447 lately. First, this proposal is wonderful. It's something I dreamt of a long time. Thanks everyone.
>
> I have a question about it: the syntax use the `...` To expand the result. Does this mean it follows all the same rules as the parameter pack expansion? Let me explain.
>
> Let's say we have this struct:
>
>      template<typename Class, typename T>
>      struct Member {
>          constexpr Memeber(T Class::*aMember, const char* aName) : member{aMember}, name{aName} {}
>
>          using Type = T;
>
>          T Class::*member;
>          const char* name;
>      };
>
>      template<typename Class, typename T>
>      constexpr auto makeMember(T Class::*member, const char* name) {
>          return Member<Class, T>{member, name};
>      }
>
> With the current proposal, is it possible to write something like this?
>
>      constexpr auto members = std::make_tuple( makeMember(typedef<AClass>, typeid<AClass>)... );
>
> Note that I used both `typedef<...>`and `typeid<...>` with the same expansion.
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-proposals/.

.