<<< Closure with explicit template parameters | Lambda Home | Alias for std::stack >>> |
Common Text Transformation Library http://cttl.sourceforge.net/
cttl::alias namespace includes helper functions that return closures for well-known formats of the member functions of STL container classes and CTTL substring classes. The following list ( alias_list.c ) presents an inventory of the simplified signatures of alias namespace helpers. Here,
X specifies the typename of the class whose member function is being aliased;
ArgumentT is the typename of function argument.
StringT is the typename of STL string: either std::string or std::wstring.
LambdaT is the typename of the lambda primitive (scalar, stack, or corresponding reference equivalent.)
// alias_list.c namespace alias { //---------------------------------------------------- // std::stack //---------------------------------------------------- void pop(); void push( value_type const& ); X::value_type& top(); X::value_type const& top() const; //---------------------------------------------------- // std::basic_string //---------------------------------------------------- namespace basic_string { void push_back( value_type ); } // namespace basic_string X& append( basic_string const& ); X& assign( basic_string const& ); int compare( basic_string const& ) const; X::size_type length() const; //---------------------------------------------------- // cttl::node //---------------------------------------------------- int identity( ArgumentT const& ) const; size_t offset() const; size_t offset( size_t ); size_t line() const; size_t go_line( size_t ); size_t go_bof(); size_t go_eof(); size_t go_line_next(); size_t go_line_previous(); size_t go_line_home(); size_t go_line_home( size_t ); size_t go_line_end(); size_t go_line_end( size_t ); size_t insert_go( StringT const& ); void insert_stay( StringT const& ); //---------------------------------------------------- // cttl::const_edge // cttl::edge //---------------------------------------------------- namespace edge { void insert_go( ArgumentT& ); void insert_stay( ArgumentT& ); void text( ArgumentT const& ); void erase(); } // namespace edge X::string_T text() const; void text_tolower(); void text_toupper(); void text( StringT const& ); void text_swap( ArgumentT& ); //---------------------------------------------------- // std::set //---------------------------------------------------- X::const_iterator find( key_type const& ) const; X::const_iterator lower_bound( key_type const& ) const; X::const_iterator upper_bound( key_type const & ) const; std::pair< typename LambdaT::value_T::const_iterator, typename LambdaT::value_T::const_iterator > equal_range( key_type const& ) const; //---------------------------------------------------- // STL sequence //---------------------------------------------------- X::const_reference at( size_type ) const; X::const_reference back() const; X::const_iterator begin() const; X::const_iterator end() const; X::const_reference front() const; X::const_reverse_iterator rbegin() const; X::const_reverse_iterator rend() const; X::reference at( size_type ); X::reference back(); X::iterator begin(); X::size_type capacity() const; void clear(); bool empty() const; X::iterator end(); X::iterator erase( iterator ); X::reference front(); X::size_type max_size() const; void pop_back(); void push_back( value_type const& ); X::reverse_iterator rbegin(); X::reverse_iterator rend(); void resize( size_type ); void reserve( size_type ); X::size_type size() const; void swap( vector& ); //---------------------------------------------------- // std::queue //---------------------------------------------------- namespace queue { X::value_type const& back() const; X::value_type& back(); X::value_type const& front() const; X::value_type& front(); } //namespace queue //---------------------------------------------------- // std::deque //---------------------------------------------------- void pop_front(); void push_front( value_type const& ); //---------------------------------------------------- // std::list //---------------------------------------------------- void remove( value_type const& ); void reverse(); void sort(); void unique(); void merge( list& ); //---------------------------------------------------- // STL associative container //---------------------------------------------------- namespace associative { X::size_type count( key_type const& ) const; X::size_type erase( key_type const& ); } // namespace associative X::iterator find( key_type const& ); X::iterator lower_bound( key_type const& ); X::iterator upper_bound( key_type const& ); std::pair< typename LambdaT::value_T::iterator, bool > insert( value_type const& ); std::pair< typename LambdaT::value_T::iterator, typename LambdaT::value_T::iterator > equal_range( key_type const& ); //---------------------------------------------------- // slist (http://www.sgi.com/tech/stl/Slist.html) //---------------------------------------------------- X::const_iterator previous( const_iterator ); X::iterator previous( iterator ); X::iterator insert_after( iterator ); X::iterator erase_after( iterator ); //---------------------------------------------------- // std::bitset //---------------------------------------------------- namespace bitset { size_t size() const; } // namespace bitset bool any() const; size_t count() const; bool none() const; bool test( size_t ) const; unsigned long to_ulong() const; } // namespace alias
When making calls through an alias, the following rules apply:
Aliases are defined for non-static member functions only.
The first argument of the alias helper specifies the object instance, wrapped by the scalar placeholder.
The second argument of the alias helper specifies the member function argument:
alias::push( &stack_ref, size_t( 5 ) )
Note, that the argument here is not a scalar type.
Constant argument should be passed by reference;
Mutable argument should be passed by address:
alias::text_swap( &substring, &edge_tail )
If argument is already enclosed by another scalar Z, the original object reference should be extracted via Z.top().
Copyright © 1997-2009 Igor Kholodov mailto:cttl@users.sourceforge.net.
Permission to copy and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.
<<< Closure with explicit template parameters | Lambda Home | Alias for std::stack >>> |