Created
May 19, 2017 07:46
-
-
Save geektoni/e78b204bb5a8fd1f17c933ab9c0912e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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