Is a `=default` move constructor equivalent to a member-wise move constructor?

Yes both are the same. But struct Example { string a, b; Example(Example&& mE) = default; Example& operator=(Example&& mE) = default; } This version will permits you to skip the body definition. However, you have to follow some rules when you declare explicitly-defaulted-functions : 8.4.2 Explicitly-defaulted functions [dcl.fct.def.default] A function definition of the form: attribute-speciļ¬er-seqopt … Read more

Change Magento default status for duplicated products

Try this: Create: app/code/local/MagePal/EnableDuplicateProductStatus/etc/config.xml <?xml version=”1.0″?> <config> <modules> <MagePal_EnableDuplicateProductStatus> <version>1.0.1</version> </MagePal_EnableDuplicateProductStatus> </modules> <global> <models> <enableduplicateproductstatus> <class>MagePal_EnableDuplicateProductStatus_Model</class> </enableduplicateproductstatus> </models> <events> <catalog_model_product_duplicate> <observers> <enableduplicateproductstatus> <type>singleton</type> <class>enableduplicateproductstatus/observer</class> <method>productDuplicate</method> </enableduplicateproductstatus> </observers> </catalog_model_product_duplicate> </events> </global> </config> Create: app/code/local/MagePal/EnableDuplicateProductStatus/Model/Observer.php class MagePal_EnableDuplicateProductStatus_Model_Observer { /** * Prepare product for duplicate action. * * @param Varien_Event_Observer $observer * @return object */ public function productDuplicate(Varien_Event_Observer … Read more

Return a default value if single row is not found

One way to do it SELECT IFNULL(MIN(`file`), ‘default.webm’) `file` FROM `show`, `schedule` WHERE `channel` = 1 AND `start_time` <= UNIX_TIMESTAMP() AND `start_time` > UNIX_TIMESTAMP()-1800 AND `show`.`id` = `schedule`.`file` ORDER BY `start_time` DESC LIMIT 1 Since you return only one row, you can use an aggregate function, in that case MIN(), that ensures that you’ll get … Read more

Set back default floating point print precision in C++

You can get the precision before you change it, with std::ios_base::precision and then use that to change it back later. You can see this in action with: #include <ios> #include <iostream> #include <iomanip> int main (void) { double d = 3.141592653589; std::streamsize ss = std::cout.precision(); std::cout << “Initial precision = ” << ss << ‘\n’; … Read more