#ifndef HEADER_H
#define HEADER_H
//...
#endif //HEADER_H
is preferred to
| template <typename T, typename = void> | |
| struct Foo; | |
| // A | |
| template <typename T> | |
| struct Foo<unique_ptr<T>, typename std::enable_if<std::is_class<T>::value>::type> {...}; | |
| // B | |
| template <typename T> | |
| struct Foo<T, typename std::enable_if<std::is_class<T>::value>::type> {...}; |
| #include <stdio.h> | |
| #include "Foo.h" | |
| #include "Baz.h" | |
| #undef API | |
| #define API __declspec(dllexport) | |
| #include "Bar.h" | |
| void Bar::Print() { | |
| printf("Bar\n"); |
| template<typename T> | |
| struct Has_My_Static { | |
| typedef char yes[1]; | |
| typedef char no[2]; | |
| template<void*> struct exist_check; | |
| template<typename U, U> struct type_check; // Use this for type checking. | |
| #ifdef _MSC_VER | |
| template<typename C> static yes& chk(C*, exist_check<(void*)&C::MyStatic>*); | |
| #else | |
| template<typename C> static yes& chk(C*, typeof(&C::MyStatic)); |
| template <typename T, void (*f)(T*)> | |
| class delete_fun | |
| { | |
| public: | |
| void operator()(T* obj) const | |
| { | |
| f(obj); | |
| } | |
| }; |
| render.rs:5:2: 6:1 error: type `gldevice::GLDevice` does not implement any method in scope named `init` | |
| render.rs:5 device.init() | |
| render.rs:6 } |
| let window; | |
| do str::as_c_str("Project Guava") |cstr| { | |
| window = SDL::SDL_CreateWindow(cstr, | |
| SDL_WINDOWPOS_CENTERED, | |
| SDL_WINDOWPOS_CENTERED, | |
| 512, 512, | |
| (SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN)); | |
| } | |
| let context = SDL::SDL_GL_CreateContext(window); |
| trait Persistable { | |
| fn persist_test(&self) -> int; | |
| } | |
| fn persist<T: Persistable>(val : T) { | |
| io::println(fmt!("Val: %d", val.persist_test())); | |
| } | |
| macro_rules! object( | |
| ($cname:ident { $($tname:ident : $typ:ty),* }) => ( |
| <html> | |
| <body> | |
| <canvas id="cvs" width="1024" height="32"> | |
| </canvas> | |
| <script type="text/javascript"> | |
| var size = 32; | |
| var cvs = document.getElementById("cvs"); | |
| cvs.width = size * size; | |
| cvs.height = size; | |
| var ctx = cvs.getContext('2d'); |
| f = (v) -> | |
| v | |
| x = [a, f | |
| b, 2] | |
| y = {a: f | |
| b: 2} |