Skip to content

Instantly share code, notes, and snippets.

@geektoni geektoni/some.cpp
Created May 19, 2017

Embed
What would you like to do?
#include <shogun/base/some.h>
#include <iostream>
class base {
public:
base() : val(1) {};
virtual void print() {std::cout << val << std::endl;}
int ref() {};
int unref() {};
private:
int val;
};
class der : public base {
public:
void print() {std::cout << "DER" << std::endl;}
};
void method(base *a) { a->print();}
void method2(shogun::Some<base> a) {a->print();}
int main() {
shogun::Some<base> tmp {new base()};
shogun::Some<der> tmp2 {new der()};
method(tmp); // <--Why these two do not fail?
method(tmp2);// <--^
method2(tmp);
//method2(tmp2); <- Fail as expected
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.