« first day (3347 days earlier)      last day (1586 days later) » 

8:29 AM
Hello.
 
hello
 
I'm having trouble getting a class template to compile
compiler gives a bunch of "undefined references".
I don't get what's meant by templates must be in header file. Does that mean the implementation isn't in a cpp file and everything is in hpp?
 
Kinda. The file extension doesn't matter, templates are made "on demand" which you can think of as in lining. This is unlike regular functions which are "built" when they are defined. This is because templates are specific to a type so the compiler needs to know what to fill in.
If you want to separate template implementation and declaration, there are a few tricks, one of which is to force the compiler to build the template for the specific types you plan on using.
 
user7659542
Hello
 
8:54 AM
See also open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1152r0.html, although it is not know if the proposal will pass, it does explain the cases where volatile is useful.
 
 
1 hour later…
10:13 AM
Here's the thing. I've got a class, separated into header (hpp) and implementation (cpp). Now I'd like to template it. What's the best approach?
@Mikhail
 
there's multiple common approaches.
Move the implementation into the .hpp
Move the implementation into a *.impl.hpp or so and include that into the existing *.hpp
Forward declare all the template instantiations you expect the code to use, this limits the types that you can use to instantiate
 
 
2 hours later…
12:43 PM
Morning
 
@LoïcFaure-Lacroix Data used to be expensive here too. But for some reasons, the price has come down quite a bit in the past few months.
So for $350 a year (the previous plan I talked about), I get 180GB.
Which is more than enough because I have unlimited data on high speed connection at home.
@Morwenn Morning.
 

« first day (3347 days earlier)      last day (1586 days later) »