Home Lab

Thursday, October 6, 2016

template fibonacci


template<long n>
struct fibonacci {
 static const long value = fibonacci<n - 1>::value + fibonacci<n - 2>::value;
};

template<> struct fibonacci<1> { static const long value = 1; };
template<> struct fibonacci<2> { static const long value = 1; };

Posted by James at 8:22 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2017 (1)
    • ►  January (1)
  • ▼  2016 (121)
    • ►  December (11)
    • ►  November (17)
    • ▼  October (20)
      • Writing Linux C++ code in VS 2015
      • Using VS code C++ extension for MSVC project
      • using iterator_trait to get iterator type to *valu...
      • C++ iterator, Func as operator () or std:function ...
      • Transform a type into awaitable by Adapter or pass...
      • co_await vs. future.get()
      • generator pipeline and accumulate
      • how future made avaitable
      • co_wait co_return co_yield
      • Delayed Evaluation and Expression template
      • type traits compile time if in typedef
      • type traits is_const and variadic template extendi...
      • Rx Replay
      • What are the frequency of HFT
      • Memory Model in Drawing
      • Set Up IDE to compile C++17 code constexpr with st...
      • Dependency Walker for .Net
      • template fibonacci
      • Specialization Template
      • VMMap and RamMap
    • ►  September (5)
    • ►  July (1)
    • ►  April (11)
    • ►  March (33)
    • ►  February (23)
Simple theme. Powered by Blogger.