<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo" -->

---
title: Forwarding references in C++ – Daniel Lemire&#x27;s blog
description: The post discusses the various ways to pass a value to a function in C++, including passing by value, passing by reference, and using forwarding references. It...
canonical: https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Forwarding references in C++ – Daniel Lemire&#x27;s blog | daily.dev
og:description: The post discusses the various ways to pass a value to a function in C++, including passing by value, passing by reference, and using forwarding references. It...
og:url: https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo
og:image: https://api.daily.dev/og/posts/CB79Nn0xo.png
og:image:alt: Forwarding references in C++ – Daniel Lemire&#x27;s blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Forwarding references in C++ – Daniel Lemire's blog

**[Daniel Lemire](https://daily.dev/sources/lemire)** · 2 min read · 0 upvotes · 0 comments

## Summary

The post discusses the various ways to pass a value to a function in C++, including passing by value, passing by reference, and using forwarding references. It explains the ownership of the object in each case and provides sample code for calling these functions.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://lemire.me/blog/2024/05/13/forwarding-references-in-c/>

---

Tags: [#c](https://daily.dev/tags/c)

[View this post on daily.dev](https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Forwarding references in C++ – Daniel Lemire's blog","url":"https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo"},"datePublished":"2024-05-13T15:57:12.154Z","dateModified":"2024-05-13T15:57:11.347Z","description":"The post discusses the various ways to pass a value to a function in C++, including passing by value, passing by reference, and using forwarding references. It...","image":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","thumbnailUrl":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","isAccessibleForFree":true,"articleSection":"Daniel Lemire","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Daniel Lemire","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/33b93b4f779a45bdaca4a8d3d678fe39","url":"https://daily.dev/sources/lemire"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/forwarding-references-in-c-daniel-lemire-s-blog-cb79nn0xo","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Daniel Lemire","item":"https://daily.dev/sources/lemire"},{"@type":"ListItem","position":3,"name":"Forwarding references in C++ – Daniel Lemire's blog"}]}
```

