« first day (593 days earlier)      last day (4581 days later) » 

15:00
@thecoshman actually a relatively simple markov chain with a simple sort-of governing neural net can make AMAZING jokes. especially if you train it on the bible.
oh, read it wrong, sorry
sbi
sbi
@RMartinhoFernandes You're a machine that executes algorithms, equipped with manipulators.
That last part was never meant to come out.
@RMartinhoFernandes but I like your algorithms :-(
Marry them if you wish.
15:00
just don't say anything about Chuck Norris and you'll be OK
@RMartinhoFernandes I never said you were an algorithm
@RMartinhoFernandes sorry but you're not my type
"were". Your argument is invalid.
sbi
sbi
@RMartinhoFernandes You meant to say "I'm creative and I'll kill anyone." only?
I'm a robophobic bigot
damnit I can't get that right
15:02
In my head, all bigots have moustaches.
A manly beard you mean
@RMartinhoFernandes So, everyone's a bigot in november?
Do all moustaches have bigots?
@EtiennedeMartel I'm lost there.
@stdOrgnlDave Hey, I'm probably the less bigoted man in the universe, and I have a beard.
15:03
hi, can somebody help me... i get the following error when running this code :

#include <iostream>
template <class Type>
Type max(Type a, Type b) {
return a>b? a:b;
}
int main()
{
std::cout<<max(3.0, 2)/2;
return 0;

}
@RMartinhoFernandes movember.com
@RMartinhoFernandes he's confusing cause and causality in an attempt at humor
@EtiennedeMartel you logic is flawed
why this happens?
15:03
@thecoshman Maybe. But it was just a pretext to plug Movember.
D:\watermelon\untitled.cpp||In function 'int main()':|
D:\watermelon\untitled.cpp|9|error: no matching function for call to 'max(double, int)'|
||=== Build finished: 1 errors, 0 warnings ===|
@EtiennedeMartel I'm only bigoted against robots. that and luddites. but I try not to actually be a bigot to those.
just because all X are Y, does not mean all Y are X
@EtiennedeMartel Oh.
@ddacot std::cout<<max<double>(3.0, 2)/2
15:04
Grow a mustache! Fight prostate cancer!
@ddacot Implicit conversions and type deduction don't mix.
That kind of shit.
You can't have both.
@ddacot Cast one of the parameters.
I'd love to the give movember a go, but it'd hardly be a even close to a possible shadow
@EtiennedeMartel profit?
15:05
@ddacot template<typename T> auto max(T a, T b) } -> decltype(a+1) { return a>b? a:b; }
You can pick implicit conversions: max<double>(3.0, 2), or you can pick type deduction: change the function to take two different type parameters. That complicates the return type though.
@ddacot Your watermelon is missing random seeds. Actually that's not true, but man that would have made a good joke.
that will do what you want, albeit stupidly
@stdOrgnlDave Missing a decltype, but doesn't really solve it.
I said it was stupid didn't I?
15:06
Well, the idea is a good start.
@thecoshman If you have a mustache, you're already making profit.
template<typename T, typename U>
auto max(T a, U b)
-> decltype(true? a : b) {
    return a>b? a:b;
}
Holy rain! :D
Today is awesome.
template<typename T, typename U>
CommonType<T, U> max(T a, U b) {
    return a>b? a:b;
}
15:08
@RMartinhoFernandes these are the solutions?
I'm sure there's a question on this on SO.
@RMartinhoFernandes why would you do this? max<double,int> ? the compiler will give good implicit conversions if you assume either type for the purposes of a max
@RMartinhoFernandes I prefer this solution
@stdOrgnlDave You don't get implicit conversions if you get type deduction.
@stdOrgnlDave I agree. We shalt not have intertype mingling going on.
15:09
@ddacot Some of them.
@RMartinhoFernandes I'm not sure what you're saying, my approach is proven to work. malform it a bit and crash a compiler. want to see? :-D
@stdOrgnlDave How is it proven to work?
@Neil then explicitly typecast to a common type
Hey guys , but is possible the following?

std::cout << max(3, 2.0) / 2 << std::endl; // to print 1
std::cout << max(3.0, 2) / 2 << std::endl; // to print 1.5
@thecoshman I prefer the one with CommonType. Lots clearer, less repetition.
15:10
visual c++ y u no be faster
template<typename T, typename U>
T max(T a, U b) {
    return a>b? a:b;
}
@ddacot Yes.
@thecoshman How can you accomplish that without knowing anything of either type? You risk losing precision if you move both to a less precise type.
@RMartinhoFernandes struct A { int a; bool operator>(const int& inty) const { return a > inty; } }; template <class A, class B> auto operator<(const A& a, const B& b) -> decltype(a>b) { return a < b; } int main(void) { A a; a.a = 1; int b = 2; if (a < b) return 4; return 0; }
that deduces bool correctly and recurses inside the operator< indefinitely
@stdOrgnlDave And so said the Lord, thou shalt write programs which return 4, not 0.
Yes, but it has two template parameters. What you posted above doesn't.
15:12
@stdOrgnlDave oh god! my eyes!
@RMartinhoFernandes oh. you're right. duh. my mistake
0
Q: Template argument deduction & template parameters

cppcoderI thought we could call the template function without template parameter. Why is this code working only if I specify the template parameter as double? #include <iostream> template <typename T> T max(T x, T y) { return x > y ? x : y; } int main() { cout<<::max(3,4.7...

Found the thingy.
@RMartinhoFernandes it's a question
@RMartinhoFernandes oo thx, that's what i want.
@Neil I always use 4 as my default constant. if you could search for '4' typed by me you'd find half the code I ever pasted
15:14
I use 17, 23, and 42.
You never need more than three random numbers.
int random() { return 4; /* randomly chosen by dice roll */ }
I only remember that old saw because it's 4
do random access iterators have to provide < and > and friends?
@stdOrgnlDave 4 happens way too often in my code to do that.
@DeadMG Think so. Lemme check.
@RMartinhoFernandes What about thirty-twelve?
not sure how to meaningfully compare < and > for two iterators if they're not into the same string
that's fine then
@DeadMG Technically, you should assert for that.
It's the same for pointers and all standard iterators, anyway.
15:16
looking up 17 23 and 42 I get amazon.com/Kings-Elephants-Books-Young-Readers/dp/0803704585 . that's pretty random I'd say.
@EtiennedeMartel Yeah, I should have asserted my debug range checking, instead of throwing an exception.
@stdOrgnlDave Oh, now you're assuming any odd thing I say is a reference to something? You're learning.
@RMartinhoFernandes Lost - > 16, 23, 42. I thought it was 17
Comparing two iterators over two different sequences is not an exceptional thing, it's a plain and simple programming error.
I have to go, it's been grand y'all
15:19
@stdOrgnlDave Later
@EtiennedeMartel Some people prefer "hard" asserts, though.
But you totally shouldn't be catching such an exception.
@RMartinhoFernandes Hm?
@RMartinhoFernandes That's what she said (if she were a programmer)
Oh fuck off, I was about to make that joke.
2
still considering, though, just providing a wrapper over u16string and using the version of BreakIterator that operates over raw wchar_t*.
15:20
What, who flagged me?
That better be a misclick.
but I guess that would not validate combining characters and stuff like that
@EtiennedeMartel Asserts that trigger on release. I guess they could just keep the asserts on, but some people are weird.
@EtiennedeMartel I did. Thought it was hilarious
@RMartinhoFernandes Actually, we used them on my AI project.
@EtiennedeMartel You fucking fucker, you fucking made a fucking insult at some fucking other fucked up fucker
15:21
I'm tired of admonishing people for flagging stuff for fun.
For performances reasons, we had to run our code in release, with debugging info.
Can someone else do the honours?
So asserts were nice to have.
@EtiennedeMartel That sounds... ass-backwards.
@RMartinhoFernandes can't flag my own posts :P
15:22
SC ran on 3 FPS in debug and 60 in release.
Oh, wait, I think I get it. You're saying that debugging it without optimizations was slow as hell.
@thecoshman I resent that. I'm not some fucking other fucked up fucker who got a fucking insult, you fucking fucker.
I thought you were saying you needed the release build to run faster, so you added debugging info.
Hmm. That does sound weird.
15:23
@Neil fuck sake! Can't a fucking fucker make a fucking fucked up joke about another fucking fucker getting a fucking fucked up insult from another fucking fuck?
So we used release as a "fast debug", with another configuration called "ReleaseFinal" that was the "real" release.
(Which removed logging and other stuff)
That VS solution was a mess.
The code was decent though.
@thecoshman I can't continue that without sounding simply redundant, sorry. I really did try though, for what it's worth.
@Neil I win :D
any way
home time for me
see y'all in the morning, or tonight maybe
@thecoshman Later, fucker. ;)
10
A: How to implement an STL-style iterator and avoid common pitfalls?

Mooing Duckhttp://www.cplusplus.com/reference/std/iterator/ has a handy chart. Basically, the iterators have tags,and the tags have a heiarchy. Below is purely symbolic, these classes don't actually exist as such. iterator { iterator(const iterator&); ~iterator(); iterator& operator=(...

15:26
Now, lets see when she logs in if she happens to check the history. :P
@stdOrgnlDave I'm also currently writing a unicode string class, but DeadMG might also be reinventing things for his libraries
@Neil The heck is that?
@RMartinhoFernandes You know who Cicada is, I presume.
@MooingDuck I'm not re-inventing anything. I'm just wrapping ICU.
@DeadMG I've been considering using ICU as a "backend" to my classes. I'll have to look at ICU's api and see how well it matches up with mine
15:28
So, basically, @Neil, your question is "if I sprinkle shit all over the place, will somebody complain?"
@EtiennedeMartel No, just testing to see if Cicada checks her history. Only that.
@Neil She's not plinked if she's not in the chat, I think.
Yes, you are.
@EtiennedeMartel It wasn't my intention to plink her, actually.
If you've been in chat recently, you're plinked even offline.
15:30
@EtiennedeMartel There was no @
There.
Wait a bit while I bang my face on my desk.
by the way
Now the apocalypse will come for us all.
15:31
what's the difference between const_iterator cbegin() const and const_iterator begin() const
@EtiennedeMartel I just logged in and immediately responded to a message directed to me from two hours ago, that's a hint
I've seen both used in Standard interfaces
I must admit I totally still don't understand what the heck is going on.
@DeadMG one is backwards compatable, other gives you a constant iterator from a non-const container
@DeadMG I figured cbegin meant const_iterator while begin was just iterator.
If they're both const_iterator, I dunno.
15:32
@DeadMG The former works even if you have a non-const variable.
right
why not just static_cast<const T&>(t).begin()?
Ugly?
There's really no other justification.
@DeadMG because a const iterator and a const_iterator are very different things
non-member non-friend function > member function
@MooingDuck I know that. But both begin() const and cbegin() return const_iterator.
@DeadMG Ah, definitely. Yeah, should have been a free function.
15:33
I'll mark that flag as invalid... what the hey.
also, I'm not going to provide non-const iteration
that's just begging for some poor sod to add an unpaired surrogate or something
@DeadMG begin is so that you always get some iterator no matter if container is const or not. But if you want a const iterator from a mutable container, you have to have cbegin
@MooingDuck Or, as I already posted, there's absolutely no need whatsoever for it to exist as a member function.
@DeadMG oh, for a unicode string? Yeah, it's not needed
template <typename Container>
ConstIterator<Container> cbegin(Container const& c) {
    return c.begin();
} // @MooingDuck
15:34
btw
@DeadMG saves callers a cast
Does plinking from code comments work?
@MooingDuck Free function? As Martinho has posted, it's a trivial implicit cast
@RMartinhoFernandes apperently not
by the way, there's no reason for us to write the same class twice
why don't we just share the code?
15:35
Would be cumbersome to have to write all that code for an implicit cast, right?
@DeadMG when dealing with iterators, few algorithms cast
@Neil It's a write once, work forever for all containers imaginable deal.
I'm trying to remember the argument for why member functions are bad.
@RMartinhoFernandes And that would not be the case without cbegin?
@MooingDuck Violates encapsulation
15:37
@Neil The point is, cbegin as a member function means you must implement it for each container.
and DRY
And the implementation is merely boilerplate, because it's token-identical to the one for begin() const.
@RMartinhoFernandes I understand that, though I fail to understand why it exists in the first place, if all you have to do to use it as a const_iterator is assign it to one.
@Neil For auto, basically.
typename Container::const_iterator is a pain the ass.
@RMartinhoFernandes Nah nah nah! I'm not listening! I'll take your word for it, just don't tell me anything more about that.
15:38
You can always alias your way into ConstIterator<Container> as I did above, though, but auto is neater.
Did I mention I really like alias templates?
hmm
Because I do.
am I violating the semantics by returning a value instead of a const reference?
Some input iterators do that.
@DeadMG I think for input/output iterators that's fine
15:39
I'm not an InputIterator
2
I mean just like, for front() for example
@DeadMG you are now, otherwise use a proxy object
@DeadMG Must be convertible to reference.
@RMartinhoFernandes tits
@DeadMG I dropped front() from my unicode string
reference doesn't have to be a reference though.
15:40
Standard containers, y u so goddamn many typedefs and stuff
I decided it was fine and probably good to make character manipulation harder for my Unicode string, since there's virtually no reason for it.
I have implemented all the C++11 concepts for Boost.ConceptCheck, except for containers. Containers have soooooooo many requirements it's not even fun.
@MooingDuck Agree, I guess.
And you hardly ever need the Container requirements. Most of the time you need "something I can call begin() and end() on", or "something I can index over". Not the whole shebang.
@RMartinhoFernandes is there a concept for that? That'd be handy.
15:43
I actually have no function to remove content from a UnicodeString
@DeadMG I kept in find/insert/replace/remove, but dropped all overloads that take an size_t position. Also changed all find to return iterators instead of indecies. (as compared to std::string)
I'm going to need to support some variant of erase, for example
@RMartinhoFernandes I've learned a lot from you guys
Ok, now I'm totally putting that cbegin thing in wheels. Thanks for the suggestion, @Dead.
15:45
I think that maybe just erase one component should be fine
@RMartinhoFernandes no probs
@RMartinhoFernandes yeah, in hindsight I don't think the const_iterator begin() const should have existed. cbegin was the way to go
@MooingDuck No, the overload is the sane thing. cbegin is what was silly
@DeadMG really? Mine only supports erasing a range
@MooingDuck That would hurt generic code. The const overload is a good thing.
@DeadMG ah right, the nonmember cast thing
15:47
@MooingDuck I can really do both, I guess.
@RMartinhoFernandes generic code should use cbegin
@MooingDuck Hmm, good point.
@MooingDuck Not really.
template<typename Container> void f(Container&& c) { algo(c.begin(), c.end()); } for example
@DeadMG Does the algorithm modify anything?
@RMartinhoFernandes Who knows? Maybe you took that by template too.
15:49
If not, cbegin is fine. If it does, passing a const container doesn't work anyway.
@DeadMG Ah.
my point is, there's no point in making people write two sets of functions when they could just write one for exactly equivalent functionality
The committee totally needs us to get the interfaces right.
lol
fine by me, because I'm gonna be designing my own container interfaces for Wide at some point
@DeadMG Having implemented a container once, I couldn't agree more.
although it's much more flexible because Wide will simply not specify many types and tell you to type infer them
15:52
That reminds me I should try compiling that thing again. Maybe newer GCCs don't cthulhu choke on it.
what thing?
@DeadMG you know, the thing
The container. An LRU cache.
hmmm, fuckdiddlies
At some point, GCC started ICEing on it for no reason.
15:53
unsure how to implement the return value of erase
yeah
presumably I need to mutate the input iterator somehow.. but not sure how
actually, I might get away with just returning the begin iterator, as they operate on indicies
@DeadMG I'm not sure what you said, but that sounds wrong
@MooingDuck If you erase the element with index 5, what's the new next element? The element which now has index 5.
if it's the last, then the last has .. index 5 and therefore compares equal to end().
@DeadMG oh, that's what you meant. Yes, that sounds right. When you said return the "begin" iterator I got concerned.
15:59
hmmm
now I'm not sure what to do about insertion
@DeadMG that method makes for larger but safer iterators. Interesting choice. And you could always make them convertible to the "normal" "pointer" iterators...
maybe I'll only allow insertion of a String
@MooingDuck Not really my choice, ICU provides those iterators, I simply wrap them into a Standard interface.
@DeadMG ah, right. I should look at ICU's interface. I bet it's completely incompatible with mine by now.

« first day (593 days earlier)      last day (4581 days later) »