« first day (992 days earlier)      last day (3965 days later) » 

sbi
5:00 PM
@R.MartinhoFernandes I am not yet used to that thing that's called enable_if. The one place I have used it is a class template, and I have added an extra template parameter to it just to sneak this in. So how do I use it with these function overloads?
 
Xeo
Return type or at the end.
For C++03, anyways.
 
Twist the return type beyond recognition!
typename std::enable_if<!std::is_same<T, std::string>::value, bool>::type f(...
 
I think I know why @Ell's SFINAE didn't work. Typename.
 
Xeo
@sbi: Whatcha want to happen with a const std::string for the second argument?
 
Ell
@BartekBanachewicz aww man
 
Xeo
5:02 PM
@BartekBanachewicz Angle brackets.
 
Ell
of course
 
sbi
@Xeo Catch another overload...
 
Ell
I'm so noob
2
 
Xeo
@sbi heh
 
@Xeo Won't be unless explicit.
 
Xeo
5:03 PM
@R.MartinhoFernandes Hm?
 
Oh, nevermind.
 
sbi
@R.MartinhoFernandes 'is_same' is not a member of 'std' Fuck. Well, I can write this on my own.
 
@sbi boost.
 
Xeo
@sbi std::tr1::is_same
 
or that.
 
Xeo
5:04 PM
<tr1/type_traits>
 
sbi
@Xeo I am currently trying this.
template argument 1 is invalid Not very helpful.
 
You borked some angle bracket.
 
sbi
I don't think so. But wouldn't this !std::tr1::is_same<T, std::string> need some ::value or something similar at the end?
 
There is one in my example!
 
@BartekBanachewicz you want to help me with something, right? :D
 
Xeo
5:07 PM
Robot's too spoiled from his EnableIf
 
@Pawnguy7 sure, if I can.
 
6 mins ago, by R. Martinho Fernandes
typename std::enable_if<!std::is_same<T, std::string>::value, bool>::type f(...
@Xeo It's right there!
(Don't you history me)
 
Ok, so um, I was working on that blending thing.
 
Xeo
@R.MartinhoFernandes Well then, let's take a look at the history...
 
And it worked, but... it was very inefficient, - outright wasteful, actually - and, um
 
sbi
5:08 PM
@R.MartinhoFernandes I wonder how I lost that. I copied it from the browser window. Mysterious.
 
It was blending the end of both, rather than the end of the one it was on and the beginning of the next.
So, I, um, changed stuff... and it broke.
 
@Pawnguy7 slower, sugarcube.
 
sbi
Anyway, it seems wrong: type/value mismatch at argument 1 in template parameter list for 'template<class Cond, class T> struct boost::enable_if'
 
Oh, boost.
 
First thing, I have no idea what blending thing you are talking about.
 
5:09 PM
Use boost::enable_if_c then.
 
sbi
Where's enable_if in TR1?
 
Um...
Like that.
 
@Pawnguy7 I don't know what's the desired output, so it's really hard to help you at this point. It's blended, no?
 
Xeo
@sbi <tr1/type_traits>
 
It is. That was the old version.
There were two issues.
 
5:10 PM
wtf was that
 
First, it blended the end of the old generation with the end of the new.
Which means, as soon as it starts at the start, all the blocks change. It should blend with the start of the next one.
 
Xeo
@R.MartinhoFernandes Or just boost::disable_if<boost::is_same<T, std::string>, bool>
 
And second, I calculated the color for all blocks, rather than just what was in view.
 
@Pawnguy7 I still have no idea what you're talking about.
Let's make a deal.
I'll go grab a burger, and you will write it in your notepad
 
I should leave.
 
5:11 PM
I'm back, I read it and help ya.
 
Xeo
Have fun
 
@R.MartinhoFernandes catch!
 
sbi
@Xeo 'enable_if' in namespace 'std::tr1' does not name a type :(
 
Xeo
@sbi wut
 
And yes, I know it is a tad ugly.
 
sbi
5:12 PM
@Xeo Remember, this is a rather old GCC.
 
@Pawnguy7 I meant write what it's s'posed to do, not the code.
 
Xeo
@sbi Well, if you have Boost anyways
 
anyway, I gotta go.
 
Ah.
 
Xeo
1 min ago, by Xeo
@R.MartinhoFernandes Or just boost::disable_if<boost::is_same<T, std::string>, bool>
 
5:12 PM
Okey.
I can do that.
 
sbi
@Xeo template argument 1 is invalid Fuck this.
 
Xeo
oO
Code?
 
sbi
template<typename T>
typename boost::enable_if<!boost::is_same<T, std::string>, bool>::type
f( const std::string& foo, T& bar, some_enum foobar, const another_enum baz = some_traits<T>::baz);
 
Xeo
No !
Read again
boost::disable_if
 
sbi
Ouch. I understand.
Can't negate a type name.
 
Xeo
5:15 PM
Aye
Either boost::bla_if<trait<T>> or boost::bla_if_c<trait<T>::value>
 
Ell
I thought you had to do ::value on is_same?
 
sbi
I suppose there's a boost::not<>, too?
@Ell boost::bla_if_c<trait<T>::value>
 
Xeo
boost::bla_if does it implicitly (i.e., in the implementation)
That's why there's bla_if_c
@sbi I'd assume so, somewhere
 
sbi
Compiles now! Thanks, folks. Now lemme check if it prevents the wrong code from compiling...
 
Xeo
Btw, if you do have yet another overload with const std::string& as the second parameter type, this will get trickier
 
sbi
5:19 PM
@Xeo I have. Tell me.
 
Xeo
T can be either std::string or std::string const now
is_same<T, std::string>::value || is_same<T, std::string const>::value :/
 
sbi
Mhmm. Either this doesn't prevent the overload from getting picked or it picks another one....
 
Xeo
@sbi Oh
It may pick the std::string const& one, since that's not a template
And is a better match than the template.
But I'd have to see the overloads to be sure.
 
Oh.
I think I may have just realized what the problem was.
 
sbi
@Xeo Sounds unlikely:
template<typename T>
typename boost::enable_if<!boost::is_same<T, std::string>, bool>::type
f( const std::string& foo, T& bar, some_enum foobar, const another_enum baz = some_traits<T>::baz);
bool f( const std::string& foo,       std::string& bar, std::string::size_type size, some_enum foobar);
bool f( const std::string& foo, const std::string& bar, std::string::size_type size, some_enum foobar);
 
Xeo
5:23 PM
Do you need special handling for the non-const std::string or why the overload, btw?
 
sbi
@Xeo Yep. I need a non-const version to allow write-access to the string, but I need read-only access for const strings, too.
 
Xeo
mh
 
erm... if I have template<int size>struct foo{} and want function bar to take a foo (but doesn't care about the size) do I have to declare it like template<int size>void bar(foo<size> theFoo);
 
Xeo
yes
@sbi hm
Are those all overloads involved?
 
is there not a way to say 'I want to take a foo, but do not care about the template aspect of it'
 
Xeo
5:25 PM
What?
 
sbi
@Xeo No! There's a dozen more. I am currently commenting out as many as possible, but many of them are used in this code.
 
Xeo
@sbi You should try an SSCCE for this
 
@BartekBanachewicz pastebin.com/7FyDXbJV
 
like just do void bar(foo theFoo) ?
 
Xeo
Also, a function with a dozen overloads? That kinda sounds nightmarish.
@thecoshman No
Every foo<N> is a differen't type.
 
5:26 PM
grumble grumble
 
sbi
@Xeo That'd be a lot of work.
 
Xeo
@sbi Why? Just make a new file with as little overloads as possible and go from there?
 
@Xeo I had a function with over 132 overloads once.
 
Xeo
@ThePhD operator<< for streams might come close to that
 
@ThePhD you would
 
5:28 PM
It was necessary!
It was a time when C# had no default arguments. :c
 
Xeo
Hahahahaha
Why do I not believe you.
 
I can prove it!
I still have the code!
.... I think...
 
Ell
@thecoshman template<class foo_t> myfunc(foo<foo_t> afoo) ?
 
Aww yiss 215/200 rep :3
 
Xeo
@Ell whatno
 
Ell
5:29 PM
why not? I'm noob. teach me :P
 
Ell
@xeo If he just wants a foo of any type, what's up with this?
 
@Borgleader Oh, so now would be a great time for me to upvote all your questions?
 
Brix were shat /cc @ThePhD
 
Haha.
 
5:30 PM
Watch dat video
 
@Borgleader New challenge: try to break 300...
 
sbi
Ok, now I have added back enough overloads so that the code compiles, but now I am back at the code compiling which wasn't supposed to compile...
 
lol I'll need more accepted answers... or a bounty
 
sbi
Ah. By renaming the overloads I can confirm that it didn't pick the one with the disable_if. Good.
Damn, why can't I compile individual .cpp files in Eclipse?
 
use make files?
And ohai!
 
Xeo
5:35 PM
y u use Eclipse :/
 
@TonyTheLion axe a Bartek
 
sbi
@Xeo Because it's better than the proprietary IDE the platform vendor provides (based on an old Eclipse version, BTW), and because Björn hacked a SCons build system into this.
 
JBL
> than the proprietary IDE the platform vendor provides
Why so shy ?
 
Xeo
That sounds kinda horrible
 
@sehe oh
 
5:37 PM
@ThePhD I'm not surprised. I think that was in a pastebin of you once.
 
Xeo
@sehe I had a pastebin with a 77-parameter function once!
 
@sbi Ah. So, it's more like: "Why is the SCons script not smart enough to build a single file?"
 
!!!
NORMAL SEHE IS BACK!
 
@Xeo Yeah, but that was on purpose :)
 
IT REALLY IS JULY 4TH. <3
 
5:38 PM
@sehe is in the house :D :D :D :D
 
Normal? What a weird definition you use
 
JBL
@ThePhD His not- license has actually expired this time ?
 
@JBL Absolutely NOT
 
JBL
Haha !
 
I just decided to be-polar again :/
 
sbi
5:39 PM
@sehe Having used, so far, BCC, BCB, and VC, I want to right-click a file in the project explorer and say "compile!"
 
@JBL July 4th - America liberated @sehe from his not- license through not-DDay. We lost many good soldiers, but we managed to free the polar bear from his paperclip jail.
 
@sehe bipolar FTFY
 
Xeo
@sbi cl.exe /EHsc /Wall blah.cpp!
 
This is a great day for America. Fuck Yeah!
 
Xeo
or equivalently g++ -Wall blah.cpp
 
5:41 PM
Fuck america, this is such a great day I can bearely express it :P
 
sbi
@Xeo That's VC. I am using GCC in Eclipse. Also, with all the include paths etc., a compile invocation has about 1k of a command line.
 
So sehe finally came back to its original account. Good.
 
Xeo
@sbi You should really just create an SSCCE for those dozen overloads. Seriously, how hard can it be?
 
I got banned for 30 minutes :(
 
@Borgleader Ah, so it's on-the-fly tessellation.
Woo.
 
sbi
5:47 PM
@Xeo You have no idea.
Ah. so this is the overloads:
template<typename T>
typename boost::enable_if<!boost::is_same<T, std::string>, bool>::type
     f( const std::string& foo, T& bar, some_enum foobar, const another_enum baz = some_traits<T>::baz);
bool f( const std::string& foo,       std::string& bar, std::string::size_type size, some_enum foobar);
bool f( const std::string& foo, const std::string& bar, std::string::size_type size);
f("blah", str, some_enumval) picks the latter one, converting the enum value into a std::string::size_type.
Is there anything I can do to prevent that?
Fuck, excessive overloading is always a pain in the ass.
 
Xeo
@sbi Scoped enums would be really helpful here :/
 
// I sometimes use something like this to prevent
template<typename T>
void f(T t)
{ f_impl(t, std::common_type<T>()); }
void f_impl(my_enum e, std::common_type<my_enum>) { ... }
void f_impl(int  i, std::common_type<int>) { ... }
 
sbi
@Xeo I don't have the nerves to whine about not having C++11 tonight. I want to go home.
@StackedCrooked Some traits that's used in an under-the-hood overload dispatching?
 
@sbi Yeah.
 
sbi
Mhmm.
 
Xeo
5:57 PM
@sbi std::common_type is just used in lieu of std::identity.
You can also use template<class T> struct type{};
 
Right.
 
Someone just accused me of showing code that does not compile. I even copied the output. The internet amuses me sometimes.
 
Because there is no std::identity.
 
Xeo
@StackedCrooked :(
 
And from cppreference:
> With a single template argument, std::common_type<T>::type is exactly T, which makes it the C++ equivalent of boost::identity<T>
 
5:59 PM
I have a bounty on my question: stackoverflow.com/questions/17409964/…
 
The original trick I learned from Johannes.
 
if anyone would like to answer.
 

« first day (992 days earlier)      last day (3965 days later) »