Why is r-value reference constructor called in this case?

The return-as-rvalue rules changed in response to the review before publication of C++14. The change was added late in the process and is captured by CWG Issue 1579, that amends 12.8/32 with the wording: or when the expression in a return statement is a (possibly parenthesized) id-expression that names an object with automatic storage duration … Read more

How do I easily convert from one collection type to another during a filter, map, flatMap in Scala?

Using breakOut Use breakOut as the CanBuildFrom and let the typer know what you want your result type to be (unfortunately you need to specify String here) scala> import collection.breakOut import collection.breakOut scala> List(1, 2, 3) res0: List[Int] = List(1, 2, 3) scala> res0.map(_.toString)(breakOut) : Vector[String] res2: Vector[String] = Vector(1, 2, 3) Using to[Collection] (starting … Read more

Is it possible in Intellij IDEA Scala plugin to know which implicit conversion was applied?

Yes it is possible (IntelliJ IDEA 11.1.3 CE with Scala Plug-In 0.5.948, but this has been possible for a while). You need to select the receiver not the method itself. For instance, assume dataDir is of type java.io.File. Then I can do dataDir.listFiles().foreach( … ) where foreach is available through implicit conversion from Array to … Read more

How can I convert Scala Map to Java Map with scala.Float to java.Float k/v conversion

The solution linked to by @pagoda_5b works: Scala convert List[Int] to a java.util.List[java.lang.Integer] scala> import collection.JavaConversions._ import collection.JavaConversions._ scala> val m = mapAsJavaMap(Map(1 -> 2.1f)).asInstanceOf[java.util.Map[java.lang.Integer, java.lang.Float]] m: java.util.Map[Integer,Float] = {1=2.1} scala> m.get(1).getClass res2: Class[_ <: Float] = class java.lang.Float

Constexpr if with a non-bool condition

Clang is diagnosing under these paragraphs [stmt.if] (emphasis mine) 2 If the if statement is of the form if constexpr, the value of the condition shall be a contextually converted constant expression of type bool; this form is called a constexpr if statement. [expr.const] 4 A converted constant expression of type T is an expression, … Read more

Is there a way to avoid implicit conversion to void*?

Is there any way to disable implicit conversion to void* for pointers to a certain class? No, you can’t prevent the implicit conversion, but you could wrap the API function(s) in proxy functions that checks types at compile time and approve/disapprove them there. Example: #include <iostream> #include <string> #include <type_traits> void api(void* p) { // … Read more

Concatenate two Dictionaries [duplicate]

I think you defined your GroupNames as Dictionary<string,string>, so you need to add ToDictionary like this: GroupNames = GroupNames.Concat(AddedGroupNames) .ToDictionary(x=>x.Key,x=>x.Value); Note that 2 original dictionaries would have different keys, otherwise we need some rule to merge them correctly.

Why is signed and unsigned addition converted differently for 16 and 32 bit integers?

When you do uint16_t(2)+int16_t(-3), both operands are types that are smaller than int. Because of this, each operand is promoted to an int and signed + signed results in a signed integer and you get the result of -1 stored in that signed integer. When you do uint32_t(2)+int32_t(-3), since both operands are the size of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)