« first day (667 days earlier)      last day (2186 days later) » 
05:00 - 20:0020:00 - 00:00

5:28 AM
@ledonter it's correct that it is not working. Inside of the class, but not inside member functions, the class is deemed incomplete and you cannot ODR use it.
for what is ODR usage, you can read this answer
 
5:55 AM
is there any machine learning software kit for C++? I was actually thinking about machine learning for some time, but couldn't find any books or thorough guides on how to do it
 
6:14 AM
tensor flow is written in C++, has several kinds of bindings
 
I just thought may be I could train it to recognize some redundant C++ code or improve it in some way
 
Sounds pretty ambitious
 
I thought I could combine clang's tree representation and clang-format to kind of combine visuals and the logic
I know it's gonna be extremely hard given complexity of the language
 
6:29 AM
Its also flawed conceptually in the sense that it is possible to completely optimize a code and achieve the best possible performance. Its not clear what your test and training data would be.
 
yeah, I have no idea either. At the moment I'm not even sure what ML is. But I believe that applying at least some ML to my code won't hurt, if done correctly
I believe the first, more or less clear and easy thing is to train it to replace raw loops with fitting standard library algorithm
 
Why do you need to train anything? Can't you just substitute? Also that specific transformation is part of clang's "modernize" family.
 
6:55 AM
@Mikhail sometimes people do some redundant jumping around. I thought I could apply ML on control flow graph and let it decide if it could make the traversing linear and adjust the code
 
I am working with a C API which accepts a char* and fills it up with a string. The length of the string is known in runtime. As of now, I do char *str = new char[len]; and then pass it on to the API function.
What's the correct way to do it?
 
@Yashas if you have C++17 available, and know the length of string in advance, use resize() on std::string and pass .data() into the API
it would be great if the api would return the pointer to the end position
 
@Incomputable what does C++17 allow here?
 
@Yashas previously .data() only produced const char*, but with C++17 it has non const overload too
 
resize and data() existed prior to C++17 I think
 
7:06 AM
if you're not scared of forgetting to delete it or exceptions, you could just use new. But I believe it might break later on, especially when somebody else messes with your code
 
nwp
7:32 AM
@Incomputable If you don't have C++17 you pass &string[0] instead. /cc@Yashas
 
@nwp forgot about that. I usually use std::addressof(*container.begin()); .I guess I'm too paranoid
 
nwp
::std::addressof for maximum paranoia.
 
@nwp isn't std a reserved name?
IIRC they also reserved std[0-9]
 
nwp
@Incomputable You can't mess with the global one, but you can make your own local one.
 
well, then life is hard, if you're C++ programmer
I wonder how many pages C++20 standard will have. I believe around 2k, if ranges will be on board
 
nwp
7:38 AM
Metaclasses give some hope that it will become shorter, but the size reduction is probably small and will be eaten by other stuff.
 
I believe executors extension is gonna be the fat boy
on ACCU 2018, it was mentioned that they will probably arrive in C++23
 
8:05 AM
What are the disadvantages of using std::fstream over std::ifstream when I'm going to only read?
 
@Yashas I guess none, except being less explicit.
I believe that any overhead that std::fstream adds over std::ifstream is gonna be neglected by I/O performance
@funkadelic, you can't chat without enough rep, I believe it was 10 rep, or 40
 
nwp
20
 
I was taking some vitamins regularly for 3-4 months, and it seems like cancellation effects are really strong
 
nwp
> Explicit write access: Even when this room is read-only or their reputation is too low, these users will be able to talk in this room.
/me adds funkadelic to the list
And all I get is some red text: "Users must have at least 20 reputation to talk"
 
I forgot that italic nickname corresponds to room-owner
 
 
1 hour later…
9:28 AM
my consideration to be able to do an operation or an undo. coliru.stacked-crooked.com/a/1159566a4266a382
 
9:42 AM
or maybe two seperate stacks, one for operations and one for the undo's.
 
 
2 hours later…
11:48 AM
139
Q: Why does flowing off the end of a non-void function without returning a value not produce a compiler error?

CatskulEver since I realized many years ago, that this doesn't produce an error by default, (in gcc at least) I've always wondered why? I understand that you can issue compiler flags to produce a warning, but shouldn't it always be an error? Why does it make sense for a non-void function not returning ...

 
 
2 hours later…
Ron
2:06 PM
How do you decide what is rule and what is dogma? I thought committee guidelines were chiseled in stone and then I saw the decline of the much drummed array_view for example.
I often see StackOverflow prevailing opinions at odds with some of the committee and cppcon receipts.
Long story short, how do you people find the balance? Especially when wanting to move to architecture and interface design.
 
find the reason why the rule exists
3
then decide for yourself if it is a valid reason
 
Ron
Plain and simple.
Appreciate it.
 
99.9% of dogma is cargo cult of a decision that made sense in the past but doesn't make sense now
 
which is also why it's important to reevaluate rules from time to time
 
2:25 PM
in Agile you'd call this a "Retrospective"
 
regarding to my last post chat.stackoverflow.com/transcript/message/42457931#42457931 here my "new" approach coliru.stacked-crooked.com/a/00ec4b778a007212 ....not compilable just to show what its about.
 
 
1 hour later…
3:30 PM
Halp! :- )
I wrote a header only class that I use to keep data in, string/int/map/vec/etc/etc
and now I need to duplicate it
but oh boy I have no idea how!
as far as I know I need 2 functions
myData(const myData&data) {}
myData&operator=(const myData&Data){}
 
3:44 PM
@Mgetz I wonder if this may not be a circular definition in disguise. As in, we only start to think of it as dogma when we see people following it, but we've realized (or at least come to believe) that it's basically obsolete.
 
i saw this phrase in a anser : "With any application, if the memory is frequently being used it's advisable to pre-allocate it and release when not required."
what does he mean by pre-allocatte ?
 
array[400]
 
that is pre allocating?
 
@jeyejow Uncertain. A few possibilities include using vector.reserve and vector.resize (or equivalent for other container types).
 
@JerryCoffin but what does pre-allocating means? how is it diferent from allocating?
dont i need to know the size i need to pre allocate?
 
3:48 PM
I take pre-allocating hapens at compile time and allocating at runtime ?
you pre-allocate when you know the size before you run the app
and allocate dynamically when u run the app
 
@jeyejow Typically it means something on the order of computing the largest size you're going to need (or likely to need) and allocating that much up-front, rather than resizing as you go along.
 
and why is that better then normal allocation?
 
allocation of memory is long process. If you do allocate(100) it will alocate space for 100 items in 1 call. But if you allocate it per item then you do 100 calls for each allocation, its 100X more work
 
ohh
yes that makes sence
 
dear god since when I know stuff o.O usually I'm the one running headless without idea of wtf is goin on O_o
 
3:52 PM
thanks!
 
you can do
std::vector<int> someVec(100), that will initialize vector with 100 items allocation
just keep in mind
there is difference between (100) and [100] as well as you can't put in more than 100 items in it
pre-allocated vectors/objects are fixed in size.
 
what is the diference between doing (100) and [100] ?
 
no idea, I just know there is :D
 
std::vector<int> someVec[100] are 100 vectors of ints
std::vector<int> someVec(100) is a single vector initialized with 100 ints
 
oh
 
3:55 PM
how does that work?
 
therre u go, I always forget it hehe
someVec[100] =
someVec[50].emplace_back(10)
2d vector I take?
 
isnt it the same thing?
 
also if you do std::vector<int> csa(9999999999); < that will take like 35gb of rame. On spot so the memory is taken/reserved
well no
 
() and []
 
a vector is just another object
you can make static array of them
I would not recommend doing so
 
3:57 PM
someVector[10]
someVector[1] = std::vector<int>
someVector[2] = std::vector<int>
someVector[3] = std::vector<int>
etc etc
someVector(10)
someVector[1] = int
someVector[2] = int
is that right?
 
ohhh ok i get it
so () takes less memory space
but we lose the methods
 
@jeyejow no that's not the point
 
no? what is it?
 
() pre-allocate memory for x items
[] pre-allocate memory for x items of vectors
I really though the above info was clear o.o
 
but isnt the size of a int shorter then the size of a std::vector<int> ?
 
4:01 PM
its a vector of vectors
{{1,2,3},{1,2,3},{1,2,3}}
 
though stay away from static arrays, they are a cludge in various ways, std::array is much better for that
 
why stay away from static arrays?
 
I gotta say the entire bussiness with [] and () causes more headache that helps lol
 
because when passed to a function they decay to a pointer
 
but array is a pointer, no?
 
4:03 PM
any code that uses sizeof to figure out the size of it will fail when you move it into a function
std::array has a api that looks a lot more like the rest of the container classes
it's a case of know that they exists and avoid using them if possible
 
@ratchetfreak i have a question that isnt really related to all this but i just want to make sure, if i do for example int arr[5], does arr[5] point to null? because then i can see when a array ends, just cycle trhu it and see when it points to null?
 
no looking past the end of an array is undefined behavior
 
usually ur pc explodes
 
but static array dont change, why would doing sizeof it give you diferent resutls?
then how can i know the size of an array without using anny functions?
 
4:10 PM
int main()
{
    {
        int i1[500];
        foo(i1);
        std::cout << sizeof(i1) << std::endl;
    }
    {
        int i1[200];
        foo(i1);
        std::cout << sizeof(i1) << std::endl;
    }
}
you can do that in main?
open { } like that?
wich code will run there?
i never saw that before
 
yeah, its like function, anything at the end of the } will get erased like normal function
 
@jeyejow yeah it's usefull to limit scopes of local variables
 
@Dariusz i didnt knew that :O thats awsome
 
note I reused i1 as an identifier
 
yes yes i see, ok im learning alot new things todday
@ratchetfreak same results but less lines of code?
is that better?
 
4:14 PM
check the output
the first one printed out 8, 2000, 8, 800
the second 500, 500, 200, 200
the second is much more intuitive
 
ohh , it gives size of int and then in main the size of all ints in the array
 
Hi I'm having a
 
size of the int pointer actually
 
so the pointer to a int has 8 bytes?
 
on a 64 bit architecture, yes
 
4:17 PM
Hi I'm having a weird problem in trying to use the <random> header. When I do that I get the error : /usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options
 
64/8 = 8
 
but on a 64 architecure doesnt a int as also 8 byets?
 
I added this to my makefile: CFLAGS = -W -Wall -g -std=gnu++11
 
what is the diference between size of int pointer and size of int?
 
But it doesn't seem to change anything
 
4:17 PM
no int is 4 bytes
 
4.8.2 is fairly old btw
 
nwp
@JohnMeighan Try CXXFLAGS.
 
@ratchetfreak i thougt only on 32 it was 4 bytes
so it has offset?
 
It's my university system so I don't know if I can update the version
@nwp Would that change anything?
 
nwp
@JohnMeighan That's the variable typically used for C++ flags. Yours is for C.
But it probably doesn't change anything because you didn't use it in the rules.
 
4:19 PM
Is there any disadvantage of opening a stream for both read and write but only writing to it compared to opening the stream for just write?
 
@nwp Oh that worked I thought that was just the name of my marker in the Makefile
 
@Yashas i think it has to process more flags the os
 
(removed because different question)
 
@milleniumbug what was the answer to the original question?
 
actually, I misread it as "opening for r/w but only reading" the first time
nvm me
 
4:26 PM
any of you familiar with something like:
error : C++ requires a type specifier for all declarations
1>          __android_log_print
 
nwp
It looks weird, but my guess is it was caused by a missing #include which makes the compiler try to interpret a type as a variable name and getting very confused by it.
 
there's an include in a .cpp file
#include<android/log.h>
should I just move this to an header?
 
nwp
Try to find the line that caused the error. The first word is probably supposed to be a type. Try to find where that type is declared.
 
I'm getting cannot open android/log.h
it's a macro
 
nwp
@user8469759 If it fails to include the header it makes a lot of sense that it doesn't know what __android_log_print is anymore.
 
4:30 PM
I know that, but visual studio is set up to use the android ndk etc
so I can't figure out where is the problem
 
nwp
You probably need to add an include directory. Try to find the missing file in the ndk directory and then adding the appropriate directory to visual studio so it finds the file.
 
I don't understand it's like the ndk is not used at all
though I can clearly see is referenced when I try to build
I've tried to add the directory manually, doesn't work
 
nwp
4:46 PM
@user8469759 What doesn't work? Did you add the directory? Are you sure that adding android/log.h to that directory actually points to an existing file? Has the error message of "cannot open android/log.h" changed to something else?
 
@nwp your suggestion of adding the relevant path to the additional include folder field
the error didn't change
 
nwp
Try to find the compiler output. It should have a bunch of flags. One of them should be your directory. Is it there? Double-check that you can cd the/dir on whatever that shows. And then check that echo android/log.h prints the file.
 
command line is this
-fpic "pch.h" -std=c++11 -fstack-protector "ARM\Release\" -Wall -fno-strict-aliasing -ffunction-sections -I "C:\Users\l.gagliano\ProjectMaterialCapture\LightWeightMethodVSSolution\LightWeightMethod\..\..\dependencies\opencv-sdk-3.4.1\sdk\native\jni\include" -I "C:\Users\l.gagliano\ProjectMaterialCapture\LightWeightMethodVSSolution\LightWeightMethod\..\LightWeightMethodSourceCode\headers" -I "C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\platforms\android-23\arch-arm\usr\include" -I "C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\include" -I
all the ndk stuff I need in theory is included
and now that I look a bit better
is also complaining about some stuff related to the standard library
these : C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\platforms\android-23\arc‌​h-arm\usr\include" -I "C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\cxx-stl\gnu-libs‌​tdc++\4.9\include" -I "C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\cxx-stl\gnu-libs‌​tdc++\4.9\libs\armeabi-v7a\include" -I "C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b\sources\cxx-stl\gnu-libs‌​tdc++\4.9\include\backward
 
5:49 PM
http://cpp.sh/82t5j
Is " b = a = new Thing(33);" undefined behaviour I'm just not noticing? Or is this valid?
If I recall correctly, the assignment operator returns a reference of an object, so I figured it should be valid, but I'm not 100% sure I haven't missed something.

Why am I doing this?; I'm trying to be cool lol, also I want to reduce the amount of clutter to a minimum(partially for OCD, partially for readability).
 
it's legal
that said
new T() is garbage
and belongs to where garbage belongs, in the trash
 
You mean the use of it sucks, or you mean that I should handle the deletion of it?
 
both
 
I've got the deletion in mind, yes, since this is a test I didn't add it because obviously the memory used is deallocated when the program shuts down.
I didn't think of the other point though lol.
 
you don't need it
I have written thousands of lines of code without a single new in it
 
5:53 PM
Doesn't it affect performance on large-scale programs? I mean when you try to copy gargantuan objects.
Or in my case, attach objects created recursively to the "tail" of the previous one.
 
use an actual container
and not an ad hoc linked list
 
Like a vector you mean?
 
yes, like a vector
 
The problem is that each node has an unspecified amount of children. I figured it might seem like bad programming or come off as incompetent if I made a vector for each node.
 
nwp
@JackOfBlades That is not very readable. Are you aware a and b point to the same Thing and you must delete exactly one of them?
 
5:55 PM
there are others, and if you see a situation where vector isn't good enough, replacing it with another container is simpler than replacing an ad hoc linked list
 
@nwp Yes, it's just for a constructor to make the head and tail point to the same thing initially before being branched off later.
 
@JackOfBlades why
it can be different for each node, and it can change during the lifetime of the program?
 
I'm unseasoned still, I don't know what the standards are "higher up". Well, up at the level I'm exploring currently. My work is to be examined by a Ph.D., I'm aiming for the highest grade.
I figured it might seem more professional if I do the "standard/prescribed solution".
Well, it can uhh... each node is to have X amount of children, that X won't change after it's set once though.
 
nwp
@JackOfBlades If it matters so much to you cheat prepare by looking at that person's recent code and copy the style. Assuming it's not terrible that is.
 
But it's a different X for each node, of course.
 
5:58 PM
so vector
 
Alrighty, I'll do that.
 
6:26 PM
yo
char*
 
@Dariusz ?
 
just testing before asking... :- ) trying to figure out if I save more memory by using map<char*,object> or map<int,object> char*="string" :- )
the char it says that its range 1-255
but I can do char* x = "cascs"
so does that mean I can have 255 letters max?
 
if anything, std::string_view instead of null-terminated strings (lol)
or just a regular std::string
 
std::string is like 40 bytes
I will have thousand of keys, I think of using int for keys and enum myKeys{} for managing it, but I was wondering if I can use string, but nearest string is 8 bytes (char) which is 2x the ints 4 bytes
 
if you're optimizing for memory usage, you already lost by using std::map (that is, a node-based container) in the first place
 
6:36 PM
-.-
I think ill add anote that to run my app the user should ensur they have at minimum 128 gb ram...
 
also, "thousands of keys" doesn't sound remotely large
 
7:11 PM
well theres going to be milions of them
 
so don't say thousands
also, you may possibly want to use an on-disk DB at that point
 
so what container should I use for memory optimization that act as map ?
 
If you have a map<int, T>, you might be able to just use std::vector<T>, but only if the keys are dense
 
a non-node based hash table
 
^ . Sadly, this doesn't exist in the standard library :(
 
7:22 PM
you won't get that from the C++ standard library, because of bucket silliness of std::unordered_map
 
@milleniumbug could have sworn you could use std::make_heap on a vector for that
 
heaps are for getting the max element, not lookups
but sure, you could simulate a boost::flat_map with sorting before binary searching
 
nwp
A sorted std::vector or boost::flat_map. Also maybe looking at benchmarks and doing some yourself with your use case makes sense.
 
note that these only work well if you insert or delete elements rarely
 
05:00 - 20:0020:00 - 00:00

« first day (667 days earlier)      last day (2186 days later) »