Hi,
I would like to have overloading functions such that they are dispatched
with boost concepts.
See minimal example below:
#include <iostream>
#include
#include
template<class T>
struct XConcept {
BOOST_CONCEPT_USAGE(XConcept) {
int x = t.x;
}
private:
T t;
};
template<class T>
struct XYConcept : XConcept<T> {
BOOST_CONCEPT_USAGE(XYConcept) {
int y = t.y;
}
private:
T t;
};
template<typename T>
BOOST_CONCEPT_REQUIRES( ((XConcept<T>)), (void))
foo(T t) {
std::cout << "XConcept works!" << std::endl;
}
template<typename T>
BOOST_CONCEPT_REQUIRES( ((XYConcept<T>)), (void))
foo(T t) {
std::cout << "XYConcept works!" << std::endl;
}
int main() {
struct { int x; } xtest;
struct { int x, y; } xytest;
foo(xtest);
foo(xytest);
return 0;
}
Expected output:
XConcept works!
XYConcept works!
Can anyone help me with this?
Att.
Neuton Jr