Created
October 4, 2023 21:37
-
-
Save Gnomorian/ff8e539a13bb92701b22055d06ffa949 to your computer and use it in GitHub Desktop.
make_array implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <array> | |
// simple template method that creates a std::array | |
template<typename...T> | |
auto make_array(T...data) -> std::array<std::tuple_element_t<0, std::tuple<T...>>, sizeof...(data)> | |
{ | |
return {data...}; | |
} | |
int main() | |
{ | |
auto arr{ make_array('a', 'b')}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment