free blog   apache   shopping directory   php powered
TinoDidriksen{ double x = 4294967296.0; cout << fixed << x; }
TinoDidriksenAh, it can hold that precisely.
BaughnNaturally. It's a power of two.
BaughnWhich also turns the division into a simple subtraction. I wonder if the FPU takes advantage?
armenceSo is there any reason the constant won't work if I do it in hex?
TinoDidriksenarmence, hex constants are not double, and C++ doesn't support long long yet.
BaughnYeah, laziness on part of the C++ standard writers. :P
armenceTinoDidriksen, OK, I get it
BaughnIt would be nice to have a way of specifying floating-point values directly
Baughn..hex would pretty much do that
CecenSpecifying floating-point values directly? :<
BaughnOr at least making it easier to see how they're translated
BaughnBase-ten stuff is just awful. :/
CecenThat seems really unsafe
tomalak<< ETYPE(0x1.0p0)
geordirvalue double
tomalak<< ETYPE(0x100000000.0p0)
geordirvalue double
BaughnCecen: Floating-point is standardized. C++ may not require that standard, but it's there anyway.
tomalak{ double x = 0x100000000.0p0; cout << x; }
Eelis<< numeric_limits<double>::is_iec559
TinoDidriksen0th power
tomalakhexadecimal floating constant exponent suffix
BaughnThat's what I wanted. Guess we /do/ have it. ^^;
Baughn{ double x = 1p1; cout << x; }
geordierror: invalid suffix "p1" on integer constant
Baughn{ double x = 0x1p1; cout << x; }
Eelisno idea if it's C++1x or just C99
tomalakBaughn: test in #geordi please
tomalakno, tomalak
Action: Baughn punts tomalak over to a barrel of phun
MikeMc68What is the best way to put a delay into the code? I am looking at 100ms
BaughnMikeMc68: Platform?
tomalakno standard way
tomalakthere are various sleep mechanisms in OS APIs
tomalake.g. posix usleep, windows Sleep
tm604probably one of usleep, microsleep, or nanosleep.
tomalakask in the relevant channel for specifics
BaughnCalling select with no FDs and your timeout is about as portable as it gets
Baughn..if you want it to work on really ancient stuff
Action: Baughn thinks even windows manages that one
BaughnMikeMc68: Besides that, usleep.
MikeMc68ok i'll try usleep - thanks
coldpizza72i ....on the bottom of this page it says you need a quite modern compiler; does this mean code:blocks is not sufficient enough
gparentcode::blocks isn't a compiler.
gparentproblem solved
CecenHow long until we get uint128_t
coldpizza72igparent i mean the compilers that are in code:blocks
gparentI don't know what compiler is in code::blocks
gparentit depends on your computer
TinoDidriksenC::B on Windows uses ooooold MinGW with g++ 3.4.5
TinoDidriksenThen it uses whatever g++ you have
MikeMc68ok microsleeo and nanosleep don't work
MikeMc68usleep does but any number i put in the brackets makes no difference
Action: Cecen reminds everyone that MSVS is the only IDE that should be used on Windows.
coldpizza72isee im trying to run cimg's helloworld but i get a bunch of build messeges
TinoDidriksenCecen, Qt Creator will also do.
CecenIf you need to sleep, grab Boost.Thread
coldpizza72ithat apear to be problems with the header
gparentCecen: I suggest a bed myself.
CecenBeds are okay too
Action: Cecen builds Boost.Bed
alphahas anyone tried miniLZO compression lib? i cant find any examples..
TinoDidriksenalpha, so use a more widely used library.
alphaTinoDidriksen: for example?
TinoDidriksenzlib, 7zip
proton23Hi! sprintf is C, right?
proton23what is the C++-function for this?
FauxFaux!give proton23 converting
nolycproton23: converting is done with std::stringstream or with boost::lexical_cast
XorlevYou can use sprintf if you include cstdio.
proton23ahhh maybe that's the problem
TinoDidriksenboost::format is also good.
proton23but shouldn't I get a compiler error without the headerfile?
proton23Hi Tino! :)
sobberproton23, In c++ you would usually use std::cout though, instead of printf.
proton23including cstdio did it
deathanatosIf I have template<int I> -- can I restrict that I to < something ?
copprodeathanatos: you can with enable_if
yuriksIs there any way to do named constructors with non-copyable objects
dhrosaare there such things as unnamed constructors?
yuriksdhrosa: named constructor idiom =P
chris_I am trying to learn c++ coming from java, and one place where I am getting hung up is with the stack vs heap
villedidn't someone already answered this last night
chris_I am a little confused on how to make an array of objects on the stack
villechris_: you can only do it if the number of elements is known at compile time
chris_ahh... ok
villechris_: any C++ book ought to show this.
ville!give chris_ ac++
nolycchris_: Accelerated C++: Practical Programming by Example", Andrew Koenig, Barbara Moo, Addison-Wesley, 2000. ISBN 0-201-70353-X.
yuriksgeordi: { Foo init = Foo::makeMe(); } class Foo : noncopyable { Foo& makeMe() { return Foo(); } private: Foo() { } };
geordierror: expected class-name before '{' token
yuriksgeordi: replace noncopyable by boost::noncopyable
geordierror: invalid initialization of non-const reference of type 'Foo&' from an rvalue of type 'Foo'
yuriksok, this
yuriksgeordi: remove : boost::noncopyable
geordiSame error.
yurikserm, what
TinoDidriksengeordi: add & after first Foo
geordiSame error.
TinoDidriksengeordi: show
geordi{ Foo& init = Foo::makeMe(); } class Foo  { Foo& makeMe() { return Foo(); } private: Foo() { } };
TinoDidriksenOh, it returns a temporary
villeit would need to be static too or use an instance.
yuriksoh, right, forgot static
yuriksgeordi: make Foo::makeMe static
geordierror: Could not find free declaration of Foo::makeMe.
yuriksbah XD, let's try again
yuriksgeordi: { Foo init = Foo::makeMe(); } class Foo : boost::noncopyable { static Foo& makeMe() { return Foo(); } private: Foo() { } };
geordierror: invalid initialization of non-const reference of type 'Foo&' from an rvalue of type 'Foo'
yuriksgeordi: remove : boost::noncopyable
geordiSame error.
yuriksgeordi: show
geordi{ Foo init = Foo::makeMe(); } class Foo  { static Foo& makeMe() { return Foo(); } private: Foo() { } };
yuriksso this still isn't working
TinoDidriksen{ Foo init = Foo::makeMe(); } class Foo  { static Foo makeMe() { return Foo(); } private: Foo() { } };
geordierror: 'static Foo Foo::makeMe()' is private
TinoDidriksen{ Foo init = Foo::makeMe(); } struct Foo { static Foo makeMe() { return Foo(); } private: Foo() { } };
geordi<no output>
jonrafkindi have 'friend int ::main(int, char**);' inside a class, which itself is inside a namespace, but gcc gives me this error: error: int main(int, char**) should have been declared inside ::
jonrafkindhow am I supposed to declare main as a friend to the class?
TinoDidriksenjonrafkind, why do you need main to be a friend? That sounds wrong design...
jonrafkindyea yea I know
jonrafkindbut do you know how to get around it?
jonrafkindthe point is so I can have a singleton where only one instance can be created by main()
TinoDidriksen...and you want a singleton too!
TinoDidriksenDouble-plus ungood
TinoDidriksenAnyway, forward declare main()
jonrafkindah ok
yuriksTinoDidriksen: oh, right, I suck at geordi
yuriksok, so that works
yuriksgeordi: add `: boost::noncopyable` after `struct Foo`
geordierror: 'noncopyable_::noncopyable::noncopyable(const noncopyable_::noncopyable&)' is private
yuriksok, so yeah, that
yuriksis there any way to do that?
yuriksso, is there any way of doing the named constructor idiom with noncopyable objects?
yuriks(except C++0x move constructors)
fernandes-geordi: show
geordi{ Foo init = Foo::makeMe(); } struct Foo: boost::noncopyable { static Foo makeMe() { return Foo(); } private: Foo() { } };
fernandes-geordi: add & before init
geordierror: 'noncopyable_::noncopyable::noncopyable(const noncopyable_::noncopyable&)' is private
copproyuriks: yes
copprouse a different type for the named constructor
copprooh wait, I see what your issue is :/
copprojust initialize with (), not =
fernandes-but it has no def constructor?
yuriksgeordi: { Foo init(Foo::makeMe()); } struct Foo : boost::noncopyable { static Foo makeMe() { return Foo(); } private: Foo() { } };
geordiSame error.
yuriksit works in msvc++, atually
fernandes-it's a copy in either case (= or ()) right?
yuriksshouldn't it RVO?
villethe C++ standard requires the thing to be copyable, even if no copy occurs.
yuriksI could return a pointer... but returning a pointer ot a subsystem, meh
villewhy do you need to return a pointer? make a facade.
sleepsteris there an easy way to determine whether an ulong to int conversion is going to overflow?
freeone3000std::numeric_limits<int>::max will give you the maximum value of the int. Compare the current value of the ulong to that.
sleepsterthanks freeone3000
[o<< std::numeric_limits<int>::max
[o<< std::numeric_limits<int>::max()
[o<< std::numeric_limits<unsigned>::max()
[o<< std::numeric_limits<int64_t>::max()
[oso huge...
d1zzyand yet so small
Love4Boobiescan anyone explain to me why in they define the parameters of the operator with a & at the end?
TerminusLove4Boobies: because the parameters are references
Love4Boobiesi see. why so?
bradenLove4Boobies: In that case, because it's cheaper than making a copy.
TerminusLove4Boobies: for objects, it's more efficient to pass a const reference than to make a copy.
Love4Boobiesah, i didn't know it'd make a copy
Love4Boobiesit's 7:25 AM here btw
bradenLove4Boobies: C passes everything by copy. C++ gives you references.
Love4Boobieswrong channel
Love4Boobiesyes, i understand now
Popular searches: not in scope xmobar   netbsd ssd root disk   teratorn bounce   fedora guitar tuner   dlinlc atheros   

Generated by 2.1mg by Jeff Waugh - return