« first day (523 days earlier)      last day (4651 days later) » 

20:00
@FredOverflow can u explain me better about this pointer approach plz?
@rogcg I'm not entirely sure what he's describing fits your problem very well
@rogcg How exactly do you call the method now? Is the object a global? How do you know about the object?
The best match seems to be: Make a "window unrolling" object, and give it's address to the one car that's allowed to unroll windows. Cars use the "window unrolling" object to unroll windows.
wanna read the problem, so u might understand how it is?
Why don't you just make the windows members of the car and don't let anyone else know about the windows? Then only that car can call methods on the windows. No pointers required.
20:05
12 mins ago, by rogcg
which pattern can I use that allows only one instance of a class to execute an action, and forbid the other objects to execute this same action. E.g. lets say I have a class car, how can I specify to only one object to be allowed to open the car windows, and the other objects not. (I mean, withou flags). I think this is more about patterns than c++ itself, but I'm implementing it with C++.
Oh, I totally misread the problem. Please forget everything I said.
@FredOverflow Just like no assembly required.
But that's quite the unusual problem, never encountered it before.
@FredOverflow I'd take a stab in the dark and say his actual code isn't cars and windows, and that he wants a mutex/criticalsection
room topic changed to Lounge<C++>: Beware of puppy. [c++] [c++11] [c++-faq]
3
Is this code multithreaded?
20:07
Make a UML class diagram where a class Car and Bus have a base class Vehicle. The Vehicle class must have attributes as the number of ports and the maximum number of passengers. The Car class must show the type, sport or luxury. Consider only the concrete classes Car and Bus. It is necessary to accelerate, brake and get the speed of any vehicle. Only one car can open the windows, and only a bus can trigger the siren to stop.
Simply don't put open_windows() on any other class?
How can I represent large number as?

243,2902,0081,7664,0000

it's 20!

I can define the base -> 10k of next manipulations with large number

and got

20! = 0 + 7664 * base + 81 * base ^ 2 + 2902 * base ^ 3 + 243 * base ^ 4

how to recut the large number

and print each part of large number in output stream?

that's how gnump works with large numbers, guys?
Ow, my screen! It's gone!
@RMartinhoFernandes I dont think its like that. Maybe I should allow the objects by instantiating it differently, or by using a pointer to the base class, IDK
@user1131997 log(20 !) / log(2) = 61.0773839, so a long long would be fine, assuming long long is 64 bit on your platform.
20:11
static_assert(sizeof(long long)*CHAR_BIT >= 62, "long long must be large enough for 20!");
also I dont think the problem is that easy
@RMartinhoFernandes or just use int64_t :)
@FredOverflow int_least64_t you mean.
I mean not only for 20! , but even for lager factorial values, like 40!

Is the method I have presented the correct way to cut large number on pieces for the next printing it?
any idea?
20:14
@user1131997 There are libraries for very large numbers like GMP.
@rogcg How is the one object that may call the method chosen?
@FredOverflow I know about GMP, and I'm wodering of different methods of cutting large nums, may be which don't use even GMP. I was asking exactly about algoith tu cut large num
@FredOverflow u mean the attributes?
@RMartinhoFernandes hey, what did I do now? :P
@rogcg Let's say you have 100 objects. How do you chose which of those is the special one? Is it the first that gets instantiated? Or is it the first that actually tries to call the method? If so, does it stay "special" forever, or can other objects become "special" once the method is done executing?
@DeadMG Nothing. I just came up with the idea.
20:16
fair 'nuffcakes
@FredOverflow anyone can become special. Im considering the first instantiated. And it will become special forever
@user1131997 GMP probably just uses an array of ints and does the arithmetic "by hand" in several steps. But that's just a shot in the blue. If you want to know for sure, look at the source.
@rogcg And you don't want to use flags at all? Or not just burden the user with the flags? Because it's easy to have the flag be an implementation detail of the class.
@user1131997 for factorial, you need multiplication. I'd imagine all bignum libraries use arrays of unsigned for holding data. You'd need to write the multiplication algorithm yourself.
@rogcg There's nothing you can do to get that behaviour without some variant of flags.
@rogcg I would guess that it's a typo, and supposed to say "only a car can". Or maybe a translation issue.
20:20
@FredOverflow well. than, Im gonna set a bool flag in car object, and create a method openWindow(),, if flag is true Im able to open it. I dont think its that easy, we have to use something related to inheritance, etc.
Otherwise it's significantly harder than the rest of the assignment all togeather
@MooingDuck Car is a typo
cdr is a typo.
@rogcg which "Car" is a typo?
Man, that one is incredibly lame.
20:21
@RMartinhoFernandes it's on the internet: it's forever
@MooingDuck Car is a class
(and true)
Bus is another class
Vehicle is another class
@rogcg I understand that, but I think the bit that says "only one car can open..." should have been "only a car can open..."
I think that it was a typo or translation issue.
yes, the factorial is multipulation process, but under the 40! I mean the very large number, which I can't write here, under 40! I mean the ready result of large value, which is better to write in short form in message and not write the very large num

so, I was only asking about different algorithms of representing large nums in small parts for output stream

How it could be done? Is the quesion I ask and have showed only one version ( which could be wrong ), I was asking only about logic
20:22
Because otherwise your assignment wouldn't make sense. Ask your professor to be sure
@MooingDuck Only an object of the type Car can open. a unique instance of Car is allowed to call the method open_window();
char can be "signed" but it can not be in the set of "signed integer types"
@rogcg are you absolutely positive? Because that doesn't make much sense
20:23
@JohannesSchaublitb char may be unsigned.
of course i am]
@user1131997 you would have to represent it as an array of unsigned
why it doesnt make sense?
for example, numeric_limits<char>::is_signed returns true on this box for gcc and clang
the spec just says "T is signed"
@rogcg because of the context of the sentance, and because it's too freaking hard.
20:24
Stupid English ambiguities.
@MooingDuck No, it's easy: flags.
@JohannesSchaublitb "on this box"
@RMartinhoFernandes updated
@MooingDuck hmmm
@RMartinhoFernandes I don't know how to do flags in UML, but I won't disagree with you
@MooingDuck Put a bool attribute.
20:25
@JohannesSchaublitb I'm pretty sure we went over this a few days ago.
@JohannesSchaublitb spec doesn't say if char is signed or unsigned, that's why there's 3 char types
@RMartinhoFernandes no. we did not go over it!
@RMartinhoFernandes well, yes, but what about the associated rules?
@JohannesSchaublitb I didn't say anything.
Well I did when I checked std::numeric_limits.
20:26
@MooingDuck Write text. UML is a tool for communication. It has this thing called "notes" for when the language cannot express all the concepts (which is not rare).
@RMartinhoFernandes excellent.
I'm still sticking with typo
UML is useful for anything?
@DeadMG no
People very often forget that UML is for communication and then... well, pain. There's a reason "notes" are part of the language.
my CIA book just arrived!
with lot hot atomic informations!
20:30
@rogcg Here is my flag solution. Is that roughly what you want?
@FredOverflow probably
thanks
@MooingDuck I think so too.
@rogcg What exactly is the reason that only one car can open the window?
27 mins ago, by rogcg
Make a UML class diagram where a class Car and Bus have a base class Vehicle. The Vehicle class must have attributes as the number of ports and the maximum number of passengers. The Car class must show the type, sport or luxury. Consider only the concrete classes Car and Bus. It is necessary to accelerate, brake and get the speed of any vehicle. Only one car can open the windows, and only a bus can trigger the siren to stop.
20:35
@FredOverflow IDK what the exercise wanted to extract from me, maybe train some inheritance, or polymorphysm, IDK the reason for that.
"Hey, my window is stuck!" - "That's by design." - "How so?" - "The other guy came first, sorry!"
@FredOverflow LOL!!
that was good.
@MooingDuck In our OOP class that would have meant a SportsCar and a LuxuryCar classes. Man, that teacher was so stupid.
> Only one car can open the windows, and only a bus can trigger the siren to stop.
pretty sure that should be a car.
@FredOverflow right
20:37
forget about it, just moved from this question. LOL
Than forget the flag nonsense. Just have a car class with an openWindow method and a bus class without such a method, done.
yeah
Called it first.
29 mins ago, by R. Martinho Fernandes
Simply don't put open_windows() on any other class?
Just replace "a" with "one", and a bunch of nerds start talking about flags and mutexes :)
@RMartinhoFernandes I wish I could travel 30 minutes into the past and beat you ;)
20:39
not in the physical sense, but in the "first!!!" sense.
(Btw, you won't find me in the past, I have already travelled to this moment from the past)
Xeo
Xeo
0
Q: Is ther a good workaround for GCC's "sorry, unimplemented: cannot expand ‘NEXT ...’ into a fixed-length argument list" error?

mtk358I have this code, and it produces the error message shown in the title: #include <iostream> template <int FIRST, int... NEXT> struct Test { static const int VALUE = FIRST + Test<NEXT...>::VALUE; }; template <int FIRST> struct Test<FIRST> { static const int...

Close votes please
i thought it was fixed in gcc4.7
4.6, I think.
Or maybe I'm confusing. It's been a while since I ran into that.
20:43
no 4.6 did still contain the bug, as does clang (only a few weeks ago the bug was fixed on trunk)
Xeo
Xeo
@JohannesSchaublitb Huh? IIRC, I could do that months ago already. I may misremember, though.
@RMartinhoFernandes Do I need 10k to see that?
> Doh - assumed question was about C#. Too tired.
by Jon Skeet
Argh, can't find it. What's the name for the virtual throw function, akin to the virtual copy clone()?
I call it virtual rethrow.
21:16
cool, I just killed my first process in Linux :)
OMG, you take joy in murder.
And I just did it for fun, the process was working fine.
You kill processes for "fun"?
How is that fun?
I need to be prepared for the real deal.
lol
Was it mass murder?
21:18
just the Firefox
Ah.
I hope foxes are not a protected species in Germany.
Are logical operators required to return 0 or 1, or are they 0 and non-zero? Specifically 2&&1
In C++, they return true or false.
2 && 1 returns true.
@FredOverflow Alright then: if true is cast to an int, is the result always 1 or non-zero?
21:21
@ScottW With xkill?
@MooingDuck yes, 1
@RMartinhoFernandes learn something new every day
@Fred If you like killing processes, you'll love xkill.
@MooingDuck You can do bool b = false; ++b; assert( b );.
21:23
> A prvalue of type bool can be converted to a prvalue of type int, with false becoming zero and true becoming one. [4.5 Integral promotions §6]
@LucDanton Isn't that deprecated now?
@LucDanton Setting bools to true via ++ is deprecated.
@RMartinhoFernandes It's been since at least 2003.
So that means "deprecated" in C++ means "stays along forever, but you may get compiler warnings for it"?
:(
@RMartinhoFernandes yes. It compiled once, it must compile forever.
21:26
I wanted it to mean "We're killing this in the next release"
Deprecated is a notice that something may be removed in the future.
@MooingDuck Don't buy a better compiler.
It's the same advice I give to the puppy, except not.
@MooingDuck No. char* ptr = "string"; is now illegal, after being deprecated.
Remember how that deprecated use of static was deprecated.
@DeadMG true, but they seem to avoid breaking changes way to much IMO
@ScottW nonsense, we still need pointers
Can you somehow store a list of polymorphic base objects without resorting to pointers?
You can use unique_ptr<Base>.
@StackedCrooked I think he meant using unique_ptr
But you still need pointers for non-owning, relocatable, references. (As well as implementing smart poitners)
@MooingDuck unique_ptr<T, noop>.
21:36
@RMartinhoFernandes doesn't have copy semantics, but I considered it
shared_ptr<T>
Don't push me.
Well, std::reference_wrapper<T> is specified in terms of a pointer but doesn't require using pointers.
@RMartinhoFernandes non-owning?
@MooingDuck Pick an appropriate deleter.
@LucDanton you can't change what it refers to
21:37
Or, an appropriate non-deleter.
@MooingDuck Yes, you can.
@RMartinhoFernandes well, I guess it kinda works
@RMartinhoFernandes reference_wrapper? Oh, I didn't think you could.
@MooingDuck It's better than a pointer in that it's not even nullable.
I guess it makes sense if you assign it from another reference_wrapper
Yeah, we should have reference_wrapper and optional as the primitives instead of *.
21:39
@RMartinhoFernandes I think with those and smart pointers you can work around actual pointers.
optional<T&> sounds like a good replacement too.
All that's missing is the arithmetic.
someone recommended using T* as the representation of optional<T&>
Yeah, that could work.
@JohannesSchaublitb Isn't that what is used?
which would make optional<T&> require 0 overhead over a normal reference really
21:40
@RMartinhoFernandes oh, I totally forgot about the arithmetic
@RMartinhoFernandes as far as I was informed it always uses a {bool,T} pair internally
of course for a reference it would need to be {bool,remove_reference<T>*}
@JohannesSchaublitb optional can't have a T member, it doesn't know how to construct it. It has to use placement-new into a buffer, doesn't it?
@MooingDuck yes
Hmm, seems you're right.
Sounds like a lost opportunity.
@JohannesSchaublitb oh, then yes
21:43
it even has an in_place factory for "perfect forwarding"-emplace'ing in the c++03 case
Does anybody here use RLE for their work-aims? It's intetesting does really RLE using in BMP and executalbe files to encode repated sequence of bytes?

Or there used another alhorithms?
lol, comment for a section with constructors and destructors.
"It's intetesting does really RLE using in BMP and executalbe files to encode repated sequence of bytes? " I can't figure out what you're trying to ask.
Now I'm really curious why they don't just use a pointer.
21:49
@MooingDuck I have meant "does RLE really using in EXE, BMP for compressing data" or not using? Because RLE is very simple, in wiki there is info , that RLE is using in its format, but I have opened BMP, EXE files and there a lot of sequences which are repeating
And don't see, where it really is using in those formats
RLE in BMPs is optional.
EXE doesn't use any compression scheme, unless you use an EXE packer.
And there are far superior compression schemes than RLE.
@user1131997 "does RLE really using in EXE, BMP for compressing data" That's still terrible English. RLE is optional for BMP, and I've never seen a BMP actually use it.
@FredOverflow som executables files both in Win && *nix don't use any compression scheme, this is what you want to tell me, yes?
@user1131997 No, I want to say that there is no such thing as a compression scheme in the "EXE standard". But there are special tools that will do that... can't remember their names though.
Ah, upx is an example.
Executable compression is any means of compressing an executable file and combining the compressed data with decompression code into a single executable. When this compressed executable is executed, the decompression code recreates the original code from the compressed code before executing it. In most cases this happens transparently so the compressed executable can be used in exactly the same way as the original. A compressed executable can be considered a self-extracting archive, where compressed data is packaged along with the relevant decompression code in an executable file. Some co...
21:53
EXE standard, lol
Well, that's why I put it in quotes :) EXE spec or whatever.
Did you see this question?
5
Q: How to get file size in ANSI C without fseek and ftell?

math4totsWhile looking for ways to find the size of a file given a FILE*, I came across this article advising against it. Instead, it seems to encourage using file descriptors and fstat. However I was under the impression that fstat, open and file descriptors in general are not as portable (After a bit o...

Is the OP right that fseek to the end of the stream is UB for "binary streams" (whatever those are)?
@MooingDuck with does I must use non-ing form? "does RLE is used in BMP?", that was a mistake in my English?
Also, has anyone installed GCC 4.7 yet :-)
21:56
@user1131997 "Is RLE used in BMP?"
what happens if I put const in front of std::string getValue() for example?
like this
std::string getValue() const
what is the concept behind this
You have a strange notion of "in front".
Don't mind me.
It's a const member function.
It means the member function cannot modify the object.
yeah, so this method would return a string const value?
21:57
@RMartinhoFernandes Haha. You fraud.
@rogcg getValue is a member of an object, and can be called on that type of object even if the object is const, that returns a string
oh got it
No, the returned string is mutable.
@rogcg no, the string is changable
@rogcg to return a const string would be const std::string whateveryourfunctionwas() const
@KerrekSB I'm serious.
gcc version 4.8.0 20120311 (experimental) (GCC)
21:58
4
Q: What is the meaning of a const at end of a member function?

MatWhat exactly does the const keyword in C++ mean when it's written at the end of a member function (after the argument list)?

@FredOverflow thx
@MooingDuck don't do that.. :(
(Is that really the best question we have on const member functions?)
oh, look who edited in the quote, lol
21:59
@RMartinhoFernandes I could have sworn you were a joke!
(Just kidding.)
So... any opinion on fseek?

« first day (523 days earlier)      last day (4651 days later) »