| 1 | #include <boost/type_traits/is_function.hpp>
|
|---|
| 2 |
|
|---|
| 3 | struct CallerConst
|
|---|
| 4 | {
|
|---|
| 5 | void Call() const
|
|---|
| 6 | {
|
|---|
| 7 | }
|
|---|
| 8 | };
|
|---|
| 9 |
|
|---|
| 10 | struct CallerNonConst
|
|---|
| 11 | {
|
|---|
| 12 | void Call()
|
|---|
| 13 | {
|
|---|
| 14 | }
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | struct FunctorNonConst
|
|---|
| 18 | {
|
|---|
| 19 | void operator()()
|
|---|
| 20 | {
|
|---|
| 21 | }
|
|---|
| 22 | };
|
|---|
| 23 |
|
|---|
| 24 | struct FunctorConst
|
|---|
| 25 | {
|
|---|
| 26 | void operator()() const
|
|---|
| 27 | {
|
|---|
| 28 | }
|
|---|
| 29 | };
|
|---|
| 30 |
|
|---|
| 31 | void Function()
|
|---|
| 32 | {
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | int main()
|
|---|
| 36 | {
|
|---|
| 37 | auto val1 = boost::is_function<void()>::value;
|
|---|
| 38 | auto val2 = boost::is_function<decltype(Function)>::value;
|
|---|
| 39 | auto val3 = boost::is_function<decltype(CallerConst().Call())>::value;
|
|---|
| 40 | auto val4 = boost::is_function<decltype(CallerNonConst().Call())>::value;
|
|---|
| 41 | auto val5 = boost::is_function<decltype(FunctorNonConst().operator())>::value;
|
|---|
| 42 | auto val6 = boost::is_function<decltype(FunctorConst().operator())>::value; // VC++ compile error if any of val1, val2, val5 is present
|
|---|
| 43 |
|
|---|
| 44 | return 0;
|
|---|
| 45 | }
|
|---|