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. :)
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
> `fr
On 3/31/11, Jesse Phillips 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 operating on a D a
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
`fromStringz`, we can do the job of to!
Why not:
string getNameOld()
{
static char[256] name;
cDispatch(name.ptr, kGetProductName);
return to!string(name.ptr);
}
On Thu, 31 Mar 2011 14:02:43 -0400, Kagamin 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, then calls
the
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 v
On 03/30/2011 04:32 PM, Caligo wrote:
> I have a struct that looks something like this:
>
> struct Box(T, size_t width, size_t height){
>
> alias width width_;
> alias height height_;
>
> //do something with a Box of different size
>void Fun( B )(B b){
> // using width and height of b
>
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, then calls
> the function.
If two template instances have
Kai Meyer Wrote:
> On 03/30/2011 08:25 AM, Kagamin wrote:
> > Kai Meyer Wrote:
> >
> >> do all the checking before hand. Arrays are a good example. When not in
> >> -release mode, array boundaries are checked upon every access to the
> >> array, and an exception is thrown if access goes out of bou
On Thu, Mar 31, 2011 at 1:30 PM, Steven Schveighoffer
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 templates:
// g
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 Wed, 30 Mar 2011 21:50:43 -0400, spir wrote:
On 03/31/2011 02:40 AM, Aleksandar Ružičić wrote:
2011/3/31 Aleksandar Ružičić:
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 opIndex and opIndexAssign but I really want
config.s
On Thu, 31 Mar 2011 02:52:15 -0400, Jacob Carlborg 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: https://gist.github.com/895571
and I ge
On Thu, Mar 31, 2011 at 8:52 AM, Jacob Carlborg 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 ...)(
15 matches
Mail list logo