Boost logo

Boost :

From: Trey Jackson (tjackson_at_[hidden])
Date: 2003-02-06 13:52:02

Hamish Mackenzie wrote:
>These scoped locks will go out of scope before you "do stuff".

Right, thanks for the catch.

I started writing it thinking I'd be doing some cool new
meta-programming, but it turned into just simple object inheritance
(thus the function calls that let the locks go out of scope).

But my original intent was actually to try to get code substituted at
compile time.


template<class ToBeSubstituted>
class userClass {
  void function() {
    // code is inserted here, not a function call to a member of ToBeSubstituted

class SubstituteHello {
  <whatever> insertCode {
    cout << "hello world" << endl;

class SubstituteGoodbye {
  <whatever> insertCode {
    cout << "goodbye world" << endl;

userClass<SubstituteHello> u1;
u1.function(); // prints 'hello world'

userClass<SubstituteHello> u2;
u2.function(); // prints 'goodbye world'

Any tips on how to do this?
Is it possible in C++? I can see how to do it with lisp macros.
I'm reading the MPL intro written by David Abrahams and Aleskey
Gurtovoy, but it's slow going...


Trey Jackson
Pilots usually try to equalize the following equation:
                # takeoffs = # landings

Boost list run by bdawes at, gregod at, cpdaniel at, john at