mirror of
https://git.adityakumar.xyz/data-structures.git
synced 2024-11-09 21:39:43 +00:00
17 lines
483 B
C++
17 lines
483 B
C++
#include <iostream>
|
|
#include <array>
|
|
#include <type_traits>
|
|
|
|
template<typename... Args>
|
|
auto build_array(Args&&... args) -> std::array<typename std::common_type<Args...>::type, sizeof...(args)> {
|
|
using commonType = typename std::common_type<Args...>::type; // Create array
|
|
return {std::forward<commonType>(args)...};
|
|
}
|
|
|
|
int main() {
|
|
auto data {build_array(1, 0u, 'a', 3.2f, false)};
|
|
for (const auto& i : data) std::cout << i << " ";
|
|
std::cout << std::endl;
|
|
|
|
return 0;
|
|
}
|