litb
|
codepad
|
|
litb
|
Saved pastes by litb:
namespace isbase_detail {
template<typename T> struct identity { typedef T type; };
template<typename,typename>
struct tovoid { typedef void type; };
|
view (39 lines, 2 lines of output) |
template <typename> struct tovoid { typedef void type; };
template <typename T, size_t KCount, typename = void>
struct ArrayStorage {
typedef T type;
|
view (32 lines, 3 lines of output) |
#include <array>
#include <cstddef>
template<typename T, std::size_t N>
struct build {
|
view (45 lines) |
template<int&> struct takes_int { };
template<typename T>
struct has_int {
static int data;
|
view (15 lines, 2 lines of output) |
struct Number
{
int num;
Number(int n=0,int d=1) {num = n/d;}
operator int() {return num;}
|
view (10 lines, 2 lines of output) |
#include <exception>
#include <iostream>
#include <cstdlib>
// provides operators for any alignment >= 4 bytes
|
view (31 lines, 2 lines of output) |
#ifndef ISBASEHPP
#define ISBASEHPP
namespace isbase_detail {
template<typename T> struct identity { typedef T type; };
|
view (37 lines) |
// Used as a container for a set of types.
template <typename... Types> struct TypePack
{
// Given a TypePack<T1, T2, T3> and T=T4, returns TypePack<T1, T2, T3, T4>
template <typename T>
|
view (35 lines) |
template<typename M, typename T>
void print_offset(M *m, T * t) {
std::cout << "this: " << (void*)t << "; member: " << (void*)m << std::endl;
}
|
view (24 lines, 5 lines of output) |
#include <boost/mpl/assert.hpp>
template<typename T> struct not_defined : boost::mpl::false_ { };
template<typename T> T GetGlobal(char const *name)
{ BOOST_MPL_ASSERT(( not_defined<T> )); }
|
view (7 lines, 4 lines of output) |
namespace detail {
struct any { template<typename T> any(T const&); };
struct tag { char c[2]; };
int operator,(detail::tag, detail::tag);
|
view (63 lines, 3 lines of output) |
#define MY_CONCAT1(D,A) D ## A
#define MY_CONCAT(D, A) MY_CONCAT1(D, A)
#define BUILD_DEDUCE(D) MY_CONCAT(DED, D)
#define DEF_DEDUCE(D) any_base const & D = make_any_concrete(BUILD_DEDUCE(D))
#define DEDUCED(D) get_t(D, true ? ded_ty() : get_idt(BUILD_DEDUCE(D)))
|
view (44 lines, 1 line of output) |
#include <boost/bind.hpp>
struct D { template<typename T> operator T() { T t; return t; } };
template<typename T> D operator|(T, D d) { return d; }
|
view (24 lines, 1 line of output) |
"ComeauTest.c", line 108: error: "nelems" is not a nonstatic data member or base
class of class "SimpleList<T>"
:head_(0), nelems(0)
^
|
view (16 lines) |
struct A { };
int main() {
int A::*p = 0;
cout << *(ptrdiff_t*)(void*)&p << endl;
memset(&p, 0, sizeof p);
|
view (7 lines, 2 lines of output) |
<!--
The following uses another way to tackle it. It uses a solution similar to the one found at [this thread](http://tinyurl.com/usenet-c), and linked to by @Roshan below. I took some of the ideas and wrote a version that uses a macro allowing to create a `has_to_string` template. The following is the code, each in parts.
|
view (142 lines) |
#include <boost/type_traits.hpp>
#include <utility>
#include <iostream>
#include <deque>
#include <stack>
|
view (79 lines) |
#include <string>
#include <iostream>
#include <boost/function.hpp>
namespace detail {
|
view (111 lines, 10 lines of output) |
#include <string>
#include <iostream>
#include <boost/function.hpp>
namespace detail {
|
view (76 lines, 6 lines of output) |
/* ranks */
template<typename> struct int_rank;
#define RANK(T, I) template<> struct int_rank<T> \
{ static int const value = I; }
|
view (103 lines, 1 line of output) |
#include <boost/mpl/vector.hpp>
#include <boost/mpl/inherit_linearly.hpp>
#include <boost/mpl/inherit.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/bool.hpp>
|
view (100 lines, 4 lines of output) |
#include <boost/mpl/vector.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/assert.hpp>
|
view (78 lines, 4 lines of output) |
#include <boost/mpl/vector.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/assert.hpp>
|
view (75 lines, 4 lines of output) |
; ModuleID = '<stdin>'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
@.str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1]
|
view (50 lines) |
boost::spirit::impl::concrete_parser<
boost::spirit::alternative<
boost::spirit::sequence<
boost::spirit::sequence<
boost::spirit::sequence<
|
view (804 lines) |
boost::spirit::impl::concrete_parser<
boost::spirit::alternative<
boost::spirit::sequence<
boost::spirit::sequence<
boost::spirit::sequence<
|
view (803 lines) |
boost::spirit::impl::concrete_parser < boost::spirit::alternative <
boost::spirit::sequence < boost::spirit::sequence <
boost::spirit::sequence < boost::spirit::optional <
boost::spirit::sequence < boost::spirit::inhibit_case <
boost::spirit::contiguous < boost::spirit::sequence < boost::spirit::chseq <
|
view (728 lines) |
#include <algorithm>
#include <boost/bind.hpp>
#include <functional>
#include <utility>
#include <vector>
|
view (26 lines) |
Of course, a minimal class interface is not necessarily the best interface.
I remarked in Effective C++ that adding functions beyond those truly necessary
may be justifiable if it significantly improves the performance of the class,
makes the class easier to use, or prevents likely client errors [10]. Based on
his work with various string-like classes, Jack Reeves has observed that some
|
view (9 lines) |
#include <boost/fusion/include/sequence.hpp>
#include <boost/fusion/include/make_vector.hpp>
#include <boost/fusion/include/next.hpp>
#include <stdexcept>
#include <iostream>
|
view (76 lines) |
/* fully c++03 conform (apart from long long, but which is supported by
major compilers). */
#include <cstdio>
/* chooses type A if cond == true, chooses type B if cond == false */
|
view (48 lines, 2 lines of output) |
#0 0x08048730 in main ()
#0 0x080487d5 in operator>><echot> ()
#0 0x080487ba in echot::chain<std::istream&>::chain ()
#0 0x080487b4 in transformer<echot::chain<std::istream&> >::transformer ()
#0 0x08048819 in operator>><echot::chain<std::istream&>, noiset> ()
|
view (15 lines) |
#0 main () at streaming.cpp:47
0
98
Current language: auto; currently asm
#0 0x080485d8 in std::ios_base::Init::~Init ()
|
view (5 lines) |
#include <boost/lambda/lambda.hpp>
#include <string>
#include <iostream>
using namespace boost::lambda;
|
view (14 lines, 1 line of output) |
#include "turing.hpp"
#include "is_same.hpp"
#include "printer.hpp"
#include "type_list.hpp"
#include <iostream>
|
view (32 lines) |