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 <algorithm> | |
#include <cassert> | |
#include <tuple> | |
#include <utility> | |
namespace detail | |
{ | |
template <size_t N> | |
struct visit_impl | |
{ |
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 <utility> | |
// The 2x2 fibonacci matrix | |
// | |
// { F(n+1) F(n) } | |
// { F(n) F(n-1) } | |
// | |
// can be represented as just the bottom row, since the top row can be computed: | |
// so just use a pair. | |
template <typename N> |
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 <functional> | |
#include <iostream> | |
using namespace std; | |
template <typename F> | |
struct Y | |
{ | |
Y(F f) : m_f(f) {} | |
template <typename T> |
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 <memory> | |
#include <type_traits> | |
// Foo is a class that has a private constructor, and it's created by a factory | |
// function that returns a smart pointer. | |
class Foo | |
{ | |
public: | |
static std::unique_ptr<Foo> Create(); |
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
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
module Main where | |
-- Here's the familiar Writer monad. For the purposes here, we're not worried | |
-- about the instances for functor, monad etc. | |
newtype Writer a x = Writer { runWriter :: (x, a) } |
NewerOlder