Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C++ templates

Name: Anonymous 2015-04-25 6:26

Meanwhile if you can use templates then you can define a function like this:
template<typename T>
__attribute__((malloc)) static inline T * allocate(size_t count) {
return reinterpret_cast<T*>(malloc(count * sizeof(T)));
}
Now you can't mess it up, the compiler does the work for you.
http://genesisdaw.org/post/progress-so-far.html

Name: Anonymous 2015-04-25 7:23

http://genesisdaw.org/post/progress-so-far.html
So I wanted templates from C++. And atomics from C++11. But that's about it. Other than that, I want to code like I'm in C. The beauty of C-style coding is that the control flow is so simple, it's impossible to not know what code is doing. Contrast that with fancy C++ stuff and you never know what's going to happen or what each line of code is going to do.

I figured out how to have my cake and eat it too. I discovered that you can compile with g++ and link with gcc, like so:

g++ -nodefaultlibs -fno-exceptions -fno-rtti -std=c++11 -c main.cpp -o main.o
gcc -o main main.o

As long as you don't use anything from the C++ standard library, you end up with working code that was compiled with the C++ compiler and does not depend on libstdc++.

Name: Anonymous 2015-04-25 9:26

>>2
I want to code
This board is not for the likes of you, coder.

Name: Anonymous 2015-04-25 12:20

>>3
He's just copying what was posted on the site he linked, dummy. However, that said, >>1,2-san doesn't know how to multi-line quote.

Ignoring that, and looking at the site, I found this gem:

At this point I felt crazy for even considering Rust. I had accomplished more in 4 days what took me 16 days in Rust. But more importantly, my abstractions were holding up.

Name: Anonymous 2015-04-25 12:32

>>4
The only thing he's saying is that it's harder to program in a language you haven't learned yet than in a language you've know for a long time. A "gem" my ass.

Name: Anonymous 2015-04-25 13:46

genes is da w

It carries out and is w.

Don't change these.
Name: Email:
Entire Thread Thread List