pstade

Next

Chapter 1. Egg 0.90.3

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Table of Contents

Overview
Introduction
Requirements
Portability
Rationale
Acknowledgements
Notation
Concepts
Lexically Typed Object
Pipable Function Object
Ambi Function Object
Major Function Object
Static Function Object
Little Function
result_of tutorial
Forwarding Strategies
by_perfect
by_ref
by_cref
by_value
Deducing nullary return types
Function Builders
function
function_facade
deferred
generator
automatic
make_function
Function Adaptors
ambiN
compose
curryN
uncurry
fuse
unfuse
indirect
lazy
memoize
mono
perfect
pipable
regular
ret
tagged
Object Generator
generator
Generating Forms
Deducers
Utilities
apply
bll_bind
bll_N
bll/result_of.hpp
infix
tuple_get
tuple_pack
Configuration
MAX_ARITY
MAX_LINEAR_ARITY
Workarounds
pstade::result_of
detect_result_type.hpp
deduced_form
DEFER
CONST
Version History

An Egg to day is better than a Hen to-morrow.” -- Benjamin Franklin

Unlike other modern languages, it is very difficult to make a function in C++ especially if you want to support Boost.ResultOf and Boost.Lambda. Egg is a small header-only framework of building functions, and offers higher-order functions.

#include <pstade/egg/pipable.hpp>
using namespace pstade::egg;

// This adaptation incurs no runtime overhead.
result_of_pipable<int(*)(int)>::type const
    to_upper = PSTADE_EGG_PIPABLE(&toupper);

void test()
{
    int maybeI = 'i'|to_upper|pipable(&tolower)|to_upper();
    BOOST_CHECK(maybeI == 'I');
}

Egg is known to work on the following platforms:

  • Microsoft Visual C++ .NET Version 7.1 SP1
  • Microsoft Visual C++ 2005 Express Edition SP1
  • MinGW with GCC 3.4.4
  • MinGW with GCC 4.1.2
  • Intel C++ Compiler Professional Edition 10.1 for Windows
  • Special thanks to David Abrahams. The Forwarding Problem workaround is based on his callable.
  • Special thanks to Eric Niebler, who pointed out importance of static initialization.
  • Special thanks to Cryolite, Takeshi Mouri, yotto-k and Yusuke Kajimoto. These people are instrumental in the design and development of Egg.

This document uses the following notation.

Valid expression

Semantics

_decltype

An imaginary operator which is the same as decltype of C++0x.

_typeof(a)

boost::remove_cv<boost::remove_reference<_decltype(a)>::type>::type

_const(a)

static_cast<_typeof(a) const>(a)

_pfo

A Polymorphic Function Object

_PFo

A Polymorphic Function Object type which is neither reference nor cv-qualified.

_lit

A Little Function object

_Lit

A Little Function type which is neither reference nor cv-qualified.

_Stg

A type which is one of the Forwarding Strageties.

_default

boost::use_default

_TUPLE_MAX_SIZE

10

++

An imaginary operator to concatenate tokens.

Also, assume that every expression is placed after:

namespace egg = pstade::egg;
using namespace egg;

Last revised: January 03, 2008 at 16:31:35 GMT


Next