#Knuth arrows in C++ metaprogramming.
Two implementations of Knuth's arrows using constexpr
and template metaprogramming.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDecJ7pnlH12W8XFJ4nGl7tZomX6esTqrzAZoTLs6ZRn8baYOKwWf57w6uSts4x0xMfVrO5YZtlBA6YSA7ysqiVLkvjCGoWbUw5goJi3kCUnQewuBy0ukobz6i/ZIEJ8vxejNggmRkQnyitBCd7nnvaCWgwDonJj4W1r77xarWvtz3QjjpGMG59i+xjuQ3Fi7sqRmwgQmBcWyo2cerA3aU4BbhmDS6tSHO2gH7I7VmII3mZX+p+0ITBGyfLgCYI85/qugR9rgK79lwEYrAuLkzxj8FArrLQWtgqfshriZRT1lBabh6dX9PWN+ArNseZVgKeycUngKclANYbl3HVfglZ |
#Knuth arrows in C++ metaprogramming.
Two implementations of Knuth's arrows using constexpr
and template metaprogramming.
#include <iostream>
constexpr int sum (int a, int b)
{
return a + b;
}
constexpr int ediv (int a, int b)
{
Bio TODO
Article topics:
In this article I’ll tell you about my pure functional library for Software Transactional Memory (STM)
that I’ve built in C++. I adopted some advanced functional programming concepts that make it composable and convenient to use. Its implementation is rather small and robust, which differentiates the library from competitors. Let’s discuss what STM is and how to use it.
takeFork :: TVar Fork -> STM () | |
takeFork tvFork = do | |
fork <- readTVar tvFork | |
case fork of | |
InUse -> retry | |
Free -> writeTVar tvFork InUse | |
makeDiningPhilosopher :: TVar Fork -> TVar Fork -> STM (TVar Philosopher) | |
makeDiningPhilosopher leftFork rightFork = do | |
takeFork leftFork |
{-# LANGUAGE TemplateHaskell, Rank2Types #-} | |
module Main where | |
import Control.Lens | |
import Control.Monad.State | |
import Data.Monoid | |
import Data.List as L (insert, isInfixOf) |