- Norco, Hydrocodone, Subutex, Percocet, Xanax, Ritalin, Vicodin, Opana ER, Dilaudid, Buprenorphine, MS Contin, Morphine Vial, Hydromorphone Vials, Hydromprhone Pills, Oxymorphone ER, Oxymorphone IR pills, Roxy 30mg, Fentanyl, Fentanyl, EMAIL : keystonemeds@protonmail.com / -Tel: +1(213) 5346894 - 1 Update
- Virtual Functions and Polymorphism - 3 Updates
- My C++ exercise for today (2017-03-30) - 1 Update
- peformance of wait notify concept of condition variable - 13 Updates
- function type inside template - 1 Update
- Virtual Functions and Polymorphism - 5 Updates
- vector<double> hour {vector<double>(24, -7777)}; <--> vector<double> hour(24, -7777); - 1 Update
Legit Deals <no_email@invalid.invalid>: Apr 27 01:17PM We strive to meet everyone of their Pharmaceutical needs. With our Service, you are guaranteed to find the absolute Lowest Prices for Buying medicine With or Without your Prescription. When you become a valued Customer of our Pharmacy, you no longer have to worry about looking elsewhere because we have everything you need We do offer discount as well to bulk buyers. We offer: - Good quality Meds. - Good and affordable prices. - Fast and Reliable delivery -Tracking Available! - Various shipping option (Overnight and Regular). - No Prescription Required! No package sign-off - Buy Direct and Save Time and Money! - 100% Customer Satisfaction Guaranteed EMAIL : keystonemeds@protonmail.com / -Tel: +1(213) 5346894 / -Get W1ckr App and message Us at W1ckr ID: intermeds247 !!!!OVERNIGHT SHIPMENTS ๐ฆ NOW AVAILABLE !!!! NO CUSTOM ISSUES & NO PACKAGE SIGN-OFFS, SUCCESSFUL DELIVERIES ๐๐ป Pain/ Anxiety Pills Seconal Nembutal (Powder,Pills and Liquid form) Oxycontin / Oxycodone 10,20 a,40 and 80 mg Actavis Promethazine Codeine Purple Cough Syrup (16oz and 320z) Hydrocodone 10500, 10325 ,7.5750 mg Valium 10,15 and 20 mg Xanax 1 and 2 mg Dilaudid 2,4 and 8 mg Ritalin 5,10, 20 mg Percocet 7.5mg,5mg and 10mg Opana 20mg and 40mg Lorcet - (Hydrocodone Bitartrate/Acetaminophen) 10 mg/650 mg Midazolam 3mg Motrin 400mg and 600mg Norco - ( Hydrocodone Bitartrate/Acetaminophen ) 5 mg/325 mg Soma 350mg Tramadol (Ultram) 50mg Valium 2mg,5mg and 10mg Valium Roche Brand 10mg Voltaren 50mg and 100mg Adderall, Anaprox, Ansaid, Acephen Bupren , !!!!OVERNIGHT SHIPMENTS ๐ฆ NOW AVAILABLE !!!! NO CUSTOM ISSUES & NO PACKAGE SIGN-OFFS, SUCCESSFUL DELIVERIES ๐๐ป ex, Butrans , Percocet, Phrenilin, Percodan Soma, Subutex Cataflam, Celebrex Flexeril, Fentora.. , Demerol, Daypro, Dilaudid Endocet Lorcet, Lortab Ibudone Methadone, Morphine Naprosyn , Norco , Oxycontin, Opana Ritalin, Roxicodone , Ultram , Vicodin, Voltaren, Vicoprofen , Cocaine, MDMA, 4-Methylaminorex, 4-MMC, MDPV, LSD, DMT, 5-MeO's PCP, Heroin, Ketamine DXM powder, Dexedrine, Adderall, Nubain nalbuphine 20mg/ml, Onax, Lorazepam, Diazepam, Clonazepam, Alprazolam, Norco, Hydrocoden, Percocet, Xanax, Ritalin, Vicodin, Opana ER, Dilaudid, Buprenorphine, MS Contin, Morphine Vial, Hydromorphone Vials, Hydromprhone Pills, Oxymorphone ER, Oxymorphone IR pills, Roxy 30mg, Fentanyl, Fent Patches Gel, Fent pops Atiq 1200mcg, Fentora, 300ug Diabetes Pills Infidelity Pills Please do contact us for your best order and good prices, Delivery is via USPS, TNT, AUSPOST, FEDEX, UPS and Express Mail depending on customers and much more. we offer discreet shipping world wide depending on the buyers location. We offer fast overnight shipping and reliable shipping within USA, to Australia, Canada, UK, Germany, Sweden etc We offer our price list as per the buyers order. Send in you order via EMAIL : keystonemeds@protonmail.com / -Tel: +1(213) 5346894 / -Get W1ckr App and message Us at W1ckr ID: intermeds247 !!!!OVERNIGHT SHIPMENTS ๐ฆ NOW AVAILABLE !!!! NO CUSTOM ISSUES & NO PACKAGE SIGN-OFFS, SUCCESSFUL DELIVERIES ๐๐ป |
ram@zedat.fu-berlin.de (Stefan Ram): Apr 27 02:40AM >"Virtual function call is resolved at run-time (dynamic binding) Forget inheritance and learn about article usage in English, unless you want to teach in an area where a dialect of English is used that follows your article usage. An expert C++ programmer or teacher must know all about this early/late binding topic. However, when your contract just requires you to teach /basic/ C++ without inheritance, you might start to teach right now, and learn inheritance topics "on the job" (while you are already teaching). When you are asked about something you don't know in the classroom, you might either decline to answer it (when it's not part of the curriculum of the current course) or answer that you need to do some research and will answer it in a week. Virtual functions are a part of the topic of »class hierarchies«, and Bjarne Stroustrup writes: "Many people taught - and some continue to teach - C++ as either a very low-level language with a focus on features shared with C, or as a language for expressing class hierarchies. Both approaches fail to emphasize C++'s greatest strengths. Worse: such approaches often spend so much time on parts of C++ that are not very supportive of programmers that they fail to teach facilities and techniques critical to effective use of C++. The standard library containers and algorithms and the use of exceptions in resource management are examples of key topics that are often neglected, or wrongly considered advanced." - BJARNE STROUSTRUP Well, let me write a program to show some of the virtual/nonvirtual effects (I am very unexperienced in this. I don't know whether I got the virtual destructor declarations right): main.cpp #include <initializer_list> #include <iostream> #include <memory> #include <ostream> #include <string> using namespace ::std::literals; namespace { struct B { void n() const { ::std::cerr << "::B::n\n"s; } virtual void v() const; virtual ~B() = default; }; void ::B::v() const { ::std::cerr << "::B::v\n"s; } struct D : public B { void n() const { ::std::cerr << "::D::n\n"s; } void v() const override; ~D() override = default; }; void ::D::v() const { ::std::cerr << "::D::v\n"s; } /* end of anonymous namespace */ } int main() { const ::std::unique_ptr< ::B >b = ::std::make_unique< ::D >(); b->n(); b->v(); } transcript ::B::n ::D::v And you /must/ read "GotW #5" "Overriding Virtual Functions" from 2013! |
ram@zedat.fu-berlin.de (Stefan Ram): Apr 27 02:49AM >{ const ::std::unique_ptr< ::B >b = ::std::make_unique< ::D >(); PS: The above might not be incorrect, buy what I wanted to write was: { const ::std::unique_ptr< ::B const >b = ::std::make_unique< ::D const >(); (with two more ่onstๅ). |
udpbot <bleachbot@httrack.com>: Apr 27 03:17PM +0200 |
Tim Rentsch <txr@alumni.caltech.edu>: Apr 27 05:42AM -0700 >> the k'th row, since any solution must have one queen in each row. > A better approach is to simply keep track of free rows, columns and > diagonals (both). [..elaboration..] Good idea. For larger board sizes I expect this approach scales better than my suggestion. For boards of modest size using bitmaps seems easier and probably also faster. Regular 8x8 boards, for example, fit nicely in a single unsigned long long. Then checking to see if a square is covered (the more common operation) is just an &, and placing a piece can be done with an indexed lookup and an |. Also, because the covering state is held in a small unit, updates can be done by value (passing the board state down a recursive call) so no "undoing" is needed. This scheme should scale reasonably up to two or four words, with four words being enough for a 16x16 board. |
Ian Collins <ian-news@hotmail.com>: Apr 27 02:26PM +1200 On 04/27/17 01:24 AM, kushal bhattacharya wrote: > notified,but within that it has some condtion to fulfil according to > condition.wait().So,thinking about this,am i compromising some > performance here and is it one of the culprit behind this delay? Google "Thundering herd problem" :) -- Ian |
woodbrian77@gmail.com: Apr 26 08:30PM -0700 On Wednesday, April 26, 2017 at 9:26:40 PM UTC-5, Ian Collins wrote: > > condition.wait().So,thinking about this,am i compromising some > > performance here and is it one of the culprit behind this delay? > Google "Thundering herd problem" :) I suggest Duckduckgo as an alternative to Google: https://duckduckgo.com Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
"Chris M. Thomasson" <invalid@invalid.invalid>: Apr 26 10:22PM -0700 On 4/26/2017 7:26 PM, Ian Collins wrote: >> condition.wait().So,thinking about this,am i compromising some >> performance here and is it one of the culprit behind this delay? > Google "Thundering herd problem" :) Oh yeah, that's bad. I have seen the problem when some code was using broadcast when it only needed a single signal, but I cannot seem to remember seeing a 10s wait time to signal a thread in a condition variable before. The OP's critical section must be overly complex and/or overloaded. Also, its not good to send 500 threads through a single funnel. ;^) |
kushal bhattacharya <bhattacharya.kushal4@gmail.com>: Apr 26 10:26PM -0700 On Wednesday, April 26, 2017 at 10:18:38 PM UTC+5:30, Marcel Mueller wrote: > service a queue of incoming requests. This limits the parallelism to a > reasonable level. > Marcel by blocking operation when i log something in a file from different threads is it part of blocking operation? |
kushal bhattacharya <bhattacharya.kushal4@gmail.com>: Apr 26 10:29PM -0700 On Thursday, April 27, 2017 at 12:27:40 AM UTC+5:30, Jerry Stuckle wrote: > Jerry Stuckle > jstucklex@attglobal.net > ================== 500 threads are run parrallely i have checked that happening.The thing i am concerned about is about the architechture i am following right now |
kushal bhattacharya <bhattacharya.kushal4@gmail.com>: Apr 26 10:31PM -0700 On Thursday, April 27, 2017 at 10:52:15 AM UTC+5:30, Chris M. Thomasson wrote: > variable before. The OP's critical section must be overly complex and/or > overloaded. Also, its not good to send 500 threads through a single > funnel. ;^) in the critical section i am just fetching out the value from the list thats the only thing i am doing right now.So,i dont think that would take much time in processing |
kushal bhattacharya <bhattacharya.kushal4@gmail.com>: Apr 26 10:34PM -0700 On Thursday, April 27, 2017 at 10:52:15 AM UTC+5:30, Chris M. Thomasson wrote: > variable before. The OP's critical section must be overly complex and/or > overloaded. Also, its not good to send 500 threads through a single > funnel. ;^) Could you please explain about what do you mean by single funnel |
Paavo Helde <myfirstname@osa.pri.ee>: Apr 27 08:38AM +0300 On 27.04.2017 8:31, kushal bhattacharya wrote: > in the critical section i am just fetching out the value from the list thats the only thing i am doing right now.So,i dont think that would take much time in processing When dealing with bottlenecks, you don't think. You measure. |
Ian Collins <ian-news@hotmail.com>: Apr 27 05:51PM +1200 On 04/27/17 05:22 PM, Chris M. Thomasson wrote: > variable before. The OP's critical section must be overly complex and/or > overloaded. Also, its not good to send 500 threads through a single > funnel. ;^) I first struct it when I was writing a simulator for a power system that could have up to 128 rectifier modules on a serial bus. Naturally I just gave each rectifier it's own thread and used a mutex/condvar for the "bus". Worked well with a couple of modules, flat lined my new shiny Pentium era build machine with 128... It would probably work OK on current 32 core/64 thread machines :) -- Ian |
"Chris M. Thomasson" <invalid@invalid.invalid>: Apr 26 11:18PM -0700 On 4/26/2017 10:34 PM, kushal bhattacharya wrote: >> overloaded. Also, its not good to send 500 threads through a single >> funnel. ;^) > Could you please explain about what do you mean by single funnel Using a single mutex is a huge bottleneck with 500 threads pounding away at it. Imagine a tiny funnel that lets one drop out at a time, and each drop was a thread. Now pour 500 drops into it and wait. Its like an hourglass where each grain of sand is a thread, and the bottleneck allows one grain through at a time. Now imagine pouring 500 drops into a colander. The bottleneck is less extreme... ;^) |
"Chris M. Thomasson" <invalid@invalid.invalid>: Apr 26 11:22PM -0700 On 4/26/2017 1:50 PM, Chris M. Thomasson wrote: > IO wrt the target platform. For instance, on windows use Input Output > Completion Ports (IOCP), on a Posix system use the AIO API. > Creating a thread per connection is not going to scale at all. Even the model of creating a couple of worker threads per cpu has issues if all of them are blasting a single mutex. |
kushal bhattacharya <bhattacharya.kushal4@gmail.com>: Apr 27 02:15AM -0700 On Thursday, April 27, 2017 at 11:52:29 AM UTC+5:30, Chris M. Thomasson wrote: > > Creating a thread per connection is not going to scale at all. > Even the model of creating a couple of worker threads per cpu has issues > if all of them are blasting a single mutex. So,How would i distribute work between notifying thread and the waiting threads these threads should work independently due to large number of connections involved here |
Ian Collins <ian-news@hotmail.com>: Apr 27 09:20PM +1200 On 04/27/17 09:15 PM, kushal bhattacharya wrote: > So,How would i distribute work between notifying thread and the > waiting threads these threads should work independently due to large > number of connections involved here You don't use one thread per connection, that is a really bad model if you want your application to scale. -- Ian |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Apr 27 07:17AM +0200 > boost::function<int(int,int)> boostFun2; > Why I cannot create an object of type int(int,int) ? e.g. > int(int,int) myFun; Shortest possible explanation: there's no syntax for that. But that short explanation ignores why there's no such syntax, so let's delve into that. Some computers (mostly digital signal processors) have Harvard architecture where machine code is kept in one memory, and data in another. Or at least it works as if that were the case. So a given address can mean one thing when used as a code memory address, and another when used as a data memory -- ordinary memory -- address. C++ and most conventional languages only support dealing directly with contents of data memory. When you declare a variable it's an abstraction of a piece of data memory. When you change the value of an object it's change of data memory contents. The language doesn't support inspecting or changing contents of code memory except that on most machines you can get at it via data memory, because on most machines, with von Neumann architecture, those memories and address spaces are in fact one and the same, the unification of code and data which Johann von Neumann (undeservedly) got famous for. However, C++ supports dealing with code memory addresses as /function pointers/. I.e. a data memory object that contains the start address of a function's machine code in code memory. You can't portably inspect the machine code at such an address, but you can copy these pointers around, in data memory, and you can invoke a function pointed to. Here's an example: #include <iostream> using namespace std; using My_func = auto(int, int) -> int; void do_something_with( My_func* const f ) { auto const addr = reinterpret_cast<void const*>( f ); cout << "It's function address " << addr << ".\n"; cout << "f(2, 3) = " << f(2, 3) << "\n"; } auto foo( int a, int b ) -> int { return a*b; } auto main() -> int { do_something_with( &foo ); } The cast to `void*` here, for the purpose of outputting the address, is not necessarily supported by any particular compiler. With C++11 and later is allowed to optionally support this, and most compilers do. But a compiler for a Harvard architecture digital signal processor may not necessarily support it, so even in practice this is not entirely portably code. A possibly more portable alternative is to use a cast to `uintptr_t`, but that's less convenient. Anyway, C++ has special support for function pointers. For example, as shown above, instead of writing `(*f)(2, 3)` you can write just `f(2, 3)`, as if the pointer were directly the name of a function. Also, instead of `My_func* f` (no `const`) you can write just `My_func f` as formal argument type, and because it is a formal argument type you get an automatic DECAY to pointer type, not just of the argument name used in an expression, but of the actual type of the argument. Which baffles many a novice. There's a corresponding decay of array to pointer to item. For both pointers and arrays there are also such decays for function and array names used in expressions, i.e. decays of expression value type. E.g. instead of `&foo` above, to get the address of `foo`, I could have written just `foo`. Happily these value type decays do not occur when you bind a function or array to a reference. Also, if you write My_func f; at namespace scope, then (as opposed to the literally same declaration as a formal argument) there's no type decay, and the result is not a data memory object but a declaration of a function in code memory. A definition of the function can't have that form -- there's no syntax for that -- but it's possible to just declare a function this way. I do not know what the rationale is. I've never needed it. Cheers & hth., - Alf |
Bilal <bilalcisco@googlemail.com>: Apr 26 05:25PM -0700 Hello everyone, I am newbie, so please bear with my post. I recently studied about 'virtual functions' (particularly in c++) and ran a couple of example codes successfully. I understood that 'virtual function' declared with virtual keyword is a member function of a class that can be overridden in its derived class. The above information/definition is more than enough for me to start using virtual functions for my purpose. However, some of the definitions available on internet are confusing. For example, over a dozen of web resources say "Virtual function call is resolved at run-time (dynamic binding) whereas the non-virtual member functions are resolved at compile time (static binding)". I read about the second definition from a dozen of books/internet resources and all of them keep iterating the same 'early/late binding' things. Just wondering how much is it useful to know the second definition for a future programmer/instructor. Finally, is it possible that a virtual member function call is resolved at compile-time and not at run-time. Thanks -Bilal |
Jerry Stuckle <jstucklex@attglobal.net>: Apr 26 08:48PM -0400 On 4/26/2017 8:25 PM, Bilal wrote: > Finally, is it possible that a virtual member function call is resolved at compile-time and not at run-time. > Thanks > -Bilal It is an important concept to understand. Virtual functions come into play when you have a pointer or reference to an object. When that is the case, the pointer or reference may be of the type base_class, but the actual object could be be of type derived_class. For instance, say you have a function class base_class { public: virtual void vf(); }; class derived_class_1 : public base_class { public: virtual void vf(); }; class derived_class_2 : public derived_class_1 { public: virtual void vf(); }; void f(base_class& br) { br.vf(); // Could call any of the virtual functions vf() } You could call it with base_class b; derived_class_1 d1; derived_class_2 d2; f(b); f(d1); f(d2); The compiler can't tell at compile time which it is, so it cannot predict which function will be called ; this must be done at run time - and is the basis of virtual functions. However, this is only if you have a pointer or reference - if you have the real object, the compiler can tell which function to call: b.vf(); // calls base_class::vf(); d1.vf(); // calls derived_class_1::vf(); d2.vf(); // calls derived_class_2::vf(); Hope this helps. Kinda hard to explain in a newsgroup post. Much easier with a whiteboard :) -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
Daniel <danielaparker@gmail.com>: Apr 26 06:52PM -0700 On Wednesday, April 26, 2017 at 8:48:46 PM UTC-4, Jerry Stuckle wrote: > The compiler can't tell at compile time which it is, so it cannot > predict which function will be called ; this must be done at run time - > and is the basis of virtual functions. Actually, sometimes the compiler can tell, and can devirtualize the function at compile time, particularly if the author of a class uses the final keyword. Daniel |
Ian Collins <ian-news@hotmail.com>: Apr 27 02:32PM +1200 On 04/27/17 12:25 PM, Bilal wrote: > resources and all of them keep iterating the same 'early/late > binding' things. Just wondering how much is it useful to know the > second definition for a future programmer/instructor. It's a very useful concept to grasp. With static/early binding the compiler always knows the the function to call and can embed the function's address directly in the generated code. Because it always knows the function to be called, it can, if conditions are right, inline the function body and avoid a call. > Finally, is it possible that a virtual member function call is > resolved at compile-time and not at run-time. Yes - if the compiler can determine which function will be called. -- Ian |
Jerry Stuckle <jstucklex@attglobal.net>: Apr 26 11:12PM -0400 On 4/26/2017 9:52 PM, Daniel wrote: > Actually, sometimes the compiler can tell, and can devirtualize the function at > compile time, particularly if the author of a class uses the final keyword. > Daniel An example? I have yet to see such a case. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
Christiano <christiano@engineer.com>: Apr 26 09:07PM -0300 On 04/26/17 03:18, Juha Nieminen wrote: >> vector of two elements (24 and -1). > I can't even begin to imagine how -7777 is converted to -1 when cast to > a double. You're right. I had not noticed that. The book defines two constants: const int not_a_reading = -7777; And const int not_a_month = -1; and the book actually says: """""book""""""""""""""""" [...] Why didn't we write struct Day { vector<double> hour {24, not_a_reading}; }; That would have been simpler, but unfortunately, we would have gotten a vector of two elements (24 and -1). [...] """"""""""""""""""""""""" The correct would be """""correction""""""""""""""""" [...] Why didn't we write struct Day { vector<double> hour {24, not_a_reading}; }; That would have been simpler, but unfortunately, we would have gotten a vector of two elements (24 and -7777). [...] """"""""""""""""""""""""" The author probably confused between not_a_reading and not_a_month. Verifying that you are right: $ cat number.cpp #include <iostream> #include <vector> using namespace std; int main() { vector<double> v {24, -7777}; cout << "Len: " << v.size() << ", v[0]: " << v[0] << ", v[1]: " << v[1] << "\n"; } $ CC number.cpp -std=c++11 $ ./a.out Len: 2, v[0]: 24, v[1]: -7777 $ I will report this bug in the ppp-public group: https://groups.google.com/forum/#!forum/ppp-public Thank you. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment