Boost logo

Boost :

From: James Curran (JamesCurran_at_[hidden])
Date: 2003-11-21 10:47:52


"Brian McNamara" <lorgon_at_[hidden]> wrote in message
news:20031118041951.GA20400_at_lennon.cc.gatech.edu...
> <wishful thinking>
>
> If only "strings" were legal "template value parameters" in C++. Then
> we could write code like
>
> typedef regexp< "(hello )+world" >::type MyRegex;
> ... MyRegex::match( someString ) ...
>
> Aaaaaah. :)
>
> </wishful>

This is not quite a slack as it needs to be, but it works:

template <const char* exp>
struct regexp
{
    regexp() { cout << exp << endl; }
};

#define REGEXP(name, strng) \
        extern char __FILE__##name[] = strng; \
        typedef regexp<__FILE__##name> name;

REGEXP(MyRegex, "(hello )+world")

MyRegex rg;


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk