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
10 export module Fibonacci.Cache;
12 export namespace Fibonacci
14 constexpr unsigned long Recursive(unsigned long n)
20 return Recursive(n - 2) + Recursive(n - 1);
23 template<unsigned long N>
26 struct DefaultStrategy
28 constexpr unsigned long operator()(unsigned long n, auto... other) const
30 return (n + ... + other);
34 constexpr unsigned long Compute(Number<10ul>, auto strategy)
36 return strategy(Recursive(10ul));
39 template<unsigned long N, typename Strategy = DefaultStrategy>
40 constexpr unsigned long Cache = Compute(Number<N>{}, Strategy{});
42 template constexpr unsigned long Cache<10ul>;
46 // expected-no-diagnostics
47 import Fibonacci.Cache;
49 constexpr bool value = Fibonacci::Cache<10ul> == 55;
51 static_assert(value == true, "");