Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

overloaded subscript operator


SourceForge.net Logo     CTTL on    
    SourceForge    
    Download    
    Latest    
    Documentation    
    Index    
    Library    
    News    
    CVS    
    Repository    
   Other    
   Links    

overloaded subscript operators

subscript access to values, CTTL node character access
void f()
{
    input<> inp( "abcdef" );
    lambda< char >::scalar ch;
    lambda< node<> >::scalar n1( new_node( inp ) );
    lambda< node<> >::scalar n2( new_node( inp ) );
    (
        // update node positions:
        alias::offset( &n1, size_t( 0 ) ),
        alias::offset( &n2, size_t( 1 ) ),
        // swap characters:
        ch = n1[ const_scalar( 0 ) ],
        n1[ const_scalar( 0 ) ] = n2[ scalar( 0 ) ],
        n2[ const_scalar( 0 ) ] = ch
    ).evaluate();
    assert( inp.text() == "bacdef" );
}

subscript operator access to vector of strings

#define CTTL_TRACE_RULES // automatically turns lambda tracing on

#include "cttl/cttl.h"
#include "lambda/lambda.h"

using namespace cttl;

int main(int argc, char* argv[])
{
    std::vector< std::string > vec( 1 ); // vector with 1 element
    lambda< std::vector< std::string > >::scalar_reference
        vec_ref( &vec );
    lambda< std::string >::scalar str( std::string( "ABC" ) );
    ( vec_ref[ 0 ] = str ).evaluate();

    return 0;
}



Copyright © 1997-2006 Igor Kholodov mailto:cttl@users.sourceforge.net.

Permission to copy, use, modify, sell 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.


Generated on Thu Nov 2 17:48:54 2006 for CTTL Lambda Expression by  doxygen 1.3.9.1