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
int max( int a, int b ) // #1 | |
{ | |
return a < b ? b : a ; | |
} | |
double max( double a, double b ) // #2 | |
{ | |
return a < b ? b : a ; | |
} |
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
template < typename T > | |
constexpr T interval<T>::rad() const | |
{ | |
return pimpl->upper() - pimpl->lower() / static_cast<T>(2.0L); | |
} | |
template < typename T > | |
constexpr T interval<T>::norm() const | |
{ | |
using std::abs; |
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
template < typename T > | |
void f(T&&){} | |
void g(int const&){}; | |
int main(){ | |
f(g); | |
} |
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 <string> | |
#include <algorithm> | |
#include <vector> | |
#include <map> | |
template < typename Container > | |
auto my_find(Container& c, typename Container::key_type key) | |
->decltype((c.find(key))) | |
{ |
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
template < typename T > | |
T max(T a, T b) ; |
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
// 変数がいっぱいある | |
int a{}, b{}, c{}; | |
double d{}, e{}, f{}; | |
std::string too_long_name_variable{}; | |
// ラムダ式 | |
auto result = [&a,&b,&c,&d,&e,&f,&too_long_name_variable](auto&& ...args){ | |
// ... | |
// 何らかの処理 | |
// ... |
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
public class FizzBuzz { | |
public static void main(String[] args){ | |
for(int i : new int[] { 1 }) // define counter | |
for(int dummy : new int[100]) | |
if( ( | |
(i%15==0) ? | |
System.out.printf("FIZZBUZZ\n") == null | |
: (i%3==0) ? | |
System.out.printf("FIZZ\n") == null | |
: (i%5==0) ? |
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
bool operator<(const Person& x, const Person& y) | |
{ | |
return (x.last_name < y.last_name) || !(y.last_name < x.last_name) | |
&& ( (x.first_name < y.first_name) || !(y.first_name < x.first_name) | |
&& (x.age < y.age )); | |
} |
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 <tuple> | |
#include <string> | |
struct Person { | |
std::string first_name; | |
std::string last_name; | |
int age; | |
}; | |
bool operator<(const Person& x, const Person& y) |
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 <tuple> | |
#include <string> | |
#include <iostream> | |
#include <iomanip> | |
class Person { | |
std::string first_name_; | |
std::string last_name_; | |
int age_; | |
public: |
OlderNewer