move user-defined literals in their own namespace (#284)

* isolate chrono literals in literals.hpp

* rclcpp.hpp: remove 'using namespace rclcpp::literals'

The examples have been migrated to the new namespace.

* literals: constexpr, make return types consistent with function body

_ms returned nanoseconds instead of milliseconds.

A few return types where using integral return type
for floating point literals.

* remove literals in favor of std::chrono_literals
This commit is contained in:
Guillaume Papin 2016-12-17 11:16:43 +01:00 committed by William Woodall
parent 2c6d95946e
commit d00a441195

View file

@ -27,39 +27,6 @@
#include "rclcpp/utilities.hpp"
#include "rclcpp/visibility_control.hpp"
// NOLINTNEXTLINE(runtime/int)
inline const std::chrono::seconds operator"" _s(unsigned long long s)
{
return std::chrono::seconds(s);
}
inline const std::chrono::nanoseconds operator"" _s(long double s)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<long double>(s));
}
// NOLINTNEXTLINE(runtime/int)
inline const std::chrono::nanoseconds operator"" _ms(unsigned long long ms)
{
return std::chrono::milliseconds(ms);
}
inline const std::chrono::nanoseconds operator"" _ms(long double ms)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<long double, std::milli>(ms));
}
// NOLINTNEXTLINE(runtime/int)
inline const std::chrono::nanoseconds operator"" _ns(unsigned long long ns)
{
return std::chrono::nanoseconds(ns);
}
inline const std::chrono::nanoseconds operator"" _ns(long double ns)
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<long double, std::nano>(ns));
}
namespace rclcpp
{