Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // TestMulti
- //
- // Created by Rizky Herucakra on 7/1/13.
- // Copyright (c) 2013 Rizky Herucakra. All rights reserved.
- //
- #include <iostream>
- template<size_t v> struct antilog2;
- template<> struct antilog2<1>{
- enum { result = 0};
- };
- template<> struct antilog2<2>{
- enum { result = 1};
- };
- template<> struct antilog2<4>{
- enum { result = 2};
- };
- template<> struct antilog2<8>{
- enum { result = 3};
- };
- template<> struct antilog2<16>{
- enum { result = 4};
- };
- template <size_t m,typename T>
- T mul_sh(T val){
- return val << antilog2<m>::result;
- }
- int main(int argc, const char * argv[])
- {
- std::cout << "result = " << mul_sh<2>(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement