Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
make_integer_sequence
#include <cstddef> #include <type_traits> template< typename T, T... i > struct integer_sequence { using value_type = T; static constexpr std::size_t size = sizeof...( i ); }; namespace detail { template< typename T, T i, bool _0 = ( i == 0 ), bool _1 = ( i == 1 ) > struct make_integer_sequence_impl { static_assert( i >= 0, "make_integer_sequence requires a non-negative size" ); template< typename = typename make_integer_sequence_impl< T, i / 2 >::type, typename = typename make_integer_sequence_impl< T, i % 2 >::type > struct helper { }; template< T... j, T... k > struct helper< integer_sequence< T, j... >, integer_sequence< T, k... > > { using type = integer_sequence< T, j..., ( j + i / 2 )..., ( k + i - 1 )... >; }; using type = typename helper<>::type; }; template< typename T, T i > struct make_integer_sequence_impl< T, i, true, false > { using type = integer_sequence< T >; }; template< typename T, T i > struct make_integer_sequence_impl< T, i, false, true > { using type = integer_sequence< T, 0 >; }; } template< typename T, T N > using make_integer_sequence = typename detail::make_integer_sequence_impl< T, N >::type; template< std::size_t N > using make_index_sequence = make_integer_sequence< std::size_t, N >; int main( int argc, char** argv ) { make_integer_sequence< std::size_t, 3 >{}; }
run
|
edit
|
history
|
help
0
hangman
hangman
Visual Studio C++ wont accept >> or << past the initial declarations
delete from list
narrow_cast
MSVC_example_fscanf_s_and_chars_wchars
MSVC ignoring unknown attributes
Program of cube
Generic EventProvider
Dices by GOOSE