Skip to content

gggin/ifconstexpr_cpp98

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

IfConstExprCpp98

I hope this project will help someone that first go into TMP(template meta program). It's not difficult but cute.

//in c++17 it's so easy:
template<typename T>
void run(T a)
{
        if constexpr(std::is_integral_v<int>)
        {
            std::cout << "FuncA " << a << std::endl;
        }
        else
        {
            std::cout << "FuncB " << a << std::endl;
        }
}
int main()
{
        run(1);
        run(2.3);
        return 0;
}

In main.cpp there is cpp98 vesrion.

About

if constexpr in cpp98

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages