Skip to content

Instantly share code, notes, and snippets.

@kaorun55
Created August 29, 2012 08:59
Show Gist options
  • Save kaorun55/3508814 to your computer and use it in GitHub Desktop.
Save kaorun55/3508814 to your computer and use it in GitHub Desktop.
C++11-2
#include <iostream>
#include <vector>
unsigned long long int operator "" _twice ( unsigned long long int value )
{
return value * 2 ;
}
int operator "" _sec ( unsigned long long int value )
{
return value * 1000 ;
}
int main()
{
std::cout << "10sec = " << 10_sec << "msec" << std::endl;
int a[] = { 1, 2, 3, 5, 8 };
for ( auto i : a ) {
std::cout << i << " ";
}
std::cout << std::endl;
std::vector<int> v = { 1, 2, 3, 5, 8 };
for ( auto i : v ) {
std::cout << i << " ";
}
std::cout << std::endl;
for ( auto i : { 1, 2, 3, 5, 8 } ) {
std::cout << i << " ";
}
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment