« first day (383 days earlier)      last day (2476 days later) » 

7:53 AM
Hi
can u help me with this?
I declare a string in c++ like this char * a = "abcdefg"
i want to get the address of the third element
memory address
 
nwp
8:06 AM
@TheArtist wrong room go here
 
@TheArtist char * p = a + 3;
7 messages moved from Lounge<C++>
 
nwp
it should be a+2 because a+0 is the first element
 
is it correct to declare this char * a = "hello"
 
nwp
@TheArtist not really, and it doesn't compile in modern C++
 
what is the correct way?
 
nwp
8:09 AM
std::string a = "hello";
 
const char * a = "hello";   // if the ++ in C++ disturbs you
 
If I name classes starting with uppercase and functions starting with lowercase, how do I name functor classes?
 
nwp
by functor classes you mean classes that have an operator()?
 
yep
 
You name functor classes according to your own naming convention.
 
8:13 AM
How do you do it?
 
I name everything lowercase.
 
Okay
 
But that is highly unusual in practice.
Basically everybody does uppercase for classes.
 
Yeah
I'll figure out something
 
nwp
I use capital letters for types and lowercase for the rest which is fairly common. But there aren't really any official rules to back that up.
 
8:17 AM
@nwp Capital letters for types sounds useful.
 
nwp
It sucks that built-in types and the standard library don't follow that convention.
want me to move that to the lounge?
 
lol yes
 
nwp
2 messages moved to Lounge<C++>
 
I just noticed a functor is not even what I want..
Ah, but then I can't use polymorphism..
But DijkstraFindShortestPath()(start_node, end_node) doesn't look good
 
nwp
@kim366 you can do auto dijkstraFindShortestPath(auto &&start_node, auto &&end_node){return DijkstraFindShortestPath{}(start_node, end_node);}
that may have been too many autos, but you can fill in the proper types
and that would make it consistent with how to use functions and types
 
8:27 AM
#define DIKESTAR DijkstraFindShortestPath() /* problem solved ;) */
 
8:59 AM
lol, I might do that. Or just declare an object beforehand
 
 
2 hours later…
10:57 AM
To cast int32 to int16 I need to do:
int a = 15;
int16_t b = static_cast<int16_t>(a);

Can I cast int16 to int32 like this?
int c = b;
 
11:29 AM
Hey I'm trying to merge/update(if python) 2 json files in to 1 but when I do it I sadly convert all empty arrays in to NULL object which is causing a massive head ache - was using this sollution > github.com/nlohmann/json/issues/252
json merge(const json &a, const json &b)
{
    json result = a.flatten();
    json tmp = b.flatten();

    for (json::iterator it = tmp.begin(); it != tmp.end(); ++it)
    {
        result[it.key()] = it.value();
    }

    return result.unflatten();
}
Can any1 suggest how I can work around it so that my empty arrays wont turn in to nulls? :- (
 
11:48 AM
ok removing flatten/unflatten fixed the issue
 
@Dariusz I wouldn't use JSON. I'm using binary, that's big "compression".
 
what you mean?
I'm suing json to save to file my data is that not the well "best way to do it" ?
 
@Dariusz Assume you have really big JSON file, for example 100MB, and if you used binary it would have only 10MB or something like that. If you want to stay with JSON, I would go for msgpack: msgpack.org
 
uuuuuuuu
interesting
but binary is not user-readable is it?
msgpack looks interesting thank you!
 
@Dariusz No, binary isn't user-readable. You have to read each byte and convert it to the data you want. (serialization and deserialization)
 
11:56 AM
I see, is it the same with msgpack ?
that its binary
 
@Dariusz Yeah, but it's more like a mix: binary + JSON. You save lot of file size.
 
I see thanks!
I guess I could instad of doing
json>saveToFile do
json>convertTo msgPack>saveToFile
 
@Dariusz I've written my own binary writer/reader: header file - pastebin.com/aCj817Ue and cpp - pastebin.com/zd65F7cA But I haven't updated it for months, so I wouldn't use it. (It needs a review)
 
12:17 PM
woah nice thanks!
 
nwp
12:48 PM
@SzymonMarczak Yes, except it's not a cast. It's an implicit conversion.
 
1:09 PM
int x=capitalize(97);
printf("%c\n", x);
for(int i=97; i<=122; i++){
    int upper = capitalize(i);
    printf('%c\n',upper);
}
why is this for loop not working?
 
@AmitSingh ' vs "
 
Oh thanks. Its working now. That was a silly mistake.
 
@AmitSingh I am pretty sure you got a warning of sort.
 
1:48 PM
7 messages moved from Lounge<C++>
 
 
2 hours later…
nwp
4:09 PM
2 messages moved to Trash can
 
4:47 PM
imm asking a basic question
i know a little c++
should I learn its ins and outs
in 2017
 
nwp
@Tobiq The only good answer is it depends. If you want to become an astronaut it's probably not a good use of your time.
 
 
3 hours later…
7:24 PM
hey, I use cLion and I started to think about some "helpfull" comments, when ever I hold ctrl and hover over object/function I get some information. Would any1 know what I need to type/where to add my own comments to these "information boxes" ? I tried some different stuf with / * // etc etc but so far no luck...
 
 
1 hour later…
8:31 PM
@Dariusz I don't have CLion, but there's a simple way you can check
Find a function which can give you such a helpful comment, and use a "go to declaration" functionality in CLion
 
 
2 hours later…
10:06 PM
@milleniumbug good idea, will try it see if I can see it! :- ) thanks
no luck
bummer
ee I think I got it, its ctrl+Q and the n u just write withj /*! text *! pretty cool lol
should we declare it in header or CPP ?
 
10:36 PM
where the declaration is
 
10:58 PM
nice thanks!
was reading over doxygen as it looks that thats the system
how can I do this ?
* @param vector<vector<string>>
this would produce only this vector>
 

« first day (383 days earlier)      last day (2476 days later) »