« first day (478 days earlier)      last day (4468 days later) » 

12:00 AM
@Xeo Can't fathom it.
 
Xeo
And Clang juse ICEing here isn't a great help either
 
You could try some saner SFINAE without arrays. ideone.com/uNTNJ
(Yes, it doesn't explain anything)
 
@Xeo int(*)[sizeof(obj.stream(os),char())] = 0 is some interesting way to detect the presence of a member function/signature :). That has got to be today's most obfuscated use of the comma operator
 
Xeo
@RMartinhoFernandes There was a reason for the array - I didn't want to use decltype. The sizeof version is going to be another option in an answer. :)
 
Xeo
12:06 AM
@RMartinhoFernandes Or rather, it was going to be
No wait, it can still work
 
I use a template <size_t> struct blah {};
 
Xeo
@sehe Only works in C++11, though. :(
 
@Xeo Or GCC.
-4
A: Need assistance with algorithm to find the maximum value in a tree

EvilTeachthe best algorithm would be to open the file, set a counter to 0. read each line in the file. for every line you read, increment the counter. close the file. that counter is your answer. The best algorithm for representing the tree would be nothing. As you are not actually doing anything ...

 
Xeo
@RMartinhoFernandes Err, the expression SFINAE addition to decltype, sizeof was only added in C++11
 
@Xeo The second snippet worked for me:
 
12:07 AM
Wow, totally unrelated shit.
 
sehe@natty:/tmp$ g++ test.cpp
sehe@natty:/tmp$ ./a.out

X::stream()
(gcc 4.6.1)
 
@Xeo For sizeof it was made clear in C++11.
 
Xeo
@sehe That was expected. I wondered why the first didn't.
@RMartinhoFernandes Oh?
 
The problem was that it wasn't clear it should work.
 
Xeo
Oh, ok.
I'll just ask that as a question, meh
 
12:15 AM
lolwut?
 
Xeo
?
 
Why the extra parameter?
 
Xeo
@RMartinhoFernandes int and long?
 
Xeo
Well, guess what happens if both forms are available. :)
 
12:16 AM
Is it for ordering?
 
Xeo
Without the extra parameter, the overload resolution will fail due to ambiguity
Sadly, it doesn't seem to work through a constructor: ideone.com/0CffA
 
I need to be running Windows to download my Windows image. Fuck you Microsoft.
 
Xeo
lol
 
I can't possibly boot Windows, because I dropped my laptop and my hard drive is... broken-ish.
 
@RMartinhoFernandes your windows image?
 
12:22 AM
I wanted to download an image to install it on the drive I'm buying tomorrow, but I'm screwed.
@sehe Yes, the image of the Windows DVD that I have a license for.
 
@RMartinhoFernandes what kind of images can you download at ms anyway?
@RMartinhoFernandes Aha MSDN
 
Xeo
template<class T>
void serialize_imp(std::ostream& os, T const& obj,
    int = sizeof((os << obj),0))
{
  os << obj;
}
Too bad this doesn't work
 
I'll have to resort to piracy to bootstrap this... Sigh.
 
Xeo
@RMartinhoFernandes Well... what's with your Windows DVD?
 
@RMartinhoFernandes sounds like what I did last tiem to install Windows XP
 
12:23 AM
@Xeo Never had a physical copy.
 
Xeo
Ah, ok.
I made my USB stick bootable for that purpose, with my Win7 installer on it
(and live images)
 
I should have access to the darn licenses but they make it so damn hard to get one (I think i need to be on my company network for some kind of VLK server to be accessible. Obviously that all depends on AD - and there is none of that on my linux boxen.
After fuming for a few minutes, I googled 'WINXP 64 key' and pronto! got a working key from someones logfile or something
 
Well, I'm using MSDNAA. The site shows me the license key, but all I can download is an .exe bootstraper.
 
@RMartinhoFernandes you gotta love that "huh, other OS-es, do they exist?" mentality
 
Xeo
0
A: Is it possible to write a C++ template to check for a function's existence?

XeoThis question is old, but with C++11 we got a new way to check for a functions existence, relying on SFINAE again: template<class T> auto serialize_imp(std::ostream& os, T const& obj, int) -> decltype(os << obj, void()) { stream << obj; } template<class T&g...

 
12:27 AM
I could accept for stuff like VS or Office, or everything but Windows. After, you will need some form of Windows to run those.
But for Windows itself? They should assume I have nothing but links and wget.
 
Xeo
Wait a second. Are you just not allowed to download the image, or are you complaining because it's .exe?
 
@Xeo It's not an image. It's an exe that downloads the image.
I can't run the exe.
 
Xeo
Oh
Yeah, that funny thing.
Sigh, everytime I see this question, I have the urge to just comment "Except encapsulation, you mean?"...
 
> And I can #include a GLSL shader in my C++ code.
What???
#version 330

layout(location = 0) in vec3 position;
layout(location = 1) in vec4 diffuseColor;
layout(location = 2) in vec3 normal;

smooth out vec4 interpColor;

uniform vec3 lightPos;
uniform vec4 lightIntensity;
uniform vec4 ambientIntensity;

uniform mat4 modelToCameraMatrix;
uniform mat3 normalModelToCameraMatrix;
Good luck getting that to compile in C++ code (I mean, without macroing most of it out).
 
Xeo
@RMartinhoFernandes Damn, I was just writing those macros!
 
12:35 AM
@Xeo You can't solve the issue with #version though.
The preprocessor is off-limits.
 
Xeo
Right
Write your own!
 
@Xeo In that case, it's probably better to write a whole GLSL -> C++ translator. That way you don't need to hack stuff in C++.
I slept for an hour, woke up, feeling like science. Here's some math: x^3+y^3=z^3 has an infinite number of solutions, none interesting.
 
Xeo
The fuck! Suddenly, Clang compiles the SFINAE code: ideone.com/pVzD7
 
Obviously you have an overloaded operator, messing with your code :)
 
Both f() and g() return void, so I don't see how that's possible.
 
Xeo
12:47 AM
@RMartinhoFernandes comma inside sizeof
 
Yeah, but since it's void, int there's no way an overloaded comma gets in the way.
 
Xeo
Ah, that
I thought you meant my code
Okay, I finally know why Clang ICEs
 
Report it. I want that shit polished when I adopt it.
 
Xeo
Ahaha, interesting. Very interesting
 
How the hell can I get around to being productive in this cold :|
 
Xeo
12:56 AM
Quiz time! Find the difference:
template<class T>
auto test(T const& obj) -> decltype(obj, void()) {}
template<class T>
auto test(T const& obj) -> decltype(obj, void(0)) {}
Damn, too easy..
 
Is this a joke?
 
Xeo
Nope
That one initializer argument inside the parens "fixes" the ICE
And BTW, it's a GCC bug that the 0 doesn't convert to the array pointer when passed as an argument. Clang compiles fine
 
Makes sense to me. But I may have been exposed to ICE's over the daily recommended limit already.
 
And it's cold.
 
Yeah!
The nice thing I can say about my flat is that I have a nice, modern and well-insulated window.
 
1:01 AM
UB? functor()(++a)(++a)
 
Not anymore or any less than functor {}.named_member(++a).one_more(++a).
 
Which means? Yes or no?
 
Xeo
Yes
 
tell you what i see: a is incremented twice, then i see the two calls
 
Xeo
It's just defined that ++a is evaluated before the call to the function it's an argument of
 
1:09 AM
oh it's guaranteed to behave this way?
 
Xeo
The sequencing between those ++a is undefined
@wilhelmtell No, I clarified.
 
@wilhelmtell No. It could be increment first a, first call, increment second a, second call.
The only guarantee is that "increment first a" happens before "first call" and "increment second a" happens before "second call".
 
yeah. that's what i thought.
it took me a while to nail this bug and see that it was there.
 
Time to switch to std::next(a)!
 
That doesn't work!
 
1:12 AM
my code was like this
transact
    (insert << "sandy" << 6)
    (insert << "george" << 7)
    (insert << "paul" << 8);
 
@RMartinhoFernandes What doesn't?
 
and i was looking for a bug where i got three sandy/6 rows. this weekend i found it was actually there.
 
@LucDanton std::next(a) only works if a is an iterator.
 
@RMartinhoFernandes Who would use ++a instead of a + 1, or worse, rely on side-effects? I'm not so rude as to suggest that...
 
1:15 AM
std::next() changes its parameter so it's no help
 
But I meant that std::next(0) doesn't work.
 
@wilhelmtell You're thinking of std::advance.
 
(It does work, but it's not supposed to. Don't try it on Hell++)
 
Xeo
@wilhelmtell No, that's exactly not the case. std::advance does
@wilhelmtell: In other words, stay pure. :)
 
that's how nazi germany started </john-cleese-voice>
 
Xeo
1:18 AM
That's an interesting point of view. So pure functional languages are racists?
 
don't take me seriously. i just got pwned for an obvious ub, i shouldn't be taken seriously tonight.
 
Anything can happen!
So, I just wrote int main() { int& x = *(int*)0; } but it didn't order pizza. I guess I'll have to raid the fridge.
 
Xeo
Damn. Seems the bug I wasted 2 hours on to identify is already fixed in a newer revision -.-
 
I reported a GCC bug once, then several months later a maintainer closed it because at some point it was fixed.
But that's GCC so I guess it's only fair.
 
1:26 AM
> Zynga's coder workforce is 75% Brogrammer.
 
I'm tempted to change the topic to "we shit stars".
2
 
1:43 AM
feeling like (removed) because I was so focused on what i was doing that when the guy came in with my chicken order i just took it and forgot to pay tip. :( i really didn't mean to be a jerk, my mind was just elsewhere! :(
 
We don't have tipping rituals around here.
 
where's that?
 
Portugal. But I think it's the same in Europe in general.
 
to be fair nobody tips me for being on time to work every morning. but who am i to complain. the chicken was hot.
 
It's silly. If you need to pay it, it should be a part of the billed amount.
 
1:49 AM
I hosted someone recently from Switzerland that was adamant about tipping (which is news to me too as I've never tipped in Switzerland). Since this was Paris though, everybody was gracious enough to accept the tips without making a fuss.
 
Xeo
In Berlin atleast, it's normal to pay small tips. Especially for waiters.
 
Restaurants? Cafes? Bars?
 
 
1 hour later…
2:54 AM
Now resorting to wearing shoes indoor as the floor is just too cold.
 
Xeo
> LLVM is my name, optimization is my game. [from llvm Bugzilla quips]
 
Bad clang.
0
Q: expected ';' after expression

frareesI'm trying to port a project from Windows to Mac. I'm having troubles compiling the class CFactory. I'll try to illustrate the problem. Here's what I have on my Factory.h namespace BaseSubsystems { template <class T> class CFactory { protected: typedef T (*Functio...

Error message not good enough.
 
Xeo
@RMartinhoFernandes What?
 
@Xeo The error message. It looks like it came from GCC: complains about parser state, and thus is extremely confusing.
 
user406009
Why does it seem that MSVC seems to like allowing a lot of non-compliant code in?
 
Xeo
3:04 AM
Yay, that decltype(obj, int()) bug is fixed. Seems the buildbot I tested the snippet on before just didn't print that the compiler ICEd
 
@EthanSteinberg MSVC doesn't implement two-phase lookup.
When it sees a template it checks for matching braces (roughly) and moves on.
 
Xeo
@RMartinhoFernandes Wait, that's a message from Clang?
woot
 
@Xeo It's on Mac and has that ^ thing below the code to point. It's certainly not from GCC.
@Xeo What a coincidence, I got mine today too.
 
Xeo
That's interesting.
 
Well, yesterday.
 
Xeo
3:08 AM
@RMartinhoFernandes Ugh, I'll see if that's still the case for Clang 3.1 ToT
after llvm+clang finishes compiling, of course
[03:15:30] <Bigcheese> chandlerc: btw, anything you can say on how Windows Devs (not nesisarily people who work for MS) thought about clang?
[03:16:26] <+chandlerc> Bigcheese: jealousy
[03:17:03] <Bigcheese> chandlerc: heh, that's what I felt Herb was thinking when you actually explained that you already have refactoring tools working at google scale.
hrhr
 
user406009
What are the main new features in clang 3.1?
 
Xeo
All the good stuff
Lambdas, initializer lists, constexpr
 
user406009
Lambdas?
 
Xeo
Of course, lambdas are still in dev
Hm, I want to get rid of
And I want those and in silver
 
Tag popularity counts for displaying there.
So it might not be easy.
 
Xeo
3:13 AM
Damn. 28 upvotes and 15 answers away from silver
 
For me what takes longer seems to be the answer count.
I'm almost at rep for silver pointers, but now I need 60 more answers.
 
Xeo
I just scratched 100 upboats there
 
Xeo
3:32 AM
> 1,233 questions tagged
Sigh
> 99 questions tagged not
 
Xeo
3:50 AM
1
Q: Mass retag request for all [c++0x] tagged questions with [c++11]

XeoSince the approval of C++11 last year, many questions have been retagged from c++0x to c++11. However, there's still a lot left. Can we have a mass retag?

 
@Xeo Is the answer I posted to your question about exceptions from block-scope static initializers still missing something?
 
Xeo
I'm still not convinced by both your answers. :/
 
@Xeo Yes, but what's missing? The Standardese is fairly clear to me so it's just a matter of communication.
 
I have 255 rep on Meta.
I am almost eight bits.
 
@Maxpm The suspense! Will it overflow?
 
4:08 AM
Eight? Wouldn't that be nine?
 
Xeo
@Maxpm You are at eight bits. 1111 1111
@Potatoswatter Well, I think I gave all the details of why I don't think the answers are enough in the comments. :/
 
Nine.
011111111, two's complement.
:P
 
@RMartinhoFernandes error: 'boost::proto::when< ... >::result_type' has no member named 'foo'
With of course tons of stuff between those angle brackets.
That's the kind of unhelpful GCC error messages I was referring to some time back.
 
Xeo
@RMartinhoFernandes huh? Unsigned integer
 
@Xeo The last comment was left by me… it seems you misunderstood which text I was saying specifies the behavior in question.
 
4:14 AM
Says who?
 
Xeo
Me
 
> The behavior that initialization is retried is implied completely by "Otherwise such a variable is initialized the first time control passes through its declaration; such a variable is considered initialized upon the completion of its initialization." In other words, passing only partway through the initialization counts for nothing, and the second time still counts as the first time. Also, the very notion of a "try" is only introduced by "tried again."
 
4:26 AM
Interesting. Adding template<typename Sig> using result_of = std::result_of<Sig>; at class-scope makes your polymorphic functor type automatically compatible with Boost.ResultOf.
 
@LucDanton GCC has template aliases now?
 
It's not that recent but I've only got to work with them not long ago.
Also, that's GCC snapshots, not current release.
 
Shouldn't result_of just work with no extra effort?
 
Polymorphic meaning the return type is covariant? I guess I don't understand.
 
4:33 AM
std::plus<int> is a monomorphic functor type that only accepts int.
struct plus { template<typename L, typename R> auto operator()(L&& l, R&& r) const -> decltype(std::declval<L>() + std::declval<R>()); }; is a polymorphic functor type that accepts any pair of types that can be added together.
The mono/polymorphism in question here is regarding the type or types that the functor accepts.
 
@LucDanton That's what result_of exists to resolve, though. You shouldn't need member typedefs, just the operator() template/overloads.
 
?
8 mins ago, by Luc Danton
Interesting. Adding template<typename Sig> using result_of = std::result_of<Sig>; at class-scope makes your polymorphic functor type automatically compatible with Boost.ResultOf.
 
result_of does (for a class type) decltype( declval< functor >()( declval< args >() ... ) ).
So it resolves which overload you're using and gets the return type from that.
That's the purpose of passing in the argument types, as opposed to using the blind result_type member.
So I don't understand under what circumstances adding a member template alias would resolve anything.
Is this particular to how Boost does things as opposed to C++11?
 
Boost didn't have decltype.
 
According to the documentation Boost.ResultOf should indeed delegate to std::result_of if detected. But either it doesn't work properly, or some parts of Boost use a Boost.ResultOf-like protocol without using Boost.ResultOf proper.
So the template alias is a non-intrusive way to bridge the two. Hence why I find it interesting.
 
4:41 AM
@LucDanton You might just be emulating the internal interface that the other parts of Boost shouldn't be using…
 
@LucDanton #define BOOST_RESULT_OF_USE_DECLTYPE?
 
@RMartinhoFernandes Getting around to touch project settings but working at a snail's pace. My fingers are freezing off, just made some tea.
> /usr/local/include/boost/proto/detail/poly_function.hpp:190:58: error: no class template named 'result' in 'struct annex::comprehension::detail::make_fusion_pair'
 
#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE)
Boost only uses decltype if you explicitly tell it, even if detected.
 
> error: 'BOOST_NO_DECLTYPE' was not declared in this scope
 
4:46 AM
This is with #include <boost/utility/result_of.hpp>
Told you, it's just misleading documentation.
 
What did you do?
 
Include a bunch of stuff and work with it? It just so happens that it requires the Boost.ResultOf protocol.
 
Xeo
253
A: <kbd> elements are way intrusive

Hilarious Comedy Pesto                                                 &nb...

Awesome answer
 
Heh… are they using preprocessor macros as template arguments rather than using #if to selectively enable implementations?
 
-DBOOST_RESULT_OF_USE_DECLTYPE no typos, right?
 
4:48 AM
@Xeo Pesto spammed that like mad.
 
'-DBOOST_NO_DECLTYPE=0', '-DBOOST_RESULT_OF_USE_DECLTYPE' works as a hack. So I'm guessting it's a configuration problem.
 
Btw, regarding misleading docs, that #if thing I posted came from the source.
 
> If your compiler supports decltype, [...]
Of course I was misled.
 
Hi guys
 
@LucDanton btw, works with my snapshot + boost 1.48.
#define BOOST_RESULT_OF_USE_DECLTYPE
#include <boost/utility/result_of.hpp>

struct f {
    template <typename T, typename U>
    auto operator()(T t, U u) -> decltype(t + u) {
        return t + u;
    }
};

int main(){
    struct {} x = boost::result_of<f(int, int)>::type();
}
 
4:53 AM
> error: no class template named 'result' in 'struct annex::comprehension::detail::make_fusion_pair'
 
This correctly prints an error saying it can't convert int to anonymous.
> gcc version 4.7.0 20120107 (experimental) (GCC)
 
Your testcase has the same results.
 
@LucDanton Same as ...?
 
as yours.
 
Hmm. Strange.
 
4:58 AM
Boost.Proto simply doesn't use Boost.ResultOf I think. It's the same protocol, but no dependency.
 
Oh, well done.
 
struct result_of { template<typename Sig> using result = std::result_of<Sig>; };
struct make_pair: operators::make_pair, callable, result_of {};
 
Hmm, snapshot is a month old. Time to roll forward.
 
Instead of just using operators::make_pair;. Surely there are worse things in life than this code.
 
@LucDanton The typedef is supposed to be result, no?
 
5:00 AM
@RMartinhoFernandes Well no. The typedef is result_type. Failing that, nested template named result.
Which itself has a typedef named type.
typename some_polymorphic_functor::result<Signature>::type
Finally went with struct polymorphic_functor: callable { /* alias goes here */ };
struct make_pair: operators::make_pair, polymorphic_functor {}; is not so bad.
 
Xeo
What's callable?
 
boost::proto::callable
Disambiguates whether foo(bar) is what Proto calls an object transform (object construction) or a callable transform (functor call) in one of its EDSL. (Because Proto uses several EDSL to help you construct EDSLs.)
 
Xeo
Ah, okay
@RMarthinho: Here's the output regarding the typename question earlier btw:
t.cpp:7:3: error: missing 'typename' prior to dependent type name 'T::type'
  T::type i;
  ^~~~~~~
  typename
I could swear this is a duplicate
4
Q: Is it possible to destroy and re-create an object this way?

MartinConsider T* o = new(T()), where T has a copy constructor defined. Also suppose expression new uses the default ::operator new() To re-use the memory allocated for o, instead of deleting the object with delete o, does the standard allow the following sequence:  call o->~T() explicitly u...

 
Xeo
@RMartinhoFernandes I can't stop grinning whenever I read those comments.
@RMartinhoFernandes Also note that that's not exactly a duplicate. The OP here has specifically new'd the object.
 
5:16 AM
It suffers from the same problem though: if the ctor fails, the object is already gone.
 
Xeo
True enough. And he even gets a memory leak then!
And if he puts it in a smart pointer, well, same situation as the other Q
 
@Xeo In a sense, it is in a smart pointer: the map will call the destructor one day.
 
I laugh at all the stared subjects to the right
 
Xeo
@RMartinhoFernandes Not if the map was new'd :>
 
Who would do that?
 
Xeo
5:18 AM
Somebody (me), just to have you wrong.
 
would just dropping delete altogether and switching to explicit dtor call and free() work?
I mean, don't mean containers and such, just simple case
 
Xeo
@AzzA Err, never mix C++ allocs with C allocs
If you want to manually call the dtor and then release the memory, use ::operator delete
 
The problem is the ctor. Since you delete before the construction, there's a moment when you have no object.
 
@Xeo True that
@RMartinhoFernandes but i still have pointer and memory... which i can just free
 
Anything goes wrong during that moment (i.e. the constructor) and bad things happen.
@AzzA But now you have to mark that space as "when the time comes don't call the destructor".
-1
A: Is it possible to destroy and re-create an object this way?

GigiThe code: #include <iostream> #include <string> struct mine { mine() : value(0), text("no") {} int value; std::string text; }; int main() { mine* m = new mine(); m->value = 1; m->text = "hi"; m->~mine(); m = new (&m) mine; std::cout << m-&...

lol, fail.
 
5:23 AM
The thing is , though, regarding some form of free() and delete... I agree with you Xeo, calling ::operator delete is in the spirit... But If I know which memory function is used to alloc/free, is there ANOTHER source of harm, except for possible portability issues?
 
You can gain a lot of insight simply by watching this chat
 
@AzzA The problem that needs solving is this: if reconstruction succeeds you need to call the destructor, regardless of how you allocated. But if it fails you cannot call the destructor.
The deallocation will be done either way.
 
@RMartinhoFernandes the guy omits ANY memory deallocation altogether... in the answer you quoted... I guess, that's one way to go about it...
 
Yeah, leaking solves that problem.
 
Xeo
Great
/usr/include/c++/v1/ratio:193:19: error: static_assert expression is not an
      integral constant expression
 
5:32 AM
> vim: error while loading shared libraries: libpng14.so.14: cannot open shared object file: No such file or directory
Wait, what?
 
Check ldconfig?
 
Why does vim need libpng anyway?
 
For PNGs, duh.
 
Erm.
Oh.
I got it.
vim, view, gvim, etc, it's all only one executable.
It picks its "mode" from argv[0].
 
Xeo
gvim == vim -g, right?
 
5:34 AM
libpng is for gvim.
 
Coming soon: Vim Office
 
TWL.
 
@Xeo Or ln -s gvim vim
I can't live without vim. WTF happened?
 
user406009
libpng got updated?
 
Xeo
@RMartinhoFernandes Conspiracy from the Emacs guys.
 
5:37 AM
@EthanSteinberg Oh, right. I left an update running on another terminal.
Shit, I this update is bad. Firefox is broken as well. I need to revert to 14.
 
user406009
What sort of unstable distro are you running? My libpng is still at v12.
 
Xeo
Great, Clang update broke libc++. :(
 
lol
Note to self: don't perform updates when you're sleepy.
Yay, vim is back.
I can still live a happy life.
 
The lack of algorithms for std::tuple is hurting me for the first time.
 
@EthanSteinberg I'm using Arch.
A "rolling-release cutting-edge distribution".
 
5:53 AM
Guess I'm switching to Boost.Fusion for this one.
 
You can grab the adapter I wrote and fix the corners (yes, it has bugs, and I know it, and I'm not fixing them).
 
Did that adapter end up shorter than initially expected?
 
That is a lot :/
 
And I no longer remember what the issues were.
 
Xeo
5:57 AM
Can anyone parse this question?
 

« first day (478 days earlier)      last day (4468 days later) »