-
Notifications
You must be signed in to change notification settings - Fork 44
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
Comments
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: |
I encountered this error with a gentoo clang profile using libcxx. Unfortunately this library seems to be unmaintained 😕 |
Probably the most pragmatic solution is to explicitly set a lower C++ standard with |
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; }
};
|
@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
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 😔 |
Unary_function is deprecated since c++11 and is being removed from current compilers e.g. clang17, so that compilation falls.
The text was updated successfully, but these errors were encountered: