Skip to content

Commit

Permalink
avoid implicit destructor in BSplineBase.h
Browse files Browse the repository at this point in the history
allows BSplineBase.h to be included by itself when the explicit
instantation will be linked from elsewhere.
create v2.2.
  • Loading branch information
garyjg committed Jun 30, 2022
1 parent 9985696 commit a48980a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions BSpline/BSpline.dox
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ The HTML documentation is generated from the source files by Doxygen

@section releasenotes Release Notes

<h2>Release 2.2</h2>

Restore the explicit destructor so BSplineBase.h can be used by itself when
explicit instantiations will be linked from a library.

<h2>Release 2.1</h2>

Fix missing assignment operator bug in BSplineBase. Thanks to @@AlexRockliff
Expand Down
9 changes: 9 additions & 0 deletions BSpline/BSplineBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ BSplineBase<T>::BSplineBase(const T* x, int nx, double wl, int bc,
setDomain(x, nx, wl, bc, num_nodes);
}

// The destructor is declared in the class definition but not defined so the
// compiler does not try to generate it when the full implementation is not
// available. The implicit destructor fails to instantiate when BSplineBaseP
// is still incomplete, because the std::unique_ptr<BSplineBaseP> destructor
// cannot be instantiated. To fully instantiate BSplineBase, this file has to
// be included. The header alone can be used when the template is explicitly
// instantiated elsewhere.
template <class T> BSplineBase<T>::~BSplineBase() {}

template <class T>
bool
BSplineBase<T>::setDomain(const T* x, int nx, double wl, int bc, int num_nodes)
Expand Down
4 changes: 4 additions & 0 deletions BSpline/BSplineBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ template <class T> class BSplineBase
/// Assignment operator
BSplineBase& operator=(const BSplineBase& right);

// Declare the destructor so it is not implicitly instantiated. It can
// only be instantiated with the full implementation in BSplineBase.cpp.
~BSplineBase();

/**
* Change the domain of this base. [If this is part of a BSpline
* object, this method {\em will not} change the existing curve or
Expand Down
2 changes: 1 addition & 1 deletion BSpline/BSplineVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define bspline_str(s) #s
#define BSPLINE_VERSION bspline_xstr(BSPLINE_AUTO_REVISION)
#else
#define BSPLINE_VERSION "v2.1-x"
#define BSPLINE_VERSION "v2.2"
#endif

#define BSPLINE_URL "https://github.com/NCAR/bspline"
Expand Down

0 comments on commit a48980a

Please sign in to comment.