« first day (418 days earlier)      last day (2659 days later) » 
02:00 - 22:0022:00 - 23:00

02:31
If I might ask, what is the difference between mingw and gnu toolchain?
 
2 hours later…
user406009
04:10
@Unknown123 What do you mean by the "gnu toolchain"?
user406009
Are you talking about cygwin?
user406009
@Lalaland GNU Toolchain is a broad collection of programming tools produced by the GNU Project right? I don't think cygwin and mingw produced by gnu project, am I correct? en.wikipedia.org/wiki/GNU_toolchain
so my question will be, what is the difference between mingw (or cygwin or msys) and gnu toolchain?
user406009
04:32
Mingw and friends just distribute the gnu toolchain
user406009
The gnu toolchain is the actual compilers and whatnot.
user406009
Mingw is just a package of those tools
user406009
(now, I think mingw makes some changes, but not too many)
user406009
The distinction usually doesn't matter that much though for average users like you or me
user406009
(except I guess where you complain about bugs)
04:45
We know that, GNU Toolchain consist of: GNU make, GNU Compiler Collection (GCC), GNU Binutils, GNU Bison, GNU m4, GNU Debugger (GDB), GNU build system (autotools)
I don't know why people often mixing the terms of toolchain, toolset, compiler suite and compilers
It confuse me as a newbie
So mingw and friends include modified gnu toolchain plus some of their own tools?
@Lalaland
user406009
Pretty much
user406009
They only make changes to port them to Windows though.
and some people also mixing gnu toolchain and gcc toolchain, which makes more confusing
user406009
To be fair, most people only really care about gcc
gcc stand for gnu compiler collection, does that mean gcc toolchain is a tool for building program but not produced by gnu project?
user406009
05:03
Gcc is from the gnu project
but gcc toolset can be from anywhere, am I correct?
05:19
@Lalaland
user406009
Gcc and the gcc toolset are pretty much synonymous
user406009
The gnu project produces both
user406009
Other projects like mingw simply port and package them.
@Lalaland I thought that it was different, I thought that gcc is a tool and gcc toolset is a set of gcc tool, i'm confused
05:52
second question, what is the difference between toolset, toolchain, and compiler suite?
 
2 hours later…
07:57
Hey guys. Newbie question: when making a c++ project, does one write all the code in a single file and compile that? I'm used to having folder structure and files separated by functionality, if that makes any sense. (php, javascript)
08:14
@sehe Indeed that I did
Made a boost::proto project on the plane ride. Got it to have a ton of different operators like ^ for pow, ~ for sqrt, etc, and writes the postfix form of the expression into a string buffer. I guess next logical step is to try to get differentiation working, but I realized it's a separate beast in and of itself
nwp
nwp
@Dante Usually people try to put different responsibilities in different files. The granularity varies.
@nwp I understand but how?
nwp
nwp
You put code in different files and then compile all of them and then link them together. How to do that depends on your development environment.
For example, g++ -o file1.cpp generates file1.o.
I've just read about header includes. Is that a proper way to structure a project? Folders with h files in them called in the main cpp file?
nwp
nwp
08:25
Usually you just click on "Add class" in your IDE and it will give you a header and cpp file and make sure it gets properly compiled.
You can then compile all of these "translation units" by g++ -c file1.o file2.o ... output_binary
nwp
nwp
@OneRaynyDay you can edit your messages for 2 minutes
So the way I mentioned is improper?
@nwp thanks for the heads up
@Dante if ytou're coming from a javascript/php background, you should realize C++ is much more unforgiving in imports and linking
nwp
nwp
@Dante Headers only contain the declaration, you need the definition in the cpp files too. But yes, folders with header files is common.
08:28
now I don't know much about php but afaik javascript is an interpreted language. You should read about how C++ does its compiling(it's a compiled language) before you write anything in C++
otherwise you will be very lost and not very sure how to proceed in getting ur code to work
nwp
nwp
Or you just let an IDE do everything for you.
headers are pretty much text files, and when you do an #include, it's pretty much a macro for saying "paste everything from that file into this part of this .cpp file"
@nwp true, I haven't worked with IDE's in a while however, so don't remember much
I know the jest of how most compiling languages translate to machine code or assembly and how the results often vary depending on the compiler.
I'm just new to the whole thing so I have lots of questions.
headers by themselves are nothing but forward declarations of saying "these symbols exist and I will use them. Don't worry about them having actual implementation yet"
nwp
nwp
@Dante What is your development environment? Window/Linux/Visual Studio/gcc via command line/something else?
08:31
np, but my point is any introductory C++ book will cover this in depth and will probably get you up to speed faster than we can
or do what nwp suggested which is IDE
@nwp Windows 10 and I'm using MinGW run by custom command line builds that I set into Sublime Text 3.
I'm not fond of IDE's no matter the language.
nwp
nwp
@Dante Ouch, that requires quite a bit of manual work.
Go with this then.
I mean I use IDE's for efficiency purposes when I need to, but that's when I'm very familiar with the language I'm working with.
Which is not the case with C++ since I started less than a week ago.
suggestion: linux VM and develop on there
I did that when I had a windows, it was a little bit more predictable, and all the stack overflow answers are mostly assuming you're working in unix shell
nwp
nwp
If you want to get to developing I would recommend an IDE. Either Visual Studio or Qt Creator so you don't need to worry about the build system. Otherwise you will have to screw with command line arguments and sublime text settings for quite a while before you can start writing C++.
08:37
In PHP there are two slightly different concepts for "linking": include and require. They're the base for project structuring. They basically "paste" the code in the files into the main script and only after that the script is run. I'm guessing it doesn't work the same in C++?
Btw thanks for the suggestions, I will definitely consider them.
nwp
nwp
You could say that C++ is similar in a way because #include <foo> is copy/pasting declarations and the linker commands add the definitions.
So if I do #include "foo/bar.h" before main() could it bring any problems? You were saying something about declarations and definitions before I didn't quite get.
nwp
nwp
@Dante Because you said you are new: Be very careful with C++ tutorials, youtube videos and books. Most of them are garbage and will ruin your experience. This is a decent list of learning resources.
Yeah I've encountered other people around the internet saying that same thing. Thanks for the list. I was actually already looking to buy one or two books about the matter.
nwp
nwp
@Dante You can't really put definitions into a header because 2 .cpp files will copy those definitions and then the linker will complain that there are 2 definitions for the same symbol.
this is a general description about the process but doesn't really explain all the things you need.
Basically you need to know that you can only put declarations in the header, not definitions and that you put the definitions into the .cpp files and that you need to compile all the .cpp files and then link them together.
08:48
Actually, you can use something called inline to define the functions. In fact, you can only do member function template specialization in inline code in your header files
nwp
nwp
gcc does the linking for you, so g++ *.cpp might be good enough
but that's another beast
But, I'm confused. I'm looking at one of the most basic header files that I've learned of (stdio.h) and the first thing that I'm seeing in it are definitions.
Tell me if I'm absolutely off the rails, haha.
nwp
nwp
What is an example of such a definition?
#define _STDIO_H is the first one I'm seeing out of many.
They're all preprocessor definitions though.
nwp
nwp
08:55
Yeah, that's probably just part of the include guard, not a definition in the sense of C++ object definition.
By definition I mean some object like int i; or void foo(){}. The declarations would be extern int i; and void foo();.
So can I not use that same implementation to avoid multiple inclusion?
nwp
nwp
#include ing headers multiple times is fine (or someone screwed up when writing it).
Excuse me, I meant multiple definition.
nwp
nwp
That's why headers are not supposed to contain definitions.
(and yes, inline disables the One Definition Rule)
Alright, well I'll try all these things you guys have helped me learn and I'll probably be back later to bug you with more questions I can't figure out with just the help of google.
nwp
nwp
09:08
@Dante It typically looks something like this.
 
6 hours later…
15:04
can anyone tell where can i find the manual (book with all descripitions of header files) of c++?
15:27
1 message moved from bin
user406009
@Anant_infinity I would recommend en.cppreference.com/w
15:53
Is there a way to input n (or less) integers from stdin using istream_iterator?
the problem is that I don't know if I have more than n integers; so I should ensure that I won't read beyond what is actually there
Is there any explanation why my message was moved to the bin before?
16:09
@milleniumbug Im sorry for responding this late. But, it is not really that easy in my case (i.e. the example you gave with char* pointing to a null terminated string in a dynamically allocated memory). By saying "how do you mean", I am confused how do you know if my class has destructor. And its not always possible to omit destructor and just refactor the responsibility into a seperate class (otherwise there wouldnt even been the rule of three). And, by the way, I have a destructor.
nwp
nwp
@Yashas Why do you want to use istream_iterator and not just cin?
@Anant_infinity You are not supposed to ask C++ questions in the lounge.
@milleniumbug And an add-on to my last message, if you really can refactor this responsibility into a seperate class, you would anyways need to use destructor in that other class. Actually, in your example as well, std::string certainly uses destructor. So still, im sticking to my previous question: "how do you mean?".
Hey guys. I am working with an old game format and they are storing a float in what I assume is a 16 bit integer. What else is required to figure out how to convert this integer back into a float?
16:25
@milleniumbug By the way, is there any source (article, book etc.) that confirms your theory?
@nwp I have a funny challenge (not use loops) to complete :P
#define pairwise_loop equal
pairwise_loop(str.begin(), str.end() - 1, str.begin() + 1, [&order_table](string &s1, string &s2)
{
return true;
});
is there a proper way to do it?
I need to loop indexes (1,2), (2,3), (3,4), ....
17:05
@sehe heya mornin, since you're the moderator of the boost tag, was wondering if you knew a single source where I can find what stl can do now that boost was compensating for a couple years ago
i.e. I was looking at boost::promote_args(made in like 2010's or around there) because if I'm performing operations between different types in specialization, I need to promote and return that type. I feel like stl shuold already cover this, but can't find anything.
I think it's always best to get up to speed with newer tech/more standard tech if I can find it
17:20
@user923 They are clearly not storing a "float" (32 bit) in a 16 bit integer. You need to figure out the actual format
nwp
nwp
17:53
@Yashas That's not funny, thats just silly. If you want to loop use a loop. If you have to loop without an explicit loop use recursion.
@OneRaynyDay Am I?
51
A: Which Boost features overlap with C++11?

seheActually, I don't think the boost libraries are going to become legacy. Yes, you should be able to use std::type_traits, regex, shared_ptr, unique_ptr, tuple<>, std::tie, std::begin instead of Boost Typetraits/Utility, Boost Smartpointer, Boost Tuple, Boost Range libraries, but there should in p...

@OneRaynyDay I'm not sure I'm getting you right but maybe you want en.cppreference.com/w/cpp/types/common_type
@user923 most likely fixed point
@MuhamedCicak have you heard about google? @R.MartinhoFernandes started blogging it, and since then every-one and their donkey have copied it. It even has it's own article on cppreference.com nowadays
18:22
@sehe You sound offensive. What do you think, did I hear about google? Yes, of course I did. But that is not the only question I asked to @milleniumbug, if you read carefully, you can find some other things that I've said as well. Like (this is a question in a way, "am I not right?": " And its not always possible to omit destructor and just refactor the responsibility into a seperate class (otherwise there wouldnt even been the rule of three)".
@sehe And, like, this: "if you really can refactor this responsibility into a seperate class, you would anyways need to use destructor in that other class. Actually, in your example as well, std::string certainly uses destructor."
@sehe Maybe you can help me to resolve my questions, as @milleniumbug is not currently here. Because, I still dont get why is it bad to use destructor? Why would then Rule of Three even been invented?
@sehe Or the destructor itself.
@sehe The best I could find is the answer by @fredoverflow, and there is an advice section, but still, he says "Most of the time". So I am trying to confirm that. From what @milleniumbug and @ratchetfreak said, I understood that you should only use destructors in low-level code, which I find not true. So, I am trying to understand that. By asking specific questions. For example, the ones that I stated above.
nwp
nwp
@MuhamedCicak The point is that each class should have 1 responsibility. There are classes like std::unique_ptr and std::vector who's responsibility it is to manage memory. And there are classes like std::string who's responsibility it is to represent text or class Window which is supposed to control a window on a screen.
please anyone help me with this :
-2
Q: How to copy array in c++

hemant _I am trying to capture array instances in a function doSomething as Arrays in c++ are passed by reference this is not possible .Is there any workaround to solve this problem! #include <iostream> using namespace std; int *A[10][10]; void doSomething(int ar[],int n){ A[1][2] = ar; for (i...

after 2 hours I could not get a working solution :(
nwp
nwp
The rule says you should separate those into different classes, so for std::string you are supposed to use some memory management class internally and concentrate on getting the text part right.
It doesn't always work out in practice, especially when things like small string optimization come into play, but it is a good general rule.
18:39
@nwp Okay, I understand that. The thing is, Window class may need to allocate (and deallocate) something. If that happens, what, I made a mistake in Window class?
nwp
nwp
@MuhamedCicak Depends on how you do it. If you let std::unique_ptr or std::vector or some other class that specializes on memory management manage the memory then you are doing it right. If you re-implement std::unique_ptr in your Window class then you are doing it wrong.
@nwp And I am working with a lot of inheritance going on, and I have a lot of my classes (user-defined). And, I do not know why (I may be doing something wrong), but I end up needing to dynamically allocate things a lot.
I tried with vector also .Still I couldnt :(
everthing seems strange
I have no hope
@MuhamedCicak Yeah. Dynamic polymorphism /tends to/ lead to a lot of pointer use, though it's not necessary. There's only a value_ptr or clone_ptr type smart pointer class required.
@MuhamedCicak I don't think your questions are "specific" at all. If you give an example, we might begin to make them specific. And I don't mean "std::string" because that predates most of the language features we're talking about here.
:/
Puppy: please please provide me a minimal working code ,If you have a little time.
18:45
@MuhamedCicak Allocating is not the problem. struct X { std::string x; }; X hello { "World!"}; allocates, but you didn't need a destructor or assignment operator.
(Note how I made a /specific/ example.)
8 messages moved from Lounge<C++>
Okay, this is one example (I know I am using horribly horrible new but I just didnt learn std::make_unique yet). How could this be done without dynamic allocation?
By using std::make_unique
also damn, that's a lot of pings
@MuhamedCicak If you want a comprehensive answer, you need to wait until I get home
@milleniumbug I do. I will wait.
@milleniumbug And, I just cant understand, if std::make_unique isn't dynamic allocation, what is it?
@MuhamedCicak Can you show us the destructor?
@fredoverflow How do you mean? Which destructor? In the example, there is destructor in B class, which I am pretty sure you noticed, but still, I dont understand what do you mean.
18:58
@MuhamedCicak Well, you wrote the following, so I thought it might be easier to discuss your concrete example:
> I am confused how do you know if my class has destructor. [...] And, by the way, I have a destructor.
"I need to use dynamic allocation" != "I need to write a destructor and the rest of the big five"
@fredoverflow Yes, it would be, though its huge code. So, I don't know if it would be approporiate to work on that example. I mean, beside it, I would need to give the code of the other 4 classes.
Guys any ideas why forward declaration in a header does not work if I want to use the type as a reference?
@SaeidYazdani SSCCE please
@milleniumbug Yeah. "You sound offensive" (plink, plink, plink, plink, plink, plink!)
19:02
what is SSCCE :D ?
@SaeidYazdani It does. It doesn't if you subsequently dereference it or require sizeof(T) of that reference T&
@SaeidYazdani A plea to use google
@MuhamedCicak Okay, then the only generic advice I can give is this:
BAD!!!
class Foo {
    Bar* p;
public:
    Foo() { p = new BarImpl(); }

    ~Foo() { delete p; } // rule of 3 violation :(
}

BETTER
class Foo {
    std::unique_ptr<Bar> p;
public:
    Foo() { p = std::make_unique<BarImpl>(); }
}
lol I forgot the semicolons after the class definitions
I mean this does not compile for me:

class QLineSeries;

class WaveGenerator : public QObject {

Q_OBJECT

public:
WaveGenerator(std::shared_ptr<WaveSettings> settings, QLineSeries& series, QObject* parent = 0);
void generate();
//..........
19:05
19 mins ago, by sehe
@MuhamedCicak Allocating is not the problem. struct X { std::string x; }; X hello { "World!"}; allocates, but you didn't need a destructor or assignment operator.
I'm afraid it won't stick until he actually does it. And then realizes it. #epiphany
sorry this is the full class

class QLineSeries;

class WaveGenerator : public QObject {

Q_OBJECT

public:
WaveGenerator(std::shared_ptr<WaveSettings> settings, QLineSeries& series, QObject* parent = 0);
void generate();


private:
//disable default copy constructor and assignement operator
explicit WaveGenerator(const WaveGenerator& other) = delete;
WaveGenerator& operator= (const WaveGenerator& other) = delete;
void generateNormalSine();
void generateAdvancedSine();

std::shared_ptr<WaveSettings> settings;
@SaeidYazdani You managed to mix a smart pointer, a reference and a raw pointer into the same signature. Congratulations, I guess!
@fredoverflow woes of Qt
@fredoverflow hmmm any improvement suggestion :D ?
19:07
@SaeidYazdani Don't worry about, I'm just tired of C++'s complexity.
@sehe was muss ich sehen lol
@SaeidYazdani If it doesn't, it's not because of the forward: coliru.stacked-crooked.com/a/4b60be0634353887
@SaeidYazdani The way to properly paste code. With formatting
I think my problem is something else as I get QLineSeries as ambigious symbol
thanks for helps guys ill try to sort it out and at the worst case just include the header for it
to hell with forward declarations
@SaeidYazdani hehehe. Next time, read the message. And post it with your problem. Instead of posting assumptions :)
Why does everything start with Q? Does Qt predate namespaces?
19:09
It's Qute
Its Quite
@fredoverflow Okay, I understand that. But another thing concerning me. As I've read here, "destructor will call delete automatically". So, will it be called in the implicit destructor?
@MuhamedCicak Yeah. Don't invent terms for it though. The default-generated destructor en.cppreference.com/w/cpp/language/destructor
@MuhamedCicak Member destructors are always called after the (possibly empty) class destructor runs. If you have a unique_ptr<Foo> member, then the Foo will always be deleted, no matter the circumstances.
But what if I want to delete it somewhere else (I mean, not in the default-generated destructor) ?
19:11
@MuhamedCicak In case you're confused, you can have the base class say virtual ~Base() = default; to make all generated destructors in the hierarchy virtual
@MuhamedCicak You use the methods on the primitive building block that you used (unique_ptr.reset(...) e.g.)
:tiltshead:
:shakesit:
@sehe Is this a proper example of doing that? And, by the way, if I do this, what would then be called in the default-generated destructor? Nothing?
GOD DAMN IT....Qt.....It appears that QLineSeries is in its own namespace
wasted 1 hour of my life
QtCharts::QLineSeries
I guess it is actually better (for me) to learn (properly) std::unique_ptr. Then, ask the questions.
2
Anyways, thanks for help.
53
Q: Object destruction in C++

fredoverflowWhen exactly are objects destroyed in C++, and what does that mean? Do I have to destroy them manually, since there is no Garbage Collector? How do exceptions come into play? (Note: This is meant to be an entry to Stack Overflow's C++ FAQ. If you want to critique the idea of providing an FAQ in...

@MuhamedCicak The implicitly-generated destructor behaves the same as a manual, empty destructor.
@fredoverflow Thanks for that, seems pretty useful to have a read in this situation (situation of confusion).
@fredoverflow Oh, I see.
19:20
> When control flow leaves the destructor body of an object, its member subobjects (also known as its "data members") are destructed in reverse order of their definition. After that, its base class subobjects are destructed in reverse order of the base-specifier-list
So the destruction of the unique_ptr happens after the (empty) destructor body.
@sehe Code like it's 1998: std::unique_ptr<Foo>().swap(p) ;)
@SaeidYazdani Burns verkaufen der Kraftwerk
hate simpsons :D
48 mins ago, by hemant _
-2
Q: How to copy array in c++

hemant _I am trying to capture array instances in a function doSomething as Arrays in c++ are passed by reference this is not possible .Is there any workaround to solve this problem! #include <iostream> using namespace std; int *A[10][10]; void doSomething(int ar[],int n){ A[1][2] = ar; for (i...

I cant figure out a solution yet :(
@SaeidYazdani Wie kann man die Simpsons hassen?
@sehe Oops, replace "moderate" with "monitor", and the std::common_type<> is good but there's no automatic common_type between primitives, are there? It doesn't seem so from their examples/interface
they say try with vector , I am not sure how!
19:26
Also, that link for boost -> C++11 is awesome, thanks :)
Ich bin allergisch auf gelbe Farbe
@hemant_ What exactly does the 10 by 10 array even represent?
see here for a dp you need linear time right
@SaeidYazdani as it should be!
Namespaces are Good(TM)
so i want to store those instances or arrays ie memoization
19:28
@MuhamedCicak Cheers
but I am not able to do so due to the fact that arrays are passed by referenece
@sehe It is one those rare cases that something has its own namespace in Qt....eg QString does not live in a namespace
Ok. Namespaces with consistency is even better
@sehe so this is confusing...and compiler does not give a good hint...you have to find it youtself
@fredoverflow so far I have got 20 points but that is exponential I need a linear time
:/
19:30
@hemant_ You can void foo(T const (&)[M][N][O]) if you must
@SaeidYazdani "ambiguous" is a hint
With experience you'll learn that ambiguity often arises from symbols being visible via different namespaces
@sehe hmmm your right that gave me the clue
@hemant_ A[1][2] = ar only copies a pointer, not the entire array.
right
can i create a 3d array
int A[10][10][5];
@hemant_ Why not. std::array<std::array<std::array<int, 3>, 4>, 5>
19:35
std::copy(ar, ar + 5, A[1][2]);
hmm that seems promising
#include <boost/multi_array.hpp>

int main() {
    boost::multi_array<int, 3> a(boost::extents[3][4][5]);
}
@fredoverflow grrr.
@fredoverflow did you read that question? :/
@hemant_ omg you ungrateful bastard
Don't use C-arrays
@hemant_ I understood that you want to copy the array, and that's exactly what std::copy is for.
19:37
if yes then I want to share my exponential solution
std::vector >> C-arrays
#include <iostream>
#define MOD 100000007
using namespace std;


void dp(long long ar[], long long a[],long long b[], long long c[], long long n ,long long start,long long end){
    for(long long i= start;i<=end;i++){

        if (a[i] == 1){
            for(int j=b[i];j<=c[i];j++){
                ar[j]+=1%MOD;
                ar[j]= ar[j]%MOD;
            }
        }
        else{
            dp(ar, a,b,c, n,b[i],c[i]);
        }
    }

}


int main(){

    long long t;
    cin>>t;
    while(t--){
now talking about it will be more clear :)
@hemant_ click edit and the press fix font
@hemant_ Press Up arrow twice, Press Ctrl+K, Press Enter
#define MOD 100000007
using namespace std;
cout<<endl;
...
19:41
sorry i couldn't edit it
Anyway, your coding puzzle is way too complex for me to get invested in.
If you have a specific question about C++, feel free to ask.
@fredoverflow: no problem I just need a workaround for my question,then i can solve it in linear time.
@hemant_ What is your question statement?
I like solving puzzles
if you have time please provide me a workaround for stackoverflow.com/questions/46016402/how-to-copy-array-in-c
thats silly but thats how this question can go linear
@hemant_ The workaround is to use std::vector. Does this quick fix do what you want?
19:52
@fredoverflow thank you so much .I think this should work for the problem now :)
Sorry, not sure why this is exponential
@hemant_ Good luck with that. Next step would be burning your C++ books and buying a decent one:
4259
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a well-written...

@fredoverflow thank you so much !,Well i mainly code in JS
C++ just for competitive programming
> competitive
In that case, don't forget to compile with optimizations turned on.
19:55
@fredoverflow hey how you saved those arrays using a 2d vector !!
He didn't. FIRST read, then comment
ah ! sorry thats vector <int> a[10][10]
He saved those vectors in a 2d array
yep ! honestly I wasted 2 hours for it..
20:15
@hemant_ You deleted it AGAIN?!?! You complain about people not reading, and then you delete the question even after many people spent time on it.
@hemant_ I guess you'll never know my answer now.
sehe : please wait..
I thought it was useless with so many downvotes and close reqeusts
@hemant_ Cheers. Anyhow, be sure to read that C++ book or at least the following answer:
397
Q: How do I use arrays in C++?

fredoverflowC++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n> since C++11), so the need for arrays does not arise quite as often as it does in C. However, when you read l...

@sehe yeah! thanks .I definitely will,
@MuhamedCicak release() does something else than reset() (release() is when you want to AVOID automatically releasing. You asked for "But what if I want to delete it somewhere else". Of course you can also release it first, but that doesn't "delete it somewhere else".
@milleniumbug WOW. Epic. This deserves to be an answer on SO. It might even serve as a FAQ post. It's really nice
Does anyone by chance know if clang penalizes structs performance in wrapping over members?
@sehe Needs a bit of cleaning, but yeah, I'll think about it
@OneRaynyDay what (the answer is no, 99%)
12
A: C++: Structs slower to access than basic variables?

delnanThe usual rules for optimization (Michael A. Jackson) apply: 1. Don't do it. 2. (For experts only:) Don't do it yet. That being said, let's assume it's the innermost loop that takes 80% of the time of a performance-critical application. Even then, I doubt you will ever see any difference. Let's...

@sehe like as in struct foo{int x;} will take up more than 4 bytes on a 64 bit machine
Ah I see. This is helpful :) thanks. I'm no expert by any means, so I'll stray away and assume nice things for now
20:42
@OneRaynyDay It all depends on how it's used. godbolt.org/g/j9cVbs
You see? The point is: if it's trivially equivalent it's trivially equivalent. You don't fool the compiler.
Ah nice. I'm no assembly expert either but at least that statement was reassuring
Really. For performance favour immutability and pass by value.
Next up, enable LTO. Take a sip of your whisky
@sehe LTO?
nevermind, googled
@milleniumbug I really appreciate that, I am reading it, but probably will take me some time to fully understand everything there. Of course, I will have a lot questions (as always) :D Probably, I will ask them tomorrow.
All of the questions are answered there. It's a long, baby-steps exposé
20:47
@sehe Hehe. Well, true, but, I am going to sleep in a bit. I wouldn't want to leave @milleniumbug without a "thanks".
That's actually nice.
Sleep well
:3861757 Don't fall asleep now
that would be a waste of time
@sehe Thank you. You too guys (@sehe @milleniumbug).
D'aw. Memetic replies don't work cross-chatroom
20:59
Oh hmm.. TIL #pragma once is not in the standards
it's not, but nobody cares
in case you encounter a compiler which doesn't implement it, conversion is trivial
Yup, it's just something to keep in the back of the head
@milleniumbug Also to be noted that it's possible to alter behaviour. If both a/x.h and b/x.h contain #pragma once you might include both. However, if both have identical guards (SHUDDER) you can only include 1 /cc @OneRaynyDay
@sehe oh I see :) why would you ever have two headers in compilation with the same name though?
copy/paste mistake most likely
or, multiple incompatible implementations, rarely
21:07
one header for 1 platform? LOL
@OneRaynyDay Happens all the time. It's important to have unique header guards though. Best policies I know is to keep file hierarchies, namespaces, header guards synced. So you can generate header guards, as it were, and be safe
@sehe right. I believe XCode does that for you by default. I've moved from XCode to vim so I just started to write #pragma once for less typing. I was always curious about why they included the hierarchy :) thanks!
@OneRaynyDay This is not unusual, and I bet 7 cheesecakes some smarty-pants programmers consciously thought it would be a great idea to re-use the same header guard. (Don't claim the prize until you've actualy analyzed all historical C++ projects)
@OneRaynyDay So know you know. AND you get to just type #prag ^X^L !!!
w0t #prag ^X^L is #pragma once? O_O
@sehe my current strategy is to use #pragma once and in case I'll ever encounter a compiler which doesn't support it, running a converter that will convert it to include guards.
#pragma once -> include guards conversion seems to be waaaaaaay less complicated than the inverse one
21:14
@OneRaynyDay If you have any other buffers using it vimdoc.sourceforge.net/htmldoc/insert.html#compl-whole-line
@milleniumbug Has been mine for ~3 years now
Ah I see. I never used that trick ever actually :)
I reckoned. Vim is awesome. You find more nuggets even after decades
haha yeah. Learning the basic patterns + a few plugins can already get you a long way
Be sure to enable persistent undo. Then do the UndoTree plugin. Because. Well. It's nice.
21:17
Ah, I already did enable persistent undo. It's amazing
@OneRaynyDay Yeah, I've gone with "vanilla" vim for a decade before even starting on plugins. I had a ~5 line vimrc that I'd just retype from memory anywhere I needed to get started
@OneRaynyDay And use tim pope's Obsession. And Vinegar. And Sensible. And Dispatch (I recommended that the other day)
@sehe Using dispatch right now :) Make! big_build seems like an invaluable feature
Obsession, by the way, helps because it naturally re-opens the list of buffers you frequently use. This then helps navigation (:buf something<Tab>) as well as ^X^L style completion
@OneRaynyDay Wait till you make it a hotkey. And yeah. Though I find myself only hitting F10 (which is :Dispatch<CR>) for re-running tests. Because YCM does a good job showing live diags in the buffer
I see :) I'm installing sensible purely for incsearch
I think it has ]e and [e too that I use a lot (nothing special, just used to them). And [yy and ]yy. ([x is nice too)
Ah. No that's Unimpaired
21:28
wow your .vimrc must be pretty huge
Hey, sorry for the interjection, but I actually got a question if ya don't mind :)
@OneRaynyDay Of course not. It's pathogen#Infect()
@OneRaynyDay make it quick. I'm ready for bed :)
here's an MVCE of the problem: pastebin.com/E7MZHtMD, the thing I'm trying to fix can be found after the line // THIS IS REALLY UGLY AND I DONT WANT TO :(
Actually, let me remove some comments that are tangential, I had to change some code to make it short enough in 1 file
I was wondering if there's any way to automagically define template arguments, in this case template <char C> from either the constructor of the terminal object or something that's slightly nicer to the eye
I would do a typedef to make this much nicer looking, but I'm not aware of a way to inject template args into a typedef.
No implementation specific restrictions here, I just want to make it look nicer :P
@OneRaynyDay Not sure why that's ugly or "to be avoided". Here's a take that makes it more readable and employs some delicious ADL (also, don't code inside the boost namespace unless you HAVE to): coliru.stacked-crooked.com/a/dd790db9f2396e5b
@OneRaynyDay ^ (by the way, suggest to make then static constexpr)
Ah, looking at it right now :)
And I see, yup. I was just a little lazy and didn't want to type boost:: and was fairly confident it was going to be a small piece of code
Size doesn't matter
Also, namespace aliases are the bomb. As you can see
21:41
Woah, what the heck is this piece of code:
namespace /*anon, file-static*/ {
...
}
^ is this to make sure that the translational units load this in when it's requested? by giving it a scope?
I've never seen this before
Basically. It's equivalent to marking all them static
But aren't they static already?
@OneRaynyDay Yeah. It could be better. Hold on. First, see en.cppreference.com/w/cpp/language/namespace#Unnamed_namespaces
namespace {
    constexpr my_lib::var<'x'> x{};
    constexpr my_lib::var<'y'> y{};
    constexpr my_lib::var<'z'> z{};
}
Ah... I just looked online for an explanation on unnamed namespaces and it seems like it is trying to make the variables unique so that ODR exists between >1 translational units
Unfortunately I'm not very familiar with constexpr, so give me one sec to digest that :)
Basically it makes sure you can include the var-declarations in the header without duplicate symbols
@OneRaynyDay It's basically "ultra-const" with a lot more leeway for the compiler to optimize. Is restricted to types that can be constexpr
21:48
Ah I see. it is possible to evaluate the value of the function or variable at compile time... Type must be a LiteralType, ... etc
Cool! Asked one question, learned like 5 things :)
Thanks so much x 5, I really felt like I learned a lot from just seeing your coliru link
@sehe Here is another implementation that's also very clean: coliru.stacked-crooked.com/a/a1136d6c01ddd024
(Without all of the things you added, of course, which makes it 10x cleaner, but just for consistency of base example)
clarification: your additions made the code 10x cleaner, not the reverse
02:00 - 22:0022:00 - 23:00

« first day (418 days earlier)      last day (2659 days later) »