简体   繁体   中英

C++ What happens to a Template Metaprogram's O notation?

Suppose that I will be able to implement a template metaprogram that will "search for a duplicate element in an array or any container" or say a Fibonacci template metaprogram. We know that the best case performance for this is O(N^2) and O(2^N) for the Fibonacci. What happens to the time complexity, since templates are evaluated/loaded on compile time? Would it become O(1) or will it depend on the number of elements of a container O(N)?

Suppose that I will be able to implement a template metaprogram that will "search for a duplicate element in an array or any container"

In order to do that with template metaprogramming, the contents of the container would have to be known at compile time .

There's no way to use template metaprogramming to shift the complexity burden off of run-time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM