sqlite3 library which can read class instances (not structs)?

Andy Valencia dont at spam.me
Mon Mar 10 21:31:02 UTC 2025


On Thursday, 6 March 2025 at 23:45:01 UTC, Andy Valencia wrote:
> Is there a sqlite3 interface library which can correctly read 
> into instances?  sqlite3-d will let me compile with a class, 
> but it segv's when run.  ddbc seems to support only structs, 
> and I can use it to punch in one value at a time out of each 
> row result.  But that feels clunky, and I'd avoid it if I could.

Dug deeper into sqlite3-d, and see the problem.  Is there a 
static-if which can tell if a type is of a struct, as opposed to 
a class?  I see ones for a final class, or an abstract one.  But 
nothing jumps out to let me know the correct way in a template 
method to allocate a struct instance as distinct from a class.

Something like:

> static if (__traits(isClass, T)) {
>    ...
> } else if (__traits(isStruct, T)) {
>    ...
> } else {
>    (failure)
> }

Thanks,
Andy



More information about the Digitalmars-d-learn mailing list