On 3/31/11 2:32 AM, Aleksandar Ružičić wrote:
Is it possible to use opDispatch as generic getter and setter at the
same time? Something like __get() and __set() in PHP..
this is what I've tried: https://gist.github.com/895571
and I get Error: template instance opDispatch!(bar) matches more
On Thu, Mar 31, 2011 at 8:52 AM, Jacob Carlborg d...@me.com wrote:
Or, I think this will work as well:
@property ref ConfigSection opDispatch(string sectionName, Args ...)(Args
args) if (Args.length == 0)
{
// getter
}
@property ref ConfigSection opDispatch(string sectionName, Args
On Thu, 31 Mar 2011 02:52:15 -0400, Jacob Carlborg d...@me.com wrote:
On 3/31/11 2:32 AM, Aleksandar Ružičić wrote:
Is it possible to use opDispatch as generic getter and setter at the
same time? Something like __get() and __set() in PHP..
this is what I've tried:
On Wed, 30 Mar 2011 21:50:43 -0400, spir denis.s...@gmail.com wrote:
On 03/31/2011 02:40 AM, Aleksandar Ružičić wrote:
2011/3/31 Aleksandar Ružičićruzicic.aleksan...@gmail.com:
Or maybe there is some other way to achive what I want and I'm not
aware of it? :-)
I know I could have used
I should have been more clear, but my actual question is how do I
access the parameters of a template parameter. My example works, but
I wanted to know if there is a different and perhaps a better of doing
it.
In your example it would look something like this:
struct SomeContainer(T, int x, int
On Thu, Mar 31, 2011 at 1:30 PM, Steven Schveighoffer
schvei...@yahoo.com wrote:
or you can change the template parameters in the opDispatch setter:
@property ref ConfigSection opDispatch(string sectionName, T : string)(T
arg)
-Steve
Thanks, that's much more readable I now have these
There are situations where you have to call a C dispatch function, and pass it
a void* and a selector. The selector lets you choose what the C function does,
for example an enum constant selector `kGetProductName` could ask the C
function to fill a null-terminated string at the location of the
On Thu, 31 Mar 2011 14:02:43 -0400, Kagamin s...@here.lot wrote:
Steven Schveighoffer Wrote:
The issue is that you can't have two templates with the same exact
template parameters, even if they have different function parameters.
This is because the compiler first instantiates the template,
Why not:
string getNameOld()
{
static char[256] name;
cDispatch(name.ptr, kGetProductName);
return to!string(name.ptr);
}
On 3/31/11, Jesse Phillips jessekphillip...@gmail.com wrote:
Why not:
string getNameOld()
{
static char[256] name;
cDispatch(name.ptr, kGetProductName);
return to!string(name.ptr);
}
Nice catch! But see my second reply. If a null terminator is missing
and we know we're
Andrej Mitrovic Wrote:
Actually, this still suffers from the problem when the returned char*
doesn't have a null terminator. It really sucks when C code does that,
and I've just experienced that. There is a solution though:
Since we can detect the length of the D array passed into
Oh I'm not trying to get this into Phobos, I just needed the function
so I wrote it and sharing it here. Maybe it should throw. For my
purposes I don't need it to throw. :)
12 matches
Mail list logo