« first day (369 days earlier)      last day (4562 days later) » 

12:00 AM
@AlfPSteinbach what if the external tape can't be addressed by the language ... ?
 
@Maxpm More modularity is better than less modularity. Boost has bcp which can create a subset of the library containing only the components that you wanted.
 
Hmm.
 
But in many cases this kind of modularity is not worth the effort.
 
Yes, you can simulate an universal computer given C++ and an infinite external tape.
 
I was going to give each module a subdirectory with its own makefile, which would produce libFooXYZ.a in the bin folder. A Master Makefile Conglomeratron 5000™ file in the root would just call each of them and link the outputs into libFoo.a.
I've barely started coding it, so it's not like I'll have to spend a day moving files around.
I figure I might as well do it.
I'll ask this on SO anyway, though. I'm a little curious about what people think.
 
12:06 AM
"(...) A Master Makefile Conglomeratron 5000™ (...)" That's scary!
 
Yeah, well, autotools are scary.
 
(Though it could be made scarier: make that a recursive, self-modifying Makefile, and you've got yourself a Makefile with a sanity breaking potential that rivals that of an Old One.)
 
0
Q: Is modularity important in libraries?

MaxpmI'm about to start writing a library that aims to be as lightweight as possible. This library will have several modules that can act independently, but can still work together to achieve a larger goal if the user so chooses. Should I provide a means of compiling "just part" of the library? Sho...

I must eat. I shall return shortly.
 
"Yes" is too short for an answer :(
> I made this bullet-proof vest out of plain cotton, because everyone uses armour-piercing rounds nowadays plus it is easier this way.
 
@Maxpm In the end it won't matter because nobody will use your library anyway. I have a little library myself and I named it Futile for exactly that reason.
5
 
12:20 AM
lol
 
I have returned.
 
12:41 AM
Is there a list of features of GNU make that are nonstandard extensions?
 
is there a "standard" make?
 
There's a POSIX standard.
 
info make has a "features" section, that lists all the "features GNU make has over other makes"
 
Great. Thanks.
 
hello everyone
I was working on time functions recently .. I was wondering if usec.end - usec.start gives me time took by a function in microseconds
I am looking for clock functions to find time in microseconds on unix
 
12:59 AM
afaik, if you also have a "sec", comparing usecs will give you the number of microseconds that aren't part of a whole second. like, if you took 1.5 seconds, usec.end - usec.start == 500000
while sec.end - sec.start would give you the number of whole seconds
 
oh then i should also be calculating this one too
makes sense thank you
 
oh, and regarding main arguments. i wondered where the standard recommends utf-8 encoding. well it doesn't but it does specify them as MBCS, multibyte character strings, where a "multibyte character" is a character encoded with possibly two or more bytes. each character is from the "extended character set", which the standard, as far as I can see, fails to define or describe. but it sounds awfully like utf-8.
^ Udders! :-)
 
1:19 AM
> Adam Smith would be turning in his grave. Especially if he ever got to level 63, which is an absolute fucking nightmare.
 
seconds = end.tv_sec - start.tv_sec;
useconds = end.tv_usec - start.tv_usec;

difftime = ((seconds) * 1000 + useconds/1000.0) + 0.5;
this gives microseconds?
 
i think milli = 1/1000 while micro = 1/1000000
 
You can edit messages.
 
@NicholeGrace that'd give you milliseconds. for microseconds, you'd multiply by 1000000 and not divide at all
though depending on how long a time scale you're worrying about, you'd have to check minutes as well...or just add 60000000 if difftime < 0, if your times will always differ by a minute or less
minutes is about as far as you can reasonably go, though. if you're measuring in microseconds, a 32-bit number will give you up to about 2100 seconds (~35 min)
 
1:37 AM
yaa my time will be always less than 2100 seconds
i guess i should do this one thanks chao
 
 
2 hours later…
3:43 AM
whose idea was it to define
inline bool hopefully( bool v ) { return v; }
?
 
I meant the name, not perhaps that exact definition
someone mentioned it
and i just tried it out, it makes for a bit more readable code
 
assert( hopefully(2 + 2 == 4) ); ?
 
#include <fstream>          // std::ifstream
#include <iostream>
#include <stdexcept>
#include <string>
#include <stdlib.h>         // EXIT_SUCCESS, EXIT_FAILURE
using namespace std;

inline bool throwX( std::string const& s ) { throw runtime_error( s ); }
inline bool hopefully( bool v ) { return v; }

int main( int argc, char* argv[] )
{
    try
    {
        hopefully( argc == 2 )
            || throwX( string() + "Usage: " + argv[0] + " FILENAME" );

        ifstream stream( argv[1] );
        hopefully( !stream.fail() )
just an example for the unicode doc i'm writing (on and off)
 
3:46 AM
That looks like the Perl idiom of writing condition or die
 
uh, the last line should be EXIT_FAILURE
yes, it's a script idiom
i like it in C++ though
 
> TIMTOWTDIBSCINABTE, pronounced “Tim Toady Bicarbonate”
 
 
1 hour later…
5:14 AM
Anyone encountered this before: /usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
I upgraded my linux distro and somehow my build setup got broken
 
From my googling that's Clang being silly.
There are workarounds but I haven't used them myself, I usually use GCC.
 
ok this is from gcc too
 
I don't have the problem with GCC. Perhaps try reinstalling it?
 
like I know that usually it's a problem with libc6 not being properly installed, but I think I have that on my system already
I've tried that but thus far have failed to get it working
I might just try that again now
 
crt*.o come with the distribution, not libc6 IIRC.
 
5:18 AM
that might be my problem
 
5:28 AM
looks like I can't even do that
annoying dependency hell right now
 
5:44 AM
til i see it actually running at highway speeds, it's just a go-kart with a shell.
so far all i've seen is people running along with it
and that steering wheel looks fake as hell. like they're just holding it in place, and it'll fall out any second
lol
 
6:09 AM
@cHao That's because they don't have enough funds to create a 2 seater. But anyway it runs properly. It even participated in the Shell-Eco marathon in Malaysia
It's called the "Devrim II"
The Devrim II is the first ever Hybrid Car of Pakistan, designed and fabricated by students of NUST using local resources, in 2010. A group of Eleven Engineering students from Department of Mechanical Engineering, Department of Mechatronics Engineering and Department of Electrical Engineering , named as Pak-Wheelers, from E&ME College of NUST participated in the Shell Eco-marathon Asia in July 2010 with their Hybrid Car. Notable Features Some of the notable things about Devrim II are * Electric gasoline series hybrid vehicle * Regenerative braking system * EFI and VEMS * Efficient Driving...
 
eh. the wikipedia page did not impress me -- looked a lot like someone who was involved in making it posted the article
 
@cHao Frankly ..... I agree. especially "Aerodynamic design and light weight chassis"
But coming from undergraduates its still something to be proud of. How many people create their own hybrid car as an extra credit project?
 
Many. Specially women.
 
@RMartinhoFernandes Lol :D
Anyway bye.
 
 
2 hours later…
sbi
8:18 AM
Interesting:
4
Q: What shortened URLs are available through s.tk?

Jeremy BanksIt was announced on the Stack Exchange Podcast episode #23 (at 1:05:26) that Stack Exchange now has its own URL shortener, http://s.tk/. At the moment, users can't create their own, they can only use the ones that are built-in. What shortened URLs are available through it?

 
8:32 AM
> I need to manually refresh to get a different user so the language would have to be able to refresh.
Can C++ refresh?
 
Well sometimes I get the urge to code.
Then I hack a bit in C++, and after that I feel refreshed.
So there's that.
 
@RMartinhoFernandes Press F5 to refresh C++.
Perhaps it will update your compiler.
In this post Koenig writes that you can free the memory from a vector by calling vector<T>().swap(v);. Is there any reason why this is preferred over: v = std::vector<T>();
 
Less copies (possibly relevant before C++11)?
If operator= uses copy-and-swap, there's an extra copy, when a single swap would be enough.
 
There's no good reason other than it's similar to the shrink to fit idiom I suppose.
Whether it ends up as better than assignment will depend on QoI so there's no telling without measuring I think.
The two aren't similar exception safety-wise but there shouldn't be any exception for those operations.
 
cpx
34
Q: Undefined, unspecified and implementation-defined behavior

ZolomonWhat is the difference between these three?

can i find more information about implementation defined behavior? standard quotes doesn't seem enough atm.
 
8:45 AM
(A roundabout way of saying that 'if it weren't nothrow, then it wouldn't be the same exception guarantee for either; but you really need it to be nothrow anyway'.)
@cpx "Each implementation shall include documentation describing its characteristics and behavior in these respects." is the important part of the quote.
 
Standard quotes for implementation-defined behaviour is a bit of an oxymoron.
 
9:04 AM
Hey does anyone know why this happens with the void operator(complex x)
http://ideone.com/206Z9
 
I assume this is a copy assignment operator.
 
yes
 
First, make your operator= return complex&. That's how it's commonly done.
 
but then where does it get assigned?
 
What do you mean?
 
9:06 AM
so complexa = complex b what changes the info in complexa?
 
operator=.
 
Does it have a predefined behaviour that cannot be overwritten or something?
 
If you don't write one in most cases the compiler will use its own, yes.
But you can customize the behaviour of operator= as you wish.
 
but i do write an overload on the operator.
I'm just confused as to what happens when you return the &reference
 
9:08 AM
If you want help I think you should post real code. There's not much to say about what you pasted.
 
Sorry, basically if you look at martinho's code, when he returns the *this WHAT sets the left handed complex equal the return?
I thought all operations have to beconducted in the overloaded operation
 
What you return is not what is assigned to the left-hand side.
 
Then what is it?
 
It's what's returned for the whole expression. For instance you can write int operator=(complex const&); and then do int i = (a = b); (where a and b are complex).
@oorosco Nothing. You do what you want inside the body of the operator.
There's no special treatment.
In other words you're writing what happens when someone uses a = b.
 
I see.
 
9:13 AM
You can't 'pass something to assign to a'. b is the something to be assigned.
 
Also how can you have a member function conduct something when the preceding number isn't an int. e.g. INTEGER + COMPLEX
I never understood that. I always just put them outside as non-member functions
 
No. There are no conversions on the left hand side of a member operator unless it's upcasting to a base.
@oorosco That's usually a good idea.
 
@oorosco You can't.
88
Q: Operator overloading

sbiWhat are the basic rules and idioms for operator overloading in C++? Index of answers: The General Syntax of operator overloading in C++ The Three Basic Rules of Operator Overloading in C++ The Decision between Member and Non-member Common operators to overload Assignment Operator Input and O...

 
If you write 1 + foo then since an int doesn't have member functions it means the call is as if you'd have written operator+(1, foo)
 
I got some long, complicated template error messages. It appears function template specializations in header files lead to multiple definitions, just like normal functions do. Am I right?
 
9:17 AM
@FredOverflow Yes.
If it helps, you can think of a specialization as defining a function, not a template.
 
This design error has been lurking in my header files for months :)
 
so say you're in my boat, i have to have a write a unary use of "-" and a binary one, does the compiler realize what's going on?
e.g. http://ideone.com/zrkoJ
 
@oorosco Both of those are binary.
 
oops
sorry i wrot ethat wihout looking, take awy the int
just : public operator-(complex x)// nonmember
 
Also, that's not how you use public in C++.
 
9:19 AM
The idea is sound, yes.
 
you can do public:
//declaratoins...
 
Hi, there^^
 
or are you talking about something else?
@LucDanton The program would realize the difference even though both take "complex" as their parameter?
 
Hm, it appears function template specializations have to be in the exact same namespace as the primary template? Makes sense...
 
9:21 AM
(I thought I could nest the specializations in an anonymous namespace.)
 
@oorosco Yes. Distinguishing between a unary and binary - at the expression level conceptually happens before functions definitions are even relevant, and a unary function is easy to distinguish from a binary function (counting the implicit *this parameter here).
@FredOverflow I tend to not put definitions in namespaces these days but to explicitly qualify them.
Well, for source files at least.
 
BTW, does the newest gcc support template class separated in header and source file?
 
I'm in header-only terrain right now.
 
@LucDanton So say i'm doing a non-member operator- do i need to do "complex::operator-" still or just "operator-" in the .cpp?
@RMartinhoFernandes What did you mean by the public use remark?
 
9:23 AM
@oorosco Only members can be qualified with complex::.
 
okay...
 
so "operator-" is perfectly okay in the cpp?
 
@liuyanghejerry It has supported that for quite some time now. It doesn't support export though, and it won't support it any time soon: export was recently removed from the standard.
 
cpx
@liuyanghejerry Do you mean separation model?
 
No, export is removed.
 
cpx
9:24 AM
Nope
 
@oorosco Putting the definition, yes. But you want a declaration alongside the type in the header.
 
@cpx just functions in source file and class defination in header
 
Is there any downside to putting everything in a header file into an anonymous namespace?
 
@FredOverflow ODR violations?
 
9:25 AM
oh hai
 
It still gives me this error message:
http://ideone.com/GDgBn
For the operator=
 
I posted a comment on Programmers
 
Oh a comment.
 
it's got 29 upvotes, more than any answer
:(
 
9:26 AM
Can I see it?
 
@LucDanton Are ODR violations a possible consequence, or are you asking whether I'm having them right now?
 
3
A: What are the areas where the .NET platform is still lagging behind the Java platform?

DeadMGI'd advance that Java is significantly lagging behind .NET. The older platform has more legacy code they have to support. .NET has stronger generics and lambdas, which are quite massive advantages, plus other serious language advantages like operator overloading. Case in point: Generics. .NET go...

ok, I missed the top answer which is 41
but I'd still really appreciate 29 Programmers upvotes
 
@FredOverflow They are a possible violation, but I suppose those can be avoided.
 
Yeah, sometimes the top answer is a bit hard to notice.
 
@LucDanton example?
 
9:29 AM
Someone uses inline void foo() { return your::header::something(); } in different TUs.
In each TU your::header::something refers to a separate entity, so foo has differing definitions. ODR violation.
 
Code: http://ideone.com/lUj0C
error: ideone.com/GDgBn
The error in the code is at the "complex& operator=(const complex suf)" part.
It makes no sense <,<
 
Your copy constructor requires a modifiable lvalue.
complex(complex& copy) should be complex(complex const& copy).
 
@LucDanton I'm not sure I get it... so if I put header stuff into an anonymous namespace, multiple inclusions in different TUs lead to ODR violation?
 
the errors are a bit WTF
 
Then anonymous namespaces don't solve my problem :-/
How about making the specializations static?
 
9:31 AM
but C99 has complex data types, and I think that having a non-namespace-qualified class called complex could be conflicting with them
 
No, the errors are quite clear: "const-correctness issue"
 
@FredOverflow If someone uses something from your header in an inline function and uses that function across different TUs, problem.
 
That is what it reads after the powerful filters in my brain.
 
The very first error line is "prog.cpp:50: error: expected id-expression before ‘__complex__’"
 
@RMartinhoFernandes Copy constructors require const?
 
9:32 AM
that is quite clearly not anything at all to do with const
 
@LucDanton Aha, so the problem does not appear without the inline? Interesting. I always thought compilers ignored inline these days.
In other words: I thought I knew C++. Silly me, I should have known better :)
 
@oorosco Technically not, but in reality one that doesn't have it is quite useless
 
@DeadMG Oh, you mean the GCC errors.
 
@FredOverflow Without inline a function defined in a header will easily result in an ODR violation.
 
@DeadMG Why is it useless?
 
9:33 AM
@FredOverflow inline is ignored as a hint to inline functions. However, it affects the semantics of a program.
 
@FredOverflow Compilers ignore inline in the idea of actually inlining the assembly. They cannot ignore it's effects on ODR violation.
 
@oorosco You can't copy temporaries.
 
@oorosco Because mutable lvalues won't bind to temporaries.
Your code won't accept, for example, complex a; complex b; complex c = a + b;
 
Morning!
 
So before you associate "const" it's a temporary?
 
9:34 AM
no, no, it's about the reference
T& will not bind to temporaries. const T& will.
 
@FredOverflow What's up?
 
Also T&& will in C++11
 
@LucDanton Hey!
 
@FredOverflow You know how struct foo { void bar(); }; void foo::bar() {} is easily an error whereas struct foo { void bar {} }; never is? That's thanks to inline. (Assuming this takes place in a header.)
 
but it's probably better to just not go there right now
 
9:36 AM
So a references cannot be assigned to temporary values?
 
Unless they're const.
T& x = T(); does not compile. T const& x = T(); does.
 
What's the definition of a temporary value? I mean everything is temporary to a certain scope.
 
sbi
Are you talking C++ again? Oh my, what has this room come to...
 
A temporary value is unnamed and lives only to the end of the expression in which it is created.
 
@sbi Lol. This room/website is probably the most educational resource in my college expreience :P
 
9:38 AM
@sbi Are you working?
 
0
Q: putting function definitions in header files

FredOverflowIf you want to put function definitions in header files, it appears there are three different solutions: mark the function as inline mark the function as static put the function in an anonymous namespace (Until recently, I wasn't even aware of #1.) So what are the differences to these solutio...

 
@oorosco Definitely so here.
 
rep whores, prepare to rep whore!
 
room topic changed to Lounge<C++>: ... where we sometimes commit the sin of discussing C++. [c++] [c++11] [c++-faq]
 
@DeadMG So adding "const" will keep the value in stack until the program terminates?
 
9:39 AM
@FredOverflow That's exactly what inline is for. The others work as a side-effect (and in some cases lead to ODR violation).
 
no, the value will stick around anyway
but basically, it's unsafe to mutate rvalues unless you're pretty sure of what you're doing
the language protects you from making many stupid mistakes by enforcing the const
of course, it also prevents many perfectly good uses and optimization opportunities, not to mention information loss, which is why C++11 introduces the dedicated "rvalue reference", which can be used to safely mutate and handle rvalues.
 
sbi
@RMartinhoFernandes Yeah, sometimes is all fine with me, but please keep C++ discussions to a minimum. Except, of course, when I feel the need to discuss C++. Then you're free to discuss as long as you stick to the topic I need to discuss. :)
 
lol
 
the problem is that C++03 simply doesn't have the expressive power to make it safe to mutate rvalues, so the Standard basically had to ban it outright where they could
 
@DeadMG I think i kinda understand
 
9:41 AM
@DeadMG T&& i_know_what_im_doing;
 
btw what is a T&&
 
@FredOverflow T&& no_you_dont_you_forgot_to_initialize = T();
 
lol
never ever seen that
 
it's an rvalue reference
it's new in C++11
 
@DeadMG I'm so starring that.
 
9:42 AM
@DeadMG It's a member!
 
only compilers from the last couple of years support them- they're a new feature in C++
 
' is not valid on identifiers.
I'm unstarring that.
:P
 
there's no ' there
 
sbi
@oorosco There's an FAQ for that.
 
so the compiler decides what c++XX is being used? Not like predefined settings/includes/etc
 
9:43 AM
@DeadMG I'm starring it back in.
 
the compiler usually uses whatever the latest is that it's written to support
but some like GCC allow you to target various levels
 
@RMartinhoFernandes Did you read my rebuttal?
 
-std=c++0x enables the juiciest new stuff.
 
1 min ago, by FredOverflow
@DeadMG It's a member!
 
in GCC you can target C++03, C++0x and choose to enable GCC extensions or not
 
9:44 AM
@FredOverflow Oh, I missed it in the middle of the surge of messages that was going on.
But it still lacks some of the cool stuff.
User-defined literals and alias templates, I'm looking at you.
I'm surprised no one asked "What the fuck is a badbox?" on TeX - LaTeX.
 
lol
 
Either that or my search-fu is seriously failing me.
 
sbi
@RMartinhoFernandes As a robot, you shouldn't have problems following a great number of discussion threads scrolling by very fast, no?
 
@sbi Sometimes I run filters for efficiency.
 
@FredOverflow I'd recommend sticking to inline (since that's what it's for) and if you really want to have the benefits of internal linkage perhaps your compiler can help you for that. For instance I use the visibility options of GCC.
 
sbi
9:47 AM
@RMartinhoFernandes To keep up with half a dozen humans? How pathetic!
 
@sbi No, to be able to do other things as well.
 
@sbi: Remember I was talking about messages which are pinned that shouldn't be?
that one at the top of the list right now is an excellent example
 
I lack a decent computer interface.
I'm stuck with the meatbag setup of keyboard + screen.
 
starred, fine, but pinned? It doesn't need to be stuck there.
 
sbi
@DeadMG No, I do not remember, of course. I'm not a robot, after all.
 
9:49 AM
Oh, and a mouse sometimes.
 
sbi
@DeadMG I feel like a message "Fuck you Markdown." should be permanently pinned above everything else. The way you post here, you won't have run into this very often yet, but Morkdown is certainly the spawn of Mordor, born to make our lives a misery.
 
So i'm a little curious.
std::vector<T> foo;
foo.push_back(different_T); //Does this attempt to construct a T(different_T)?
 
@oorosco Yes, it most assuredly does.
@sbi Need to find that One Site Owner and throw him into Mount Doom.
 
Okay so if i have a constructor taking different_T everything is fine and dandy when i push_back(Different_T);
 
Is this how you say in english, "what time suits you best" ?
 
sbi
9:53 AM
@DeadMG That would be too nice a fate for Him!
 
Are you conspiring to toss Jeff into a volcano?
 
@oorosco Yes, that's fine.
 
... or worse?
 
@DeadMG KK. THanks :)
 
Ha! Found the badbox question!
 
9:54 AM
assuming that T has an implicit constructor from Different_T
 
hey does anyone in here know how to get /usr/bin/ld to find crt1.o, I know which folder it is in but ld appears not to find it
 
@LucDanton Okay, so inline is the way to go? I'll update my header files, then.
 
sbi
@RMartinhoFernandes Things that are said here a genuinely public. It can hardly be called a "conspiring" then.
 
@sbi But you're using codes!
 
I send-him-the-codez
 
sbi
9:57 AM
@DeadMG Or Different_T has (GASP!) an implicit conversion operator to T. (Ugh, now I let that out of the bottle. It's starting to smell already.)
 
In C++03 all conversion operators are implicit :(
 
uh
all explicit?
i think u maed mistaek
 
What about object definitions, should I make them static or put then into an anonymous namespace? Yes, I want one of those objects per TU :)
 
sbi
@RMartinhoFernandes Really, what's wrong with you today? You can't keep up with human discussions, do not find what you are looking for, and can't decode such simple attributes as "site owner" without asking us for confirmation? Do we need to worry?
 

« first day (369 days earlier)      last day (4562 days later) »