Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers max.hpp Source File

max.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Namespace.hpp>
00008 
00009 #include <stddef.h>  // for size_t
00010 
00011 namespace ARDUINOJSON_NAMESPACE {
00012 
00013 // A meta-function that returns the highest value
00014 template <size_t X, size_t Y, bool MaxIsX = (X > Y)>
00015 struct Max {};
00016 
00017 template <size_t X, size_t Y>
00018 struct Max<X, Y, true> {
00019   static const size_t value = X;
00020 };
00021 
00022 template <size_t X, size_t Y>
00023 struct Max<X, Y, false> {
00024   static const size_t value = Y;
00025 };
00026 }  // namespace ARDUINOJSON_NAMESPACE