This file contains hidden or 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
#!/usr/bin/env bash | |
set -ex | |
PLATFORM=${PLATFORM:?no platform, available: mac, linux} | |
CLANG_PATH=${CLANG_PATH:?no clang path, need some compiler} | |
CLEANUP=${CLEANUP:-true} | |
CWD=$( (cd $(dirname "$0") && pwd) ) | |
DC=$CWD |
This file contains hidden or 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 <array> | |
#include <cassert> | |
#include <random> | |
#include <unistd.h> | |
int main(int ac, char* av[]) { | |
std::mt19937_64 e; | |
if (ac == 2) { | |
e.seed(std::stoi(av[1])); |
This file contains hidden or 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 <vector> | |
template<class It> typename It::value_type sum(It begin, It end) { | |
typename It::value_type res = 0; | |
while (begin != end) | |
res += *begin++; | |
return res; | |
} |
This file contains hidden or 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 <vector> | |
template<class It> using Value = typename std::iterator_traits<It>::value_type; | |
template<class It> Value<It> sum(It begin, It end) { | |
Value<It> res = 0; | |
while (begin != end) | |
res += *begin++; | |
return res; |
This file contains hidden or 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 <iterator> | |
#include <list> | |
template<typename It> | |
size_t DistanceImpl(It begin, It end, std::forward_iterator_tag) { | |
size_t result = 0; | |
while (begin++ != end) | |
++result; | |
return result; |
This file contains hidden or 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
malets@mac:~$ cat 2.cc | |
constexpr int f() { | |
int x[] = {0}; | |
return x[1]; | |
} | |
int main(void) { | |
return f(); | |
} | |
malets@mac:~$ clang++ -std=c++14 2.cc |
This file contains hidden or 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
malets@ub:~$ cat 1.C | |
#include <cstdlib> | |
struct C { | |
int *ptr; | |
int& operator*() { | |
return *ptr; | |
} | |
}; |
This file contains hidden or 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 <sstream> | |
#include <type_traits> | |
template<bool is_function, typename T> struct Parser; | |
template<typename T> struct Parser<true, T> { | |
static void Parse(const std::string& input, T& parser) { | |
parser(input); | |
} |
This file contains hidden or 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> struct T { | |
}; | |
template<typename T> struct S { | |
}; | |
template<typename X> struct S<T<X>> { | |
static const int value = 1; | |
}; |
This file contains hidden or 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> struct T { | |
}; | |
template<typename T> int f(); | |
template<> int f<T<int>>() { | |
return 1; | |
} | |
template<> int f<int>() { |
NewerOlder