Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Who said Sepples can't Cudder?

Name: Anonymous 2011-08-05 4:03


//
// prog_cudder.hpp
//

#ifndef PROG_CUDDER_HPP
#define PROG_CUDDER_HPP

#include <cstddef>
#include <tuple>

namespace prog
{
    namespace detail
    {
        template <class... List>
        struct cudder;

        template <>
        struct cudder<std::nullptr_t>
        {
            typedef std::nullptr_t car_type;
            typedef std::nullptr_t cdr_type;
        };

        template <class Tail>
        struct cudder<Tail>
        {
            typedef Tail car_type;
            typedef std::nullptr_t cdr_type;
        };

        template <class Tail>
        struct cudder<std::tuple<Tail>>
        {
            typedef Tail car_type;
            typedef std::nullptr_t cdr_type;
        };

        template <class Car, class... Cdr>
        struct cudder<Car, Cdr...>
        {
            typedef Car car_type;
            typedef std::tuple<Cdr...> cdr_type;
        };

        template <class Car, class... Cdr>
        struct cudder<std::tuple<Car, Cdr...>>
        {
            typedef Car car_type;
            typedef std::tuple<Cdr...> cdr_type;
        };
    }

    template <class... List>
    struct car
    {
        typedef typename detail::cudder<List...>::car_type type;
    };

    template <class... List>
    struct cdr
    {
        typedef typename detail::cudder<List...>::cdr_type type;
    };
}

#endif

//
// cudder_test.cpp
//

// Compile with C++11/C++0x extensions enabled.
// Example: g++ -std=gnu++0x -o cudder_test cudder_test.cpp

#include "prog_cudder.hpp"
#include <type_traits>

using std::is_same;
using std::nullptr_t;
using prog::car;
using prog::cdr;

int main(int, char**) {
    static_assert(is_same<int, car<int, bool, long>::type>::value, "should pass");
    static_assert(is_same<bool, car<cdr<int, bool, long>::type>::type>::value, "should pass");
    static_assert(is_same<long, car<cdr<cdr<int, bool, long>::type>::type>::type>::value, "should pass");
    static_assert(is_same<nullptr_t, cdr<cdr<cdr<int, bool, long>::type>::type>::type>::value, "should pass");
    return 0;
}

This has been distilled and cleaned up from another thread by the original author.

Name: Anonymous 2011-08-05 4:19

SEPPLES ELEVEN

Name: Anonymous 2011-08-05 4:22

But can you implement the fibonacci BUTT SORT?

Name: Anonymous 2011-08-05 6:22

But can it CADR?

Name: Anonymous 2011-08-05 11:09

why does "cudder" mean "cons" on this board?

Name: Anonymous 2011-08-05 11:24

>>5
"cudder" is sexually explicit.

Name: Anonymous 2011-08-05 11:40

>>5
A cons will have a cudder anyway.

Name: Anonymous 2011-08-05 11:57

Downboat for raping C++

Name: Anonymous 2011-08-05 13:30

>>5
``Cudder'' actually means ``cdr'' on this board.

Name: Anonymous 2011-08-05 14:47

>>9
My other ``car" is a ``cdr".

Name: Anonymous 2013-03-13 13:31

Can Cudder sepples, or is she just jewing it up with her Intel menorahs?

Name: Anonymous 2013-03-13 13:53

I once put my car in Cudder's cdr

Don't change these.
Name: Email:
Entire Thread Thread List