-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add rvalue support Co-authored-by: Malofeev Mikhail <malofeev.mikhail@huawei.com>
- Loading branch information
Showing
10 changed files
with
251 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <utility> | ||
#include "function_with_rvalue_params.h" | ||
|
||
int double_max(int && first, int && second) { | ||
if (first > second) { | ||
return 2 * first; | ||
} else { | ||
return 2 * second; | ||
} | ||
} | ||
|
||
int remainder(const int && value) { | ||
if (value % 3 == 0) { | ||
return 0; | ||
} else if (value % 3 == 1) { | ||
return 1; | ||
} else { | ||
return 2; | ||
} | ||
} | ||
|
||
int && return_and_get_rvalue_reference(int && first, int && second) { | ||
if (first % 5 == 0) { | ||
return std::move(first); | ||
} else if (second % 5 == 0) { | ||
return std::move(second); | ||
} else { | ||
return std::move(first + second); | ||
} | ||
} | ||
|
||
int get_rvalue_custom_struct_as_param(Closet && closet) { | ||
if (closet.height > 5 && closet.width > 5 && closet.length > 5) { | ||
closet.height /= 5; | ||
closet.volume /= 5; | ||
closet.width /= 5; | ||
return 1; | ||
} else { | ||
closet.width = 5; | ||
closet.height = 5; | ||
closet.length = 5; | ||
closet.volume = 125; | ||
return 2; | ||
} | ||
} | ||
|
||
Closet::Closet() { | ||
length = 1.5; | ||
width = 0.5; | ||
height = 2.5; | ||
volume = height * width * length; | ||
} | ||
|
||
Closet::Closet(double length_, double width_, double height_, double volume_) { | ||
length = length_; | ||
width = width_; | ||
height = height_; | ||
volume = volume_; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef UNITTESTBOT_FUNCTION_WITH_RVALUE_PARAMS_H | ||
#define UNITTESTBOT_FUNCTION_WITH_RVALUE_PARAMS_H | ||
|
||
struct Closet { | ||
double length; | ||
double width; | ||
double height; | ||
double volume; | ||
|
||
Closet(); | ||
Closet(double length_, double width_, double height_, double volume_); | ||
}; | ||
|
||
int double_max(int && first, int && second); | ||
|
||
int remainder(const int && value); | ||
|
||
int && return_and_get_rvalue_reference(int && first, int && second); | ||
|
||
int get_rvalue_custom_struct_as_param(Closet && closet); | ||
|
||
#endif // UNITTESTBOT_FUNCTION_WITH_RVALUE_PARAMS_H |