1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-12-03 21:15:42 +00:00
Sprout/docs/_sources/libs/array/make_array.txt

53 lines
1.7 KiB
Text
Raw Permalink Normal View History

2013-08-29 12:51:44 +00:00
.. _sprout-array-make_array:
2014-08-15 12:27:31 +00:00
2013-08-29 12:51:44 +00:00
###############################################################################
make_array
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T, typename... Types>
2014-04-28 02:06:06 +00:00
inline SPROUT_CONSTEXPR sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>
make_array(Types&&... args);
2014-08-15 12:27:31 +00:00
2014-04-28 02:06:06 +00:00
template</*implementation-defined*/, typename... Types>
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
2013-08-29 12:51:44 +00:00
make_array(Types&&... args);
Returns
========================================
| Returns an array object initialized with the argument all elements.
Remarks
========================================
2014-04-28 02:06:06 +00:00
| A first version needs to be specified in the template parameters explicitly type T of the elements in the array.
| And, the type of the elements in the array is a decayed common type of all arguments in the second version.
2014-08-15 12:27:31 +00:00
|
| Narrowing conversion is **not** prohibited in this make_array function. (It behaves like a static_cast)
| If you want to prohibit narrowing conversion, use :doc:`make_array_without_narrowing <./make_array_without_narrowing>` function.
2013-08-29 12:51:44 +00:00
Examples
========================================
.. sourcecode:: c++
#include <sprout/array.hpp>
SPROUT_STATIC_CONSTEXPR auto x = sprout::make_array<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
static_assert(x.size() == 10, "array x initialized with 10 elements.");
Complexity
========================================
| Recursive function invocations in *O(1)* (constant) depth.
Header
========================================
| ``sprout/array/make_array.hpp``
| Convenience header: ``sprout/array.hpp``