Skip to content

Instantly share code, notes, and snippets.

@geektoni
Created May 19, 2017 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geektoni/e78b204bb5a8fd1f17c933ab9c0912e8 to your computer and use it in GitHub Desktop.
Save geektoni/e78b204bb5a8fd1f17c933ab9c0912e8 to your computer and use it in GitHub Desktop.
#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