This discussion provides an insight into library maintenance issues
associated with Standard C++17; especially with third-party libraries that
require backwards compatibility with both old and new software development
platforms.
What is the best way to provide backwards compatible <functional> STL
templates for std::binary_function and std::unary function? The Xalan
code base has numerous functions based on the std::unary_function and
std::binary_function templates.
There is a need to retain a backward compatible implementation, even as
Standard C++17 removes these <functional> templates.
Standard C++11 deprecates these <functional> core definitions.
Standard C++17 removes these <functional> core definitions.
There is a need for some developers to maintain Standard C++98 compatibility.
Microsoft Visual Studio 2017 supports Standard C++17.
The deprecated std::auto_ptr is not used in Xalan. Similar template
classes are used internally to provide related functionality (XalanAutoPtr
and XalanMemMgrAutoPtr).
The standard functors (before C++11) have their argument classes (or
traits) propogated by inheriting these standard structs. The functor
classes define an operator() method. The unary_function and
binary_function provide a wrapper mechanism by which standard functions
can be made compatible with many classes. The new paradigm is to take
advantage of traits, unknown to the earlier C++ standards.
template<typename _Arg, typename _Result>
struct unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
template<typename _Arg1, typename _Arg2, typename _Result>
struct binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};
The keyword typename is synonymous to the overloaded keyword class. The
use of the keyword typename for templates is newer than the use of class,
both serving the same purpose.
The software build problem is to perform some pre-build tests to establish
the existence or absence of the std::unary_function and
std::binary_function so that proper insertion of backward-compatible
definitions can be inserted as needed into the std:: namespace. Or rework
the code to supply an application replacement for the depricated or
removed wrapper structs.
Sincerely,
Steven J. Hathaway
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]