/dpt/ - Daily Programming Thread

What are you working on, Any Forums?
Previous:

Attached: 4d22efecabcfe5869bc5492ab6ea24c4.gif (784x792, 614.48K)

Other urls found in this thread:

youtube.com/watch?v=JPQWQfDhICA
github.com/friendlyanon/cmake-init
youtu.be/XS2JddPq7GQ?t=296
twitter.com/NSFWRedditGif

erlang

I have to make a function in C++ that takes in various types: strings, ints, void pointers and converts them all to strings. Whats the best way to implement this? Template classes or function overloading? I have no practice with either.

Attached: 00112E44-747C-4AA7-B3AC-2CAD91B89703.jpg (1000x1459, 935.67K)

How do you plan to convert them to strings? I'd recommend templates if it can be generic.

I don't have the code in front of me, but I believe I have access to a map that can help with conversion. Each int, pointer, etc is mapped to a syscall param. I'm implementing the strace for context

Attached: 4833D5A3-79EA-46F2-9625-7E285FA182D1.jpg (982x2000, 332.75K)

use auto and a stringstream or something

here's a start:

string make_string(auto inp)
{
stringstream ss;
ss

Started making a new website with React. Their upcoming beta guide does everything differently than current one and it's jarring.

>webfags rewrite their stack again
lol

...

no, you should use generics

This is another neural network set, they learned how to jump really high

Attached: evolving6.gif (620x620, 2.55M)

yeah and he shouldn't have me do his homwork for him probably

use a template and add a requires clause to it where necessary

and probably use runtime type information to tell what type you are working with, or perhaps if-constexpr to do it at compile time

"best" is relative to how you want to interface with it, how universal it's meant to be, how generic it's meant to be, what the Strings should look like for different types

>I have no practice with either.

well then it's time to pull your skirt up and get to work

62 | layout layouts[] = {
| ^
63 | [SE_UNIFORM_LAYOUT_NONE] = {0},
| -
| {{{0}}}


>{{{0}}}
what did gcc mean by this

fuck yes, DLLs

youtube.com/watch?v=JPQWQfDhICA

hmm I wonder if R*st can even build a DLL?

oh fuckin' nice, the structure of a DLL

Attached: DLL file structure.png (2000x1072, 1.02M)

got dam this is really interesting

also it's Jesus day

are there better ways to profile than compiling with -pg and running gprof?

gprof tells me my solve function and floodfill are taking the most time, but it is not saying what part of the functions is taking most of the time.
not to mention my solve function calls functions that do not appear in the gprof output at all

also the whole program takes 1m55s to terminate, but the gprof output only accounts for (I think?) 57 of those seconds.

I tried tcov but could not get it to work/compile (it might be deprecated or only supported for fortran77)

Attached: profiling.png (1911x1059, 264.51K)

best advice I know of is to watch that CppCon video from the guy at Google who worked on test frameworks and benchmarking there.

Reminding anons to use github.com/friendlyanon/cmake-init when creating new C++ and C projects!

fuck off

auto p = std::make_unique(5);
std::vector v{std::move(p)};

Why does this compilen"t?

maybe it can't cta(r)d the template argument
try = {std::move(p)} ?

What is the right way to create android apps without using Java?
Can you create whole apps using NDK?
Should I just create the app in JS?
>why not Java?
I want a langue that I can easily compile my existing code into or just call the android libraries using an FFI, writing something that compiles my code to Java seems like a daunting task.

Which vector constructor do you expect that would call?

> Template classes or function overloading?
It should be both. For the types that you can generalize, group them as a templates (e.g: For every pointer type, returning its address in hex; for every arithmetic type, return the number). You need concepts or std::enable_if to achieve that. For the types that can't be grouped in any way, write seperate overloads for them.

It's different kind of error, you can't assign pointer to vector directly. Plus I'm trying to do it in member initializer list, or whatever that : init syntax is called.

Huh, does it really lack T&& constructor? My disappointment is immense and my day is ruined.

he probablyexpects initializer list

Don't know why you think it would. Use the fill constructor with 1 element.

a silly solution to a silly problem
template
auto make_vector( std::array&& a )
-> std::vector
{
return { std::make_move_iterator(std::begin(a)), std::make_move_iterator(std::end(a)) };
}

template
auto make_vector( T&& ... t )
{
return make_vector( std::to_array({ std::forward(t)... }) );
}

int main()
{
auto p = std::make_unique(5);
auto v = make_vector(std::move(p));
}

hmm
what happens if you do:
std::vector v{ {std::move(p)} };
?

If you are trying to create std::vector
std::vector v{*std::move(p)};


If you are trying to create std::vector
std::vector v;
v.push_back(std::move(p));


A unique_ptr has no copy constructor. And std::vector{some_val} tries to copy some_val into the vector, that's why it fails.

is that a memory leak? moving a dynamically allocated int into a vector like that?

no its an int copy

i mean if it wasnt a unique_ptr but was just a regularly temporary pointer it would be i guess
{*(int*)(malloc(sizeof(int)))}
unless you mean the unique ptr

why is cnile so fucking garbage?
printf("0x%lx\n", (uint64_t)0xffffffff

OHHH you're right, std::move() creates a unique_ptr instance of some kind right? So it when it gets copied and goes out of scope it deletes the original?

He doesn't need move there, it would work the same with
std::vector v{*p};

and it doesn't leak, move only casts pointer to &&, it will free the memory all the same unless you move assign it to another unique_ptr.

it depends which you mean, the int version is fine because it just copies the int (in fact the move does nothing) the other version is fine because you don't actually lose track of the resource to be cleaned up

PE to shellcode generator

Decided to switch over to some back-to-basics on lvalue/rvalue/r-ref

youtu.be/XS2JddPq7GQ?t=296