
On Sun, Jan 13, 2013 at 11:23 AM, Thomas Heller <thom.heller@gmail.com> wrote:
On Sunday, January 13, 2013 14:36:50 Mathias Gaunard wrote:
On 13/01/2013 10:38, Thomas Heller wrote:
The C++11 code looks too complicated. Wouldn't https://gist.github.com/4522812 be enough?
Indeed it is! I've updated the C++11 code to use the simpler initialization method. Thanks!
I don't think it is a good idea that make_array(1, 1., 1.f) makes an array of int. It seems quite arbitrary that the first argument would decide the type.
Right. That is another problem. I just tried to simplify the implementation of the original proposal.
As far as type-deduction, how would you guys feel about an implementation using boost::common_type? Something along the lines of: // make_array with deduced type template<class... Args> inline array<typename common_type<Args...>::type, sizeof...(Args)> make_array(Args&&... args) { typedef typename common_type<Args...>::type T; return array<T, sizeof...(Args)> {{ static_cast<T>(std::forward<Args>(args))... }}; } So that make_array(1, 2.1f) would return array<float, 2> and make_array(1, 2.1f, 3.2) would return array<double, 3>. Thoughts? Thanks, Kyle