Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unary_function is deprecated since c++11 #65

Open
th-2021 opened this issue Jun 10, 2023 · 5 comments
Open

Unary_function is deprecated since c++11 #65

th-2021 opened this issue Jun 10, 2023 · 5 comments

Comments

@th-2021
Copy link

th-2021 commented Jun 10, 2023

Unary_function is deprecated since c++11 and is being removed from current compilers e.g. clang17, so that compilation falls.

@jrobcary
Copy link

jrobcary commented Jul 20, 2023

I see this using llvm-16 on MacOS. Is there a fix?

In file included from /Users/cary/projects/xsimall-dev1/builds/trilinos-14.0.0/packages/tpetra/core/src/Epetra_TsqrMessenger.cpp:55:
In file included from /Users/cary/projects/xsimall-dev1/builds/trilinos-14.0.0/packages/tpetra/core/src/Epetra_TsqrMessenger.hpp:58:
/Users/cary/projects/xsimall-dev1/builds/trilinos-14.0.0/packages/tpetra/core/src/Tpetra_ConfigDefs.hpp:153:34: error: no template named 'binary_function' in namespace 'std'; did you mean '__binary_function'?
class project1st : public std::binary_function<Arg1, Arg2, Arg1> {
~~~~~^~~~~~~~~~~~~~~
__binary_function
/opt/homebrew/Cellar/llvm/16.0.6/bin/../include/c++/v1/__functional/binary_function.h:49:1: note: '__binary_function' declared here
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;

@theoparis
Copy link

I encountered this error with a gentoo clang profile using libcxx. Unfortunately this library seems to be unmaintained 😕

@orbea
Copy link

orbea commented Jan 8, 2024

I see this using llvm-16 on MacOS. Is there a fix?

Probably the most pragmatic solution is to explicitly set a lower C++ standard with -std.

@LinuxUserGD
Copy link

Alternatively, applying the following patch resolves the Clang deprecation errors:

--- a/libaudiofile/modules/SimpleModule.h
+++ b/libaudiofile/modules/SimpleModule.h
@@ -125,13 +125,17 @@ struct signConverter
 	static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
 	static const int kMinSignedValue = 0-(1U<<kScaleBits);
 
-	struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
+	struct signedToUnsigned
 	{
+		typedef SignedType argument_type;
+		typedef UnsignedType result_type;
 		UnsignedType operator()(SignedType x) { return x - kMinSignedValue; }
 	};
 
-	struct unsignedToSigned : public std::unary_function<SignedType, UnsignedType>
+	struct unsignedToSigned
 	{
+		typedef SignedType argument_type;
+		typedef UnsignedType result_type;
 		SignedType operator()(UnsignedType x) { return x + kMinSignedValue; }
 	};
 };
@@ -323,8 +327,10 @@ private:
 };
 
 template <typename Arg, typename Result>
-struct intToFloat : public std::unary_function<Arg, Result>
+struct intToFloat
 {
+	typedef Arg argument_type;
+	typedef Result result_type;
 	Result operator()(Arg x) const { return x; }
 };
 
@@ -389,14 +395,18 @@ private:
 };
 
 template <typename Arg, typename Result, unsigned shift>
-struct lshift : public std::unary_function<Arg, Result>
+struct lshift
 {
+	typedef Arg argument_type;
+	typedef Result result_type;
 	Result operator()(const Arg &x) const { return x << shift; }
 };
 
 template <typename Arg, typename Result, unsigned shift>
-struct rshift : public std::unary_function<Arg, Result>
+struct rshift
 {
+	typedef Arg argument_type;
+	typedef Result result_type;
 	Result operator()(const Arg &x) const { return x >> shift; }
 };
 
@@ -491,8 +501,10 @@ private:
 };
 
 template <typename Arg, typename Result>
-struct floatToFloat : public std::unary_function<Arg, Result>
+struct floatToFloat
 {
+	typedef Arg argument_type;
+	typedef Result result_type;
 	Result operator()(Arg x) const { return x; }
 };
 

@elsandosgrande
Copy link

elsandosgrande commented Feb 18, 2024

@LinuxUserGD Thank you so much for sharing your patch! With it, the Gentoo audiofile package finally builds for me when using libc++ 17 instead of libstdc++.


Edit

@orbea I've tried setting -std=c++11, but then configuration fails, at least on Linux, at the checking whether the C compiler works step because CXXFLAGS seem to be in use instead of CFLAGS, leading to the following error:

error: invalid argument '-std=c++11' not allowed with 'C'

Looks like mpruett hasn't been active on GitHub for the past seven years and some change, so locally carrying this patch is probably as good as it's going to get 😔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants