The [std.net.curl](https://dlang.org/phobos/std_net_curl.html)
module provides these functions:
```d
T[] post(T = char, PostUnit)(const(char)[] url, const(PostUnit)[]
postData, HTTP conn = HTTP())
T[] post(T = char)(const(char)[] url, string[string] postDict,
HTTP conn = HTTP())
```
How can
I have this code:
```
import std.array, std.exception, std.stdio;
mixin template RealizeException() {
this(string msg, string file = __FILE__, size_t line =
__LINE__) {
super(msg, file, line);
}
}
class WrongUsage : Exception {
mixin RealizeException;
this(string[]
On Wednesday, 9 February 2022 at 10:01:15 UTC, Anonymouse wrote:
On Wednesday, 9 February 2022 at 08:12:52 UTC, Vindex wrote:
[...]
I would do this.
```
import std;
alias Record = Tuple!(string, string, string);
static immutable string[][] table = () {
string[][] table;
string
Will the loop (foreach) run at compile time? How can I make it
work at compile time?
```
import std.csv, std.stdio;
alias Record = Tuple!(string, string, string);
immutable string[][] table;
shared static this() {
string csvText = import("file.csv");
foreach (record;
On Thursday, 14 October 2021 at 15:29:13 UTC, MoonlightSentinel
wrote:
On Wednesday, 13 October 2021 at 20:02:05 UTC, Vindex wrote:
Is there a decomposition for tuples and other data structures?
No, but you can emulate it, e.g. by using AliasSeq:
```d
import std.meta : AliasSeq;
import
Is there a decomposition for tuples and other data structures?
For example,
```
auto t = tuple(1, "2");
auto (x, y) = t; // or auto (x, y) = t.expand;
```
On Sunday, 18 July 2021 at 17:31:24 UTC, Adam D Ruppe wrote:
On Sunday, 18 July 2021 at 17:28:07 UTC, Vindex wrote:
Error: file "thing.json" cannot be found or not in a path
specified with -J
You need to specify the path where it is found with the -J
switch to the compiler. Like `ldc2 -J.
On Sunday, 18 July 2021 at 17:31:24 UTC, Adam D Ruppe wrote:
On Sunday, 18 July 2021 at 17:28:07 UTC, Vindex wrote:
Error: file "thing.json" cannot be found or not in a path
specified with -J
You need to specify the path where it is found with the -J
switch to the compiler. Like `ldc2 -J.
One of my library modules (for example, libmylib) has the line
`immutable string jsonText = import("thing.json")`
When I try to build a program with this (already installed)
library I see error
```
ldc2 source/main.d -ofmyprogram -L-l:libmylib.so.0
Error: file "thing.json" cannot be found
Thanks everyone!
The solution that works for me now looks like this:
template ndim(T) {
static if (std.traits.isArray!T) {
static if (is(typeof(T.init[0]))) {
alias SubArrayType = typeof(T.init[0]);
enum ndim = ndim!SubArrayType + 1;
}
else
size_t ndim(A)(A arr) {
return std.algorithm.count(typeid(A).to!string, '[');
}
Is there a way to find out the number of dimensions in an array
at compile time?
Thank you!
For other sites, the first solution somehow worked (I did it
following the example from the documentation).
Header requests to Wikipedia give 405 error for some reason.
```
import std.stdio, std.net.curl;
void main() {
auto url = "https://en.wikipedia.org/wiki/Passenger_pigeon;;
auto http = HTTP();
options(url, http);
writeln(http.responseHeaders);
}
```
Output:
```
On Sunday, 8 April 2018 at 06:51:22 UTC, ikod wrote:
On Saturday, 7 April 2018 at 23:54:21 UTC, Vindex wrote:
On Saturday, 7 April 2018 at 15:58:14 UTC, Seb wrote:
On Saturday, 7 April 2018 at 13:02:39 UTC, Vindex wrote:
There is an error on some sites when using HTTP-methods
On Saturday, 7 April 2018 at 15:58:14 UTC, Seb wrote:
On Saturday, 7 April 2018 at 13:02:39 UTC, Vindex wrote:
There is an error on some sites when using HTTP-methods
(std.net.curl.get, std.net.curl.post):
std.encoding.EncodingException@std/encoding.d(2505):
Unrecognized Encoding: utf8
Is
There is an error on some sites when using HTTP-methods
(std.net.curl.get, std.net.curl.post):
std.encoding.EncodingException@std/encoding.d(2505): Unrecognized
Encoding: utf8
Is there a beautiful way around it?
For the GET-method I use the download() and readText(). But for
the POST-method I
On Monday, 19 March 2018 at 14:31:05 UTC, Adam D. Ruppe wrote:
On Monday, 19 March 2018 at 14:07:52 UTC, Vindex wrote:
dmd main.d -L-L. -L-l:mod.a
It still needs to know where to find the import file to get D
information like names and types out of it that aren't in the
lib (well they sorta
'main.d':
import pack.mod;
void main() {
fn("Hello");
}
'mod.d':
module pack.mod;
void fn(string s) {
import std.stdio;
writeln("Hello");
}
Both files are in the same directory.
So all is well:
dmd main.d mod.d
So all is bad:
dmd mod.d -lib
dmd main.d -L-L. -L-l:mod.a
main.d(1):
18 matches
Mail list logo