Skip to content

Commit

Permalink
Refs #21186: Fix windows build
Browse files Browse the repository at this point in the history
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
  • Loading branch information
JesusPoderoso committed Jul 9, 2024
1 parent d09d810 commit 5293219
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions examples/cpp/topic_instances/CLIParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,6 @@ class CLIParser
subscriber_config sub_config;
};

//! Get the shape color as a string
static std::string shape_color(
int index)
{
const int max_colors = 10;
const std::array<std::string, max_colors> shape_colors =
{ "RED", "BLUE", "GREEN", "YELLOW", "ORANGE", "CYAN", "MAGENTA", "PURPLE", "GREY", "BLACK"};
return shape_colors[index % max_colors];
}

/**
* @brief Print usage help message and exit with the given return code
*
Expand Down Expand Up @@ -721,6 +711,25 @@ class CLIParser
}
}

//! Get the shape color as a string
static std::string shape_color(
int index)
{
constexpr int max_colors = 10;
const auto& shape_colors = get_shape_colors();
return shape_colors[index % max_colors];
}

private:

//! Private method to declare constant array of colors
static const std::array<std::string, 10>& get_shape_colors()
{
static const std::array<std::string, 10> shape_colors =
{ "RED", "BLUE", "GREEN", "YELLOW", "ORANGE", "CYAN", "MAGENTA", "PURPLE", "GREY", "BLACK" };
return shape_colors;
}

};

} // namespace topic_instances
Expand Down

0 comments on commit 5293219

Please sign in to comment.