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 <stdbool.h> | |
| #include <string.h> | |
| #include <stdio.h> | |
| /* | |
| 1. Compile this program with Fil-C to ./a.out | |
| 2. Execute: echo FILFAIL | ./a.out |
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 <math.h> | |
| volatile _Bool b; | |
| volatile int i; | |
| void foo () | |
| { | |
| b = NAN; | |
| i = NAN; | |
| } |
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
| data Combinators a = I a | K a a | S a a a | |
| primes = | |
| K | |
| (S I I (S (K (S (S (K (S I I (S (S (K S)(S (K (S (K S)))(S (K (S (S (K S)(S S (S (S (K S)K))(K K))))) | |
| (S (S (K S)(S (K K)(S (K S)(S (S (K S)(S (K K)(S (K S)(S (S (K S)(S (K K)(S I I))) | |
| (K (S I (K K)))))))(K (S (K (S (S (K S)(S (K (S I))(S (K K)(S (K (S (S (K S)K)(S (S (K S)K)I) | |
| (S (S I I)I (S (S (K S)K)I)(S (S (K S)K)))))(S I (K (K I)))))))))(S (K K)K)))))))(K (S (K K) | |
| (S (S I (K (S (S (S (S (S S K (S I (K (K I))))(K (S (S (K S)K)I (S (S (K S)K)(S (S (K S)K)I)) | |
| (S (K (S (S I (K (K I)))))K)(K K))))(K K))(S (S (K S)(S (K (S I))(S (K K)(S (K (S (S (K S)K))) |
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
| bool validateChecksum() | |
| { | |
| std::filebuf buf; | |
| buf.open(_path, std::ios::in | std::ios::binary); | |
| uint32_t checksum = -1; | |
| uint32_t actualChecksum = 0; | |
| for(int c; ((c=buf.sbumpc()) != EOF); ) | |
| { |
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
| // inspired by: http://bloglitb.blogspot.nl/2010/07/access-to-private-members-thats-easy.html | |
| // but removed unnecessary machinery to make the trick work | |
| #include <iostream> | |
| using namespace std; | |
| template<typename Ptr, Ptr value, Ptr& obj> | |
| class rob { | |
| static struct filler { |
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
| // explicit type conversion made easy! | |
| template<class T> | |
| struct auto_deref_t { | |
| auto_deref_t(T t) : _obj(t) { } | |
| template<class U> | |
| operator U() const { return *(U*)_obj; } | |
| auto_deref_t<auto_deref_t> operator*() const | |
| { return *this; } | |
| const T _obj; |
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
| void sort(int a[], size_t N) | |
| { | |
| if(N>1) do { | |
| swap(&a[0], &a[1]); | |
| sort(a+1, N-1); | |
| } while(a[0]>a[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
| sieve() { | |
| if read p; then | |
| echo $p | |
| while read n; do | |
| if [ `expr $n % $p` != 0 ]; then | |
| echo $n | |
| fi | |
| done | sieve | |
| fi | |
| } |
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 <string> | |
| struct foo { | |
| operator const std::string() | |
| { return "hatsjekiedee"; } | |
| }; | |
| int main() | |
| { | |
| std::string s; |
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 <class T> struct cont; | |
| template<class T> struct proxy { | |
| cont<T> data; | |
| }; | |
| extern struct cont<char> foo; // gcc,clang,msvc fine with this | |
| extern struct proxy<char> bar; // msvc not ok with this |
NewerOlder