Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
fd8ed198
Commit
fd8ed198
authored
Apr 01, 2016
by
Kenton Varda
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #303 from katreniak/bka-styleGuide
style-guide: fix isConst and UnConst examples
parents
981814eb
ff9d72e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
style-guide.md
style-guide.md
+5
-5
No files found.
style-guide.md
View file @
fd8ed198
...
...
@@ -323,16 +323,16 @@ In C++11, we can do better. Where before you would have declared a struct named
Example:
template <typename T> struct IsConst_ {
constexpr bool value = false; }
template <typename T> struct IsConst_<const T> {
constexpr bool value = true; }
template <typename T> struct IsConst_ {
static constexpr bool value = false; };
template <typename T> struct IsConst_<const T> {
static constexpr bool value = true; };
template <typename T> constexpr bool isConst() { return IsConst_<T>::value; }
// Return true if T is const.
Or:
template <typename T> struct UnConst_ { typedef T Type; }
template <typename T> struct UnConst_<
T> { typedef T Type; }
template <typename T> using UnConst = UnConst_<T>::Type;
template <typename T> struct UnConst_ { typedef T Type; }
;
template <typename T> struct UnConst_<
const T> { typedef T Type; };
template <typename T> using UnConst =
typename
UnConst_<T>::Type;
// If T is const, return the underlying non-const type.
// Otherwise, just return T.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment