3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/Cache.cppm -o %t/Cache.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fmodule-file=Fibonacci.Cache=%t/Cache.pcm \
7 // RUN: -fsyntax-only -verify
9 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/Cache.cppm -o %t/Cache.pcm
10 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fmodule-file=Fibonacci.Cache=%t/Cache.pcm \
11 // RUN: -fsyntax-only -verify
14 export module Fibonacci.Cache;
16 export namespace Fibonacci
18 constexpr unsigned long Recursive(unsigned long n)
24 return Recursive(n - 2) + Recursive(n - 1);
27 template<unsigned long N>
30 struct DefaultStrategy
32 constexpr unsigned long operator()(unsigned long n, auto... other) const
34 return (n + ... + other);
38 constexpr unsigned long Compute(Number<10ul>, auto strategy)
40 return strategy(Recursive(10ul));
43 template<unsigned long N, typename Strategy = DefaultStrategy>
44 constexpr unsigned long Cache = Compute(Number<N>{}, Strategy{});
46 template constexpr unsigned long Cache<10ul>;
50 // expected-no-diagnostics
51 import Fibonacci.Cache;
53 constexpr bool value = Fibonacci::Cache<10ul> == 55;
55 static_assert(value == true, "");