Skip to content

Instantly share code, notes, and snippets.

View Kaminate's full-sized avatar
🙃
Killin' it

白★能盛 Kaminate

🙃
Killin' it
  • United States
View GitHub Profile
@Kaminate
Kaminate / variadic_specialization.cpp
Last active March 31, 2016 02:36
Call functions with differently ordered arguments using template specialization, c++11 variadic templates, and <utility>'s std::forward. g++ variadic_specialization.cpp -otest.exe -std=c++11
#include <utility> // std::forward
template< typename T, typename... Args >
void SetValues( T* t, Args&&... args ) {
SetValues( t );
SetValues( std::forward< Args >( args )... );
}
template<> void SetValues< int >( int *p ) { *p = 69; }
template<> void SetValues< float >( float* p ) { *p = 3.14f; }
#include <iostream> // std::cout, std::endl
@Kaminate
Kaminate / pay_respects.cpp
Last active September 21, 2023 05:06
Press F to pay respects
#ifdef _WIN32
#include <conio.h> // _getch
#include <ctype.h> // toupper
#include <stdio.h> // printf
int main(int argc, char** )
{
printf( "Press F to pay respects: " );
for( ;; )
{