c++boost.gif (8819 bytes)HomeLibrariesPeopleFAQMore

11. Relationships with other libraries

Table of Contents

11.1. Interfaces to STL
11.2. Relation to Boost

In this section we briefly describe the relationship between FC++ and other C++ libraries.

11.1. Interfaces to STL

The main interface to the STL is via iterators in the list class. FC++ lists, like STL containers, have a constructor which takes two iterators deliniating a range, so that the contents of an STL container can be (lazily) copied into a list. For example:

   std::vector<int> v = ...;
   fcpp::list<int> l( v.begin(), v.end() );
   // l is not yet evaulated; still holds iterators into v
   fcpp::length( l );  // force evaluation of entire list
   // now l has a true copy of the elements in v
Additionally, lists themselves have forward iterators:
   for( fcpp::list<int>::iterator i = l.begin(); i != l.end(); ++i )
      cout << *i;      // print each element of list

In addition to fcpp::lists, there is also a class called fcpp::strict_list, which has the same structural interface as list, but does not do lazy evaluation. The library "list" functions work on any datatype which meets the FC++ "ListLike" concept, which includes list, odd_list, and strict_list. For many applications, strict_list may be the preferred datatype to use, as it avoids incurring the costs of lazy evaluation when that feature is not needed.

Monomorphic FC++ (unary or binary) functoids are STL "adaptables". The fcpp::ptr_to_fun() functoid promotes C++ function/method pointers into FC++ full functoids. The stl_to_funN functions turn STL adaptables into functoids.

11.2. Relation to Boost

FC++ is related to a number of Boost libraries.

11.2.1. boost::bind and boost::lambda

FC++'s lambda (see Section 12) and currying (Section 7) capabilities do approximately the same thing that boost::lambda and boost::bind do. These libraries were developed with different design rationales; for a description of the comparison, see [McN&Sma03].

Since FC++ supports the result_of method for return-type-deduction (see Section 7), FC++ interoperates with boost::lambda and boost::bind.

11.2.2. boost::function

FC++ indirect functoids (Section 6) are similar to boost::function objects. Indirect functoids have all of FC++'s full functoids capabilities (like currying and infix syntax; see Section 7) built in. Indirect functoids can only pass parameters by value (actually, const&), though (see Section 16 for discussion on this point).

11.2.3. Other Boost libraries

FC++ uses a number of other boost libraries in its implementation:
  • boost::intrusive_ptr in indirect functoids and lists, for automatic memory management
  • boost::is_base_and_derived and boost::is_convertible in a number of places
  • boost::addressof to implement the address_of() functoid
  • boost::type_with_alignment and boost::alignment_of in the implementation of the list and by_need datatypes
  • boost::noncopyable in a number of places
Last revised: October 03, 2003 at 23:27:22 GMTCopyright © 2000-2003 Brian McNamara and Yannis Smaragdakis