Reputation: 11
I saw a program in android source code ,it's about the return value in c++,please look the following ,Thanks!
Return<void> RadioResponse_v1_1::getIccCardStatusResponse(const RadioResponseInfo& info,
const CardStatus& card_status) {
rspInfo = info
cardStatus = card_statu parent_v1_1.notify(info.serial30);
return void();
}
My question is that the Return represent what?I've never seen this program before. Best Regards
Upvotes: 0
Views: 1097
Reputation: 4079
It's hard to dig through all the layers of code generation of the android source code, but here is some documentation about it: https://source.android.com/devices/architecture/hidl-cpp/functions
It gets used in code generated from some hardware abstraction layer interface language used by AOSP. From the documentation:
Return objects store transport error indications as well as a T value (except Return).
...
Return objects have implicit conversion to and from their T value
So, in this case Return<T>
is a container that can store a value or an error. This function doesn't return anything when it's successful, so it returns Result<void>
. In functional programming languages, this is sometimes called an either: https://www.ibm.com/developerworks/library/j-ft13/index.html
EDIT: aha, here it is: https://android.googlesource.com/platform/system/libhidl/+/refs/heads/master/base/include/hidl/Status.h
Upvotes: 1