std::chrono:: operator+, std::chrono:: operator- (std::chrono::year_month_day)
| 
           Defined in header
            
            
             <chrono>
            
            | ||
| 
           
            
             constexpr
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            operator
            
             +
            
            
             (
            
            
             const
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            
             &
            
            ymd,
             
             
              const
             
             
              
               std::
               
                chrono
               
               
                ::
               
               
                months
               
              
             
             
              &
             
             dm
              | (since C++20) | |
| 
           
            
             constexpr
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            operator
            
             +
            
            
             (
            
            
             const
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               months
              
             
            
            
             &
            
            dm,
             
             
              const
             
             
              
               std::
               
                chrono
               
               
                ::
               
               
                year_month_day
               
              
             
             
              &
             
             ymd
              | (since C++20) | |
| 
           
            
             constexpr
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            operator
            
             +
            
            
             (
            
            
             const
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            
             &
            
            ymd,
             
             
              const
             
             
              
               std::
               
                chrono
               
               
                ::
               
               
                years
               
              
             
             
              &
             
             dy
              | (since C++20) | |
| 
           
            
             constexpr
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            operator
            
             +
            
            
             (
            
            
             const
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               years
              
             
            
            
             &
            
            dy,
             
             
              const
             
             
              
               std::
               
                chrono
               
               
                ::
               
               
                year_month_day
               
              
             
             
              &
             
             ymd
              | (since C++20) | |
| 
           
            
             constexpr
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            operator
            
             -
            
            
             (
            
            
             const
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            
             &
            
            ymd,
             
             
              const
             
             
              
               std::
               
                chrono
               
               
                ::
               
               
                months
               
              
             
             
              &
             
             dm
              | (since C++20) | |
| 
           
            
             constexpr
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            operator
            
             -
            
            
             (
            
            
             const
            
            
             
              std::
              
               chrono
              
              
               ::
              
              
               year_month_day
              
             
            
            
             &
            
            ymd,
             
             
              const
             
             
              
               std::
               
                chrono
               
               
                ::
               
               
                years
               
              
             
             
              &
             
             dy
              | (since C++20) | |
       For durations that are convertible to both
       
        std::chrono::years
       
       and
       
        std::chrono::months
       
       , the
       
        years
       
       overloads
       
        (3,4,6)
       
       are preferred if the call would otherwise be ambiguous.
      
Notes
       Even if
       
        
         ymd.
         
          ok
         
         
          (
         
         
          )
         
        
       
       is
       
        
         
          true
         
        
       
       , the resulting
       
        year_month_day
       
       may not represent a valid date if
       
        
         ymd.
         
          day
         
         
          (
         
         
          )
         
        
       
       is 29, 30, or 31.
      
Example
#include <chrono> #include <iostream> int main() { std::cout << std::boolalpha; auto ymd{std::chrono::day(1)/std::chrono::July/2021}; ymd = ymd + std::chrono::months(4); std::cout << (ymd.month() == std::chrono::November) << ' ' << (ymd.year() == std::chrono::year(2021)) << ' '; ymd = ymd - std::chrono::years(10); std::cout << (ymd.month() == std::chrono::month(11)) << ' ' << (ymd.year() == std::chrono::year(2011)) << '\n'; }
Output:
true true true true