constexpr Endian conversion in c++14 This is my take for constexpr big / little endian conversions.

The code supports only little and big endian; mixed endian such PDP is not supported. 

#include &lt;cstdio&gt;
#include &lt;cstdint&gt;

namespace myendian_impl_{

    template&lt;typename UINT&gt;
    UINT byteswap(UINT const a);

    template&lt;&gt;
    constexpr uint16_t byteswap(uint16_t const a){
        constexpr uint8_t b[] = {
            8 * (2 - 1)
        };

        auto const x =
            (0x00ffULL &amp; a) &lt;&lt; b[0] |
            (0xff00ULL &amp; a) &gt;&gt; b[0]
        ;

        return static_cast&lt;uint16_t&gt;(x);
    }

    template&lt;&gt;
    constexpr uint32_t byteswap(uint32_t const a){
        constexpr uint8_t b[] = {
            8 * (2 - 1),
            8 * (4 - 1)
        };

        auto const x =
            (0x000000ffULL &amp; a) &lt;&lt; b[1] |
            (0x0000ff00ULL &amp; a) &lt;&lt; b[0] |
            (0x00ff0000ULL &amp; a) &gt;&gt; b[0] |
            (0xff000000ULL &amp; a) &gt;&gt; b[1]
        ;

        return static_cast&lt;uint32_t&gt;(x);
    }

    template&lt;&gt;
    constexpr uint64_t byteswap(uint64_t const a){
        constexpr uint8_t b[] = {
            8 * (2 - 1),
            8 * (4 - 1),
            8 * (6 - 1),
            8 * (8 - 1)
        };

        auto const x =
            (0x00000000000000ffULL &amp; a) &lt;&lt; b[3] |
            (0x000000000000ff00ULL &amp; a) &lt;&lt; b[2] |
            (0x0000000000ff0000ULL &amp; a) &lt;&lt; b[1] |
            (0x00000000ff000000ULL &amp; a) &lt;&lt; b[0] |
            (0x000000ff00000000ULL &amp; a) &gt;&gt; b[0] |
            (0x0000ff0000000000ULL &amp; a) &gt;&gt; b[1] |
            (0x00ff000000000000ULL &amp; a) &gt;&gt; b[2] |
            (0xff00000000000000ULL &amp; a) &gt;&gt; b[3]
        ;

        return static_cast&lt;uint64_t&gt;(x);
    }

    // ==============================

    class isBE{
        constexpr static uint32_t u4 = 1;
        constexpr static uint8_t  u1  = (const uint8_t &amp;) u4;
    public:
        constexpr static bool value = u1 == 0;
    };

    // ==============================

    template&lt;bool b&gt;
    struct be_tag{};

    // ==============================

    template&lt;typename UINT&gt;
    constexpr UINT htobe(UINT const a, be_tag&lt;true&gt;){
        return a;
    }

    template&lt;typename UINT&gt;
    constexpr UINT htobe(UINT const a, be_tag&lt;false&gt;){
        return byteswap(a);
    }

} // namespace myendian_impl_

constexpr inline uint16_t htobe16(uint16_t const a){
    using namespace  myendian_impl_;
    return htobe(a, be_tag&lt;isBE::value&gt;{});
}

constexpr inline uint32_t htobe32(uint32_t const a){
    using namespace  myendian_impl_;
    return htobe(a, be_tag&lt;isBE::value&gt;{});
}

constexpr inline uint64_t htobe64(uint64_t const a){
    using namespace  myendian_impl_;
    return htobe(a, be_tag&lt;isBE::value&gt;{});
}


int main(){
    printf("%16x %16x\n",   0x1122,         htobe16(0x1122)         );
    printf("%16x %16x\n",   0x11223344,     htobe32(0x11223344)     );
    printf("%16lx %16lx\n", 0x1122334455667788, htobe64(0x1122334455667788) );
}
In all, this looks pretty solid to me, so I have only a few suggestions:

Eliminate spurious inline

The inline keyword is only useful if this is moved to a header file, so it's not strictly needed in the context of the code in the question. 

Consider defining a string literal

Here's a small enhancement: provide the ability to define a string literal.  Here's how it might be done:

constexpr uint32_t operator"" _be32(unsigned long long num) {
    return htobe32(num);
}


Usage:

printf("%16x %16x\n",   0x11223344,     0x11223344_be32     );


This makes things very tidy and easy to use.  Naturally, 16- and 64-bit versions are almost identical except for return type and name.