[ create a new paste ] login | about

Niels

Name: Niels Dekker
Email:
Site/Blog: http://www.xs4all.nl/~nd/dekkerware/
Location: Netherlands
Default language: C++
Favorite languages: C++
About:

Saved pastes by Niels:

C++, pasted on Dec 25:
1
2
3
4
5
// 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)
C++, pasted on Nov 3:
1
2
3
4
5
// NullClass from Scott Meyers, Effective C++ CD, Item 25.
class NullClass {
public:
  template<class T>
    operator T*() const { return 0; } 
...
view (15 lines)
C++, pasted on Nov 2:
1
2
3
4
5
template <unsigned N>
unsigned GetNumberOfChars(const char(&)[N])
{
  return N;
}
...
view (10 lines)
C++, pasted on May 18:
1
2
3
4
  struct foo { int first; int second; };

  int main() {
    int foo::*ptr_to_member = 0;
...
view (10 lines, 1 line of output)
C++, pasted on May 5:
1
2
3
4
5
// 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)
C++, pasted on Apr 2:
1
2
3
4
5
struct E {
  E(){}
  E(const E&) {
    throw 42;
  }
...
view (15 lines, 2 lines of output)
C++, pasted on Apr 2:
1
2
3
4
5
namespace boost {
  template<class T> class initialized
  {
    T m_data;
  public:
...
view (45 lines)
C++, pasted on Jan 25:
1
2
3
4
5
#include <algorithm>

int main() {
  unsigned long big = 76543210UL;
  unsigned short small = 12345;
...
view (7 lines, 3 lines of output)
C++, pasted on Jan 8:
1
2
3
4
5
struct foo {
  explicit foo(int) {}
};

int main() {
...
view (8 lines)
C++, pasted on Jan 7:
1
2
3
4
5
#include <iostream>
#include <memory>
using namespace std;

// noncopyable is copied (!) from boost/noncopyable.hpp, by David Abrahams.
...
view (28 lines, 1 line of output)
C++, pasted on Jan 6:
1
2
3
4
5
#include <iostream>
#include <memory>
using namespace std;

struct A {
...
view (17 lines, 1 line of output)
C++, pasted on Jan 6:
1
2
3
4
template<class T> class value_initialized
{
public:
  value_initialized();
...
view (23 lines, 3 lines of output)
C++, pasted on Jan 3:
1
2
3
4
5
#include <iostream>
class Parent;
class Child
{
public:
...
view (27 lines, 1 line of output)
C++, pasted on Dec 5:
1
2
3
4
#include <cstdlib>
#include <new>
#include <stdexcept>
#include <string>
...
view (41 lines, 2 lines of output)
C++, pasted on Dec 1:
1
2
3
4
5
#include <exception>
#include <new>
class MyException: public std::exception
{
public:
...
view (28 lines, 2 lines of output)
C++, pasted on Nov 13:
1
2
3
4
5
#include <fstream>

int main() {
  std::ifstream inputFileStream( L"UnicodeFileName.dcm" );
  return 0;
...
view (6 lines, 3 lines of output)
C++, pasted on Oct 26:
1
2
3
4
5
  int main()
  {
  	unsigned foo = 0;
  	return foo;
  }
...
view (6 lines)
C++, pasted on Oct 24:
1
2
3
4
5
#include <iostream>
#include <string>

std::string min_by_value(std::string value)
{
...
view (18 lines, 1 line of output)
C++, pasted on Sep 23:
1
2
3
void f1(const int(&)[]);

int main() {}
view (3 lines, 2 lines of output)
C++, pasted on Aug 24:
1
2
3
4
5
// 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)
C++, pasted on Aug 17:
1
2
3
4
5
#include <vector>
#include <string>

class Foo: public std::vector<std::string>
{
...
view (14 lines)
C++, pasted on Aug 3:
1
2
3
4
5
#include <iostream>

class exception
{
  const char * m_what;
...
view (36 lines, 1 line of output)
C++, pasted on Jul 30:
1
2
3
4
#include <exception>
#include <stdexcept>
#include <string>
#include <cassert>
...
view (19 lines)
C++, pasted on Jul 29:
1
2
3
4
5
#include <exception>
#include <cassert>
#include <cstring>

class user_exception: public std::exception
...
view (18 lines, 3 lines of output)
C++, pasted on Jul 29:
1
2
3
4
5
#include <exception>
#include <cassert>
#include <cstring>
  
int main() {
...
view (10 lines, 3 lines of output)
C++, pasted on Jul 29:
1
2
3
4
5
#include <exception>
#include <iostream>

int main() {
  const std::exception& rhs = std::bad_exception(); 
...
view (9 lines, 2 lines of output)
C++, pasted on Jul 27:
1
2
3
4
5
  #include <exception>
  #include <stdexcept>
  #include <cassert>
  #include <cstring>
  
...
view (12 lines, 3 lines of output)
C++, pasted on Jun 30:
1
2
3
4
5
 ////////////////////////////////////////

 namespace foo // "boost"
 {
  template<class T1, class T2>
...
view (33 lines)
C++, pasted on Jun 29:
1
2
3
4
5
#include <string>
#include <algorithm>

namespace foo
{
...
view (20 lines, 4 lines of output)