numeric/endian: Add constexpr endian conversion functions

These are as fast as the c library versions but they are also constexpr.

Change-Id: I95bb1562a5a15a7f9c57a3483afe364a0286da48
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/numeric/endian.cpp b/test/numeric/endian.cpp
new file mode 100644
index 0000000..d8f2ae8
--- /dev/null
+++ b/test/numeric/endian.cpp
@@ -0,0 +1,24 @@
+#include <stdplus/numeric/endian.hpp>
+
+#include <array>
+
+#include <gtest/gtest.h>
+
+namespace stdplus
+{
+
+TEST(Byteswap, Swap)
+{
+    EXPECT_EQ(38, bswap(uint8_t{38}));
+    EXPECT_EQ(38 << 8, bswap(uint16_t{38}));
+    EXPECT_EQ(0x240082fe, bswap(uint32_t{0xfe820024}));
+    EXPECT_EQ(0x240082fe00000000, bswap(uint64_t{0xfe820024}));
+    struct
+    {
+        std::array<char, 4> a = {1, 2, 3, 4};
+    } s;
+    EXPECT_EQ((std::array<char, 4>{4, 3, 2, 1}), bswap(s).a);
+    EXPECT_EQ(40, ntoh(hton(40)));
+}
+
+} // namespace stdplus