Niels
|
codepad
|
|
Niels
|
Saved pastes by Niels:
// C++ code from Johannes Schaub (litb)
// C++0x: Is this "this-parameter" forwarder for function<void(???)> correct?
// http://groups.google.com/group/comp.lang.c++/msg/9a6c60fdb70d638c
// Tested by doing g++ -std=c++0x on GCC 4.5.1 20100924 (Red Hat 4.6.1-4)
//
|
view (30 lines) |
// NullClass from Scott Meyers, Effective C++ CD, Item 25.
class NullClass {
public:
template<class T>
operator T*() const { return 0; }
|
view (15 lines) |
// Based upon an example by Scott Bilas:
// http://stackoverflow.com/questions/547290/is-the-empty-base-optimization-in-gcc-configurable
#include <iostream>
struct Base {};
|
view (16 lines, 3 lines of output) |
#include <algorithm>
int main() {
unsigned long big = 76543210UL;
unsigned short small = 12345;
|
view (7 lines, 3 lines of output) |
#include <iostream>
#include <memory>
using namespace std;
// noncopyable is copied (!) from boost/noncopyable.hpp, by David Abrahams.
|
view (28 lines, 1 line of output) |
#include <exception>
#include <new>
class MyException: public std::exception
{
public:
|
view (28 lines, 2 lines of output) |
#include <fstream>
int main() {
std::ifstream inputFileStream( L"UnicodeFileName.dcm" );
return 0;
|
view (6 lines, 3 lines of output) |
// Tests the postcondition proposed by LWG 471, with respect to homogeneous copying.
// http://open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#471
// Tests all 15 C++03 exception classes.
//
// Tested implementations (so far):
|
view (232 lines, 47 lines of output) |
#include <exception>
#include <cassert>
#include <cstring>
class user_exception: public std::exception
|
view (18 lines, 3 lines of output) |
#include <exception>
#include <iostream>
int main() {
const std::exception& rhs = std::bad_exception();
|
view (9 lines, 2 lines of output) |
////////////////////////////////////////
namespace foo // "boost"
{
template<class T1, class T2>
|
view (33 lines) |