fixup! containers

accidentally committed sandbox
This commit is contained in:
Robert Haschke 2017-10-17 17:31:44 +02:00
parent 51e4bba212
commit f6a40a4a02
3 changed files with 1 additions and 36 deletions

View File

@ -1,6 +1,3 @@
add_executable(foo test.cpp)
target_link_libraries(foo)
add_executable(plan_pick_ur5 plan_pick_ur5.cpp)
target_link_libraries(plan_pick_ur5 ${PROJECT_NAME}_stages ${PROJECT_NAME})

View File

@ -1,33 +0,0 @@
#include <iostream>
#include <memory>
void overloaded( std::unique_ptr<int> const &arg ) {
std::cout << " by lvalue " << arg.get() << std::endl;
}
void overloaded( std::unique_ptr<int> && arg ) {
std::unique_ptr<int> x = std::move(arg);
std::cout << " by rvalue, x: " << x.get() << " arg: " << arg.get() << std::endl;
}
/* "t &&" with "t" being template param is special, and adjusts "t" to be
(for example) "int &" or non-ref "int" so std::forward knows what to do. */
void forwarding(std::unique_ptr<int> &&arg ) {
std::cout << "- via std::forward: ";
overloaded( std::forward<std::unique_ptr<int>&>( arg ) );
std::cout << "- via std::move: ";
overloaded( std::move( arg ) ); // conceptually this would invalidate arg
std::cout << "- by simple passing: ";
overloaded( arg );
}
void forwarding(std::unique_ptr<int> &arg) {
std::cout << "* via extra std::move" << std::endl;
forwarding(std::move(arg));
}
int main() {
std::cout << "initial caller passes rvalue:\n";
forwarding(std::make_unique<int>(5));
std::cout << "initial caller passes lvalue:\n";
auto x = std::make_unique<int>(5);
forwarding( x );
}

View File

@ -120,6 +120,7 @@ const robot_state::RobotState& Task::getCurrentRobotState() const {
void Task::printState(){
ContainerBase::StageCallback processor = [](const Stage& stage, int depth) -> bool {
std::cout << std::string(2*depth, ' ') << stage << std::endl;
return true;
};
traverseStages(processor);
}