« first day (1574 days earlier)      last day (1503 days later) » 

05:43
@PeterT How is Clang compatible with G++ then?
I mean Clang++
If I build something with G++ and others with Clang++. Things might break?
 
2 hours later…
07:15
@Rick well I was using msvc because that's the one that regularly broke ABI
gcc and clang have tried to keep it mostly stable
there was some ABI break around C++11, but you can compile for either version usually if you specify the standard library with libstdc++ or libstdc++11
 
4 hours later…
11:00
ok
 
1 hour later…
12:27
@PeterT Ok I don't understand what you mean until I read this answer and the comments.
Wow that's insane. The binary is not compatible with a different C++ standard implementation, under the same platform.
how would you make it compatible? You would have to mandate an ABI for all platforms, so that they don't fragment
Oh sorry, I mean under the same platform.
94
A: Using libstdc++ compiled libraries with clang++ -stdlib=libc++

Howard HinnantWhat you're seeing is the use of inline namespaces to achieve ABI versioning. What that means: The libstdc++ std::string is a different data structure than the libc++ std::string. The former is a reference counted design, whereas the latter is not. Although they are API compatible, they are n...

I just read this
my point still stands if you don't mandate a specific implementation for each platform, then there will naturally be the possibility for different implementations on the same platform
Yes, I know it's not compatible under different platforms.
13:07
Well I still don't get it.
I see people say libc++ and libstdc++ is not compatible at all.
you're free to use types from either in one single program, you just can't pass a type from one of them to a translation unit that uses the other
So for a project, does it mean that I have to compile all the code with g++ or clang++ only, which means I could not compile some code with g++ then some else with clang++?
you can use both libc++ and libstdc++ with clang
so just use -stdlib=libstdc++ with clang
So what you are saying is that, for a project, I can compile some code with g++ and some other code with clang++ -stdlib=libstdc++. But I can't compile some code with g++ while some other code with clang++ -stdlib=libc++. Do I get it right?
I just haven't done it, but I'm sure there's a way to link gcc programs with libc++
13:18
Well, forget the tricks. I am newbie so I would only consider the safest way.
an like I said, as long as you don't pass standard-library types between the two, you can link them just fine
Then I would take it as a "Yes".
so if it's just C types and your own C++ types that you pass between the interface of the two, you can link them just fine
@PeterT Ah ok. Damn I learnt a lot today.
@PeterT Btw, I didn't know this till you told me. Thanks a lot.
13:52
hi all,
can anyone help me how this comparator works,
 auto min = std::min_element(ins.begin(), ins.end(),[](auto &lhs, auto &rhs){
    return lhs > 0 && (rhs <= 0 || lhs < rhs);
});
i want to find positive min_element from ins vector which has negative integers
^ found in SO answer
I know how a comparator works in a sort function....but how it is for min_element? what is the complexity of the min_element algorithm? any info available?
> Exactly max(N-1,0) comparisons, where N = std::distance(first, last).
All std algorithms have a Complexity section on this site.
okay i found the complexity...but how it works?
Check the Possible implementation section
This is how it works:
template<class ForwardIt, class Compare>
ForwardIt min_element(ForwardIt first, ForwardIt last, Compare comp)
{
    if (first == last) return last;

    ForwardIt smallest = first;
    ++first;
    for (; first != last; ++first) {
        if (comp(*first, *smallest)) {
            smallest = first;
        }
    }
    return smallest;
}
nice!...thanks...let me check that...
ins.begin() is ForwardIt first for example
Ya, check that and see whether your comp does what you want.
 
3 hours later…
17:02
hi
what is the standard way to deal with errors in threads?
thoughts and prayers
raising exceptions or using return values as error indicators?
prayers are the backbone of programming
Exceptions probably aren't the best of ideas since even std::exception_list wasn't added to the standard when they introduced parallel algorithms
let's say I'm reading USD-EUR conversion value from an API and I receive a http status 500 - server error. Should I raise an exception and somehow catch it in the main thread? Or return an impossible value -1
I don't think you can throw exceptions across threads
17:06
ok so back to C-style and err return values
You need to store the error information in such a way that it can be accessed from the calling thread if it's where you need to handle it
 
2 hours later…
18:44
you can use std::exception_ptr
it's how you rethrow stuff across threads
 
2 hours later…
20:55
what does a virtual inheritance actually mean? I know when to use it but its quite not clear
 
2 hours later…
22:31
Isn't this the classic case of don't use an exception because there is no RAII advantage as the "error" occurs outside of the calling context? AKA you're going to read the stuff from another thread anyways. Probably better for the thread to return an "invalid" reply and handle it in the logic.

« first day (1574 days earlier)      last day (1503 days later) »