Skip to content

Commit

Permalink
Merge pull request #46 from brunocodutra/develop
Browse files Browse the repository at this point in the history
Bump to 0.3.2
  • Loading branch information
brunocodutra authored Oct 2, 2016
2 parents 0d2cbf3 + 9c8ad40 commit d383f2b
Show file tree
Hide file tree
Showing 105 changed files with 2,883 additions and 2,933 deletions.
5 changes: 3 additions & 2 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ add_custom_target(doc
COMMAND ${CMAKE_COMMAND} -E remove_directory "html"
COMMAND ${DOXYGEN_EXECUTABLE} METAL_DOXYFILE
COMMAND ${CMAKE_COMMAND} -E remove
"html/*.png" "html/dir_*.html" "html/namespacemetal.html"
"html/dynsections.js" "html/doxygen.css" "html/tabs.css"
"html/*.png" "html/dynsections.js" "html/doxygen.css" "html/tabs.css"
"html/dir_*.html" "html/namespacemetal.html"
"html/namespacemembers_type.html"
)
231 changes: 144 additions & 87 deletions doc/Doxyfile.in

Large diffs are not rendered by default.

27 changes: 4 additions & 23 deletions doc/css/metal.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,6 @@ html, body {
width: 102px;
}

.toolbar > * {
border-bottom: 1px solid #EEEEEE;
}

.nav-pills > li > a:hover,
.nav-pills > li > a:focus,
.nav-pills > li > a:active {
background-color: #F9F9F9;
}

.nav-pills > li.active > a,
.nav-pills > li.active > a:hover,
.nav-pills > li.active > a:focus,
.nav-pills > li.active > a:active {
background-color: #464646;
}

.nav-pills > li > a {
color: #464646;
padding-left: 0px;
padding-right: 0px;
}

.toc {
background-color: #F9F9F9;
border: 1px solid #EEEEEE;
Expand Down Expand Up @@ -211,6 +188,10 @@ i.octicon {
margin-right: 10px;
}

.caret {
margin-left: .5em;
}

.strike {
text-decoration: line-through;
}
2 changes: 1 addition & 1 deletion doc/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<li><iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=brunocodutra&amp;repo=metal&amp;type=watch&amp;count=true" title="Star on GitHub"></iframe></li>
<li><iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=brunocodutra&amp;repo=metal&amp;type=fork&amp;count=true" title="Fork on GitHub"></iframe></li>
</ul>
&copy; Copyright 2015
&copy; Copyright 2015-$year
<a href="https://github.com/brunocodutra">Bruno Dutra</a>,
<span class="hidden-xs">Distributed under the</span>
<a href="http://www.boost.org/LICENSE_1_0.txt">
Expand Down
17 changes: 15 additions & 2 deletions doc/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
<script type="text/javascript" src="$relpath^bootstrap.min.js"></script>
<script type="text/javascript" src="$relpath^metal.js"></script>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-83817633-1', 'auto');
ga('send', 'pageview');
</script>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
Expand All @@ -50,8 +60,11 @@
</div>
<ul class="nav navbar-nav navbar-left">
<li id="sections" class="active dropdown">
<a class="active dropdown-toggle" data-toggle="dropdown" href="#"><span class="name"></span><span class="caret"></span></a>
<a class="active dropdown-toggle" data-toggle="dropdown" href="#"><span id="name"></span><span class="caret"></span></a>
<ul id="menu" class="dropdown-menu">
<li><a href="index.html"><i class="octicon octicon-book"></i><span>Documentation</span></a></li>
<li><a href="modules.html"><i class="octicon octicon-code"></i><span>Reference</span></a></li>
<li><a href="namespacemembers.html"><i class="octicon octicon-list-unordered"></i><span>Alphabetical Index</span></a></li>
</ul>
</li>
</ul>
Expand All @@ -75,4 +88,4 @@
</nav>
<div class="container">
<div class="row">
<div class="toolbar">
<div>
72 changes: 37 additions & 35 deletions doc/js/metal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,29 @@
$(function(){
var page = window.location.pathname.split("/").pop().split("#")[0];

$("li > a[href='index.html'] > span")
.before("<i class='octicon octicon-book'></i>");
$("li > a[href='modules.html'] > span")
.before("<i class='octicon octicon-code'></i>");
$("li > a[href='namespacemembers.html'] > span")
.before("<i class='octicon octicon-list-unordered'></i>");

$(".current").removeClass("current").addClass("active");

$("#navrow1 > ul > li").appendTo("#menu");

$("#sections").on("click", function(){
$("> .active > .name", this).text($("#menu > .active", this).text());
}).click();
if(/[^_]+__[^_.]+.html/.test(page))
section = "modules.html";
else
section = page;

$("#sections > #menu a[href='" + section +"']").each(function(){
$(this).parent().addClass("active");
$("#sections #name").html($(this).html());
});

if(/namespacemembers(_type)?\.html$/.test(page)){
$("[id='navrow4']")
.removeAttr("id")
.addClass("hidden-xs")
.find("> ul")
.addClass("nav nav-pills nav-justified")
.find("> li")
.removeClass("active")
var $entries = $("h3").addClass("index-entry");

$entries
.find("> a")
.click(function(){
.each(function(){
var entry = $(this).attr("id").replace(/index_(.+)/g, "$1");
$(this)
.parent().addClass("active")
.siblings().removeClass("active");
.addClass("anchor")
.attr("id", entry)
.attr("href", "#" + entry);
});

var $entries = $("h3").addClass("index-entry");

$entries
.find("+ ul")
.addClass("list-inline")
Expand All @@ -52,8 +43,13 @@ $(function(){
})
}

$(".levels, .arrow, .heading, .memSeparator, \
[id^='navrow'], [id^='nav-path'], [class^='separator\\:']").remove();
$("a[href^='" + page + "#']").each(function(){
$(this).attr("href", $(this).attr("href").replace(/.*(#.+)/g, "$1"));
});

$(".levels, .arrow, .heading, .memtitle, .memSeparator, [class^='separator\\:']").remove();

$("a + .memitem").prev().addClass("anchor");

$("div.header")
.each(function(){
Expand Down Expand Up @@ -92,16 +88,22 @@ $(function(){
.append($(".memtemplate", this).append("<br>").contents())
.append($(".memname td", this).contents())
.prependTo(this)
.each(function(){
if(/.*=[^=]*detail::[^=]*/.test($(this).text())){
$(this).html(
$(this).html().replace(
/(.+=) typedef.+/,
"$1 unspecified"
)
);
}
})
.contents()
.each(function(){
if(this.nodeType == 3){
this.data = this.data
.replace(
/= typedef( typename)? (?!std::).+/g,
"= unspecified"
)
.replace(/= typedef/g, "=")
.replace(/detail::[_a-zA-Z_]+/g, "unspecified");
.replace(/= typedef/, "=")
.replace(/detail::[_a-zA-Z0-9_]+/, "unspecified");
}
});

Expand Down Expand Up @@ -167,7 +169,7 @@ $(function(){
$(this).attr("href", "#" + $(this).attr("id"));
});

$("a[href^='" + page + "#'], a[href^='#']").click(function(){
$("a[href^='#']").click(function(){
var href = "#" + $.attr(this, "href").split("#").pop();
if(href.length > 1){
$("html, body").animate({
Expand Down
2 changes: 1 addition & 1 deletion doc/layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt
<tab type="mainpage" visible="yes" title="Documentation"/>
<tab type="modules" visible="yes" title="Reference" intro=" "/>
<tab type="namespacemembers"
visible="$ALPHABETICAL_INDEX"
visible="yes"
title="Alphabetical Index"
intro=" "
/>
Expand Down
42 changes: 35 additions & 7 deletions doc/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,33 @@ A [Map] is a [List] of [Pairs], whose first elements are all distinct, that is

metal::map, metal::is_map, metal::keys, metal::values

A Word on SFINAE-Friendliness {#SFINAE}
================================================================================

An [Expression] is said to be SFINAE-friendly when it is carefully designed so
as never to prevent the [SFINAE] rule to be triggered. In general, such
[Expressions] may only trigger template substitution errors at the point of
instantiation of the *signature* of a type, which includes the instantiation of
alias templates and default template arguments.

SFINAE-friendly [Expressions] are exceedingly powerful, because they may be used
to drive overload resolution, much like [`std::enable_if`][enable_if] does.
For that reason all [Expressions] within `namespace metal` are guaranteed to be
themselves SFINAE-friendly.

\snippet sfinae.cpp SFINAE

Conversely, an SFINAE-unfriendly [Expression] produces so called *hard errors*,
which require the compilation to halt immediately. Examples of *hard errors*
are failed `static_assert`'ions or template substitution errors at the point of
instantiation of the nested members of a type.

SFINAE-unfriendly [Expressions] are very inconvenient, because they force
compilation to halt when they are not selected by overload resolution, thereby
hindering the usage of the entire overloaded set. For that reason
SFINAE-unfriendly [Expressions] should always be avoided.


Metal in Action {#metal_in_action}
================================================================================

Expand Down Expand Up @@ -459,8 +486,8 @@ At a first glance it might be tempting to try something like this
\snippet literal.cpp naive_2
}

but do not forget why we're here to begin with, that is, recall we can't
instantiate a template using a non-constexpr variable as argument!
but let us not forget why we're here to begin with, that is, recall we can't
instantiate a template using a non-`constexpr` variable as argument!

At this point, a watchful reader might argue that in theory there is no real
reason for this to be rejected, since the literal value must always be known at
Expand Down Expand Up @@ -508,8 +535,8 @@ individual digits according to the radix.
To parse characters into their corresponding numerical value, we must first
remove all digit separators.
That can be easily accomplished using `metal::remove`, which takes a [List] `l`
and a [Value] `v` and returns another [List] that contains every element from
`l` and in the same order, except for those that are identical to `v`.
and a [Value] `val` and returns another [List] that contains every element from
`l` and in the same order, except for those that are identical to `val`.

\snippet literal.cpp remove

Expand All @@ -523,8 +550,7 @@ another [List] containing the results of invoking `lbd` for each element in `l`.

\snippet literal.cpp transform

Notice how integral values of type `char` are translated into their actual
numerical representation.
Notice how characters are translated into their actual numerical representation.

So there it is

Expand Down Expand Up @@ -605,7 +631,7 @@ And ignores digit separators too.
Church Booleans {#church_booleans}
--------------------------------------------------------------------------------

TODO
[TODO]

[Value]: #value
[Values]: #value
Expand Down Expand Up @@ -646,7 +672,9 @@ TODO
[constexpr]: http://en.cppreference.com/w/cpp/language/constexpr
[tuple]: http://en.cppreference.com/w/cpp/utility/tuple
[get]: http://en.cppreference.com/w/cpp/utility/tuple/get
[enable_if]: http://en.cppreference.com/w/cpp/types/enable_if
[literal]: http://en.cppreference.com/w/cpp/language/user_literal
[SFINAE]: http://en.cppreference.com/w/cpp/language/sfinae

[CMake]: http://cmake.org/
[Doxygen]: http://doxygen.org/
Expand Down
2 changes: 1 addition & 1 deletion example/src/literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ struct AugmentedTuple :
return std::get<i>(*this);
}
};
///[augmented_tuple]
#else
///[augmented_tuple]
template<typename... T>
Expand All @@ -322,6 +321,7 @@ struct AugmentedTuple :
return std::get<i>(*this);
}
};
///[augmented_tuple]
#endif

///[teaser_1]
Expand Down
25 changes: 25 additions & 0 deletions example/src/sfinae.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Bruno Dutra 2015-2016
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt

#include <metal.hpp>

#include <tuple>

#include "example.hpp"

/// [SFINAE]
template<typename num>
constexpr metal::if_<metal::is_number<num>, metal::int_> make() {
return num::value;
} // instantiated for Numbers only

template<typename seq>
constexpr metal::apply<metal::lambda<std::tuple>, seq> make() {
return {};
} // instantiated for Lists only

static_assert(make<metal::number<42>>() == 42, "");
static_assert(make<metal::list<int, char>>() == std::tuple<int, char>{}, "");
/// [SFINAE]

2 changes: 1 addition & 1 deletion include/metal/config/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
///
/// ### See Also
/// \see [Semantic Versioning](http://semver.org/)
#define METAL_PATCH 1
#define METAL_PATCH 2

/// \ingroup config
/// \hideinitializer
Expand Down
Loading

0 comments on commit d383f2b

Please sign in to comment.