![]() (Note that the above implies the same rule as range-for that 'std' is an And of course all A0 An must be valid type where An are "optional" (as long as either A0 is provided or every Suggested above, since those only entail relatively simple logic toĬombine the type-and-or-modifier correctly to form each "longhand" Implement the non-auto-valued and with-type-modifier variants as I Will just magically work, and can also be extended to user types.Īlso, the above would mean the compiler effectively is just generatingĬode like in your (elided) examples, which should make it much easier to Then as long as there is a std::get(std::pair) this creates anĪnonymous temporary and uses a well-known function ('get') to getĮach value. Maybe it should be implemented like range-based for, i.e. Related: bonus points if 'auto (a,b)' can also be used with std::pair. Separate proposal but this suddenly makes them really attractive. Key/value (std::iterate?) containers like this. Now we just need functions in std to unpack indexed (std::enumerate) and this could save me from writing iterator-based loops!! :-D > An interesting application would be tuple unpacking in ranged-for loops, Not that anyone these days *shouldn't* be using auto, but I wonder,Īlso, I would like if the following are also valid:Īuto const& (a, b) = foo() // a and b are both constĪuto (const& a, b) = foo() // a -> auto const&, b -> auto Thinking the other day how it's a shame that C++ can't handle Regardless of other considerations, I like this syntax ever so muchīetter than either of the above. > tuple element variables using the correct type, and assigns to them? > Would it be possible to introduce a new syntax, which both declares the Neither of these solutions seems particularly clean to me. > but then you create a new variable and the whole thing seems unnecessarily > but then you have to know the return types. > one can access the returned values using std::tie Currently, given a function that returns a tuple
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |