This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tr1::array initialization


> This is a language issue, not a library issue. Tom wants the N  
> deduced from the initializer, but doing so would require tr1::array  
> to be recognized by the compiler as magic; at least, I can't think
> of any extension that makes this not magic. Here's an alternative  
> formulation that does work:
> 
> Add a make_array function that builds an array from the arguments it  
> receives, e.g.,
> 
> 	template<typename T, typename... Args>
> 	inline array<T, sizeof...(Args)> make_array(Args&&... args) {
> 		return { std::forward<Args>(args)... } ; // assumes
> we have generalized initializer lists in C++0x!
> 	}
> 
> Then, the way to build an array from a list of unknown size is:
> 
> 	auto a = make_array<T>(1, 4, 6);

Nice!!! Thanks Doug. Here's hoping that the initializer list stuff goes
in at Nice.

This is probably enough specification for an LWG issue, I think.

-benjamin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]