diff --git a/Packages/Interval_arithmetic/changes.txt b/Packages/Interval_arithmetic/changes.txt index e03211e1745..80fb3377c19 100644 --- a/Packages/Interval_arithmetic/changes.txt +++ b/Packages/Interval_arithmetic/changes.txt @@ -1,3 +1,7 @@ +Version 4.187 on 18 December 2003 +- Filtered_exact stores its potential cache as private base, to benefit from + the empty base class optimization. + Version 4.186 on 27 November 2003 - FreeBSD fix. diff --git a/Packages/Interval_arithmetic/include/CGAL/Filtered_exact.h b/Packages/Interval_arithmetic/include/CGAL/Filtered_exact.h index 41e46202398..9561c7cbb17 100644 --- a/Packages/Interval_arithmetic/include/CGAL/Filtered_exact.h +++ b/Packages/Interval_arithmetic/include/CGAL/Filtered_exact.h @@ -73,6 +73,7 @@ typedef Interval_nt_advanced Filter_Cache; template < class CT, class ET, class Type = Dynamic, bool Protection = true, class Cache = No_Filter_Cache > class Filtered_exact + : private Cache // To benefit from the empty base class optimization. { typedef Filtered_exact Fil; typedef Interval_nt_advanced IA; @@ -97,12 +98,13 @@ class Filtered_exact inter = give_interval (No_Filter_Cache()); } - void update_cache() { compute_cache (_cache); } + void update_cache() { compute_cache (cache()); } - // Private data members. + const Cache & cache() const { return *this; } + Cache & cache() { return *this; } + // Private data member. CT _value; - Cache _cache; public: @@ -112,7 +114,7 @@ public: Filtered_exact () {} Filtered_exact (const Filtered_exact & fil) - : _value(fil._value), _cache(fil._cache) {} + : Cache(fil.cache()), _value(fil._value) {} Filtered_exact (const CT & ct) : _value(ct) { update_cache(); } template @@ -121,7 +123,7 @@ public: // The access functions. const CT & value() const { return _value; } - IA interval() const { return give_interval(_cache); } + IA interval() const { return give_interval(cache()); } ET exact() const { return convert_to(_value); } double to_double() const { return CGAL::to_double(_value); }