![]() |
What I think especially impressed me was Andrei Alexandrescu's article on improving copies. I like most programmers had thought this was a done deal and we'd got as good as we got - but as I'm really an assembler programmer at heart, I knew C++ was very suboptimal especially with regard to temporaries. From that point onwards I resolved to learn this skill.
The generic tools provided by FXGenericTools.h
provide the following facilities:
Unfortunately, these come with a price - you will need a compiler supporting partial template specialisation plus Koenig lookup. That means MSVC7.1 or higher and GCC v3.4 or higher - with other compilers, your milage may vary. I've heard Intel's C++ compiler v7.x works fine too. If your compiler is not up to scratch, I did design the generic tools to be redirectable to a much more comprehensive library eg; Boost (http://www.boost.org/).
Speaking of Boost, TnFOX's compile-time metaprogramming tools are only fairly comprehensive. I've aimed merely to provide the most common and useful facilities which can do 95% of day to day stuff. If you want to do anything more complicated than this, I strongly recommend Boost which should be able to convert TnFOX's typelists to its own pretty easily.
For lots more on compile-time metaprogramming (especially if you want to learn it), please consult the book "Modern C++ Design" by Andrei Alexandrescu.
Namespaces | |
namespace | Generic |
Modules | |
Typelists | |
Class Traits | |
Classes | |
struct | FX::Generic::NullType |
A type representing no type (ie; end of list etc). More... | |
struct | FX::Generic::IntToType< n > |
A small template which maps any int to a type (and thus allows number-based overloading and type specialisation - and thus compile-time determined code generation). More... | |
struct | FX::Generic::TypeToType< type > |
A small template which maps any type to a lightweight type suitable for overloading eg; functions. More... | |
struct | FX::Generic::Boolean< v, type > |
A small template whose value is v. Useful for delayed static assertions. More... | |
struct | FX::Generic::select< v, A, B > |
Selects one of two types based upon a boolean. More... | |
struct | FX::Generic::sameType< A, B > |
Returns true if the two types are the same. More... | |
struct | FX::Generic::addRef< type > |
Adds a reference indirection unless type already has one. More... | |
struct | FX::Generic::addConstRef< type > |
Ensures a type is a const reference. More... | |
struct | FX::Generic::convertible< to, from > |
Returns true if from can become to. More... | |
struct | FX::Generic::lessIndir< ptr > |
Removes if possible a level of indirection from a pointer or reference type. More... | |
struct | FX::Generic::indirs< type > |
Returns how many levels of indirection this type has eg; int ** is two. More... | |
struct | FX::Generic::leastIndir< ptr > |
Removes all levels of indirection from a pointer or reference type. More... | |
struct | FX::Generic::typeInfo< type > |
Enhanced version of std::type_info. More... | |
class | FX::Generic::ptr< type, ownershipPolicy > |
A policy-based smart pointer. More... | |
struct | FX::Generic::FnInfo< fn > |
Extracts type information from a function pointer type. More... | |
struct | FX::Generic::FnFromList< list > |
Converts a typelist into a function pointer type. More... | |
struct | FX::Generic::IntegralLists |
A series of typelists of kinds of integral type. More... | |
struct | FX::Generic::BiggestValue< type, minus > |
Returns the biggest positive or negative value which can be stored in an integral type. More... | |
struct | FX::Generic::SmallestValue< type, minus > |
Returns the smallest positive or negative value which can be stored in an integral type. More... | |
class | FX::Generic::Traits< type > |
Determines qualities of a type via introspection. More... | |
class | FX::Generic::Functor< parslist > |
Represents a callable API. More... | |
class | FX::Generic::BoundFunctorV |
A call to a specific API with specific arguments, throwing away the return. More... | |
class | FX::Generic::BoundFunctor< parslist > |
A call to a specific API with specific arguments. More... | |
struct | FX::Generic::MapBools< len > |
Mapper of C++ bools to a bitfield. More... | |
class | FX::Generic::DoUndo< obj, doaddr, undoaddr > |
Performs an action on construction and another action on destruction. More... | |
struct | FX::Generic::hasSerialise< type > |
Determines if a FXStream operator<< exists for the specified type. More... | |
struct | FX::Generic::hasDeserialise< type > |
Determines if a FXStream operator>> exists for the specified type. More... | |
Defines | |
#define | FXSTATIC_ASSERT(expr, msg) |
Functions | |
BoundFunctor | FX::Generic::BindFunctor (FX::Generic::Functor &functor[, par1[, par2...]]) |
BoundFunctor * | FX::Generic::BindFunctorN (FX::Generic::Functor &functor[, par1[, par2...]]) |
BoundFunctor | FX::Generic::BindFunc (functptr[, par1[, par2...]]) |
BoundFunctor | FX::Generic::BindFuncN (functptr[, par1[, par2...]]) |
BoundFunctor | FX::Generic::BindObj (obj &, memfunctptr[, par1[, par2...]]) |
BoundFunctor | FX::Generic::BindObjN (obj &, memfunctptr[, par1[, par2...]]) |
#define FXSTATIC_ASSERT | ( | expr, | |||
msg | ) |
A macro which provides compile-time assertion tests, causing the compiler to issue a useful message msg if the assertion fails. The message must be a legal C++ identifier though it can start with a number. You also must place it somewhere where code can be compiled as it relies on a scope to remove a temporarily created variable (which is optimised away on release builds). If you want it without the scope (eg; as a member variable) use FXSTATIC_ASSERT2().
On C++0x compilers, this uses the new static_assert() feature.
Referenced by FX::FXIPCChannel::invokeMsgHandler(), FX::FXIPCChannelIndirector::sendMsg(), FX::FXIPCChannel::sendMsg(), and FX::TnFXSQLDB::toSQL92Type().
BoundFunctor FX::Generic::BindFunctor | ( | FX::Generic::Functor &functor] | [, par1[, par2...] | ) |
Binds a functor to a set of parameters and returns the binding
BoundFunctor* FX::Generic::BindFunctorN | ( | FX::Generic::Functor &functor] | [, par1[, par2...] | ) |
Binds a functor to a set of parameters and returns the binding as a newed pointer
BoundFunctor FX::Generic::BindFunc | ( | functptr] | [, par1[, par2...] | ) |
Binds a function to a set of parameters and returns the binding
BoundFunctor FX::Generic::BindFuncN | ( | functptr] | [, par1[, par2...] | ) |
Binds a function to a set of parameters and returns the binding as a newed pointer
BoundFunctor FX::Generic::BindObj | ( | obj & | , | |
memfunctptr] | [, par1[, par2...] | |||
) |
Binds a member function of a specific object to a set of parameters and returns the binding
BoundFunctor FX::Generic::BindObjN | ( | obj & | , | |
memfunctptr] | [, par1[, par2...] | |||
) |
Binds a member function of a specific object to a set of parameters and returns the binding as a newed pointer