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 <sstream> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
string ss2s(ostream const& os) { | |
return static_cast<stringstream const&>(os).str(); | |
} | |
int main() { |
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
use std::rt::io::Writer; | |
use std::rt::io::stdio::with_task_stdout; | |
struct MagicWriter(); | |
impl Writer for MagicWriter { | |
fn write(&mut self, buf: &[u8]) { | |
do with_task_stdout |o| { o.write(buf); } | |
} | |
fn flush(&mut self) { | |
do with_task_stdout |o| { o.flush(); } |
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
use std::rt::io::{stdout,Writer}; | |
fn main() { | |
print("Hello"); | |
stdout().write(" World".as_bytes()); | |
println("!"); | |
} |
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
#define F_CPU 12000000UL | |
#include <krdln/port.h> | |
int main() { | |
Output<A::Pin<0>> led; | |
Output<A::Pin<2>, false> err; // false: "on" level is 0V | |
Button<C::Pin<3>> but; // automagic pullup, yay! | |
int const T = 300; | |
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 <cstdio> | |
struct _Ms { int x; }; | |
struct _Us { int x; }; | |
constexpr _Ms operator "" ms(long long unsigned x) { return {(int)x}; } | |
constexpr _Us operator"" us(long long unsigned x) { return {(int)x}; } | |
void fun(_Ms x) { printf("%d milisekund\n", x.x); } | |
void fun(_Us x) { printf("%d mikrosekund\n", x.x); } |
NewerOlder