urn a + (x - a + 13) % 26;
    }
     
    char rot13(const char x)
    {
        if ('Z' >= x and x >= 'A')
            return rot13a(x, 'A');
     
        if ('z' >= x and x >= 'a')
            return rot13a(x, 'a');
     
        return x;
    }
     
    int main()
    {
        auto show = [](const unsigned char x) { [std::putchar](http://en.cppreference.com/w/cpp/io/c/putchar)(x); };
     
        [std::string](http://en.cppreference.com/w/cpp/string/basic_string) in{"cppreference.com\n"};
        std::[ranges::for_each](http://en.cppreference.com/w/cpp/algorithm/ranges/for_each)(in, show);
        std::[ranges::for_each](http://en.cppreference.com/w/cpp/algorithm/ranges/for_each)(in | std::views::transform(rot13), show);
     
        [std::string](http://en.cppreference.com/w/cpp/string/basic_string) out;
        std::[ranges::copy](http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/copy)(std::views::transform(in, rot13), [std::back_inserter](http://en.cppreference.com/w/cpp/iterator/back_inserter)(out));
        std::[ranges::for_each](http://en.cppreference.com/w/cpp/algorithm/ranges/for_each)(out, show);
        std::[ranges::for_each](http://en.cppreference.com/w/cpp/algorithm/ranges/for_each)(out | std::views::transform(rot13), show);
    }

Output:

    
    
    cppreference.com
    pccersrerapr.pbz
    pccersrerapr.pbz
    cppreference.com

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/transform_view&action=edit&section=5 "Edit
section: See also") ]  See also

[ ranges::transform  ](/w/cpp/algorithm/ranges/transform "cpp/algorithm/ranges/transform") (C++20)  |  applies a function to a range of elements   
(niebloid)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/algorithm/ranges/dsc_transform&action=edit)  
---|---  
  
Retrieved from " [
https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/transform_view&oldid=168757
](https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/transform_view&oldid=168757)
"

#####  Navigation

  * [ Support us ](http://www.cppreference.com/support)
  * [ Recent changes ](/w/Special:RecentChanges "A list of recent changes in the wiki \[r\]")
  * [ FAQ ](/w/Cppreference:FAQ)
  * [ Offline version ](/w/Cppreference:Archives)

#####  Toolbox

  * [ What links here ](/w/Special:WhatLinksHere/cpp/ranges/transform_view "A list of all wiki pages that link here \[j\]")
  * [ Related changes ](/w/Special:RecentChangesLinked/cpp/ranges/transform_view "Recent changes in pages linked from this page \[k\]")
  * [ Upload file ](http://upload.cppreference.com/w/Special:Upload "Upload files \[u\]")
  * [ Special pages ](/w/Special:SpecialPages "A list of all special pages \[q\]")
  * [ Printable version ](/mwiki/index.php?title=cpp/ranges/transform_view&printable=yes "Printable version of this page \[p\]")
  * [ Permanent link ](/mwiki/index.php?title=cpp/ranges/transform_view&oldid=168757 "Permanent link to this revision of the page")
  * [ Page information ](/mwiki/index.php?title=cpp/ranges/transform_view&action=info)

  * In other languages 

  * [ Español ](http://es.cppreference.com/w/cpp/ranges/transform_view "cpp/ranges/transform view")
  * [ 日本語 ](http://ja.cppreference.com/w/cpp/ranges/transform_view "cpp/ranges/transform view")
  * [ Русский ](http://ru.cppreference.com/w/cpp/ranges/transform_view "cpp/ranges/transform view")
  * [ 中文 ](http://zh.cppreference.com/w/cpp/ranges/transform_view "cpp/ranges/transform view")

  * This page was last modified on 17 January 2024, at 00:50. 
  * This page has been accessed 108,591 times. 

  * [ Privacy policy ](/w/Cppreference:Privacy_policy "Cppreference:Privacy policy")
  * [ About cppreference.com ](/w/Cppreference:About "Cppreference:About")
  * [ Disclaimers ](/w/Cppreference:General_disclaimer "Cppreference:General disclaimer")

  * [ ![Powered by MediaWiki](/mwiki/skins/common/images/poweredby_mediawiki_88x31.png) ](//www.mediawiki.org/) [ ![Powered by GeSHi](//upload.cppreference.