[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Announcing: Luaxx 0.1, a C++ Lua wrapper
- From: "Matthew A. Nicholson" <matt@...>
- Date: Tue, 27 Feb 2007 09:53:58 -0600
Matthew A. Nicholson wrote:
JÃrÃme VUARAND wrote:
2007/2/25, Thomas Harning Jr. <email@example.com>:
On 2/25/07, Matthew A. Nicholson <firstname.lastname@example.org> wrote:
Great job on the library, however I think it could use a little fixing
for the 'as' function. Passing in a variable of the type in order to
get C++ to know what type to use doesn't sound like the best idea.
Using C++ templates seems to make the most sense to me.
int val = L.as(0, index);
It would be:
int val = L.as<int>(index);
... Just my 2 cents.
I was about to make the same suggestion. And if your original
intention was to write more generic code like :
val = L.as(val, index);
with a modern compiler you could write :
int val = L.as<typeof(val)>(index);
Not all compiler support the typeof operator yet, but GCC does and
template based limited implementations exist for those that don't.
The design for that function was taken from pqxx:
Looking at their docs, they use a template for it too (and have the
option to specify a default value to return if the conversion fails). I
will update it to match.
Here is the proper link:
Thanks for the feedback.
Matthew A. Nicholson