On Monday, 21 December 2015 at 06:00:45 UTC, Shriramana Sharma
wrote:
I suppose what you mean is, the onus of guaranteeing that
const(char)* refers to a null-terminated string is upon the
person calling the to! function? Yes I understand, and Phobos
documentation does say that using a pointer f
So, the extra confusion of the typeof(iota) Result return goes
away when slicing arrays.
auto a1 = new int[100];
auto t3 = a1.sliced(3,4,5);
pragma(msg,typeof(t3)); //This prints Slice!(3u, int*)
Slice!(3u, int*) t4 = a1.sliced(3,4,5); // and this works ok
Jakob Ovrum wrote:
> Use std.string.fromStringz. to!string assumes that pointers to
> characters are null-terminated strings which is not safe or
> general
I suppose what you mean is, the onus of guaranteeing that const(char)*
refers to a null-terminated string is upon the person calling the to
On Monday, 21 December 2015 at 04:39:23 UTC, drug wrote:
You can use
alias Type = typeof(t0);
Type t1 = 1000.iota.sliced(3, 4, 5);
IIRC Result is the Voldemort type. You can think of it as a
detail of implementation of ndslice that isn't intended to be
used by a ndslice user directly.
ok, we
On Monday, 21 December 2015 at 05:39:32 UTC, Rikki Cattermole
wrote:
size_t strLen = ...;
char* ptr = ...;
string myCString = cast(string)ptr[0 .. strLen];
I can't remember if it will include the null terminator or not,
but if it does just decrease strLen by 1.
Strings from C libraries shoul
On Monday, 21 December 2015 at 05:43:04 UTC, Rikki Cattermole
wrote:
On 21/12/15 6:41 PM, Shriramana Sharma wrote:
Rikki Cattermole wrote:
string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to
append to the
returned string using ~= or such
Rikki Cattermole wrote:
> string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to append to the
returned string using ~= or such? In which case it is not safe, right?
--
Shriramana Sharma, Penguin #395953
On 21/12/15 6:41 PM, Shriramana Sharma wrote:
Rikki Cattermole wrote:
string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to append to the
returned string using ~= or such? In which case it is not safe, right?
Correct, ~= should only be use
On Monday, 21 December 2015 at 05:41:31 UTC, Shriramana Sharma
wrote:
Rikki Cattermole wrote:
string myCString = cast(string)ptr[0 .. strLen];
Thanks but does this require that one doesn't attempt to append
to the returned string using ~= or such? In which case it is
not safe, right?
Grow
On Monday, 21 December 2015 at 05:34:07 UTC, Shriramana Sharma
wrote:
Hello. I have the following code:
import std.stdio, std.conv;
extern(C) const(char) * textAttrN(const (char) * specString,
size_t n);
string textAttr(const(char)[] specString)
{
const(char) * ptr = textAttrN(specString.p
On 21/12/15 6:34 PM, Shriramana Sharma wrote:
Hello. I have the following code:
import std.stdio, std.conv;
extern(C) const(char) * textAttrN(const (char) * specString, size_t n);
string textAttr(const(char)[] specString)
{
const(char) * ptr = textAttrN(specString.ptr, specString.length);
Hello. I have the following code:
import std.stdio, std.conv;
extern(C) const(char) * textAttrN(const (char) * specString, size_t n);
string textAttr(const(char)[] specString)
{
const(char) * ptr = textAttrN(specString.ptr, specString.length);
writeln(ptr);
return to!string(ptr);
}
voi
Basile B. wrote:
> without the parens, 'const' means that the function doesn't
> mutate the state of the object or of the struct it's declared in.
> So it's meaningless for a global function.
Thank you people.
--
Shriramana Sharma, Penguin #395953
On Monday, 21 December 2015 at 02:03:14 UTC, Shriramana Sharma
wrote:
I'm trying to interface to a C function:
extern(C) const char * textAttrN(const char * specString,
size_t n);
and getting the error:
Error: function .textAttrN without 'this' cannot be const
Please advise as to what I'm d
21.12.2015 07:23, Jay Norwood пишет:
import std.stdio;
import std.experimental.ndslice;
void main() {
import std.algorithm.iteration: map;
import std.array: array;
import std.range;
import std.traits;
auto t0 = 1000.iota.sliced(3, 4, 5);
pragma(msg, typeof(t0));
On Monday, 21 December 2015 at 04:20:16 UTC, Jay Norwood wrote:
I pulled down the std.experimental.ndslice examples and am
attempting to build some of the examples and understand the
types being used.
I know don't need all these imports, but it is hard to guess
which ones are needed, and the
import std.stdio;
import std.experimental.ndslice;
void main() {
import std.algorithm.iteration: map;
import std.array: array;
import std.range;
import std.traits;
auto t0 = 1000.iota.sliced(3, 4, 5);
pragma(msg, typeof(t0));
Slice!(3u, Result) t1 = 1000.iota.slic
I pulled down the std.experimental.ndslice examples and am
attempting to build some of the examples and understand the types
being used.
I know don't need all these imports, but it is hard to guess
which ones are needed, and the examples often don't provide them,
which I suspect is a common g
I'm trying to interface to a C function:
extern(C) const char * textAttrN(const char * specString, size_t n);
and getting the error:
Error: function .textAttrN without 'this' cannot be const
Please advise as to what I'm doing wrong?! :-(
--
Shriramana Sharma, Penguin #395953
On Monday, 21 December 2015 at 02:03:14 UTC, Shriramana Sharma
wrote:
I'm trying to interface to a C function:
extern(C) const char * textAttrN(const char * specString,
size_t n);
and getting the error:
Error: function .textAttrN without 'this' cannot be const
Please advise as to what I'm d
Got simpledisplay.d/color.d working by simply adding them to my
project's folder and I'm now playing with it. What I've
accomplished so far:
http://i.imgur.com/aik9Ovj.gif
(some objects from a class to draw circles in their position, and
a simple collision check with screen borders)
I'm pre
On Saturday, 19 December 2015 at 14:16:36 UTC, anonymous wrote:
On 19.12.2015 14:20, Marc Schütz wrote:
As this is going to be passed to a C function, it would need
to be
zero-terminated. `.dup` doesn't do this, he'd have to use
`std.string.toStringz` instead. However, that function returns
a
On Saturday, 19 December 2015 at 17:30:02 UTC, Kagamin wrote:
On Saturday, 19 December 2015 at 13:20:03 UTC, Marc Schütz
wrote:
As this is going to be passed to a C function
No, ODBC API is designed with multilingual capability in mind,
it doesn't rely on null terminated strings heavily: all
On Sunday, 20 December 2015 at 01:17:50 UTC, Basile B. wrote:
On Saturday, 19 December 2015 at 14:16:23 UTC, TheDGuy wrote:
is it possible to set the color of a single pixel with Cairo?
Not like you would do with a classic canvas (2d grid), because
colors are applied with `cairo_fill()` and `
24 matches
Mail list logo