|
Boost : |
From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-06-08 10:48:38
Explanation from Jaakko Järvi, forwarded by Gary.
-----Original Message-----
From: Jaakko Järvi [mailto:jaakko.jarvi_at_[hidden]]
Sent: Thursday, June 07, 2001 11:53 PM
To: gary.powell_at_[hidden]
Subject: nil / const_nil
Hi,
There was something wrong with our mail system and
I'm 99% sure that I read an email with a question:
Why does LL have both nil and const_nil ?
Anyway, here's an explanation, if it was forwarded by you, I'm sure you
can pass it on:
(This seems weird, was I dreaming, am I loosing it... )
On internal calls within LL we usually take arguments as
template<class T>
void foo(T& t);
We also pass nil objects to function templates with such prototypes.
We have been using two ways of doing this:
1. A nil variable in anonymous namespace
2. a function returning a const temporary nil object:
const nil const_nil() { return nil(); }
Now foo(const_nil()) deduces to
void foo(const nil& t);
and the call is ok.
If the temporary would be non-const, it would deduce to:
void foo(nil& t) and would result in an attempt to bind a non-const
reference to a
temporary.
Anyway, using the const_nil function caused a performance hit on some
gcc version,
and we went back to 1 (const_nil() is currently a macro that expands to
constant_nil,
which is a variable in the anonymous namespace.
Jaakko
-- Jaakko Järvi / Turku Centre for Computer Science, Finland
-- jaakko.jarvi_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk