Bug Vanquisher

14 January 2008

C++ Needs Serious Variable Inferencing

Filed under: C++ — Tanveer Badar @ 1:40 AM

A little excerpt from a little project of mine.

int array [ 5 ] = { 0 , 1 , 2 , 3 , 4 };
query::as_query( array , array + 5 ).select< query::actions::identity< int* > >( )
    .where( query::actions::condition< query::actions::identity< int* > , std::less< int > >( std::less< int >( ) ) )
    .orderby< query::actions::order< query::actions::condition< query::actions::identity< int* > , std::less< int > > > >( );

Those who can See will notice what is going on here given my history. Apart from that, notice how template arguments have gone out of hand with only three consecutive function calls. Consider the chaos when you bring in the big brothers, groupby, *join, subqueries and so on.

C++ seriously needs variable inferencing. I cannot wait to get my hands on a compiler which supports auto (no pun) type deduction. Above snippet is with no functionality and only compiling on bare bones at the moment. That library isn’t even functional and things will definitely get messier when it actually does something.

[Update]

Some 20 minutes later, the glue has been reduced by a great amount due to clever hard coding to condition in where definition.

query::as_query( array , array + 5 ).select< query::actions::identity< int* > >( )
    .where( std::less< int >( ) )
    .orderby< query::actions::order< query::actions::condition< query::actions::identity< int* > , std::less< int > > > >( );

Advertisements

1 Comment »

  1. […] the above to this. Almost all the clutter is […]

    Pingback by It is coming « Bug Vanquisher — 13 April 2008 @ 8:03 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: