Skip to content

Commit

Permalink
Add demo for floating point as template parameter
Browse files Browse the repository at this point in the history
- this feature is not yet supported by gcc10
  • Loading branch information
mdj2812 committed Jan 19, 2022
1 parent 7bc50c5 commit fb1df21
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StringLiteralTemplate.hpp"
#include "NonTypeTemplateParameter.hpp"

#include <cstring>
#include <iostream>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp17/cpp17Demos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include "GenericLambda.hpp"
#include "LambdaCapture.hpp"
#include "RangeBasedLoop.hpp"
#include "StringLiteralTemplate.hpp"
#include "NonTypeTemplateParameter.hpp"
#include "ThreeComp.hpp"
#include "WithoutConstinitSpecifier.hpp"
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#include "StringLiteralTemplate.hpp"
#include "NonTypeTemplateParameter.hpp"

#include <algorithm>
#include <cstddef>
#include <iostream>

namespace cpp20
{
#if 0
template <float value>
struct X
{
}; // assume that this is ok

void function(X<1.0>) {}

void function(X<1.00000000001>) {} // is this a valid overload?

void floatingPointAsTemplateParameterDemo()
{
function(X<1.0000000000999999>());
// is it void function( X< 1.00000000001 > ) ?
}
#endif

/**
* Literal class type that wraps a constant expression string.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

namespace cpp20
{
void floatingPointAsTemplateParameterDemo();
void stringLiteralAsTemplateParameterDemo();
}
2 changes: 1 addition & 1 deletion cpp20/cpp20Demos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "DesignatedInitializer.hpp"
#include "EmptyClass.hpp"
#include "LambdaCapture.hpp"
#include "NonTypeTemplateParameter.hpp"
#include "RangeBasedLoop.hpp"
#include "StringLiteralTemplate.hpp"
#include "TemplateLambda.hpp"
#include "ThreeWayComp.hpp"
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ int main(int, char **)
std::cout << "**********************************************\n\n";
#endif

// string literal as template parameter
std::cout << "***** string literal as template parameter *****\n";
// Non-type template parameter
std::cout << "********* Non-type template parameter ********\n";
cpp17::stringLiteralAsTemplateParameterDemo();
cpp20::stringLiteralAsTemplateParameterDemo();
std::cout << "**********************************************\n\n";
Expand Down

0 comments on commit fb1df21

Please sign in to comment.