| 1 | #include <iostream>
|
|---|
| 2 | #include <boost/concept_check.hpp>
|
|---|
| 3 | #include <boost/concept/requires.hpp>
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | template <typename T>
|
|---|
| 7 | struct foo
|
|---|
| 8 | { };
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | template <class X>
|
|---|
| 12 | struct DummyConcept
|
|---|
| 13 | {
|
|---|
| 14 | typedef typename X::something something;
|
|---|
| 15 |
|
|---|
| 16 | BOOST_CONCEPT_USAGE(DummyConcept){
|
|---|
| 17 | }
|
|---|
| 18 | };
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | template<typename T>
|
|---|
| 22 | BOOST_CONCEPT_REQUIRES(
|
|---|
| 23 | ((DummyConcept<T>)),
|
|---|
| 24 | (void))
|
|---|
| 25 | func(T&)
|
|---|
| 26 | { std::cout << "first overload" << std::endl; }
|
|---|
| 27 |
|
|---|
| 28 | template<typename T>
|
|---|
| 29 | void func(foo<T>)
|
|---|
| 30 | { std::cout << "second overload" << std::endl; }
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | int main()
|
|---|
| 34 | {
|
|---|
| 35 | func(foo<int>());
|
|---|
| 36 | return 0;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|