Changeset 092a436 in mainline


Ignore:
Timestamp:
2018-07-05T21:41:19Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fff05d3
Parents:
2987160
git-author:
Dzejrou <dzejrou@…> (2018-01-05 23:01:03)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:19)
Message:

cpp: changed limits to the primitive types so that we can be sure we cover them all

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/limits.hpp

    r2987160 r092a436  
    3131
    3232#include <cstdint>
     33#include <climits>
    3334
    3435namespace std
     
    345346
    346347    template<>
    347     class numeric_limits<int8_t>: public aux::numeric_limits<int8_t>
    348     {
    349         public:
    350             static constexpr bool is_specialized = true;
    351 
    352             static constexpr int8_t max()
    353             {
    354                 return INT8_MAX;
    355             }
    356 
    357             static constexpr int8_t min()
    358             {
    359                 return INT8_MIN;
    360             }
    361 
    362             static constexpr int8_t lowest()
    363             {
    364                 return min();
    365             }
    366     };
    367 
    368     template<>
    369     class numeric_limits<int16_t>: public aux::numeric_limits<int16_t>
    370     {
    371         public:
    372             static constexpr bool is_specialized = true;
    373 
    374             static constexpr int16_t max()
    375             {
    376                 return INT16_MAX;
    377             }
    378 
    379             static constexpr int16_t min()
    380             {
    381                 return INT16_MIN;
    382             }
    383 
    384             static constexpr int16_t lowest()
    385             {
    386                 return min();
    387             }
    388     };
    389 
    390     template<>
    391     class numeric_limits<int32_t>: public aux::numeric_limits<int32_t>
    392     {
    393         public:
    394             static constexpr bool is_specialized = true;
    395 
    396             static constexpr int32_t max()
    397             {
    398                 return INT32_MAX;
    399             }
    400 
    401             static constexpr int32_t min()
    402             {
    403                 return INT32_MIN;
    404             }
    405 
    406             static constexpr int32_t lowest()
    407             {
    408                 return min();
    409             }
    410     };
    411 
    412     template<>
    413     class numeric_limits<int64_t>: public aux::numeric_limits<int64_t>
    414     {
    415         public:
    416             static constexpr bool is_specialized = true;
    417 
    418             static constexpr int64_t max()
    419             {
    420                 return INT64_MAX;
    421             }
    422 
    423             static constexpr int64_t min()
    424             {
    425                 return INT64_MIN;
    426             }
    427 
    428             static constexpr int64_t lowest()
    429             {
    430                 return min();
    431             }
    432     };
    433 
    434     template<>
    435     class numeric_limits<uint8_t>: public aux::numeric_limits<uint8_t>
    436     {
    437         public:
    438             static constexpr bool is_specialized = true;
    439 
    440             static constexpr uint8_t max()
    441             {
    442                 return UINT8_MAX;
    443             }
    444 
    445             static constexpr uint8_t min()
    446             {
    447                 return UINT8_MIN;
    448             }
    449 
    450             static constexpr uint8_t lowest()
    451             {
    452                 return min();
    453             }
    454     };
    455 
    456     template<>
    457     class numeric_limits<uint16_t>: public aux::numeric_limits<uint16_t>
    458     {
    459         public:
    460             static constexpr bool is_specialized = true;
    461 
    462             static constexpr uint16_t max()
    463             {
    464                 return UINT16_MAX;
    465             }
    466 
    467             static constexpr uint16_t min()
    468             {
    469                 return UINT16_MIN;
    470             }
    471 
    472             static constexpr uint16_t lowest()
    473             {
    474                 return min();
    475             }
    476     };
    477 
    478     template<>
    479     class numeric_limits<uint32_t>: public aux::numeric_limits<uint32_t>
    480     {
    481         public:
    482             static constexpr bool is_specialized = true;
    483 
    484             static constexpr uint32_t max()
    485             {
    486                 return UINT32_MAX;
    487             }
    488 
    489             static constexpr uint32_t min()
    490             {
    491                 return UINT32_MIN;
    492             }
    493 
    494             static constexpr uint32_t lowest()
    495             {
    496                 return min();
    497             }
    498     };
    499 
    500     template<>
    501     class numeric_limits<uint64_t>: public aux::numeric_limits<uint64_t>
    502     {
    503         public:
    504             static constexpr bool is_specialized = true;
    505 
    506             static constexpr uint64_t max()
    507             {
    508                 return UINT64_MAX;
    509             }
    510 
    511             static constexpr uint64_t min()
    512             {
    513                 return UINT64_MIN;
    514             }
    515 
    516             static constexpr uint64_t lowest()
     348    class numeric_limits<char>: public aux::numeric_limits<char>
     349    {
     350        public:
     351            static constexpr bool is_specialized = true;
     352
     353            static constexpr char max()
     354            {
     355                return CHAR_MAX;
     356            }
     357
     358            static constexpr char min()
     359            {
     360                return CHAR_MIN;
     361            }
     362
     363            static constexpr char lowest()
     364            {
     365                return min();
     366            }
     367    };
     368
     369    template<>
     370    class numeric_limits<signed char>: public aux::numeric_limits<signed char>
     371    {
     372        public:
     373            static constexpr bool is_specialized = true;
     374
     375            static constexpr signed char max()
     376            {
     377                return SCHAR_MAX;
     378            }
     379
     380            static constexpr signed char min()
     381            {
     382                return SCHAR_MIN;
     383            }
     384
     385            static constexpr signed char lowest()
     386            {
     387                return min();
     388            }
     389    };
     390
     391    template<>
     392    class numeric_limits<short>: public aux::numeric_limits<short>
     393    {
     394        public:
     395            static constexpr bool is_specialized = true;
     396
     397            static constexpr short max()
     398            {
     399                return SHRT_MAX;
     400            }
     401
     402            static constexpr short min()
     403            {
     404                return SHRT_MIN;
     405            }
     406
     407            static constexpr short lowest()
     408            {
     409                return min();
     410            }
     411    };
     412
     413    template<>
     414    class numeric_limits<int>: public aux::numeric_limits<int>
     415    {
     416        public:
     417            static constexpr bool is_specialized = true;
     418
     419            static constexpr int max()
     420            {
     421                return INT_MAX;
     422            }
     423
     424            static constexpr int min()
     425            {
     426                return INT_MIN;
     427            }
     428
     429            static constexpr int lowest()
     430            {
     431                return min();
     432            }
     433    };
     434
     435    template<>
     436    class numeric_limits<long>: public aux::numeric_limits<long>
     437    {
     438        public:
     439            static constexpr bool is_specialized = true;
     440
     441            static constexpr long max()
     442            {
     443                return LONG_MAX;
     444            }
     445
     446            static constexpr long min()
     447            {
     448                return LONG_MIN;
     449            }
     450
     451            static constexpr long lowest()
     452            {
     453                return min();
     454            }
     455    };
     456
     457    template<>
     458    class numeric_limits<long long>: public aux::numeric_limits<long long>
     459    {
     460        public:
     461            static constexpr bool is_specialized = true;
     462
     463            static constexpr long long max()
     464            {
     465                return LLONG_MAX;
     466            }
     467
     468            static constexpr long long min()
     469            {
     470                return LLONG_MIN;
     471            }
     472
     473            static constexpr long long lowest()
     474            {
     475                return min();
     476            }
     477    };
     478
     479    template<>
     480    class numeric_limits<unsigned char>: public aux::numeric_limits<unsigned char>
     481    {
     482        public:
     483            static constexpr bool is_specialized = true;
     484
     485            static constexpr unsigned char max()
     486            {
     487                return SCHAR_MAX;
     488            }
     489
     490            static constexpr unsigned char min()
     491            {
     492                return SCHAR_MIN;
     493            }
     494
     495            static constexpr unsigned char lowest()
     496            {
     497                return min();
     498            }
     499    };
     500
     501    template<>
     502    class numeric_limits<unsigned short>: public aux::numeric_limits<unsigned short>
     503    {
     504        public:
     505            static constexpr bool is_specialized = true;
     506
     507            static constexpr unsigned short max()
     508            {
     509                return USHRT_MAX;
     510            }
     511
     512            static constexpr unsigned short min()
     513            {
     514                return USHRT_MIN;
     515            }
     516
     517            static constexpr unsigned short lowest()
     518            {
     519                return min();
     520            }
     521    };
     522
     523    template<>
     524    class numeric_limits<unsigned int>: public aux::numeric_limits<unsigned int>
     525    {
     526        public:
     527            static constexpr bool is_specialized = true;
     528
     529            static constexpr unsigned int max()
     530            {
     531                return UINT_MAX;
     532            }
     533
     534            static constexpr unsigned int min()
     535            {
     536                return UINT_MIN;
     537            }
     538
     539            static constexpr unsigned int lowest()
     540            {
     541                return min();
     542            }
     543    };
     544
     545    template<>
     546    class numeric_limits<unsigned long>: public aux::numeric_limits<unsigned long>
     547    {
     548        public:
     549            static constexpr bool is_specialized = true;
     550
     551            static constexpr unsigned long max()
     552            {
     553                return ULONG_MAX;
     554            }
     555
     556            static constexpr unsigned long min()
     557            {
     558                return ULONG_MIN;
     559            }
     560
     561            static constexpr unsigned long lowest()
     562            {
     563                return min();
     564            }
     565    };
     566
     567    template<>
     568    class numeric_limits<unsigned long long>: public aux::numeric_limits<unsigned long long>
     569    {
     570        public:
     571            static constexpr bool is_specialized = true;
     572
     573            static constexpr unsigned long long max()
     574            {
     575                return ULLONG_MAX;
     576            }
     577
     578            static constexpr unsigned long long min()
     579            {
     580                return ULLONG_MIN;
     581            }
     582
     583            static constexpr unsigned long long lowest()
    517584            {
    518585                return min();
Note: See TracChangeset for help on using the changeset viewer.