#include <type_traits>
#include <utility>
#include <cstdint>
struct ICounter {};
struct Counter: public ICounter {
void increase() {
}
};
template <typename T> void inc_counter(
T& counterObj,
typename std::enable_if<
std::is_base_of<ICounter, T>::value
>::type* = nullptr ){
counterObj.increase();
}
template <typename T> void inc_counter(
T& counterInt,
typename std::enable_if<
std::is_integral<T>::value
>::type* = nullptr ){
++counterInt;
}
void doSomething() {
Counter cntObj;
uint32_t cntUI32;
inc_counter(cntObj);
inc_counter(cntUI32);
}
struct Counter {
void increase() {
}
};
template <typename T>
void inc_counter(T& intTypeCounter, std::decay_t<decltype(++intTypeCounter)>* = nullptr) {
++intTypeCounter;
}
template <typename T>
void inc_counter(T& counterObj, std::decay_t<decltype(counterObj.increase())>* = nullptr) {
counterObj.increase();
}
void doSomething() {
Counter cntObj;
uint32_t cntUI32;
inc_counter(cntObj);
inc_counter(cntUI32);
}