overloading

C++ explicit return type template specialisation

喜你入骨 提交于 2019-12-25 09:34:29
问题 This is a follow up on this (more general) question: previous question. A partial answer to the present question is given here: partial answer to the present question. I am interested in explicit specialisation of the return type based on the template argument. While the answer presented above provides a solution to the problem, I believe that there is a more elegant way of solving the problem using C++11/14 techniques: template<int N> auto getOutputPort2(); template<> auto getOutputPort2<0>(

Is there a way to work around Ambiguous method call without casting?

痴心易碎 提交于 2019-12-25 08:47:20
问题 Initial Question I have the following code: public static void main(String[] args) throws Exception { test(new LinkedList()); } public static void test(Queue qeueue){ System.out.println("Queue"); } public static void test(List list){ System.out.println("List"); } InteliJ is not letting me run the project. Is there any way to work around this issue? Which of the two would the JVM use if both are equal in specificity? Is it random? I have read related SO q/a but no one gives an answer how to

Ambiguous lambda overload in Guava Futures

老子叫甜甜 提交于 2019-12-25 08:21:54
问题 I believe I am facing an eclipse bug here, but I'd like to confirm. I am using java 8 (jdk 1.8.0_102), and my code compiles normally, but eclipse gives me an error. My code looks like this: public ListenableFuture<ProtoBufExchange> myMethod( //some code here return Futures.transform(future,(Request.Builder reqBuilder) -> { //some code here return Futures.immediateFuture(exchange); } The error shown in eclipse is this: The method transform(ListenableFuture<Request.Builder>, AsyncFunction<?

Operator<< Overloading, endl leads to segmentation fault [closed]

不打扰是莪最后的温柔 提交于 2019-12-25 05:35:31
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Just moved my program over from windows to linux and the same code that worked now gives me a segmentation fault when calling the operator<< function from main. (overview) My programs is a Vector class that takes input and returns what the input is, but when reach << endl it crashes, if I remove endl from main()

Add a Property to Entity Class in ViewModel

被刻印的时光 ゝ 提交于 2019-12-25 05:30:42
问题 I have a profile with a EntityCollection of ProfileUser. In this Class I have a Profile_ID ald a Profile relation and a User_ID but no USer relation, because User is in another Database. In a Datagrid I want to access via User.Username I tried this, but ofc it doesnt work... public EntityCollection<ProfileUser> ProfileUsers { get { if (profile != null) return profile.ProfileUser; else return null; } set { profile.ProfileUser = value; } } and here my custom Class public class

Is it possible to have polymorphic member overloading in C++?

别来无恙 提交于 2019-12-25 04:38:22
问题 I have been working on a Roguelike, and run into a problem with it. My problem is that I would like to use "polymorphic overloading" or sorts, but I'm guessing C++ doesn't support. My class diagram is like this: xMapObject <- xEntity <- xVehicle An the problem is, it is possible to have this: class xMapObject { public: virtual void Bump(xMapObject *MapObject); virtual void Bump(xEntity *Entity); virtual void Bump(xVehicle *Vehicle); virtual void BumpedBy(xMapObject *MapObject); virtual void

Dynamic cast in Java

若如初见. 提交于 2019-12-25 03:25:14
问题 I'm not sure if this is what it's called, but here is the problem: I have a superclass with three subclasses. Let's say Superclass, Subclass1, Subclass2,Subclass3 I have another class with the following overloaded method: public void exampleMethod (Subclass1 object1){ //Method to be called if the object is of subclass 1 } public void exampleMethod (Subclass2 object2){ //Method to be called if the object is of subclass 2 } public void exampleMethod (Subclass3 object3){ //Method to be called if

How to ignore white spaces input stream in operator overload >>

为君一笑 提交于 2019-12-25 02:11:50
问题 Currently my overloaded operator>> function takes the input [4: 1 2 3 4 ] and works fine. But how can I ignore any number of white spaces so that it can accept [ 4 : 1 2 3 4 ] , i.e any number of white spaces before the input? istream& operator>>( istream & stream, my_vector & vector_a ) { string token2; int vec_size; vector<double> temp_vec; bool push = false; while (stream >> token2) { if (token2[0] == '[' && token2[2] ==':') { push = true; } if (token2 == "]") { break; } else if(!(token2[0

Specializing and or Overloading member function templates with variadic parameters

淺唱寂寞╮ 提交于 2019-12-25 01:48:54
问题 Trying to resolve overload resolution for class member: static function template overload - partial specialization. I currently have a class declared / defined as such: Note: my use of Param a , Param b , Param c etc. are not related to the actual declarations / definitions directly. These can be any arbitrary type that is passed into the functions for example: it could be int a , enum b , char c . I'm just using this to only show the pattern of the declarations, however all of the different

What is (is there?) a purpose behind declaring a method twice when parent class appears to not change any properties?

旧街凉风 提交于 2019-12-25 01:05:50
问题 So I am looking at these respective classes (and subclasses)... public class Control{ public Control(){} public Control(String name, String type, ContainerControl owner){ //do stuff here } } public class ContainerControl extends Control{ public ContainerControl() { super(); } public ContainerControl(String name, String type, ContainerControl owner) { super(name, type, owner); controls = new Controls(); //exists somewhere else } } public class SSTab extends ContainerControl{ public SSTab(){