« first day (471 days earlier)      last day (4479 days later) » 

11:00 AM
@IntermediateHacker So someone discovered function pointers, what's the big deal?
 
@IntermediateHacker that pretty much sums up why I dislike programming in C though: I basically end up re-implementing all the nice features of C++ in a crude way for every program.
 
@awoodland well, they didn't make C++ for the fun of it :P
 
Is this a good class interface? Does it need documentation?
 
@StackedCrooked can the constructor throw?
 
11:11 AM
and what does inURL represent? I.e. what's valid to use for an inURL? is it just hostname or IP address?
(my first thought was "on my system unsigned is a lot bigger than what you can put in the port field in a UDP header)
 
inURL can be an IP or an URL.
Perhaps unsigned short is a better choice for port number.
 
erm... is not UDP 'connectionless' ie, you just send data with out having a fixed tunnel for it. Rather then TCP that requires you handshake and set up the connection first
 
URL = "file:///home/foo/bar"? or "http://foo.bar.com"
@StackedCrooked I'd use one of the types that can hold at least 16bytes, but not one of the only 16bytes types
 
Both are URLs. I don't know if file url can point to a local server..
 
@StackedCrooked passing an HTTP URL to a UDP client seems odd
 
11:16 AM
URL can be resolved to IP.
@awoodland What would you suggest?
 
@StackedCrooked I'm not sure. I think either I'm not getting what you're doing in the implementation, or URL isn't the right term
 
well, I think he is getting at the fact that you would want to use TCP for HTTP, in fact, HTTP might even dictate that TCP is used
 
Boost asio samples use the names "host" and "port". Perhaps that is better.
 
RFC 2616: HTTP communication usually takes place over TCP/IP connections. The
default port is TCP 80 [19], but other ports can be used. This does
not preclude HTTP from being implemented on top of any other protocol
on the Internet, or on other networks. HTTP only presumes a reliable
transport; any protocol that provides such guarantees can be used;
which explicitly forbids plain UDP
host makes sense
that could be an IP address or a DNS name
 
host does make sense, your client connects to a host
 
11:24 AM
@thecoshman It's UDP server and client. I didn't mention HTTP.
 
@StackedCrooked it because @awoodland was mentioning use of HTTP urls
 
I guess the term URL implied HTTP. My bad.
 
URL dose dictate HTTP, it is just that most of time, we use HTTP
 
Xeo
Mornin'
 
though URL dose imply that you are accessing a particular resource, rather then just a server you are connecting to
 
11:28 AM
Hmm... ...I'm beginning to think I can drastically reduce my C++ code size if I use Boost's tuple (with typedefs) in place of my struct-like classes... ...may be worth a try
 
@StackedCrooked also, what is private: struct Impl; boost::scoped_ptr<Impl> mImpl; for?
 
(code size in terms of loc)
 
@kfmfe04 'struct-like classes' what does that mean?
 
classes that shouldn't be really be classes - more like records
(no need for encapsulation - just holding data)
 
@kfmfe04 reduced loc usually means simpler code, which makes for more maintainable code
 
11:30 AM
@thecoshman that's exactly my thought
 
ooh, your using that odd mentality that if it is a simple data object it should be a struct whilst if you are performing logic on it it should be a class
plus, if Boost have already solved something for you, why redo it your self
 
@thecoshman most of my code can be split up into real classes (with encapsulation) and record-like data-structures - I should be able to clean up the latter - going to experiment with boost tuples now
@thecoshman exactly my thoughts - if boost tuples can return by value and can copy-construct (I'm 99% sure they can without looking at the code), I should be fine
 
well then, of to work with you :D
 
yes - I take the POV that if a class just seems to be 95% getters and putters, it's not really a class
I wonder if tuples will ever make it into the std...
seems to be in cppref
 
Xeo
@kfmfe04 Huh? They're already there.. oO
 
11:36 AM
well it depends, you could have a class that only has getters and setters. It's mostly when you have data that can't be stored, or you don't need to store. let's say erm... storing a hash of some data, if you only ever need to "storeThis" and "getHash" then just store the hash (exceptions apply ofc)
 
@Xeo nice - going to check if it's in 4.6.1
 
ahh! Stupid cats. They so cute, but give me the sniffles for ages!
 
Xeo
@thecoshman Ooh, allergy?
 
@Xeo yeah, but not too bad
though it could just be a dusty house ¬_¬
 
12:00 PM
@kfmfe04 most definitely. Otherwise, boost tuple is at your disposal, but G++ uses variadics in it's libstdc++0x version
 
12:12 PM
@thecoshman it uses the Pimpl idiom.
 
Interesting question:
1
Q: Can C++11 bind type check at compile time?

user643722Is it possible to statically type check the arguments given to std::bind? I'm tempted to use it, but it lets me away with almost anything; for example, std::bind(1,2); is accepted. Alternatively I could roll my own solution using std::result_of.

 
12:43 PM
@StackedCrooked go on...
 
Xeo
@rubenvb The fact that libstdc++ and libc++ actually allow bind(1,2) is far more interesting, imho.
 
oh ok... so from a very short read over Pimpl, why would you do that?
 
Xeo
Anyone with GCC 4.7 here?
 
Sorry GCC 4.7 is at home on my Fedora VMWare install
 
12
Q: How can I implement a C++ class in Python, to be called by C++?

hal3I have a class interface written in C++. I have a few classes that implement this interface also written in C++. These are called in the context of a larger C++ program, which essentially implements "main". I want to be able to write implementations of this interface in Python, and allow them ...

any boost python users fancy a 100rep bounty for adding the alternative to my SWIG answer there?
the current boost.python answer isn't very detailed..
 
12:56 PM
that stuff is way over my skill level
 
@Xeo shoot, I have 4.7
 
Xeo
@rubenvb int main(){ std::bind(1,2); } with #include <functional>
 
In file included from test.cpp:1:0:
m:\development\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/functional:1521:5: note: template<class _Func, class ... _BoundArgs> typename std::_Bind_helper<std::__is_socketlike<_Func>::value, _Func, _BoundArgs ...>::type std::bind(_Func&&, _BoundArgs&& ...)
m:\development\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/functional:1521:5: note: template argument deduction/substitution failed:
m:\development\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/function
 
@rubenvb ಠ_ಠ
 
evil gcc error messages ftw!
 
Xeo
12:58 PM
@rubenvb lol
 
Haha, Clang is awesomely nice in this case:
test.cpp:2:13: error: no matching function for call to 'bind'
int main(){ std::bind(1,2); }
            ^~~~~~~~~
M:/Development/mingw64/bin\..\lib\clang\3.1/../../../include/c++/4.7.0\functional:1547:5: note:
      candidate template ignored: couldn't infer template argument '_Result'
    bind(_Func&& __f, _BoundArgs&&... __args)
    ^
M:/Development/mingw64/bin\..\lib\clang\3.1/../../../include/c++/4.7.0\functional:1520:5: note:
      candidate template ignored: substitution failure [with _Func = int,
same header btw, both are libstdc++
 
Xeo
Ah, SFINAE
Seems recent version of libstdc++ fixed the behaviour
 
let me check 4.6
It's a compiler bug it seems, not the library; Clang on 4.6 libstdc++ gives me the same error, g++ 4.6.3(ish) is happy with it.
 
Xeo
Hm, Clang TOT with 4.2 libstdc++ gives me a whole slew of strange errors
 
well, 4.2 is stone age... To be expected.
 
Xeo
1:06 PM
heh
But GCC 4.2 itself is fine
 
does that even have a c++11 mode?
 
Xeo
Sure
 
Really? This mentions zaroo features for GCC 4.2: gcc.gnu.org/projects/cxx0x.html
You're probably messing with hacked together C++03 tr1 stuff
 
Xeo
Oh, wait, it's GCC 4.4.5 :'D
 
lol. Clang web page says it needs a patch to work.
 
Xeo
1:23 PM
Hell yeah, 2 days countdown till GoingNative 2012!
 
Xeo
> “Do not accept from an iPhone lest you corrupt the invite for everyone!”
lol
 
@Xeo what the hell?
 
Xeo
From the interview @TonyThePervert linked
 
I see :S
 
1:30 PM
pervert? It seems I missed something
 
Xeo
@rubenvb You missed how he pops up every single time "sex" is mentioned in any way?
 
> char* strstr(char* haystack, char* needle)
I can't parse that
 
@Xeo well, in his defence, he's far from alone in here in posessing that... skill
 
Xeo
@Abyx Why not?
 
AAArrgh my chaotic balanced neural network won't balance!
 
1:33 PM
@Xeo did you seen that function implementation?
with two loops, three ifs and one break?
 
Xeo
@Abyx No... ?
 
@Xeo oh is that my new name?
 
Xeo
@TonyTheLion Yes, you're going to change to it. You just don't know yet.
 
@Xeo it's from that interview
 
@Xeo lol
 
Xeo
1:35 PM
Oh, I didn't read that far yet
 
char* strstr(char* haystack, char* needle) {
    for (;; ++haystack) {
        char* h = haystack;
        for (char* n = needle;; ++n, ++h) {
            if (!*n) return haystack;
            if (*h != *n) break;
        }
        if (!*h) return NULL;
    }
}
 
@thecoshman The implementation is in the .cpp file.
 
1:49 PM
well fuck me, transistors that are only 9nm :O
 
so you could take a deep breath and accidentally inhale half a computing device?
 
@thecoshman I realized that when I first got a hold of a 4GB microsd card.
 
9nm, 30nm, potato potàto
same order of magnitude
 
well... 30 is a tens of nm rather then just nm, so its one order of magnitude larger
 
1:58 PM
9 nm \approx 10 nm = 10^-9 m ~ 30 nm, sheesh.
where's the LaTeX when you need it
 
but I doubt we will see any mass market products with those transistors in the next ten years
 
@rubenvb meh
 
2:17 PM
So after the transition, will they rename Silicon Valley to Carbon Nanotube Valley?
 
@CatPlusPlus o_0 did you just spend the last ten minutes thinking that up?
 
No, I just woke up.
 
thecoshman is in a bad mood
 
@rubenvb am I? this is news to me
 
ouch, and this is why too much abstraction hurts readability: stackoverflow.com/questions/9065298/…
seldom has so much code been written to achieve so little
 
user406009
2:30 PM
And the quote from the questioner when asked why he is writing Java in C++:
 
user406009
> Unfortunately I'm stuck with C++; I can't switch to Java (although I'd love to as C++ is driving me crazy ;) ) –
 
| Unfortunately I'm stuck with C++; I can't switch to Java (although I'd love to as C++ is driving me crazy ;) ) – Sebastian Krysmanski 21 secs ago
Hehe. That was quite a notable comment.
 
user406009
Perhaps C++ would not be as bad if he actually wrote real C++.
 
Xeo
@jalf Either I'm overlooking something, or everything should be fine with that code. He's just returning a reference to the base pointer all the way through
Ah, wait. It's indeed a local variable
 
well, I'm not complaining about what the code does, but that he's using 50 lines of code to do what could be done in 1
 
Xeo
2:34 PM
Heh
 
user406009
@Xeo But it's a local reference variable.
 
help the poor sucker
remove that &
he probably doesn't understand "return-by-value"
 
Xeo
@EthanSteinberg Exactly, derived ptr -> base ptr conversion
 
user406009
Oh, the compiler is sneaking in a local variable?
 
user406009
To extend the temporary resulting from the cast.
 
Xeo
2:35 PM
A temporary
Exactly
 
user406009
Darn sneaky compilers. Do what I mean, not what I type.
 
Lol ReferenceProvider.
 
typedef ChildClass* ChildClassPointer; wtf
 
1 minute later and 2 more answers which overlap quite a lot with the first one. Is that common for SO?
 
Xeo
0
A: Strange C++ reference invalidation on return

XeoTo explain what's going on: const BaseClassPointer& val = g_somePointer; This line is the problem. Let's do away with the typedef: BaseClass* const& val = g_somePointer; Here, the type of g_somePointer is ChildClass*. In order to assign it to a BaseClass*, a conversion is needed. Fr...

 
2:38 PM
@rubenvb looks like the sort of vomit code MS write
 
@thecoshman the typedef'ed name is actually longer than the real type. derps
 
@John Yes.
 
I think the felt that * might confuse people
 
aaaaah pointers. Run for your lives!
 
why did I put that * in ` I will never know :(
 
2:40 PM
enjoy listening and programming youtube.com/watch?v=NrHKwBl8DQY ))
 
I hope this plays, grooveshark has been shity for me all day :(
wtf! How can youtube stream audio and video seamlessly yet grooveshark fail to send more then 5 seconds at a time
 
Crappier CDN?
 
Xeo
@thecoshman Be happy that you still have grooveshark at all. They cancelled their service in Germany
 
@Xeo laggy groove shark is ... youtube just cut out due to lag... not much better then no grooveshark
 
Xeo
> @jalf: I don't see your point. Just like I said, it's an example. And are you telling me that in your opinion C++ programs should work without inheritance? Seriously? I thought this was the point of C++. – Sebastian Krysmanski 2 mins ago
lol
 
2:48 PM
@Xeo lol, where did he say that?
 
Xeo
Comment on his question
 
I assume you where saying something like inheritance is tool that you can use, not something to try and shoe horn into everything
 
Xeo
Just read for yourself: stackoverflow.com/q/9065298/500104 :P
 
user406009
@Xeo Rapping on printf? Printf is the best way to format stuff.
 
thanks :D
 
Xeo
2:52 PM
@EthanSteinberg And it's so type-unsafe, it's not funny anymore.
 
printf is broken and should never be even mentioned.
 
Xeo
He's clearly a beginner, and as such should stay away from the C libraries.
 
user406009
Well the idea, format strings, are very nice. Printf is a somewhat bad implementation of format strings, but that does not mean the concept of format strings is bad.
 
Xeo
Nobody ever said that. :P
 
Nobody said that.
 
Xeo
2:54 PM
There's Boost.Format for example
 
Pascal or C for teaching procedural programming?
 
Xeo
std::cout << boost::format("Hi! Age: %1% years, Height: %2% cm\n") % 20 % 190;
There, type-safe formatting. :)
 
user406009
What exactly is "procedural programming"? All languages have functions and use them.
 
Well, Pascal if those are only two options. But some modern dialect.
C sucks.
// first thing Eigen does: stop the compiler from committing suicide
#include "src/Core/util/DisableStupidWarnings.h"
3
Lol.
 
Xeo
2:57 PM
lol
 
I'm asking because I want to try to write an introductory tutorial. C++ seems to complex. Any other ideas?
 
Xeo
C++
 
What seems too complex?
 
Everything about C++
 
Xeo
> But in my case I need to use OOP. – Sebastian Krysmanski 1 min ago
Anybody else not believing this guy?
 
user406009
2:58 PM
Random question: Considering looking into policy template programming as a style for my next trial project. Looking at wikipedia it seems like the whole code has to be practically header only. Is that correct?
 
Also, what's procedural programming, anyway?
 
I don't want to teach C++, I want to teach procedural
 
If you have a data structure and set of functions that operate on it, then it might as well be OOP.
 
Xeo
The only difference really is encapsulation
 
The distinction between functional and imperative programming is useful. Procedural/OOP/whatever, not so much.
 
3:00 PM
Yeah, I guess imperative is more what I'm looking for
Just without OOP
 
Xeo
Why?
 
C++, Go, whatever. I'm not big with paradigm theory, anyway.
 
wow, my work has really good ping, and pretty good up speed, but good god is the down speed terrible!
It's like being able to transport the library of congress via rockets in order to detail which letter of the alphabet you want sent back to you in response
 
Xeo
@thecoshman Have a round-mail to everyone to stop loading porn.
 
hey guys,, which one is more powerful , WinAPI or Qt?
 
Xeo
3:03 PM
Hey guys, which one is more blue, apples or oranges?
 
@ddacot well, the WinAPI is like having teeth pulled.
 
Xeo
@ddacot You need to specify the environment and context. :P
 
not that I have used Qt, or had teeth pulled
 
I don't know about WinApi, but Qt is pretty cool. Tons of Widgets, Threading, networking and stuff
 
@Xeo red apples or green?
 
3:04 PM
Doesn't matter which UI library you'll pick. You'll hate it after a week anyway.
6
 
Xeo
GUI programming in C++ is still a disaster.
 
I wish it was easier to make browser based GUIs for applications
 
Yuck.
 
well, I've never really tried to make a proper application that is controlled via a web page
 
@CatPlusPlus let's say for a windows app, which of them (qt , winapi) has more feature and is more powerful? )
@CatPlusPlus lol))))
 
3:06 PM
Neither.
Or both.
Whatever.
You probably don't want to use raw WinAPI.
It can make GTK+ look nice sometimes.
 
@CatPlusPlus well, I know how to lay things out in HTML/CSS rather simply
 
Don't webify things that don't make sense webified.
 
@CatPlusPlus true enough
 
@CatPlusPlus i would like to try qt, seems pretty nice. WinAPI's syntax is really messed up (imo).
 
though I still think HTML/CSS are a rather nice way of dealing with data, and presentation of said data
 
3:13 PM
htmlayout ftw.
 
just a curious question here... would it be possible, in theory, to create a distributed web server and database? One which has no central server, where not all the content is in one place rather it is duplicated across many servers providing a level of redundancy. A sort of swarm server that as long as enough people are willing to run the hosting software can not be just 'shut down'
 
@thecoshman The freenet project does that in some sort. You have sites, which get an ID and are then duplicated along the way they travel in the network.
but in a fully distributed way you may have to deal with problems on how to find stuff
the freenet project tried a new routing based on social networking behavior but their current implementation doesn't work that good
 
yeah, I guess you will almost always come back to the issue of how to index stuff. But if there was an entire 'internet' that was distributed in this way, you could have search engines as well.
I might look into freenet
lol, freenet.org is filtered at work :P
proxy avoidance :D
 
the website is freenetproject.org
 
yet another reason why I should sort out having an ssh server at home :P
ah, yes, that's the one I went to :P
not sure why I said freenet.org :S
huh, freenet is written in Java
 
3:34 PM
Another thing that falls within your topic are the algorithms for trackerless torrents. As long as you are part of the swarm you can use the DHT to find stuff.
 
user142019
Is there a term for a class that has always got exactly four instances?
 
user142019
Like a singleton, but four instances instead of one.
 
Fourgleton.
No, really, it sounds stupid.
 
Xeo
@WTP "useless"?
 
user142019
:p
 
3:46 PM
@WTP some random googling: "Quadrupleton" ideasgroup.org/foundation/index.htm?goto=2:1:7:285
hmm but doesn't seem to include code
 
user142019
I have such a class right here.
 
user142019
@John thanks!
 
Hey Peeps.
 
user142019
Hello.
 
It seems also featured on the portuguese uncyclopedia
 
3:51 PM
Is it possible for a method of an object to accept variable number of arguments in C++ ?
 
user142019
Yes.
 
Xeo
@Olumide C++11 allowed?
 
With variadic templates.
 
Xeo
Or many overloads
 
Thanks. And how might I write that? Bear in mind that I do not wish to specify the number of arguments?
@Xeo I don't wanna do overloads
 
Xeo
3:52 PM
template<class... A>
void f(A&&... a){ /*...*/ }
 
template <typename... Args> void foo(Args&&...);
 
user142019
What about cstdarg? :p
 
Don't use it, that's what.
 
Xeo
@WTP Burn it.
 
Do I really need templates?
 
3:53 PM
Yes.
 
Xeo
@FredOverflow: Ping me when you're here again
@Olumide Do you want a variable number of a specific type?
 
For specific type, just pass std::vector or something.
 
Xeo
Or { ... } with std::initializer_list
 
Okay. I'm trying to get my mind around what && means in this context. I'm passing a variable number of unsigned chars
 
Use std::vector. Really.
 
user142019
3:54 PM
@Olumide rvalue reference
 
Xeo
@Olumide It's for perfect forwarding. Forget it if you're only using chars
 
Variable number of char arguments sounds silly.
 
Xeo
@CatPlusPlus Why?
 
Because it's called a string.
 
@CatPlusPlus trust me. It makes sense in my application domain.
 
user142019
3:55 PM
What if you want '\0' to be a valid character?
 
Xeo
Though std::initializer_list could certainly benefit from an operator[], imho.
 
It always does.
 
Xeo
@CatPlusPlus See where my Why was directed at
 
The chars are commend sequences
 
@Xeo list.begin()[n]!
 
3:56 PM
@Xeo Oh. Because I didn't think about std::string. :P
 
Xeo
lol
@RMartinhoFernandes Ah, right, it returns pointers. Still.
 
So std::initializer_list<char> l = {'a' , 'b' , 'c'} is valid?
 
@WTP It is, why wouldn't it be?
 
Xeo
@Olumide Yes?
 
hmmm, what would the easiest way to check if the ints in a std::vector<int> all have a difference no greater than 1 between them?
 
user142019
3:57 PM
@CatPlusPlus if you want to have C-strings with '\0' you need to specify their length separately. Olumide didn't want to do that.
 
I think you can initialise string with initializer_list<char>.
 
That means I can have a method Foo::Bar(std::initializer_list<float> & ch ) and call it as follows: Bar('a', 'b', 'c')?
 
No, Bar({ 'a', 'b', 'c' }).
 
@TonyTheLion all (<= 1) $ map (uncurry (-)) $ zip x (tail x) :P
 
Thanks
 
Xeo
3:59 PM
@Olumide No, you need initializer_list<char> :P
 
I thought these were unsigned chars.
Damn.
 
Xeo
Also, const& or just by-value (initializer_list is a small type)
 
So I should declare Foo::Bar(...)?
 
This is non-type-safe C-ism.
Don't use that.
 
user142019
Foo::Bar(std::initializer_list<char> characters)
 

« first day (471 days earlier)      last day (4479 days later) »